Thursday 15 April 2010

javascript - Can't find where/how WordPress scripts are imported wp_head(); -



javascript - Can't find where/how WordPress scripts are imported wp_head(); -

hi have problem wordpress website.

i'm changing way scripts loaded on website (async vs sync) , doing purge useless scripts (multiple versions of jquery etc. etc.). of them loaded plain , simple on header (header.php) , have moved them already, of others loaded function called wp_head();

this function loads lot of stuff (scripts , plain text javascript) can't find is...

i read there how find html rendered <?php wp_head(); ?> in wordpress? there many function hooked 1 by, instace, plugins , more how possible find them all?

anyone can help me?

thanks

usually scripts hooked in wp_enqueue_scripts hook hooked in wp_head. i mean because not every developer follows guidelines.

you can check functions hooked in wp_enqueue_scripts using functions, @rarst created

put in functions.php.

function dump_hook( $tag, $hook ) { ksort($hook); echo "<pre>>>>>>\t$tag<br>"; foreach( $hook $priority => $functions ) { echo $priority; foreach( $functions $function ) if( $function['function'] != 'list_hook_details' ) { echo "\t"; if( is_string( $function['function'] ) ) echo $function['function']; elseif( is_string( $function['function'][0] ) ) echo $function['function'][0] . ' -> ' . $function['function'][1]; elseif( is_object( $function['function'][0] ) ) echo "(object) " . get_class( $function['function'][0] ) . ' -> ' . $function['function'][1]; else print_r($function); echo ' (' . $function['accepted_args'] . ') <br>'; } } echo '</pre>'; } function list_hooks( $filter = false ){ global $wp_filter; $hooks = $wp_filter; ksort( $hooks ); foreach( $hooks $tag => $hook ) if ( false === $filter || false !== strpos( $tag, $filter ) ) dump_hook($tag, $hook); }

and phone call this: list_hooks( 'wp_enqueue_scripts' );

i recommend in development environment. homecoming list of functions hooked in wp_enqueue_scripts hook. know more functions check post debug wordpress hooks.

javascript wordpress

No comments:

Post a Comment