WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 3 weeks ago

#38796 new defect (bug)

Customize media control button labels should automatically reflect the specified mime type

Reported by: celloexpressions Owned by:
Milestone: 4.8 Priority: normal
Severity: normal Version: 4.7
Component: Customize Keywords: has-patch
Focuses: Cc:

Description

[39234] updated the button labels for the header video control to reflect that it's used for videos, rather than media in general. However, this approach only fixes this one control instance, and is something that should be brought to all media controls.

For 4.7, we should add an inline note where [39234] is referencing this ticket and explaining that in the future all media controls will default to labeling the buttons based on the mime type (and as a reminder to remove those overrides). Then, this ticket can transition to a future release/4.8 enhancement for updating the default button labels to use the mime_type where possible, and fall back to the existing defaults with media. We'll need an array of known mime types mapped to the corresponding media type labels and should be able to substitute those into each of the default button label strings in the control constructor.

Attachments (1)

38796.0.diff (3.1 KB) - added by Christian1012 3 weeks ago.

Download all attachments as: .zip

Change History (4)

#1 @westonruter
5 months ago

  • Milestone changed from 4.7 to 4.8

#2 @westonruter
5 months ago

In 39237:

Customize: Only show video header controls if previewing front page; show explanatory notice when controls are hidden.

Also include todo for the header_video control's button_labels. See #38796.

Props westonruter, joemcgill, celloexpressions.
Fixes #38778.

#3 @Christian1012
3 weeks ago

  • Keywords has-patch added; needs-patch removed

Added 38796.0.diff.

I don't have tests setup locally for trunk, plus I noticed that tests for WP_Customize_Control are still todos. I could write tests but would need a little help on where to put them. Plus I didn't want to write too many until I got feedback on the first pass.

/**
 * Test WP_Customize_Media_Control::get_default_button_labels() when mime type is 'video'.
 * 
 * @see WP_Customize_Media_Control::get_default_button_labels()
 */
public function test_get_default_button_labels_with_video_mime_type() {
        // Decalare expectations.
        $expected = array(
                'select'       => 'Select Video',
                'change'       => 'Change Video',
                'default'      => 'Default',
                'remove'       => 'Remove',
                'placeholder'  => 'No video selected',
                'frame_title'  => 'Select Video',
                'frame_button' => 'Choose Video',
        );

        // Act.
        // Assumes TestCase container has wp_customize property, instance of WP_Customize_Manager.
        // See /trunk/tests/phpunit/tests/customize/control.php for example that this is based on.
        do_action( 'customize_register', $this->wp_customize );
        $control = new WP_Customize_Media_Control( $this->wp_customize, 'nosetting', array(
                'settings' => array( 'nosetting' ),
                'mime_type' => 'video',
        ) );
        
        // Unit.
        $this->assertEquals( $expected, $control->get_default_button_labels() );

        // Functional.
        $this->assertEquals( $expected, $control->button_labels );
}
Last edited 3 weeks ago by westonruter (previous) (diff)
Note: See TracTickets for help on using tickets.