1

I am looking for a way to remove/unhook all assets (css and javascript) files added to customize_controls_enqueue_scripts hook when the query string mo-reset=true is added to the customize url.

2

You can use the global $wp_scripts and global $wp_styles; to get all registerd scripts and styles.

Eg.

enter image description here

All Scripts

// All Scripts
global $wp_scripts;

$all_scripts = array();

foreach( $wp_scripts->registered as $script ) :
    $all_scripts[$script->handle] = $script->src;
endforeach;

// echo '<pre>';
// print_r( $all_scripts );
// echo '</pre>';

All Styles

// All Styles
global $wp_styles;

$all_styles = array();

foreach( $wp_styles->registered as $style ) :
    $all_styles[$style->handle] = $style->src;
endforeach;

// echo '<pre>';
// print_r( $all_styles );
// echo '</pre>';
|improve this answer|||||
  • Awesome. Exactly what I needed. Thanks @maheshwaghmare – Collizo4sky Mar 17 '18 at 8:15
0

Check wp_deregister_script().

|improve this answer|||||
  • That requires I know the handles. Which I don't know. I need to programatically know all handles added by the current theme. – Collizo4sky Mar 16 '18 at 15:16
  • I don't know if you can do get those handles by code. – Beee Mar 16 '18 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.