WordPress.org

Make WordPress Core

Ticket #18662: 18662.diff

File 18662.diff, 1.3 KB (added by Latz, 3 years ago)
  • wp-admin/includes/plugin.php

     
    15091509        return $page_type . '_page_' . $plugin_name; 
    15101510} 
    15111511 
     1512function admin_page_exists() { 
     1513        global $plugin_page; 
     1514        global $_registered_pages; 
     1515        // it's not an plugin setting page, so never mind 
     1516        if ( ! $plugin_page ) 
     1517          return true; 
     1518        $parent = get_admin_page_parent(); 
     1519        $hookname = get_plugin_page_hookname( $plugin_page, $parent ); 
     1520        if ( ! isset( $_registered_pages[$hookname] ) ) 
     1521                return false; 
     1522        return true; 
     1523} 
     1524 
    15121525function user_can_access_admin_page() { 
    15131526        global $pagenow; 
    15141527        global $menu; 
  • wp-admin/includes/menu.php

     
    220220        unset( $menu[ $last_menu_key ] ); 
    221221unset( $last_menu_key ); 
    222222 
     223if ( ! admin_page_exists() ) { 
     224        do_action( 'admin_page_not_exists' ); 
     225        wp_die( 'Plugin setting page does not exist.' ); 
     226} 
     227 
    223228if ( !user_can_access_admin_page() ) { 
    224229        do_action('admin_page_access_denied'); 
    225230        wp_die( __('You do not have sufficient permissions to access this page.') );