WordPress.org

Ready to get started?Download WordPress

Forums

wp_enqueue_script problem! (2 posts)

  1. Igor Sazonov
    Member
    Posted 1 year ago #

    Hi.
    I found may be a bug with wp_register_script/wp_enqueue_script.
    I have some handle-scripts like jquery, jquery-ui to enqueue, its ok. Also I have my known js-files to enqueue, ok too. BUT! When I want to enqueue dynamic js (gets from folders), it enqueue too BUT BEFORE jquery, jquery-ui itc. Some code:

    wp_enqueue_script('jquery'); //ok
    wp_register_script('jquery-ui-tabs-rotate', plugins_url('js/jquery-ui-tabs-rotate.js', $this->indexFile/*my index file*/), self::$_requiredJSHandles /* this is like array('jquery')*/);
    wp_enqueue_script('jquery-ui-tabs-rotate');//ok
    foreach ($this->_enabledSliders as $slidernum) {
                    $skin_name = self::_lenslider_get_slider_skin_name($slidernum);
                    if($skin_name != self::$defaultSkin) {
                        $skinObjStatic = LenSliderSkins::lenslider_get_skin_params_object($skin_name);
                        if(!empty($skinObjStatic->jsFiles) && is_array($skinObjStatic->jsFiles)) {
                            foreach ($skinObjStatic->jsFiles as $filename) {
                                $reg_name = str_ireplace(".js", '', basename($filename)."-{$skin_name}");
                                wp_register_script($reg_name, str_ireplace(ABSPATH, self::$siteurl."/", $filename), self::$_requiredJSHandles);//ok but goes BEFORE jquery and jquery-ui
    wp_enqueue_script($reg_name);
                            }
                        }
    ....

    The html output:

    <!--NEED TO GO AFTER JQUERY AND JQUERY UI LOAD-->
    <script type='text/javascript' src='http://site.com/wp-content/plugins/len-slider/skins/nemo_target/output/js/nemo-target-skin.js?ver=3.5-RC2'></script>
    <!--NEED TO GO AFTER JQUERY AND JQUERY UI LOAD-->
    <script type='text/javascript' src='http://site.com/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
    <script type='text/javascript' src='http://site.com/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.9.2'></script>
  2. Moving this to the Troubleshooting forum. Alpha/Beta is for issues relating to the current development version (right now, that's 3.5) only.

Topic Closed

This topic has been closed to new replies.

About this Topic