X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f5fcdc7994bb67cce809bc4777944ae8b7fad4a4..refs/tags/wordpress-4.3:/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 bf17fb20..1e621462 100644
--- a/wp-includes/class-wp-customize-control.php
+++ b/wp-includes/class-wp-customize-control.php
@@ -20,6 +20,8 @@ class WP_Customize_Control {
* Used when sorting two instances whose priorities are equal.
*
* @since 4.1.0
+ *
+ * @static
* @access protected
* @var int
*/
@@ -137,9 +139,9 @@ class WP_Customize_Control {
*
* @since 3.4.0
*
- * @param WP_Customize_Manager $manager
- * @param string $id
- * @param array $args
+ * @param WP_Customize_Manager $manager Customizer bootstrap instance.
+ * @param string $id Control ID.
+ * @param array $args Optional. Arguments to override class property defaults.
*/
public function __construct( $manager, $id, $args = array() ) {
$keys = array_keys( get_object_vars( $this ) );
@@ -215,7 +217,7 @@ class WP_Customize_Control {
* @since 4.0.0
* @access public
*
- * @return bool Always true.
+ * @return true Always true.
*/
public function active_callback() {
return true;
@@ -299,9 +301,7 @@ class WP_Customize_Control {
final public function get_content() {
ob_start();
$this->maybe_render();
- $template = trim( ob_get_contents() );
- ob_end_clean();
- return $template;
+ return trim( ob_get_clean() );
}
/**
@@ -568,9 +568,9 @@ class WP_Customize_Color_Control extends WP_Customize_Control {
* @since 3.4.0
* @uses WP_Customize_Control::__construct()
*
- * @param WP_Customize_Manager $manager
- * @param string $id
- * @param array $args
+ * @param WP_Customize_Manager $manager Customizer bootstrap instance.
+ * @param string $id Control ID.
+ * @param array $args Optional. Arguments to override class property defaults.
*/
public function __construct( $manager, $id, $args = array() ) {
$this->statuses = array( '' => __('Default') );
@@ -678,7 +678,9 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
* @since 4.1.0
* @since 4.2.0 Moved from WP_Customize_Upload_Control.
*
- * @param WP_Customize_Manager $manager {@see WP_Customize_Manager} instance.
+ * @param WP_Customize_Manager $manager Customizer bootstrap instance.
+ * @param string $id Control ID.
+ * @param array $args Optional. Arguments to override class property defaults.
*/
public function __construct( $manager, $id, $args = array() ) {
parent::__construct( $manager, $id, $args );
@@ -714,8 +716,10 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
*/
public function to_json() {
parent::to_json();
+ $this->json['label'] = html_entity_decode( $this->label, ENT_QUOTES, get_bloginfo( 'charset' ) );
$this->json['mime_type'] = $this->mime_type;
$this->json['button_labels'] = $this->button_labels;
+ $this->json['canUpload'] = current_user_can( 'upload_files' );
$value = $this->value();
@@ -810,7 +814,7 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
<# } else { #>
-
+
{{ data.attachment.title }}
<# } #>
@@ -818,9 +822,11 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
+ <# if ( data.canUpload ) { #>
+ <# } #>
<# } else { #>
@@ -838,7 +844,9 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
<# if ( data.defaultAttachment ) { #>
<# } #>
+ <# if ( data.canUpload ) { #>
+ <# } #>
<# } #>
@@ -899,9 +907,9 @@ class WP_Customize_Image_Control extends WP_Customize_Upload_Control {
* @since 3.4.0
* @uses WP_Customize_Upload_Control::__construct()
*
- * @param WP_Customize_Manager $manager
- * @param string $id
- * @param array $args
+ * @param WP_Customize_Manager $manager Customizer bootstrap instance.
+ * @param string $id Control ID.
+ * @param array $args Optional. Arguments to override class property defaults.
*/
public function __construct( $manager, $id, $args = array() ) {
parent::__construct( $manager, $id, $args );
@@ -967,7 +975,7 @@ class WP_Customize_Background_Image_Control extends WP_Customize_Image_Control {
* @since 3.4.0
* @uses WP_Customize_Image_Control::__construct()
*
- * @param WP_Customize_Manager $manager
+ * @param WP_Customize_Manager $manager Customizer bootstrap instance.
*/
public function __construct( $manager ) {
parent::__construct( $manager, 'background_image', array(
@@ -992,6 +1000,127 @@ class WP_Customize_Background_Image_Control extends WP_Customize_Image_Control {
}
}
+/**
+ * Customize Cropped Image Control class.
+ *
+ * @since 4.3.0
+ *
+ * @see WP_Customize_Media_Control
+ */
+class WP_Customize_Cropped_Image_Control extends WP_Customize_Media_Control {
+
+ /**
+ * Control type.
+ *
+ * @since 4.3.0
+ * @access public
+ * @var string
+ */
+ public $type = 'cropped_image';
+
+ /**
+ * Suggested width for cropped image.
+ *
+ * @since 4.3.0
+ * @access public
+ * @var int
+ */
+ public $width = 150;
+
+ /**
+ * Suggested height for cropped image.
+ *
+ * @since 4.3.0
+ * @access public
+ * @var int
+ */
+ public $height = 150;
+
+ /**
+ * Whether the width is flexible.
+ *
+ * @since 4.3.0
+ * @access public
+ * @var bool
+ */
+ public $flex_width = false;
+
+ /**
+ * Whether the height is flexible.
+ *
+ * @since 4.3.0
+ * @access public
+ * @var bool
+ */
+ public $flex_height = false;
+
+ /**
+ * Enqueue control related scripts/styles.
+ *
+ * @since 4.3.0
+ * @access public
+ */
+ public function enqueue() {
+ wp_enqueue_script( 'customize-views' );
+
+ parent::enqueue();
+ }
+
+ /**
+ * Refresh the parameters passed to the JavaScript via JSON.
+ *
+ * @since 4.3.0
+ * @access public
+ *
+ * @see WP_Customize_Control::to_json()
+ */
+ public function to_json() {
+ parent::to_json();
+
+ $this->json['width'] = absint( $this->width );
+ $this->json['height'] = absint( $this->height );
+ $this->json['flex_width'] = absint( $this->flex_width );
+ $this->json['flex_height'] = absint( $this->flex_height );
+ }
+
+}
+
+/**
+ * Customize Site Icon control class.
+ *
+ * Used only for custom functionality in JavaScript.
+ *
+ * @since 4.3.0
+ *
+ * @see WP_Customize_Cropped_Image_Control
+ */
+class WP_Customize_Site_Icon_Control extends WP_Customize_Cropped_Image_Control {
+
+ /**
+ * Control type.
+ *
+ * @since 4.3.0
+ * @access public
+ * @var string
+ */
+ public $type = 'site_icon';
+
+ /**
+ * Constructor.
+ *
+ * @since 4.3.0
+ * @access public
+ *
+ * @param WP_Customize_Manager $manager Customizer bootstrap instance.
+ * @param string $id Control ID.
+ * @param array $args Optional. Arguments to override class property defaults.
+ */
+ public function __construct( $manager, $id, $args = array() ) {
+ parent::__construct( $manager, $id, $args );
+ add_action( 'customize_controls_print_styles', 'wp_site_icon', 99 );
+ }
+}
+
/**
* Customize Header Image Control class.
*
@@ -1005,7 +1134,11 @@ class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
public $default_headers;
/**
- * @param WP_Customize_Manager $manager
+ * Constructor.
+ *
+ * @since 3.4.0
+ *
+ * @param WP_Customize_Manager $manager Customizer bootstrap instance.
*/
public function __construct( $manager ) {
parent::__construct( $manager, 'header_image', array(
@@ -1021,6 +1154,9 @@ class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
}
+ /**
+ * @access public
+ */
public function enqueue() {
wp_enqueue_media();
wp_enqueue_script( 'customize-views' );
@@ -1046,6 +1182,10 @@ class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
parent::enqueue();
}
+ /**
+ *
+ * @global Custom_Image_Header $custom_image_header
+ */
public function prepare_control() {
global $custom_image_header;
if ( empty( $custom_image_header ) ) {
@@ -1058,23 +1198,26 @@ class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
$this->uploaded_headers = $custom_image_header->get_uploaded_header_images();
}
+ /**
+ * @access public
+ */
public function print_header_image_template() {
?>