diff -r f507feede89a -r 09a1c134465b web/wp-includes/class-wp-customize-control.php
--- a/web/wp-includes/class-wp-customize-control.php Wed Dec 19 12:35:13 2012 -0800
+++ b/web/wp-includes/class-wp-customize-control.php Wed Dec 19 17:46:52 2012 -0800
@@ -6,25 +6,71 @@
* @subpackage Customize
* @since 3.4.0
*/
+class WP_Customize_Control {
+ /**
+ * @access public
+ * @var WP_Customize_Manager
+ */
+ public $manager;
-class WP_Customize_Control {
- 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 @@
* 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 @@
* 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 @@
* 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 @@
settings[ $setting_key ] ) )
return '';
@@ -151,6 +213,14 @@
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 @@
}
}
+/**
+ * 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() {
?>