你在插件中所能做的一切都可以在主题中完成。更像是倾向于分离,见文章:https://managewp.com/blog/themes-design-plugins-functionality
Below an example adding editor stylesheet:
/**
* Registers an editor stylesheet for the theme.
*/
add_editor_style( array(
\'assets/css/bootstrap.min.css\',
\'https://use.fontawesome.com/releases/v5.3.1/css/all.css\',
\'style.css\',
));
Below an example to add scripts to the WP admin backend.
function admin_scripts() {
wp_enqueue_style( \'bootstrap\', get_theme_file_uri( \'/assets/css/bootstrap.min.css\' ), array(), null );
wp_enqueue_script( \'bootstrap-bundle-js\', get_theme_file_uri( \'/assets/js/bootstrap.bundle.min.js\' ), array(\'jquery\'), null, true );
}
add_action( \'admin_enqueue_scripts\', \'admin_scripts\' );
如果出于任何原因需要提前加载脚本,请尝试
admin_init
在下面
add_action( \'admin_init\', \'admin_scripts\' );