Execute function activatedeactivate plugin in specific pages

Good evening, I'm not a php developer but I wrote this script (tested and fully working):function deactivate_plugin

Good evening, I'm not a php developer but I wrote this script (tested and fully working):

function deactivate_plugin_conditional() {
    if ( is_plugin_active('plugin-name/plugin.php') ) {
        require_once(ABSPATH .'/wp-admin/includes/plugin.php');
    deactivate_plugins('plugin-name/plugin.php');   
    }
}
add_action( 'admin_init', 'deactivate_plugin_conditional' );

sleep(1);

function activate_plugin_conditional() {
    if ( is_plugin_inactive('plugin-name/plugin.php') ) {
    require_once(ABSPATH .'/wp-admin/includes/plugin.php');
    activate_plugins('plugin-name/plugin.php');   
    }
}
add_action( 'admin_init', 'activate_plugin_conditional' );

I inserted it in functions.php theme, but doing so everytime some one (backed or front end) open the website it runs (obviously). I have to make it run in two specific page (imagine with id 321 and 322). To intercept a page from functions.php I wrote this code:

add_filter( 'template_include', function( $template ) {
    if ( is_page( array( 321, 322 ) ) ) 
        echo 'Here You are';
        else
    {
    echo 'KO';
    }

   return $template;
});

And this script works too, BUT if I try to merge theme....it doesn't work. Is there anyone that could help me to figure it out? Warm regards Ale

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744970723a4603946.html

相关推荐

  • Execute function activatedeactivate plugin in specific pages

    Good evening, I'm not a php developer but I wrote this script (tested and fully working):function deactivate_plugin

    1天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信