WordPress.org

Make WordPress Core

Ticket #23367: src.diff

File src.diff, 1.4 KB (added by VarunAgw, 8 years ago)

Code required for fix

  • new file src.js

    commit c9f09d6611c6edafc69f7b5f73e8d2a6fa1c4938
    Author: Varun Agrawal <Varun@VarunAgw.com>
    Date:   Thu Feb 6 15:38:29 2014 +0530
    
        Patch for ticket #23367 'Remove message parameters fron admin URl's in the browser address bar'
    
    diff --git src.js src.js
    new file mode 100644
    index 0000000..0288198
    - +  
     1  function removeParam(key, sourceURL) {
     2    var rtn = sourceURL.split("?")[0],
     3        param,
     4        params_arr = [],
     5        queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : "";
     6    if (queryString !== "") {
     7        params_arr = queryString.split("&");
     8        for (var i = params_arr.length - 1; i >= 0; i -= 1) {
     9            param = params_arr[i].split("=")[0];
     10            if ($.inArray( param, key ) > -1 ) {
     11                params_arr.splice(i, 1);
     12            }
     13        }
     14        rtn = rtn + "?" + params_arr.join("&");
     15    }
     16    return rtn;
     17}
     18
     19    var remove_query_args=[ 'user_switched', 'switched_off', 'switched_back',
     20                        'message', 'updated', 'settings-updated', 'saved',
     21                        'activated', 'activate', 'deactivate',
     22                        'locked', 'skipped', 'deleted', 'trashed', 'untrashed' ];
     23   
     24    url = $(location).attr('href');
     25    url = removeParam( remove_query_args, url );
     26
     27    if (typeof history.replaceState === 'function') { // check html5 functionality support
     28       history.replaceState( {},'',url);
     29    }
     30 No newline at end of file