Disable prettyPhoto WordPress (Visual Composer)

两盒软妹~` 提交于 2019-12-04 03:50:37

Place the following code in your theme's function file.

function remove_vc_prettyphoto(){
  wp_dequeue_script( 'prettyphoto' );
  wp_deregister_script( 'prettyphoto' );
  wp_dequeue_style( 'prettyphoto' );
  wp_deregister_style( 'prettyphoto' );
}
add_action( 'wp_enqueue_scripts', 'remove_vc_prettyphoto', 9999 );

I have tested this on my installation and it works flawlessly.

What it does is dequeues and deregisters the javascript and stylesheets that Visual Composer enqueues and registers throughout the plugin's PHP files for the various template elements and shortcodes that use the prettyPhoto lightbox.

The '9999' parameter enforces that the dequeuing/deregistering happens well after any enqueuing or registering took place earlier on in the loading of the plugin. Any number will do, but the higher the number the better.

You have to enqueue a custom javascript in your child theme where you override the following function:

function vc_prettyPhoto() {

}

in this way you disable prettyPhoto script initialization made by Visual Composer.

You can use code bellow to disable that javascript lib. Put that into your functions.php of theme

wp_dequeue_script( 'prettyphoto' );
wp_dequeue_style( 'prettyphoto' );

Also other page buider you can use is King Composer, which is faster VC https://wordpress.org/plugins/kingcomposer/

Not sure if you solved the problem, but I have a solution (not very elegant, but it works).

I did buy ePix theme for a photographer and noticed that Masonry Media Grid from Visual Composer isn't fully responsive. So my soulution was to edit 3 files from wp-content/assets/js/dist. Those files are: vc_grid.min.js page_editable.min.js js_composer_front.min.js

Just remove window.vc_prettyPhoto() or vc_prettyPhoto() from wherever they appear.  

After that I installed Lightbox by dFactor, choose swipebox and used as selector prettyPhoto. Also I did force lightbox on link images. Now the lightbox is fully-responsive.

Hopefully this will help somebody :)

WhiteHorse

You can disable Pretty Photo. Use the below code in theme's function file, thats it.

function remove_scripts(){
  wp_dequeue_script('prettyphoto' );
  wp_deregister_script('prettyphoto' );
}

add_action( 'wp_enqueue_scripts', 'remove_scripts', 100 );

It will work.

I have tested on my own issue to deactivate some sliders from the Visual Composer and it works. An example how to deactivate the whole Flexslider, Nivoslider and Owl Carousel sliders in the Visual Composer plugin. Add this code into theme functions.php file:

add_action( 'wp_enqueue_scripts', 'deregister_vc_modules', 99 );
function deregister_vc_modules() {
    wp_deregister_style( 'flexslider' );
    wp_deregister_script( 'flexslider' );

    wp_deregister_style( 'nivo-slider-css' );
    wp_deregister_style( 'nivo-slider-theme' );
    wp_deregister_script( 'nivo-slider' );

    wp_deregister_style( 'owl-carousel' );
    wp_deregister_script( 'owl-carousel' );
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!