Disable prettyPhoto WordPress (Visual Composer)
Asked Answered
Z

6

9

Hi I'm trying to get WP Featherlight setup as the default lightbox, right now Visual Composer is using prettyPhoto. So I need to disable it, so that WP Featherlight will overwrite it.

I asked wpbakery and I got this response.

Hello, you can actually overwrite prettyphoto by adding prettyPhoto() in your functions.php and call another lightbox.

And from the plug-in author I got this:

Once prettyPhoto has been disabled, you shouldn't need to do anything else to lightbox images on the site.

So it's pretty clear what I need to do. Disable prettyPhoto. But I don't know how to do that. Can I add a simple line to my child theme's functions.php? Or?

Any help would really be appreciated.

Thanks.

Zorn answered 12/5, 2016 at 6:36 Comment(0)
A
9

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.

Armada answered 8/9, 2016 at 2:39 Comment(0)
S
1

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.

Superannuated answered 10/6, 2016 at 21:44 Comment(0)
M
0

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/

Madelainemadeleine answered 12/5, 2016 at 7:1 Comment(1)
It actually doesn't work. I created a blank functions.php in my Child Theme directory and added those two lines of code. But prettyPhoto is still active. I use the media grid / grid builder for creating galleries.Zorn
D
0

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 :)

Devote answered 8/7, 2016 at 16:34 Comment(0)
P
0

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.

Passing answered 24/8, 2016 at 10:0 Comment(3)
Inside the remove scripts function, they it should be DEqueue .. not enqueue. Plus you need to dequeue and deregister the styles as well. THEN.... it will work.Armada
But that had worked me. Even i see similar answer below, its now same to what you edited now. But the answer what i had entered is working for me with wp_enqueue_script('prettyphoto' );Passing
Well the reason why it worked for you, is because you didn't re-register a script with that name and path. So the enqueue call basically blanked out the action for that script name. That does work, but I prefer to dequeue and deregister altogether completely to ensure there are no handlers for that script name.Armada
T
0

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' );
}
Tracietracing answered 25/1, 2017 at 19:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.