NextGen Gallery issues with Iframe plugins - wordpress

I have tried few iframe based popup plugins with WordPress Nextgen gallery. It always generates a js error from frame_event_publisher.js file.
Is there anyway to prevent the loading of this file within another plugin?

One way to fix it is to forcibly dequeue the script. You'll have to add a condition to dequeue it only when needed since NextGEN probably needs this script to work.
add_action( 'wp_print_scripts', 'dequeue_frame_event_publisher', 100 );
function dequeue_frame_event_publisher() {
if ( is_admin() ) { // Add another condition to check if in an iframe.
wp_dequeue_script( 'frame_event_publisher' );
}
}

Related

Disable WP Gutenberg prepublish checks globaly

Im creating custom user edit post interface and i need to completely remove gutenberg pos prepublish checks and publish. How can i do this?
You can disable the publish sidebar completly with
wp.data.dispatch('core/editor').disablePublishSidebar();
Simply enqueue this JS with a dependance to .
add_action( 'enqueue_block_editor_assets', function () {
wp_enqueue_script( 'so69031961', 'gutenberg-editor.js', [ 'wp-edit-post', 'wp-dom-ready' ] );
} );
This will have the same effect than unchecking this box :
So yes, your users might still be able to reactivate the checks, but it's better than nothing ;)

Must delete cache in Chrome to see css changes I made on a Wordpress wesbite. Can this be handled automatic?

I've made an Wordpress theme. But recently, after every change I make in the code, the cache in Chrome has to be deleted to see the change.
Can this be handled automatic with a plugin or a line of code to add to the funtions.php?
Yes, you can make the link to the css use a query string with a timestamp. This way you will get a unique link each load.
Assuming you are using wp_enque_style() to load the style, there is a version parameter, set this to the current time with the function time() and it will add it to the link.
function themeslug_enqueue_style() {
wp_enqueue_style( 'mystyle', 'path/to/mystyle.css', false, time() );
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );
More info about wp_enqueue_scripts

Disable prettyPhoto WordPress (Visual Composer)

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.
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 :)
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' );
}

Removing action added by a plugin in Wordpress

