PHP must expand the shortcode and assign the expanded value to javascript, either when it is echoing out the <script> block or by using wp_localize_script().
The only way to get dynamic PHP values when javascript is actually being executed is via an AJAX request.
im no coding genius but hers a try
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(window).load(function () {
jQuery('#comp1').HoverAlls({tooltip:true,starts:"-100px,-20px",ends:"-100px,5px",returns:"-100px,-20px",bg_class:"tooltip4background",speed_in:1000,speed_out:380,effect_in:"easeOutBack",effect_out:"easeInSine",bg_width:"400px",bg_height:"325px",html_mode:"'.do_shortcode('[shortname]').'"});
});
</script>
i included '.do_shortcode('[shortname]').'
………….and look over your code, make sure it ends properly,
jquery is better to use, so it won’t conflict with anything..
http://codex.ww.wp.xz.cn/Shortcode
http://codex.ww.wp.xz.cn/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers
My code works properly. I have it set up to work in html, then moved it over to WordPress, then intergrated to the plugin, that way I knew at what point it broke. I’m not a strong coder, so I knew that it would break at some point.
When I get the ‘.do_shortcode(‘[shortname]’).’ into the footer, it prints it as ‘.do_shortcode(‘[shortname]’).’ without replacing the content 🙁
strangely it doesn’t mind the $ being in the code, and it works fine as you see here
http://demo6.getblinged.com/new-company-2/
In order to get that to work. I’ve called this function in the function
function hoverall_footer() {
echo '<script type="text/javascript">
$(window).load(function () {
$(\'.kimberlee-aubrey\').HoverAlls({tooltip:true,starts:"-100px,-20px",ends:"-100px,5px",returns:"-100px,-20px",bg_class:"tooltip4background",speed_in:1000,speed_out:380,effect_in:"easeOutBack",effect_out:"easeInSine",bg_width:"450px",bg_height:"auto",html_mode:"#kimberlee-aubrey"});
});</script>';
}
add_action ('wp_footer','hoverall_footer');
but the kimberlee-aubrey needs to be replaced with [staff-name-slug]
Thanks so much for the help!
i used jQuery, because $ might conflict with a plugin or theme later on. So jQuery is WordPress safety….
And are you sure that you are using the double quotes and single quotes with it like so:
“‘.do_shortcode(‘[shortname]’).'”
one double quote, one single quote then .do_shortcode(‘[shortname]’). and one single quote then one double quote….
??
try this..
function hoverall_footer() {
echo '<script type="text/javascript">
$(window).load(function () {
$(\'.kimberlee-aubrey\').HoverAlls({tooltip:true,starts:"-100px,-20px",ends:"-100px,5px",returns:"-100px,-20px",bg_class:"tooltip4background",speed_in:1000,speed_out:380,effect_in:"easeOutBack",effect_out:"easeInSine",bg_width:"450px",bg_height:"auto",html_mode:"#'.do_shortcode('[shortname]').'"});
});</script>';
}
add_action ('wp_footer','hoverall_footer');
test the shortcode on a post, and make sure the slug-name is really working..also
leave the # just how i have it, in the above reply