public function get_html() { $params = $this->params; $params['style'] = $params['style'] . " " . $params['direction'] . " ppv" . $params['ppv'] . " img_size" . $params['img_size']; // adds classes of (eg) "vertical img_size75 ppv2" $html = "\n\n<div class='" . $params['style'] . "'>\n"; // manually tweak classes ppv2, ppv3 etc to set height of this div $html .= extra_markup($params); // v4.2 if ($params['heading'] != '') { $html .= "<div class='hwrap'><h2>" . $params['heading'] . "</h2></div>\n"; // <div class='hwrap'> added for carplus v3.16 } $html .= "<!-- root element for scrollable -->\n"; $html .= "<div class='scrollable " . $params['direction'] . "'>\n"; $html .= "<!-- root element for the scrollable elements -->\n"; $html .= "<div class='items'>\n"; if (!$params['cat']) { // specific posts are specified $args = array('post_type' => array_merge(get_post_types(array('_builtin' => false)), array('post')), 'posts_per_page' => -1, 'post_status' => null, 'post_parent' => null, 'post__in' => $params['ids']); $scrollposts = get_posts($args); $imax = count($params['ids']); for ($i = 0; $i < $imax; $i++) { $content = wf_filter_content($scrollposts[$i]->post_content); //$title = $scrollposts[$i] -> post_title; $title = remove_square_brackets($scrollposts[$i]->post_title); //v3.36 $link = get_permalink($scrollposts[$i]->ID); if ($i % $params['ppv'] == 0) { // 0, 2, 4 - it's the start of a new scrollable screenful $html .= "\n<div class='view'>\n"; // v4.2 } $html .= "<div class='item'>\n"; // v4.2 if (has_post_thumbnail($scrollposts[$i]->ID) && $params['img_size'] != 0) { // v3.38 $img_html = wp_get_attachment_image(get_post_thumbnail_id($scrollposts[$i]->ID), 'thumbnail'); //$img_html= add_class($img_html,'alignleft'); $img_html = change_width_and_height($img_html, $params['img_size'], $params['img_size']); // v3.49 Was 100,100 $html .= $img_html; } $html .= "<div class='content'>\n"; if (strpos($params['format'], 'h') === false) { // v3.45 $html .= "<h3 class='h3 link'><a href='" . wf_linkfix($link) . "'>" . $title . "</a></h3>\n"; } $html .= wpautop($content); $html .= "\n<div class='fade'> </div>\n"; $html .= "</div>\n"; // <div class='content'> $custom_fields = get_post_custom($scrollposts[$i]->ID); // v3.37 // preint_r($custom_fields); // v3.37 This section now looks for a customfield "extras" applied to the post, and gives priority to this for "link" if (isset($custom_fields['extras'])) { // v3.37 $qstring = qscode($custom_fields['extras'][0]); // the QUERYSTRING version parse_str($qstring, $q_array); // parses the querystring into an associative array if ($q_array['link']) { if ($q_array['link'] == 'default') { // go and get the stored version $coverlink = $link; } else { $coverlink = wf_linkfix($q_array['link']); } $html .= "<a class='coverlink' href='" . $coverlink . "'> </a>\n"; // v3.37 } } $html .= "</div>\n"; // <div class='item'> if (($i + 1) % $params['ppv'] == 0) { // 0, 2, 4 - it's the end of this scrollable screenful $html .= "</div>\n"; } } // for loop } else { // category has been specified $args = array('post_type' => array_merge(get_post_types(array('_builtin' => false)), array('post')), 'post_status' => $params['status'], 'posts_per_page' => $params['show_posts'], 'category__in' => $params['cat'], 'order' => strtoupper($params['order']), 'paginate' => false); $html .= get_catposts($args, $params); // all wrapped in <div class="posts"></div> } $html .= "</div>\n"; // class='items' $html .= "</div>\n"; // class='scrollable vertical' $html .= "</div>\n\n"; // id='vert_scroller' $widget_params['interval'] = $params['interval']; $widget_params['speed'] = $params['speed']; $widget_params['direction'] = $params['direction']; // Clever wheeze to get round lack of anonymous function support before PHP 5.3 if (!function_exists('pass_scroller_params')) { function pass_scroller_params($widget_params) { wp_enqueue_script('init_scroller'); wp_localize_script('init_scroller', 'scroller_params', $widget_params); } } pass_scroller_params($widget_params); return $html; }
public function get_html() { $params = $this->params; if ($params['ids'] === false) { // v6.2 || $params['height'] === false || $params['width'] === false) { return; // bail out if we haven't got the required parameters } if ($params['layout']) { // v5.6 $params['style'] = $params['style'] . " " . $params['layout']; // adds class of (eg) 'tabs' } //$posttypes = array_merge(get_post_types( array('_builtin'=> false)),array('post','attachment','page') ); // v6.28 added page $posttypes = array_keys(get_insertable_posttypes()); // v6.52 $args = array('post_type' => $posttypes, 'posts_per_page' => -1, 'post_status' => 'any', 'post_parent' => null, 'post__in' => $params['ids']); //FB::info($args,'$args'); $rankedposts = get_ranked_posts($args); // v6.4 Was $this->get_ranked_posts $html_slidemain = "\n\n<div id='slidemain'>\n"; $html_text = ''; // needed for attachment version $html_thumb = "<div id ='slidethumbs'>\n"; $c = 0; // NB non-human counting from 0! $video_ids = array(); // an array of ids used by the YouTube API // v4.1 foreach ($rankedposts as $rankedpost) { $img_id = ''; // v6.11 so wf_get_credits($img_id) can bail out for videos unset($q_array); // v6.28 so that values from last time get destroyed. Don't need to check isset() first $html_slidemain .= "\n<div id ='slide" . $c . "' class='slide'>\n"; if ($rankedpost->post_type != 'attachment') { // a post, so get image id (and link?) from customfield in the post (not the page) $custom_value = get_post_meta($rankedpost->ID, 'extras', true); // the contents of customfield extras - or '' if ($custom_value != '') { $qstring = qscode($custom_value); // the QUERYSTRING version parse_str($qstring, $q_array); // parses the querystring into an associative array } if (isset($q_array['featured_video'])) { // v4.1 'featured_video' takes precedence over 'slidepic_id' and featured image $this_img = "<iframe id='player_" . $c . "' width='290' height='200' src='http://www.youtube.com/embed/" . $q_array['featured_video'] . "?rel=0&enablejsapi=1' frameborder='0' allowfullscreen></iframe>"; $video_ids[] = 'player_' . $c; } else { if (isset($q_array['slidepic_id'])) { $img_id = $q_array['slidepic_id']; // v4.1 'slidepic_id' takes precedence over featured image } else { if (has_post_thumbnail($rankedpost->ID)) { $img_id = get_post_thumbnail_id($rankedpost->ID); } else { throw new WF_Exception('Slideshow: no image or video found'); // v4.1 } } $this_img = wp_get_attachment_image($img_id, $size = $params['pic_size'], $icon = false, $attr = array('alt' => '', 'title' => '')); } $html_slidemain .= $this_img; if ($params['text_type'] != 'none') { // v6.28 $html_slidemain .= "\n<div class='slide_text'>\n"; if ($params['showtitles'] || $params['text_type'] == 'titles') { // v6.28 $html_slidemain .= "<h4>" . remove_square_brackets($rankedpost->post_title) . "</h4>\n"; // v6.28 } //$html_slidemain .= postProcessSidepost($rankedpost->post_content)."</div>\n"; $html_slidemain .= Wf_Widget::get_excerpt_or_full($rankedpost, $params['text_type'], $list = false) . "</div>\n"; // v6.28 } if (isset($q_array['link']) || $params['selflinks']) { // some sort of link is required // v4.1 v4.3 $coverlink = $params['selflinks'] ? get_permalink($rankedpost->ID) : wf_linkfix($q_array['link']); // v4.1 $html_slidemain .= "<a class='coverlink' href='" . $coverlink . "'> </a>\n"; // v3.22 (was slidelink) } //} else { //throw new WF_Exception('Slideshow: no customfield found'); // v4.1 } else { // it's an attachment $img_id = $rankedpost->ID; $this_img = wp_get_attachment_image($img_id, $size = $params['pic_size'], $icon = false, $attr = array('alt' => '', 'title' => '')); $html_slidemain .= $this_img . "\n"; } $html_slidemain .= wf_get_credits($img_id); // returns empty if no 'credit=' in description, otherwise a <div> (or <a> if it's a link) // v6.27 switch ($params['layout']) { case 'tabs': //case 'buttons': $this_img = " "; case 'thumbnails': // and 'buttons' $html_thumb .= "\n<span class='slidethumb' id ='slidethumb" . $c . "'>\n" . $this_img . "\n"; $html_thumb .= "<span class='darkner'></span>\n</span>\n"; // v6.30 changed divs to spans break; } $html_slidemain .= "</div>\n"; // v6.27 $c++; } // foreach $html = "\n\n<div id='slideshow' class='" . $params['style'] . "'>"; // assemble it all $html .= extra_markup($params); // v6.65 if ($params['heading']) { // v3.36 $html .= "\n<div class='hwrap'>\n<h2>" . $params['heading'] . "</h2>\n</div>\n"; } $html .= $html_slidemain . "\n</div>\n\n"; if ($params['layout']) { // == 'thumbnails' || $params['layout'] == 'buttons') { // v6.27 $html .= $html_thumb . "\n</div>\n\n"; } $html .= "</div>\n\n"; $html = str_replace('title=""', '', $html); if (!empty($video_ids)) { // v4.1 global $widget_params; $widget_params = $video_ids; if (!function_exists('pass_youtube_params')) { function pass_youtube_params($widget_params) { wp_enqueue_script('init_videos_js'); global $widget_params; wp_localize_script('init_videos_js', 'video_params', $widget_params); } } add_action('wp_enqueue_scripts', 'pass_youtube_params'); } // v6.69 $this->js_params['speed'] = $params['speed']; $this->js_params['interval'] = $params['interval']; self::add_action('wp_enqueue_scripts', 'pass_js_params'); return $html; }
protected function output_a_post($rankedpost, $params) { // v3.50 global $post; $post_store = $post; //v6.52 $post = $rankedpost; // v3.40 $html = ''; d('$rankedpost->ID', $rankedpost->ID); if ($rankedpost->post_type != 'attachment') { // changed from == 'post' 19.3.12 3.18 $html .= "\n<div class='" . $params['style'] . "'>\n"; $html .= Wf_Widget::wf_editlink($rankedpost->ID); // v5.9 $html .= extra_markup($params); // v4.2 $custom_fields = get_post_custom($rankedpost->ID); // v3.32 // v3.37 This section now looks for a customfield "extras" applied to the post, and gives priority to this for "when" and "link" $when_html = ''; // if (isset($custom_fields['when'])) { // an array //$html .= "<p class = 'details'>".$when[0]."</p>\n"; // v3.37 DODGY!! Has $when been defined? $when_html = "<p class = 'details'>" . $custom_fields['when'][0] . "</p>\n"; } if (isset($custom_fields['extras'])) { // v3.37 $qstring = qscode($custom_fields['extras'][0]); // the QUERYSTRING version parse_str($qstring, $q_array); // parses the querystring into an associative array //preint_r($q_array); if (isset($q_array['link'])) { $params['link'] = wf_linkfix($q_array['link']); // NB this over-rides any "link" parameter that's set for leftpost, rightpost etc. } if (isset($q_array['when'])) { $when_html = "<p class = 'details'>" . $q_array['when'] . "</p>\n"; // NB this over-rides any value set in customfield "when". } } $html .= $when_html; if ($params['show_title']) { $title = remove_square_brackets($rankedpost->post_title); //v3.36 $html .= "<div class='hwrap'><h2>" . $title . "</h2></div>\n"; // <div class='hwrap'> added for carplus v3.15 } $img_html = ''; if ($params['pic_size']) { if (has_post_thumbnail($rankedpost->ID) && $params['pic_size'] != '0') { // v3.38 $feature_pic_id = get_post_thumbnail_id($rankedpost->ID); $img_html = wp_get_attachment_image($feature_pic_id, $params['pic_size']); //$img_html = change_width_and_height($img_html,$img_size,$img_size); // v3.49 Was 100,100 $img_html .= wf_get_caption($rankedpost, $params['caption']); // 3.26 $img_html .= wf_get_credits($feature_pic_id); // returns empty if no 'credit=' in description, otherwise a suitable <div> (or <a> if it's a link) $img_html = "<div class='picwrap'>" . $img_html . "</div>\n"; // v3.65 } } if (isset($params['format']) && strpos($params['format'], 'l') !== false) { //v5.12 $list = true; } else { $list = false; } //d('$list',$list); // (F3) calls Wf_Debug $html .= "<div class='postwrap'>" . $img_html . Wf_Widget::get_excerpt_or_full($rankedpost, $params['type'], $list) . "</div>\n"; //v5.12 $list } else { // assume it must be 'attachment' $html .= "\n<div class='" . $params['style'] . " attachment'>\n"; // v4.2 $html .= Wf_Widget::wf_editlink($rankedpost->ID); // v5.9 $html .= extra_markup($params); // v4.2 $html .= "\n<div class='credit_wrap'>\n"; // v6.46 $html .= wp_get_attachment_image($rankedpost->ID, $size = $params['pic_size'], $icon = false, $attr = array('title' => '')); $html .= wf_get_credits($rankedpost->ID); // returns empty if no 'credits=' in description, otherwise a suitable <div> (or <a> if it's a link) $html .= "</div>\n"; // .credit_wrap // v6.46 $html .= wf_get_caption($rankedpost, $params['caption']); // 3.26 } if ($params['link']) { if (!isset($q_array['linktext'])) { //v3.40 $linktext = " "; } else { $linktext = $q_array['linktext']; } $html .= "\n<a class='endlink coverlink' href='" . $params['link'] . "'>" . $linktext . "</a>\n"; //v3.40 //v3.41 } $html .= "</div>\n"; $post = $post_store; //v6.52 return $html; }