Theme Customizer: Move upload and image controls to subclasses. see #19910.

Instead of grouping together every control parameter into a single  array and passing them all to the JS, use subclasses with custom parameters to implement additional PHP functionality and the  parameter to send only the necessary variables to the JavaScript control.

Replaces WP_Customize_Control->control_params with WP_Customize_Control->json and WP_Customize_Control->to_json(). The to_json() method refreshes the json array passed to the JavaScript control (set to control.param by default).

Creates WP_Customize_Upload_Control and WP_Customize_Image_Control.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
koopersmith
2012-03-29 06:35:54 +00:00
parent 7ddbabb3db
commit 79f8b89fbc
5 changed files with 119 additions and 100 deletions

View File

@@ -585,20 +585,17 @@ final class WP_Customize {
'theme_supports' => 'custom-header',
) );
$this->add_control( 'header_image', array(
$this->add_control( new WP_Customize_Image_Control( $this, 'header_image', array(
'label' => 'Header Image',
'section' => 'header',
'type' => 'image',
'control_params' => array(
'context' => 'custom-header',
'removed' => 'remove-header',
'get_url' => 'get_header_image',
'tabs' => array(
array( 'uploaded', __('Uploaded'), 'wp_customize_print_uploaded_headers' ),
array( 'included', __('Included'), 'wp_customize_print_included_headers' ),
),
'context' => 'custom-header',
'removed' => 'remove-header',
'get_url' => 'get_header_image',
'tabs' => array(
array( 'uploaded', __('Uploaded'), 'wp_customize_print_uploaded_headers' ),
array( 'included', __('Included'), 'wp_customize_print_included_headers' ),
),
) );
) ) );
/* Custom Background */
@@ -627,14 +624,12 @@ final class WP_Customize {
'theme_supports' => 'custom-background',
) );
$this->add_control( 'background_image', array(
$this->add_control( new WP_Customize_Upload_Control( $this, 'background_image', array(
'label' => __( 'Background Image' ),
'section' => 'background',
'type' => 'upload',
'control_params' => array(
'context' => 'custom-background',
),
) );
'context' => 'custom-background',
) ) );
$this->add_setting( 'background_repeat', array(
'default' => 'repeat',