[wp-trac] [WordPress Trac] #23367: Remove message parameters from admin URl's in the browser address bar

WordPress Trac noreply at wordpress.org
Thu Feb 19 23:48:41 UTC 2015


#23367: Remove message parameters from admin URl's in the browser address bar
-------------------------------------------------+-------------------------
 Reporter:  mark-k                               |       Owner:
     Type:  enhancement                          |  morganestes
 Priority:  low                                  |      Status:  assigned
Component:  Administration                       |   Milestone:  Future
 Severity:  minor                                |  Release
 Keywords:  good-first-bug has-patch needs-      |     Version:
  unit-tests                                     |  Resolution:
                                                 |     Focuses:
                                                 |  administration
-------------------------------------------------+-------------------------

Comment (by markjaquith):

 Summarizing some feedback I gave @morganestes in Slack:

 1. This approach sets a global `wp-admin` list of URL parameters that
 can't be used for anything other than transient message passing. If any
 plugin is using one of these for non-transient information (like selecting
 a plugin admin menu's sub-tab), a user refresh will result in that query
 parameter being gone, with unexpected results. It’s not the end of the
 world, but something to keep in mind.

 2. We shouldn't be doing all this work in JavaScript. We have PHP
 functions for removing query args. We should just make a function that, in
 the `<head>` section, outputs two things:

 {{{
 <link id="wp-admin-canonical" rel="canonical" href="<?php echo
 wp_admin_canonical_url(); ?>" />
 }}}

 and

 {{{
 <script>if ( typeof history.replaceState === 'function' ) {
 history.replaceState( null, null, document.getElementById('wp-admin-
 canonical').href ); }</script>
 }}}

 And then `wp_admin_canonical_url()` would be something like this:

 {{{
 function wp_admin_canonical_url() {
     $parameters_to_remove = array(
     'message',
     'updated',
     'settings-updated',
     'saved',
     'activated',
     'activate',
     'deactivate',
     'locked',
     'skipped',
     'deleted',
     'trashed',
     'untrashed',
     );
     $parameters_to_remove = apply_filters( 'removable_url_params',
 $parameters_to_remove );
     return remove_query_arg( $parameters_to_remove );
 }
 }}}

 Reasons:

 1. Less code.
 2. Not duplicating something in JS that we already have in PHP.
 3. `rel=canonical` is a standard practice, and I think this is a good use
 of it.
 4. No Underscore.js dependency on every admin screen. Indeed, this has no
 dependencies.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/23367#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list