0

Here is a simple plugin. It use CSS code and importing it. The problem is that in the HTML file there are several external CSS files.

My goal is to compress them in one CSS file. Here's the code from the plugin, to my mind, it imports the CSS file.

I already copied the plugins CSS code and transferred it to main CSS file. But how to delete the code plugin so that it will never import its CSS file?

function addStylesAndScripts()
{
  wp_enqueue_style('zvr-font', 'https://fonts.googleapis.com/css?family=Open+Sans');
  wp_enqueue_style('zvr-style', trailingslashit(plugin_dir_url(__FILE__)) . 'assets/css/zvr-styles.css', array() , "1.0.3");
  wp_enqueue_script('zvr-script', trailingslashit(plugin_dir_url(__FILE__)) . 'assets/js/zvr-script.js', array(
    'jquery'
  ) , "1.0.3");
  $localize = array(
    'ajax_url' => admin_url('admin-ajax.php') ,
  );
  wp_localize_script('zvr-script', 'zvr_data', $localize);
}
}

2 Answers 2

1

To stop integrating the CSS file please write the following code in your functions.php :

function dequeueStyles() {
   wp_dequeue_style('zvr-font');
   wp_dequeue_style( 'zvr-style' );
}
add_action( 'wp_enqueue_scripts', 'dequeueStyles', 100 );

Hope this will help

Sign up to request clarification or add additional context in comments.

2 Comments

SHould i delete my added code from plugin file and add only your code to theme function file?
You can, or I suggest you to comment out the code you have written and paste the above code into your functions.php, if this works for you, then delete your code.
0

You can dequeue those scripts, but you need to execute it after the plugin does it. For example, add this to your theme's functions.php

function dequeue_unneeded_css() {
   wp_dequeue_style( 'zvr-style' );
}
add_action( 'wp_enqueue_scripts', 'dequeue_unneeded_css', 99999 );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.