WP | Dequeque Styles from Calculated Fields Form - wordpress

My wp dequeque function in the functions.php isn't removing the styles from the plugin "Calculated Fields Form". How can I remove these styles from my page?
My function:
// Remove CFF Styles
function remove_calcform_styles() {
wp_dequeue_style( 'cpcff_stylepublic' );
wp_dequeue_style( 'cpcff_jquery_ui' );
wp_dequeue_style( 'cpcff_template_csscp_cff_11' );
}
add_action( 'wp_enqueue_scripts', 'remove_calcform_styles', 999 );

In Calculated Form fields plugin wp_enqueue_style used directly, that's why when you add hook for the wp_enqueue_scripts nothing happens.
Try to add hook for the init action:
function remove_calcform_styles() {
wp_dequeue_style( 'cpcff_stylepublic' );
wp_dequeue_style( 'cpcff_jquery_ui' );
wp_dequeue_style( 'cpcff_template_csscp_cff_11' );
}
add_action( 'init', 'remove_calcform_styles', 10 );
UPDATE
Try also plugins_loaded action:
add_action( 'plugins_loaded', 'remove_calcform_styles', 10 );

Related

wp_dequeue_script not work | WordPress 6.1.1

I want to remove custom js and css of core wordpress.
I followed the construction on wordpress.org
function wpdocs_dequeue_script( ) {
wp_dequeue_script( 'jquery-ui-core' );
}
add_action( 'wp_print_scripts', 'wp_dequeue_script', 100 );
Unfortunately, this not work in my case.
I installed WordPress 6.1.1. Is there any changes?
you need to call your function in the hook:
function wpdocs_dequeue_script( ) {
wp_dequeue_script( 'jquery-ui-core' );
}
add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 );

How to dequeue or deregister specific woocoomerce script in wordpress admin panel

I need to remove Woocommerce script: wc-admin-order-meta-boxes-js (woocommerce/assets/js/admin/meta-boxes-order.min.js) from the edit-order page or all admin pages in woocommerce. I tried everything but nothing works. Can anyone help me? Thanks.
For example, I tried this:
add_action( 'admin_print_script', 'remove_admin_scripts', 1 );
function remove_admin_scripts() {
// Dequeue
wp_dequeue_script( 'wc-admin-order-meta-boxes-js' );
// Deregister
wp_deregister_script( 'wc-admin-order-meta-boxes-js' );
}
You are calling the wrong name of the script. You can just dequeue as it is enqueued, but with a higher priority.
add_action( 'admin_enqueue_scripts', 'remove_admin_scripts', 99 );
function remove_admin_scripts() {
// Dequeue.
wp_dequeue_script( 'wc-admin-order-meta-boxes' );
// Deregister.
wp_deregister_script( 'wc-admin-order-meta-boxes' );
}
This is tested and works.

Remove photoswipe-css and photoswipe-default-skin-css in WordPress

I am building a custom webshop and I am trying to remove the photoswipe style documents but I can't seem to get rid of them, I tried a couple of "solutions" that I found online but they are not working. This is what I tried so far in the functions.php:
remove_theme_support( 'wc-product-gallery-zoom' );
remove_theme_support( 'wc-product-gallery-lightbox' );
remove_theme_support( 'wc-product-gallery-slider' );
and
add_filter( 'woocommerce_enqueue_styles', 'wpf_dequeue_styles' );
function wpf_dequeue_styles( $enqueue_styles ) {
unset( $enqueue_styles['photoswipe-css'] );
unset( $enqueue_styles['photoswipe-default-skin-css'] );
return $enqueue_styles;
}
and
wp_dequeue_script('photoswipe-css');
wp_dequeue_script('photoswipe-default-skin-css');
Can someone help me finding the solution? I don't have any images in my webshop so I do not need these scripts.
You can remove_theme_support using after_setup_theme action hook.
add_action( 'after_setup_theme', 'remove_photoswipe_css', 11 );
function remove_photoswipe_css() {
remove_theme_support( 'wc-product-gallery-zoom' );
remove_theme_support( 'wc-product-gallery-lightbox' );
remove_theme_support( 'wc-product-gallery-slider' );
}
You can wp_dequeue_style using wp_enqueue_scripts action hook.
add_action( 'wp_enqueue_scripts', 'dequeue_photoswipe_css', 11 );
function dequeue_photoswipe_css() {
wp_dequeue_style( 'photoswipe-css' );
wp_dequeue_style( 'photoswipe-default-skin-css' );
}
If anyone is still looking for the answer to this then the correct code would be :
add_action( 'wp_enqueue_scripts', 'dequeue_photoswipe_css', 99);
function dequeue_photoswipe_css() {
wp_dequeue_style( 'photoswipe' );
wp_dequeue_style( 'photoswipe-default-skin-css' );
wp_dequeue_script( 'photoswipe-ui-default' );
}

How to remove gutenberg_render_title_tag from theme function file?

I have try remove action but not working.
add_action( 'wp_loaded', 'remove_my_action' );
function remove_my_action() {
remove_action( 'wp_head', 'gutenberg_render_title_tag', -1 );
}
or
add_action( 'init', 'remove_my_action' );
function remove_my_action() {
remove_action( 'wp_head', 'gutenberg_render_title_tag', -1 );
}
i am using yoast plugin. Yoast plugin also using remove action https://github.com/Yoast/wordpress-seo/blob/trunk/src/integrations/front-end-integration.php#L220 but it's not working. Still tag coming two time. i wants to remove gutenberg title tag.
I got the solution for this.
add_action( 'wp', 'remove_default_guten_title' );
function remove_default_guten_title() {
foreach ( gutenberg_get_template_type_slugs() as $template_type ) {
add_filter( str_replace( '-', '', $template_type ) . '_template', 'remove_default_title', 21, 3 );
}
}
function remove_default_title() {
remove_action( 'wp_head', 'gutenberg_render_title_tag', 1 );
return gutenberg_dir_path() . 'lib/template-canvas.php';
}

Deregister scripts on unnecessary pages in WP

I have installed WP Pokks plugin. I using in on some of pages and need to deregister its styles and scripts on other pages.
I found some code in plugin which registers scripts:
### Function: Enqueue Polls JavaScripts/CSS
add_action('wp_enqueue_scripts', 'poll_scripts');
function poll_scripts() {
// code
}
So for deregistering its scripts i am using next code in my functions.php:
add_action( 'wp_enqueue_scripts', 'deregister_polls_scripts_and_styles' );
function deregister_polls_scripts_and_styles() {
if ( is_home() ) {
remove_action( 'wp_enqueue_scripts', 'poll_scripts');
}
}
So it must deregister polls scripts on homepage, but id does not. What i am doing wrong?
You can use like this
add_action( 'wp_print_scripts', 'de_script', 100 );
function de_script() {
wp_dequeue_script( 'jquery' );
wp_deregister_script( 'jquery' );
}

Resources