I try to load the css and js files in specific pages. and use this code:
public $pages = array(
'post', 'post-new', 'profile', 'user-edit',
'options-general',
);
public function admin_scripts() {
$screen = get_current_screen();
$css_path = 'lib/css/app-admin.css';
$js_path = 'lib/js/app-admin.js';
wp_register_style( 'app-admin', APP_URL . $css_path, array(), _ver( $css_path ) );
wp_register_script( 'app-admin', APP_URL . $js_path, array(), _ver( $js_path ), true );
if ( in_array( $screen->base, $this->pages ) ) {
wp_enqueue_style( 'app-admin' );
wp_enqueue_script( 'app-admin' );
wp_localize_script( 'app-admin', 'XFAPJS', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'app_nonce', 'app_nonce' ),
'base' => $screen->base,
'blocksEditor' => method_exists( $screen, 'is_block_editor' ) && $screen->is_block_editor() ? true : false
) );
wp_add_inline_script( 'app-admin', 'APP.init();' );
}
}
So the scripts are loaded in 'post', 'post-new', 'profile', 'user-edit', but not in settings page.
I want to load in my plugin settings page also http://wp.local/wp-admin/options-general.php?page=xapp
where is the problem?