• [ Moderator note: moved to How-to and Troubleshooting. ]

    Hi,

    I’ve been going through a lot of plugins, 349 plugins to be exact (of premium and www.ads-software.com plugins), to see which plugins are loading their admin asset files site wide, when those admin asset files should only be loaded on their admin pages or selectively where needed. Honestly, I just got tired of plugins slowing things down because of this and when I am done I will submit these changes to the plugin authors so that all other cases of www.ads-software.com and premium plugins and users will have a better admin experience.

    In doing so I have about 4 different methods of achieving this conditional admin script loading, but I’m having a problem with one plugin that doesn’t offer anything too unique from the get_current_screen method, leaving the only unique option to be the parent_base or parent_file of the get_current_screen.

    But, for awhile I thought just maybe I was doing something wrong when the parent_base or parent_file wouldn’t enqueue the script at all, but id, base, post_type, etc. would. So today, after having to further test this out, I find the I am missing something completely or parent_base and parent_file just don’t work anymore or in this scenario.

    Here is an example of code I might use, which is also what I used to troubleshoot the parent_base and parent_file and find that it is not working.

    global $current_screen;
        $base = $current_screen->base;
        $id = $current_screen->id;
        $parent_base = $current_screen->parent_base;
    if( $base == 'edit'
     || $id == 'edit'
     || $parent_base == 'edit' ) {
    // Then enqueue the scripts and styles... etc.

    Can someone help me out to help us out as to why the parent_base or parent_file is not working like the other screen variable?

  • The topic ‘parent_base and parent_file in get_current_screen don't work anymore?’ is closed to new replies.