WordPress: Load custom CSS for specific plugin admin Page

Solution:1

add_action('admin_enqueue_scripts', 'ln_reg_css_and_js');

    function ln_reg_css_and_js($hook)
    {

    $current_screen = get_current_screen();

    if ( strpos($current_screen->base, 'my-fist-slug') === false) {
        return;
    } else {

        wp_enqueue_style('boot_css', plugins_url('inc/bootstrap.css',__FILE__ ));
        wp_enqueue_script('boot_js', plugins_url('inc/bootstrap.js',__FILE__ ));
        wp_enqueue_script('ln_script', plugins_url('inc/main_script.js', __FILE__), ['jquery'], false, true);
        }
    }

Solution:2

You can use get_current_screen() to check which page is being displayed now, and if it was your plugin’s page, enqueue the script.

However the easier way is to use the global variable, $pagenow:

if(( $pagenow == 'my-plugin.php' ) {
    wp_enqueue_style('my-style', 'URL-HERE' );    
}

In which my-plugin.php is the slug of your plugin screen’s URL, such as:

www.example.com/wp-admin/my-plugin.php