我有两个插件。伪代码如下。我只想在调用该插件时加载CSS / JS。 现在,所有插件中的所有js / css都将被调用。我该如何预防?
插件1
class Plugin1 {
function __construct() {
add_action('wp_enqueue_scripts', array($this, 'enqueue')
}
function enqueue() {
wp_register_style('xxx','path');
wp_eneque_style('xxx);
}
}
插件2
class Plugin2 {
function __construct() {
add_action('wp_enqueue_scripts', array($this, 'enqueue')
}
function enqueue() {
wp_register_style('xxx','path');
wp_eneque_style('xxx);
}
}