WordPress.org

Make WordPress Core

Ticket #27888: 27888.2.diff

File 27888.2.diff, 722 bytes (added by mwtsn, 3 years ago)

Patch to add a get_current_admin_hookl() function into wp-admin/includes/misc.php. This is only my second patch, so feedback appreciated.

  • wp-admin/includes/misc.php

     
    936936        </script>
    937937        <?php
    938938}
     939
     940/**
     941 * Outputs the current admin page url
     942 */
     943function get_current_admin_page_url() {
     944
     945        if ( ! is_admin() ) {
     946                return false;
     947        }
     948
     949        global $pagenow;
     950
     951        $url = $pagenow;
     952        $query_string = $_SERVER['QUERY_STRING'];
     953
     954        if ( ! empty( $query_string ) ) {
     955                $url .= '?' . $query_string;
     956        }
     957
     958        return $url;
     959}
     960
     961/**
     962 * Outputs the current admin hook
     963 */
     964function get_current_admin_hook() {
     965
     966        if ( ! is_admin() ) {
     967                return false;
     968        }
     969
     970        return current_filter();
     971}