Make WordPress Core

Opened 6 years ago

Last modified 2 years ago

#44641 assigned defect (bug)

Customizing Button Text in Custom Media Manager Frame Doesn't Work Anymore

Reported by: kelderic's profile Kelderic Owned by: antpb's profile antpb
Milestone: Future Release Priority: normal
Severity: normal Version: 4.9.7
Component: Media Keywords: has-patch needs-testing 2nd-opinion
Focuses: Cc:

Description

Summary

I have a plugin that calls up the Media Manager. I use the "gallery" state, and customize the main button text via the wp.media arguments. I've noticed a regression. The text in the primary button is no longer overridden by the arguments that I pass.

What I'm Doing (Code is simplified)

var file_frame = wp.media.frame = wp.media({
	frame: 'post',
	state: 'gallery',
	library : { type : 'image'},
	button: {text: 'Edit Image Order'},  // <----- LINE IN QUESTION
	multiple: true
});

file_frame.open();

What Should Happen

The text inside the primary button in the media manager modal should change from "Create a new Gallery" to "Edit Image Order".

https://imgur.com/faJevb7

What Actually Happens

The button ignores my arguments and retains its default text.

https://imgur.com/6gLdtLv

Attachments (2)

44641.diff (1.5 KB) - added by donmhico 5 years ago.
44641.2.diff (718 bytes) - added by donmhico 5 years ago.
A better fix than the first patch.

Download all attachments as: .zip

Change History (18)

#1 @Kelderic
6 years ago

I've found a workaround, btw. Before triggering the frame.open() function, I can set my own value into wp.media.view.l10n.insertIntoPost. Then reset that value after I open the frame.

// CUSTOMIZE THE MAIN BUTTON TEXT

var originalInsertIntoPost = wp.media.view.l10n.insertIntoPost;

wp.media.view.l10n.insertIntoPost = 'Select Icon';

// OPEN THE MODAL

frame.open();

// RESET THE MAIN BUTTON TEXT

wp.media.view.l10n.insertIntoPost = originalInsertIntoPost;

This works and doesn't affect any other frames, but it seems hacky.

#2 @joemcgill
5 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 5.3

Hi @Kelderic,

Thanks for the report and for following up with your workaround. I agree that this is hacky and should be fixed. I was able to confirm that this is still an issue in WordPress 5.2-beta3, though I wasn't able to investigate why this is happening. I'm going to add this to the 5.3 milestone for further investigation.

#3 @Kelderic
5 years ago

I appreciate the response, @joemcgill, but I'm afraid that this has gotten lost in the hundreds of tickets assigned to 5.3.

@donmhico
5 years ago

#4 @donmhico
5 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

I've attached a patch, 44641.diff, but i'm not sure if this is what we want. On one hand, it does change the button label in the initial frame displayed. However, when you try to go to different frames by clicking the menu nav links in the left panel. The button labels of the new loaded frames will then revert to using the default label.

Now my question is, do we want the button label we set in the initialization of wp.media() -

var file_frame = wp.media.frame = wp.media({
	frame: 'post',
	state: 'gallery',
	library : { type : 'image'},
	button: {text: 'Edit Image Order'},  // <----- LINE IN QUESTION
	multiple: true
});

used in all of the frames? Or we just want it to be in the initial opened frame?

@donmhico
5 years ago

A better fix than the first patch.

#5 @davidbaumwald
4 years ago

  • Keywords 2nd-opinion added

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.


4 years ago

#7 @davidbaumwald
4 years ago

  • Keywords early added
  • Milestone changed from 5.3 to 5.4

This ticket was discussed during today's bug scrub. It's a little late in the 5.3 cycle for inclusion, so it's being moved to 5.4 with an early tag for more soak time.

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.


4 years ago

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


4 years ago

#10 @antpb
4 years ago

  • Owner set to antpb
  • Status changed from new to assigned

#11 @antpb
4 years ago

Thanks so much for the patch @donmhico ! I’ve assigned this ticket to myself to track it and test your patch. Will update soon with any findings. :)

#12 @donmhico
4 years ago

Sure thing @antpb. Thanks for owning the ticket. If there's anything else I can do to bring this ticket to resolution, let me know :)

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.


4 years ago

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


4 years ago

#15 @audrasjb
4 years ago

  • Milestone changed from 5.4 to Future Release

Hi,

With 5.4 Beta 3 approaching and the Beta period reserved for bugs introduced during the cycle, this is being moved to Future Release. If any maintainer or committer feels this should be included or wishes to assume ownership during a specific cycle, feel free to update the milestone accordingly.

#16 @johnbillion
2 years ago

  • Keywords early removed
Note: See TracTickets for help on using tickets.