490 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says
hi
as themeforest require load scripts from wp_head . and the wp_head must be immediately </head>
so how can I call a function with options from php?
I can’t call this function inside the script.js to load from wp_head. I must place this function below the wp_head because I can get jquery work after wp_head loaded
jQuery(document).ready(function(){
            //call slider
            jQuery('#main-slider').wopeslider({
                'height': 960,
                'width' : <?php echo empty($slider_options['slider_height']) ? 400 : $slider_options['slider_height'] ;?>
            });
...
});
1465 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Croatia
OriginalEXE says

I am not sure what the problem is, but you don’t have to manually echo php variables, use wp_enqueue_script to enqueue script.js, make sure it’s dependency is set to jquery, and then use this function: http://codex.wordpress.org/Function_Reference/wp_localize_script

490 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says

maybe you’re right , let me try it.

193 posts
  • Author had a Free File of the Month
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 2-3 years
  • Exclusive Author
  • Bought between 1 and 9 items
  • Europe
ikaruna says

maybe you’re right , let me try it.

he is definitely right, otherwise you will get rejected, and worse – different problems might show up on different systems, also don’t forget to enqueue script specifying which lib the script depends on.

cheers!

490 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says


maybe you’re right , let me try it.

he is definitely right, otherwise you will get rejected, and worse – different problems might show up on different systems, also don’t forget to enqueue script specifying which lib the script depends on.

cheers!

thanks!
I call javascript below the html blocks :D

161 posts
  • Bought between 1 and 9 items
  • Europe
  • Has been a member for 1-2 years
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
themebros says

Or you can go with this:

add_action( 'wp_head', 'yourprefix_head_js' );
function yourprefix_head_js(){
    ?>
         <script type="text/javascript">
             /* The JavaSript */
         </script>
    <?php
}
1179 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 6-7 years
mabuc says

try this..

function slider() {

<script type="text/javascript">    
jQuery(document).ready(function(){
            //call slider
            jQuery('#main-slider').wopeslider({
                'height': 960,
                'width' : <?php echo empty($slider_options['slider_height']) ? 400 : $slider_options['slider_height'] ;?>
            });
...
});
</script> 

}

add_action( 'wp_head', 'slider' );
161 posts
  • Bought between 1 and 9 items
  • Europe
  • Has been a member for 1-2 years
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
themebros says

@mabuc

Always add a prefix.

Prefix everything

And $slider_options doesn’t exists in there, needs to be defined at the top of the function first.

490 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
wopethemes says

thanks bros for suggestions :D

161 posts
  • Bought between 1 and 9 items
  • Europe
  • Has been a member for 1-2 years
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
themebros says

thanks bros for suggestions :D

You’re welcome :)

by
by
by
by
by
by