From 800ad7bd0498f98788bdc1e0f50af2f36343d87a Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 20 Sep 2017 21:24:46 +0000 Subject: [PATCH] Customize: Let media control button labels better automatically reflect the specified MIME type. Props Christian1012, celloexpressions, westonruter. Fixes #38796. Built from https://develop.svn.wordpress.org/trunk@41550 git-svn-id: http://core.svn.wordpress.org/trunk@41383 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-manager.php | 8 --- .../class-wp-customize-image-control.php | 24 ------- .../class-wp-customize-media-control.php | 69 ++++++++++++++++--- wp-includes/version.php | 2 +- 4 files changed, 59 insertions(+), 44 deletions(-) diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index 5e66a1aa75..87a14193f3 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -4004,14 +4004,6 @@ final class WP_Customize_Manager { 'description' => $control_description, 'section' => 'header_image', 'mime_type' => 'video', - // @todo These button_labels can be removed once WP_Customize_Media_Control provides mime_type-specific labels automatically. See . - 'button_labels' => array( - 'select' => __( 'Select Video' ), - 'change' => __( 'Change Video' ), - 'placeholder' => __( 'No video selected' ), - 'frame_title' => __( 'Select Video' ), - 'frame_button' => __( 'Choose Video' ), - ), 'active_callback' => 'is_header_video_active', ) ) ); diff --git a/wp-includes/customize/class-wp-customize-image-control.php b/wp-includes/customize/class-wp-customize-image-control.php index 38ac608f1f..d056f8be61 100644 --- a/wp-includes/customize/class-wp-customize-image-control.php +++ b/wp-includes/customize/class-wp-customize-image-control.php @@ -18,30 +18,6 @@ class WP_Customize_Image_Control extends WP_Customize_Upload_Control { public $type = 'image'; public $mime_type = 'image'; - /** - * Constructor. - * - * @since 3.4.0 - * @uses WP_Customize_Upload_Control::__construct() - * - * @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 ); - - $this->button_labels = wp_parse_args( $this->button_labels, array( - 'select' => __( 'Select Image' ), - 'change' => __( 'Change Image' ), - 'remove' => __( 'Remove' ), - 'default' => __( 'Default' ), - 'placeholder' => __( 'No image selected' ), - 'frame_title' => __( 'Select Image' ), - 'frame_button' => __( 'Choose Image' ), - ) ); - } - /** * @since 3.4.2 * @deprecated 4.1.0 diff --git a/wp-includes/customize/class-wp-customize-media-control.php b/wp-includes/customize/class-wp-customize-media-control.php index 446713f623..db990cda69 100644 --- a/wp-includes/customize/class-wp-customize-media-control.php +++ b/wp-includes/customize/class-wp-customize-media-control.php @@ -52,17 +52,7 @@ class WP_Customize_Media_Control extends WP_Customize_Control { public function __construct( $manager, $id, $args = array() ) { parent::__construct( $manager, $id, $args ); - if ( ! ( $this instanceof WP_Customize_Image_Control ) ) { - $this->button_labels = wp_parse_args( $this->button_labels, array( - 'select' => __( 'Select File' ), - 'change' => __( 'Change File' ), - 'default' => __( 'Default' ), - 'remove' => __( 'Remove' ), - 'placeholder' => __( 'No file selected' ), - 'frame_title' => __( 'Select File' ), - 'frame_button' => __( 'Choose File' ), - ) ); - } + $this->button_labels = wp_parse_args( $this->button_labels, $this->get_default_button_labels() ); } /** @@ -209,4 +199,61 @@ class WP_Customize_Media_Control extends WP_Customize_Control { <# } #> mime_type ) ? strtok( ltrim( $this->mime_type, '/' ), '/' ) : 'default'; + + switch ( $mime_type ) { + case 'video': + return array( + 'select' => __( 'Select video' ), + 'change' => __( 'Change video' ), + 'default' => __( 'Default' ), + 'remove' => __( 'Remove' ), + 'placeholder' => __( 'No video selected' ), + 'frame_title' => __( 'Select video' ), + 'frame_button' => __( 'Choose video' ), + ); + case 'audio': + return array( + 'select' => __( 'Select audio' ), + 'change' => __( 'Change audio' ), + 'default' => __( 'Default' ), + 'remove' => __( 'Remove' ), + 'placeholder' => __( 'No audio selected' ), + 'frame_title' => __( 'Select audio' ), + 'frame_button' => __( 'Choose audio' ), + ); + case 'image': + return array( + 'select' => __( 'Select image' ), + 'change' => __( 'Change image' ), + 'default' => __( 'Default' ), + 'remove' => __( 'Remove' ), + 'placeholder' => __( 'No image selected' ), + 'frame_title' => __( 'Select image' ), + 'frame_button' => __( 'Choose image' ), + ); + default: + return array( + 'select' => __( 'Select file' ), + 'change' => __( 'Change file' ), + 'default' => __( 'Default' ), + 'remove' => __( 'Remove' ), + 'placeholder' => __( 'No file selected' ), + 'frame_title' => __( 'Select file' ), + 'frame_button' => __( 'Choose file' ), + ); + } // End switch(). + } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 85f7022783..10ec500778 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41549'; +$wp_version = '4.9-alpha-41550'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.