* @date May 12th 2010 * */ Class BannerManager{ var $path; function BannerManager(){ $this->path = dirname(__FILE__).'/'; } function getBannersByName($name){ $banners = array(); $bannerResults = query_posts(array( 'post_type'=>'animated-banner', 'name'=>$name )); foreach($bannerResults as $banner){ // get captions $captions=array(); $captionResults = wp_get_object_terms($banner->ID,'caption'); foreach($captionResults as $caption){ $captions[]= "
". ""; } $banners[]=array( 'content'=>$banner->post_content, 'captions'=>$captions ); } return $banners; } function getBannerContent($options){ // defaults if(!$options['selector']) $options['selector']='IMG'; // supporting scripts wp_enqueue_script('jquery'); global $scriptLoaded; if(!$scriptLoaded){ $content = ''; $scriptLoaded=true; } // get our banners and captions $banners = $this->getBannersByName($options['name']); // write script and tags for these banners foreach($banners as $banner){ // unique ID for js, could use the slug possibly $bannerID=md5(serialize($banner)); $delay=1000; // Javascript Array format for Captions $theseCaptions = implode($banner['captions'], "','" ); $theseCaptions = ereg_replace("\r\n", " ",$theseCaptions);; $theseCaptions = "['{$theseCaptions}']"; $content.='