仅在wordpress中调用该插件时加载CSS / JS

时间:2020-05-06 11:30:18

标签: wordpress

我有两个插件。伪代码如下。我只想在调用该插件时加载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);
 }
}

0 个答案:

没有答案
相关问题