Thanks Marventus/ Voodo - went through the suggested articles.
And while i think i have followed things said over there, i am still facing issues. The same old js and css files appear in header, even after going through the suggested process.
Here's what I did:
STEP 1: I located the handlers for the plugin in question - "paypal shopping cart"
add_action('wp_head', 'wp_cart_css');
add_action('wp_head', 'wp_cart_add_read_form_javascript');
The said plugin does not use
wp_enqueue_style
Accordingly the handlers are:
for css - wp_cart_css
for js -wp_cart_add_read_form_javascript
I then used the following code in functions.php. I used an if statement with condition !is_page() because, i needed this plugin to load only on pages and not on single post or archive pages.
/* ------------------------------------------------------------------------------------
Code to Deregister unwanted plugin related styles & scripts from loading on all unncecessary pages
----------------------------------------------------------------------------------------*/
//Deregister scripts
add_action( 'wp_print_scripts', 'bhaskar_deregister_javascript', 100 );
//DEREGISTER wp cart javascript on all posts - load only if is page
function bhaskar_deregister_javascript() {
if ( !is_page() ) {
wp_deregister_script( 'wp_cart_add_read_form_javascript' );
}
}
//Deregister styles
//DEREGISTER wp cart css on all posts - load only if is page
add_action( 'wp_print_styles', 'bhaskar_deregister_styles', 100 );
function bhaskar_deregister_styles() {
if ( !is_page() ) {
wp_deregister_style( 'wp_cart_css' );
}
}
Even after this action - the culprit js file and the wp_shopping_cart_style.css still load onto the header in every post and archive page.
What could i be missing - Any ideas ?
Thanks for the help.