为什么有些钩子在类上下文中不起作用?
我对此很困惑。我在插件类中使用add_action做某些事情-将脚本和样式添加到头部,wp_ajax等。这是__construct中的操作: function __construct(){ add_action('admin_menu', array($this, 'sph_admin_menu')); add_action('sph_header', array($this, 'sph_callback')); add_action('sph_header_items', array($this, 'sph_default_menu'), 1); add_action('sph_header_items', array($this, 'sph_searchform'), 2); add_action('sph_header_items', array($this, 'sph_social'), 3); //Below here they don't work. I have to call these outside of the class (but I need class variables within the functions) add_action('wp_print_styles', array(&$this, 'sph_stylesheets')); add_action('wp_print_scripts', array(&$this, 'sph_scripts')); add_action( …