Detect Visual Composer

前端 未结 4 1168
攒了一身酷
攒了一身酷 2021-02-09 01:08

Is there a way to detect if a WordPress page is using Visual Composer?

I have 2 different page templates:

  1. Default template for regular pages.
  2. Temp
4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-09 01:33

    if( defined( 'WPB_VC_VERSION' ) ) { ... }
    

    works like a charm. I was searching for a possibility to hide the Nag screen that occurs when you get the WPBakery Page Builder as a bundeled plugin with a commercial theme to avoid customer's confusion. In case someone could need that snippet:

    // hide nag screen of WP Bakery Visual composer if found
    if( defined( 'WPB_VC_VERSION' ) ) {
        if(!isset($_COOKIE['vchideactivationmsg_vc11'])) {
            setcookie('vchideactivationmsg', '1', strtotime('+3 years'), '/');
            setcookie('vchideactivationmsg_vc11',  WPB_VC_VERSION, strtotime('+3 years'), '/');
         }
    }
    

    Hook that into admin_init and you're good to go!

提交回复
热议问题