X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8f374b7233bc2815ccc387e448d208c5434eb961..8a4706fdeb1ae30268e510df6ccf3c39b3028059:/wp-includes/class-wp-customize-control.php diff --git a/wp-includes/class-wp-customize-control.php b/wp-includes/class-wp-customize-control.php index 5ded24ca..d24a5f2e 100644 --- a/wp-includes/class-wp-customize-control.php +++ b/wp-includes/class-wp-customize-control.php @@ -6,25 +6,71 @@ * @subpackage Customize * @since 3.4.0 */ - class WP_Customize_Control { + /** + * @access public + * @var WP_Customize_Manager + */ public $manager; + + /** + * @access public + * @var string + */ public $id; - // All settings tied to the control. + /** + * All settings tied to the control. + * + * @access public + * @var array + */ public $settings; - // The primary setting for the control (if there is one). + /** + * The primary setting for the control (if there is one). + * + * @access public + * @var string + */ public $setting = 'default'; + /** + * @access public + * @var int + */ public $priority = 10; + + /** + * @access public + * @var string + */ public $section = ''; + + /** + * @access public + * @var string + */ public $label = ''; - // @todo: remove choices + + /** + * @todo: Remove choices + * + * @access public + * @var array + */ public $choices = array(); + /** + * @access public + * @var array + */ public $json = array(); + /** + * @access public + * @var string + */ public $type = 'text'; @@ -34,6 +80,10 @@ class WP_Customize_Control { * If $args['settings'] is not defined, use the $id as the setting ID. * * @since 3.4.0 + * + * @param WP_Customize_Manager $manager + * @param string $id + * @param array $args */ function __construct( $manager, $id, $args = array() ) { $keys = array_keys( get_object_vars( $this ) ); @@ -75,6 +125,9 @@ class WP_Customize_Control { * Grabs the main setting by default. * * @since 3.4.0 + * + * @param string $setting_key + * @return mixed The requested setting's value, if the setting exists. */ public final function value( $setting_key = 'default' ) { if ( isset( $this->settings[ $setting_key ] ) ) @@ -119,6 +172,7 @@ class WP_Customize_Control { * Check capabilities and render the control. * * @since 3.4.0 + * @uses WP_Customize_Control::render() */ public final function maybe_render() { if ( ! $this->check_capabilities() ) @@ -144,6 +198,14 @@ class WP_Customize_Control { settings[ $setting_key ] ) ) return ''; @@ -151,6 +213,14 @@ class WP_Customize_Control { return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"'; } + /** + * Render the data link parameter for a setting + * + * @since 3.4.0 + * @uses WP_Customize_Control::get_link() + * + * @param string $setting_key + */ public function link( $setting_key = 'default' ) { echo $this->get_link( $setting_key ); } @@ -238,53 +308,117 @@ class WP_Customize_Control { } } +/** + * Customize Color Control Class + * + * @package WordPress + * @subpackage Customize + * @since 3.4.0 + */ class WP_Customize_Color_Control extends WP_Customize_Control { + /** + * @access public + * @var string + */ public $type = 'color'; + + /** + * @access public + * @var array + */ public $statuses; + /** + * Constructor. + * + * If $args['settings'] is not defined, use the $id as the setting ID. + * + * @since 3.4.0 + * @uses WP_Customize_Control::__construct() + * + * @param WP_Customize_Manager $manager + * @param string $id + * @param array $args + */ public function __construct( $manager, $id, $args = array() ) { $this->statuses = array( '' => __('Default') ); parent::__construct( $manager, $id, $args ); } + /** + * Enqueue control related scripts/styles. + * + * @since 3.4.0 + */ public function enqueue() { - wp_enqueue_script( 'farbtastic' ); - wp_enqueue_style( 'farbtastic' ); + wp_enqueue_script( 'wp-color-picker' ); + wp_enqueue_style( 'wp-color-picker' ); } + /** + * Refresh the parameters passed to the JavaScript via JSON. + * + * @since 3.4.0 + * @uses WP_Customize_Control::to_json() + */ public function to_json() { parent::to_json(); $this->json['statuses'] = $this->statuses; } + /** + * Render the control's content. + * + * @since 3.4.0 + */ public function render_content() { + $this_default = $this->setting->default; + $default_attr = ''; + if ( $this_default ) { + if ( false === strpos( $this_default, '#' ) ) + $this_default = '#' . $this_default; + $default_attr = ' data-default-color="' . esc_attr( $this_default ) . '"'; + } + // The input's value gets set by JS. Don't fill it. ?> context ) $this->json['context'] = $this->context; + + if ( $this->extensions ) + $this->json['extensions'] = implode( ',', $this->extensions ); } + /** + * Render the control's content. + * + * @since 3.4.0 + */ public function render_content() { ?>