Profile image for Christi Richards christirichards
Slider example to debug a camel casing issue.
Language
PHP
Tags
camel case debug slider

Slider

1 if ($sq->have_posts()) : 2 $slider_id = 'slider-'.rand(2,20000); 3 $out = "<script type=\"text/javascript\"> var \$s = jQuery.noConflict(); \$s(window).load(function(){ \$s('#".$slider_id."').cycle({ fx: 'fade', speed: ".$speed.", timeout: ".$timeout.", sync: 1, pause: 1, cleartype: true, pager: '#".$slider_id."-nav', })})</script>"; 4 $out .= "<div class=\"slider\"><ul class=\"cycle_slider\" id=\"".$slider_id."\">"; 5 while ($sq->have_posts()) : $sq->the_post(); 6 $time = get_the_time(get_option('date_format')); 7 $permalink = get_permalink(); 8 $title = get_the_title(); 9 $excerpt = short(get_the_excerpt(), 140); 10 $bloginfo = get_template_directory_uri(); 11 if ( has_post_thumbnail()) { 12 $img_src = wp_get_attachment_image_src( get_post_thumbnail_id($GLOBALS['post']->ID), 'size_460_200'); 13 $thumbnail = $img_src[0]; 14 } 15 else $thumbnail = ''; 16 $default_thumb = $bloginfo.'/images/post_thumb.jpg'; 17 $thumbnail = ( $thumbnail == '' ) ? $default_thumb : $thumbnail; 18 $format = '<li><span class="slide_date">Daily video for %6$s</span><a href="%3$s" onClick="' . '_gaq.push' . '([' . '"_trackEvent", "HomepageSlider", "Click", "%4$s", "1", "true"' . '])' .'" rel="bookmark" title="' . __( 'Permanent Link to %4$s', 'nutritionfacts' ) . '"><img src="%2$s" alt="%4$s"/></a><span class="player_control"><a class="play_video" href="%3$s" rel="bookmark" title="" onClick="' . '_gaq.push' . '([' . '"_trackEvent", "HomepageSlider", "Click", "%4$s", "1", "true"' . '])' .'"></a></span><div class="show_desc"><h1><a href="%3$s" rel="bookmark" title="' . __( 'Permanent Link to %4$s', 'nutritionfacts' ) . '" onClick="' . '_gaq.push' . '([' . '"_trackEvent", "HomepageSlider", "Click", "%4$s", "1", "true"' . '])' .'">%4$s</a></h1><p>%5$s</p></div></li>'; 19 $out .= sprintf ($format, $bloginfo, $thumbnail, $permalink, $title, $excerpt, $time); 20 endwhile; 21 $out .= "</ul><ul class=\"cycle_nav\" id=\"".$slider_id."-nav\"></ul></div>"; 22 return $out; 23 endif; 24 wp_reset_postdata(); // Restore global post data stomped by the_post(). 25 }

Comments