Opened 11 years ago
Closed 9 years ago
#28505 closed enhancement (worksforme)
Allow button manipulation in `get_sample_permalink_html()`
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | has-patch |
Focuses: | administration | Cc: |
Description
Currently, default buttons (Edit, View {Post Type}, Get Shortlink) are added directly as html strings within the get_sample_permalink_html
filter. This makes it highly difficult for developers to re-order, remove, or otherwise manipulate these buttons.
I propose adding a new filter within the get_sample_permalink_html()
function that builds these extra buttons as an array, allowing plugins/themes to hook in and manipulate them cleanly before they're converted to a long HTML string.
Attachments (3)
Change History (13)
This ticket was mentioned in IRC in #wordpress-dev by ericmann. View the logs.
11 years ago
#2
@
11 years ago
- Milestone changed from Awaiting Review to 4.0
Sounds good to me, have needed this in the past and present. Patch looks good at a glance, but somebody other than ericmann should probably actually apply and test it first. :)
#3
@
11 years ago
The original patch only allows filtering the buttons if the default permalink structure is chosen. In most cases I would want this filter regardless of permalink structure. The get_sample_permalink_html
filter is applied to both cases, it stands to reason that the get_sample_permalink_buttons
would as well.
@
11 years ago
Adds filtering to the buttons array for both default permalinks and pretty permalinks.
#4
follow-up:
↓ 7
@
11 years ago
- Keywords needs-patch added
This looks like a pretty good start, though there's still a bit of work to do here.
For instance, the 'Get Shortlink' button is actually appended to the end of the get_sample_permalink_html()
output in edit-form-advanced.php. So I'd suggest bringing that logic into get_sample_permalink_html()
so the button is included with the filter.
Also, this is just a readability nitpick, but the multi-conditional and subsequent link buttons string, could probably be broken up into multiple lines, a la:
<?php if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && ! ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) { $link_buttons['change-permalinks'] = '<span id="change-permalinks">'; $link_buttons['change-permalinks'] .= '<a href="options-permalink.php" class="button button-small" target="_blank">' . __( 'Change Permalinks' ) . '</a>'; $link_buttons['change-permalinks'] .= "</span>\n"; }
Last, not sure what if any concerns the accessibility team might have with keeping or removing the target=blank on that link, either. Seems like lately we've been in the habit of removing blank targets on links in the back-end.
#5
@
11 years ago
See 7:ticket:22980, #16477, #16478. I'm not convinced of an particular approach here. Whatever we do, it should not be shoved inside get_sample_permalink_html().
@
11 years ago
Break the buttons out into a separate action (for edit-slug-buttons) and filter the array there instead of forcing things into the sample permalink html.
#6
@
11 years ago
The new patch looks sensible to me. I'll try to apply this sooner than later to test it.
#7
in reply to:
↑ 4
@
11 years ago
Replying to DrewAPicture:
Last, not sure what if any concerns the accessibility team might have with keeping or removing the target=blank on that link, either. Seems like lately we've been in the habit of removing blank targets on links in the back-end.<
Hi, we really appreciate the accessibility considerations! target=blank is indeed problematic for accessibility, so a change to that would be welcome. Thanks so much!
Converts HTML concatenation to first a filterable array. Also adds brackets around one-line conditionals to stay inline with WP coding standards.