我如何阻止钩子破坏登录/注销功能?

时间:2017-11-05 作者:Steve

我将此代码添加到我的函数文件中,因此根据插件是否被激活,有不同的主题选项。

function theme_options_select() {
if( is_plugin_active( \'gallery-nails/gallery-nails.php\' )) {
    require get_template_directory() . \'/inc/theme-options/nails/theme-options.php\';
}
else {
    require get_template_directory() . \'/inc/theme-options/default/theme-options.php\';
}
}
add_action( \'wp_loaded\', \'theme_options_select\' );
我尝试了plugin\\u loaded和setup\\u theme,但主题选项无法访问。init也可以工作,但也会中断登录。

有人知道怎么解决这个问题吗?

1 个回复
SO网友:jaswrks

如果这个在functions.php, 那么你根本不需要钩子,因为functions.php 文件为loaded right where you want it. 所以只需将其展开,并将其从函数调用中移出即可;i、 e.仍然在你的functions.php, 但未连接到任何特定挂钩。

或者,使用after_setup_theme 如果你想稍微延迟一下,就勾住它。

结束

相关推荐

使用Functions.php的出列脚本

您好,我正在尝试将在我的队列中找到的脚本“jquery.favorite.js”退出队列。php:// WP_ENQUEUE_SCRIPTS static function wp_enqueue_scripts_callback() { global $javo_tso; $javo_register_scripts = Array( \'oms.min.js\'