Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#30035 closed defect (bug) (fixed)

Can't put buttons in the Publish meta box

Reported by: ericlewis's profile ericlewis Owned by: helen's profile helen
Milestone: 4.1 Priority: normal
Severity: normal Version: 4.1
Component: Editor Keywords:
Focuses: javascript, administration Cc:

Description (last modified by SergeyBiryukov)

<?php
add_action( 'post_submitbox_misc_actions', function() { ?><button type='button'>hi</button><?php } );

Clicking that button and then preview will break your stuffs.

This is because this selector is too greedy. We should remove the :button selector here.

Attachments (2)

30035.diff (578 bytes) - added by ericlewis 9 years ago.
30035.mov (4.1 MB) - added by ericlewis 9 years ago.

Change History (11)

@ericlewis
9 years ago

#1 @SergeyBiryukov
9 years ago

  • Component changed from Administration to Editor
  • Description modified (diff)
  • Milestone changed from Awaiting Review to 4.1

#2 @SergeyBiryukov
9 years ago

Introduced in [7103], refactored in [11874] and [26995].

#3 @helen
9 years ago

What does "break your stuffs" entail, and is there any possibility people are relying on this currently for whatever reason? Not against removing it, just like to know the details first.

@ericlewis
9 years ago

#4 follow-up: @ericlewis
9 years ago

attachment:30035.mov shows what putting a button in the Publish meta box does.

Clicking our button adds the callback that's only intended only to be added when the submit button is clicked, so when Preview button is clicked, this callback runs unintentionally, and disables the submit buttons.

Last edited 9 years ago by ericlewis (previous) (diff)

#5 in reply to: ↑ 4 @adamsilverstein
9 years ago

Replying to ericlewis:

attachment:30035.mov shows what putting a button in the Publish meta box does.

Clicking our button adds the callback that's only intended only to be added when the submit button is clicked, so when Preview button is clicked, this callback runs unintentionally, and disables the submit buttons.

Makes sense; wondering why :button was used in the first place, agree seems overly aggressive!

#6 @helen
9 years ago

Still curious if anybody is weirdly relying on this, or if this was done this way for a specific reason - paging azaozz.

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


9 years ago

#8 @ericlewis
9 years ago

azaozz and I spoke about it in IRC a while ago, he agreed it was too generous of a selector and we should remove it.

#9 @helen
9 years ago

  • Owner set to helen
  • Resolution set to fixed
  • Status changed from new to closed

In 30698:

Don't over-target buttons in the publish meta box.

This selector caused breakage for any custom buttons added.

props ericlewis.
fixes #30035.

Note: See TracTickets for help on using tickets.