I am using Popup Maker plugin for Wordpress and I am trying to prevent it to load on a particular page using the functions.php file of a child theme.
I've located in the plugin's directory the file popup-maker.php which contains the following line at the end:
add_action( 'plugins_loaded', 'popmake_initialize', 0 );
If I remove / comment this line, the popup will not fire, so I guess this is the action I need to remove. I have read the WP codex and numerous posts but still can't get it to work.
Right now I am stuck at this (function I have added in my child theme's functions.php file):
function remove_popmaker() {
remove_action('plugins_loaded', 'popmake_initialize', 0);
}
add_action( 'init', 'remove_popmaker', 1 );
PS: I am using shopkeeper theme and Woocommerce.
All help appreciated, thanks.
you are adding a action to init which is after plugins_loaded so you cannot remove a action after it has run.
you can try the same action but you will have to do this from a plugin
remove_action( 'plugins_loaded', 'remove_popmaker', 0 );
But i suspect actions added before yours will be run after, this may be unpredictable if not you may have to code a MUplugin (google this).
There is a way I managed to do this:
add_action('wp', 'disableEmailPopup');
function disableEmailPopup () {
global $post;
if ($post->ID === 11625249) return remove_action( 'wp_enqueue_scripts', 'popmake_load_site_scripts');
}
#BMM - Without knowing the use case as to why you need to disable the entire plugin on one page its hard to give you the best answer.
For example if you simply wanted a single popup to not show on one page you can use the conditions panel to add a negative condition using the (!) button. Click it to turn it red and you will check for the opposite of a condition, so (!) Page Selected: Page xyz would prevent it from loading on that page.
Alternatively you can create your own custom conditions allowing you to add that condition to any popup.
Lastly if you wanted to unhook it just from the front end you can simply remove the rendering & script handlers
remove_action( 'wp_footer', 'popmake_render_popups', 1 );
remove_action( 'wp_head', 'popmake_script_loading_enabled' );
And if you want to prevent the queries as well
remove_action( 'wp_enqueue_scripts', 'popmake_preload_popups', 11 );
Hope that helps.

How do I remove Woocommerce sidebar from cart, checkout and single product pages?

Like many people that start using woocommerce for the first time I need to know how to customise it. In my particular situation I want to remove the sidebar from the Cart, Checkout and single product pages. My sidebar is defined and called from sidebar.php using the code below:
<?php dynamic_sidebar('global-sidebar'); ?>
I have tried for a long time to find an answer that works but I can't seem to find the correct code or solution. Perhaps asking the question myself will work. By the way I really appreciate the answers in the other articles and how-to's but they don't work for me.
Before I go any further I am using Bootstrap (latest version as of 2014) to style my Wordpress website. Not sure if that matters but maybe it does somehow.
Can someone please tell me how I find and then tell Woocommerce not to display any kind of sidebar on the Cart, Checkout and Single Product pages?
p.s.
The website can be found here > wp.wunderful.co.uk (staging site for a client website project)
Go to "Cart" page from dashboard pages, from "Page Attribute Section" -> "Templates" choose "Full Width" this will give you a page without sidebar.
In theory, something like the following ought to work, but I haven't tested it. (To be added to your theme's functions.php)
function so_25700650_remove_sidebar(){
if( is_checkout() || is_cart() || is_product() ){
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
}
}
add_action('woocommerce_before_main_content', 'so_25700650_remove_sidebar' );
If you look at the Woo templates you will see
<?php
/**
* woocommerce_sidebar hook
*
* #hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
?>
This is Woo saying: "Display the sidebar here". But it is adding the woocommerce_get_sidebar function to the woocommerce_sidebar hook... which is convenient because it allows you to unhook that function like I've shown above. Finally, I am using Woo's conditional logic to only unhook the function from its action on the pages you requested.
I'm running my function on the woocommerce_before_main_content hook, which I think should work assuming your theme hasn't removed that hook. If so, then you could probably use wp_head or something that is guaranteed to be there, though then you'd probably want to check that the is_checkout(), etc functions exist or risk breaking your theme should you ever deactivate WooCommerce. As I have it, i should only run on WooCommerce-specific pages and so checking if the WooCommerce functions are defined is probably overkill.
Important Note:
This assumes the default theme or a theme that isn't running its own custom sidebar functions. If your theme is doing something else you will need to investigates its particular functions and templates.
What you should do is to create a files called woocomemrce.php in your theme if it doesn't already exists. Then you should look at your page template files for full width and for page with sidebar to see how they are structured and see where they differ.
Then copy the contents of one the files into woocommerce.php and replace the loop with woocommerce_content(), see this page for details.
Lastly see where the different page templates differ and then use if-statements in the places where they differ.
if( is_post_type_archive( 'product' ) ) :
//Content to display in the list view (i.e. with sidebar)
else :
//Content to display all other views (i.e. without sidebar)
endif;
.woocommerce-cart .sidebar {
display: none;
}
.woocommerce-cart .content-area {
width: 100%;
}
add this in custom/style.css.
From
https://wordpress.org/support/topic/remove-sidebar-for-woocommerce-cart-and-checkout-pages/
On your theme, likely subtheme, function.php
add_action('wp_head', 'hide_sidebar' ); function hide_sidebar(){ if(is_cart() || is_checkout()){ ?>
<style type="text/css">
#secondary {
display: none;
}
</style>
<?php
}
To remove sidebar from the Cart, Checkout and single product pages you want to use action hook in function.php file -
add_action('woocommerce_before_main_content', 'remove_sidebar' );
function remove_sidebar()
{
if( is_checkout() || is_cart() || is_product()) {
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
}
}
Here you can get WooCommerce Action and Filter Hook
-https://docs.woothemes.com/wc-apidocs/hook-docs.html

Resources