Monday, February 13, 2023
HomeWordPress Developmentplugins - admin_enqueue_scripts utilizing hook_suffix vs GET web page

plugins – admin_enqueue_scripts utilizing hook_suffix vs GET web page


My menu code:

add_action('admin_menu', 'waf_admin_menu'); 

perform waf_admin_menu(){

    add_menu_page('WordPress Audio Filter', 'WordPress Audio Filter', WAF_CAPABILITY, 'waf_settings', 'waf_settings_page', plugins_url('property/menu.png', __FILE__));

    add_submenu_page('waf_settings', __('WordPress Audio Filter', WAF_TEXTDOMAIN), esc_html__('World settings', WAF_TEXTDOMAIN), WAF_CAPABILITY, 'waf_settings');
        
    add_submenu_page('waf_settings', esc_html__('WordPress Audio Filter', WAF_TEXTDOMAIN), esc_html__('Participant supervisor', WAF_TEXTDOMAIN), WAF_CAPABILITY, 'waf_player_manager', 'waf_player_manager_page');  

}

I’m utilizing following code to detect web page and enqueue acceptable property for my plugin pages:

add_action('admin_enqueue_scripts', 'my_admin_enqueue_scripts');

perform my_admin_enqueue_scripts( $hook_suffix ) {

      swap ( $hook_suffix ) {

            case get_plugin_page_hookname( 'waf_settings', 'waf_settings' ):

              
            break;

            case get_plugin_page_hookname( 'waf_player_manager', 'waf_settings' ):

            break;

       }

 }

Is that this the identical as utilizing $_GET[‘page’]? (with out $hook_suffix)

perform my_admin_enqueue_scripts() {


    $web page = isset($_GET['page']) ? $_GET['page'] : null;

    if($web page && $web page == 'waf_settings'){
    


    } 
    else if($web page && $web page == 'waf_player_manager')){
    


    } 

}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments