how to move wp_enqueue_scripts in front of ?
-
a plugin wp_enqueue_scripts function adds 2 JS scripts in my header between meta title and description …
How can I move them directly in front of </head> or if possible into footer?protected function enqueue_js($slug, $file, $ver = false, $prerequisite=false, $params=false, $footer = false, $json = false)
{
if(is_array($params) && $json)
{
?>
<script type=”text/javascript”>
var <?php echo str_replace(‘-‘,’_’,$this->id).’_’.$slug; ?> = <?php echo json_encode( $params ); ?>;
</script>
<?php
}
wp_enqueue_script($this->id.($slug?(‘_’.$slug):”), $file, is_array($prerequisite)?$prerequisite:array(‘jquery’), $ver ? $ver : $this->ver, $footer);if(is_array($params) && !$json)
wp_localize_script($this->id.($slug?(‘_’.$slug):”), str_replace(‘-‘,’_’,$this->id).’_’.$slug, $params);
}
/** function/method
* Usage: helper for hooking css scripts
* Arg(3): slug (string), file (string), ver (string)[optional, default: ‘0.1’]
* Return: void
*/
protected function enqueue_css($slug, $file, $ver = false)
{
wp_register_style( $this->id.($slug?(‘_’.$slug):”), $file, false, $ver ? $ver : $this->ver );
wp_enqueue_style( $this->id.($slug?(‘_’.$slug):”));
}
}$kkStarRatings_obj = new BhittaniPlugin_kkStarRatings(‘bhittani_plugin_kksr’, ‘kk Star Ratings’, ‘2.4’);
// Setup
register_activation_hook(__FILE__, array($kkStarRatings_obj, ‘activate’));// Scripts
add_action(‘wp_enqueue_scripts’, array($kkStarRatings_obj, ‘js’));
add_action(‘wp_enqueue_scripts’, array($kkStarRatings_obj, ‘css’));
add_action(‘wp_head’, array($kkStarRatings_obj, ‘css_custom’));
add_action(‘admin_init’, array($kkStarRatings_obj, ‘admin_scripts’));// Menu
add_action(‘admin_menu’, array($kkStarRatings_obj, ‘menu’));// AJAX
add_action(‘wp_ajax_kksr_admin_reset_ajax’, array($kkStarRatings_obj, ‘kksr_admin_reset_ajax’));
add_action(‘wp_ajax_kksr_ajax’, array($kkStarRatings_obj, ‘kksr_ajax’));
add_action(‘wp_ajax_nopriv_kksr_ajax’, array($kkStarRatings_obj, ‘kksr_ajax’));
- The topic ‘how to move wp_enqueue_scripts in front of ?’ is closed to new replies.