Пример #1
0
 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'>&nbsp;</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 . "'>&nbsp;</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;
 }
Пример #2
0
 public function get_html()
 {
     $params = $this->params;
     if ($params['username'] === false || !is_int($params['count'] + 0)) {
         return;
         // bail out if we haven't got the required parameters
     }
     $html = "\n<div id='tweets' class='" . $params['style'] . "'>\n";
     $html .= extra_markup($params);
     // v6.65
     if ($params['heading']) {
         $html .= "<div class='hwrap'>\n<h2>" . $params['heading'] . "</h2>\n</div>\n";
         // including its link if there is one
     }
     $html .= "<div class='tweet_wrapper' id='twitter_fetcher'></div>\n";
     // v6.53 added #twitter_fetcher
     $html .= Wf_Widget::get_endlink($params);
     // v5.7
     $html .= "</div>\n\n";
     global $widget_params;
     $widget_params['username'] = $params['username'];
     $widget_params['count'] = $params['count'];
     $widget_params['method'] = $params['method'];
     $widget_params['outlaw_key'] = $params['outlaw_key'];
     //v6.79 - so don't have to hardwire for Carplus!
     if (!function_exists('pass_tweet_params')) {
         function pass_tweet_params($widget_params)
         {
             global $widget_params;
             //wp_enqueue_script('twitter_script');
             wp_enqueue_script('twitter_' . $widget_params['method']);
             // v6.78  approved or outlaw
             wp_enqueue_script('init_tweets_js');
             wp_localize_script('init_tweets_js', 'twitter_params', $widget_params);
             // Necessary that the array declaration and the wp_localize_script stay before wp_head()
             // wp_localize_script() MUST be called after the script it's being attached to has been enqueued.
         }
     }
     add_action('wp_enqueue_scripts', 'pass_tweet_params');
     return $html;
 }
Пример #3
0
 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 = "&nbsp;";
         } 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;
 }