function get_catposts($args, $params) { // v3.51 Was $args, $format, $type global $post; $post_store = $post; $widget_query = new WP_Query($args); $catposts = $widget_query->posts; d('catposts', $catposts); if ($params['date_format']) { // v6.63 $date_format = $params['date_format']; // v6.63 } else { $date_format = strpos($params['format'], 't') === false ? '\\P\\u\\b\\l\\i\\s\\h\\e\\d j/n/y g:iA' : '\\P\\u\\b\\l\\i\\s\\h\\e\\d j/n/y'; // v6.63 } $list = strpos($params['format'], 'l') === false; // v5.18 // Default behaviour (ie: no 'l' so $list is true) truncates all excerpts as plain text. $has_reveal = strpos($params['format'], 'r') !== false; // v3.84 $html = "<div class='posts " . $params['type'] . "'>\n"; // added for carplus v3.15. $type for v3.20 foreach ($catposts as $catpost) { $post = $catpost; // necessary to make 'More' links work if ($params['filter']) { // v5.9 name of function used to filter posts $fname = $params['filter']; if (function_exists($fname)) { if (!$fname($catpost)) { // true=keep, false=discard continue; } } } //$cid = $catpost ->ID; // v6.63 $html .= "<div class='post wfpid_" . $catpost->ID . " " . ($has_reveal ? 'reveal' : '') . "'>\n"; // v6.79 added class wfpid_1234 for easier jQ manipulation $html .= Wf_Widget::wf_editlink($catpost->ID); // v5.9 if (strpos($params['format'], 'w') !== false) { // 'w' shows writer $author_id = $catpost->post_author; //$html .= "<p class='author'>Author: ".get_userdata($author_id)->display_name."</p>\n"; $author = "<span class='author'>by <strong>" . get_userdata($author_id)->display_name . "</strong></span>"; } else { $author = ''; } // v6.63 if ($params['date_field']) { $date = get_post_meta($catpost->ID, $params['date_field'], true); // $single = true //echo $date; } else { $date = $catpost->post_date; // v3.35 } $date = date($date_format, strtotime($date)); // v6.63 $date = str_replace(" ", " ", $date); //$date_intro = $params['date_intro'] ? $params['date_intro'] : 'Published '; // v6.63 if (strpos($params['format'], 'd') === false) { // 'd' suppresses the date $html .= "<p class='date'>" . $date . $author . "</p>\n"; // v6.63 'Published' moved from here to date format } $img_html = ''; // v3.53 if ($params['pic_size']) { if (has_post_thumbnail($catpost->ID) && $params['pic_size'] != '0') { // v3.38 $feature_pic_id = get_post_thumbnail_id($catpost->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 if (isset($params['caption'])) { $img_html .= wf_get_caption($catpost, $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) } } $custom_fields = get_post_custom($catpost->ID); // v3.32 if (isset($custom_fields['when'])) { // an array $html .= "<p class = 'details'>" . $custom_fields['when'][0] . "</p>\n"; } if (isset($custom_fields['Descriptor'])) { // an array $html .= "<p class='type'>" . $custom_fields['Descriptor'][0] . "</p>\n"; } $title = strpos($params['format'], 'a') === false && strpos($params['format'], 'r') === false ? "<a href='" . get_permalink($catpost->ID) . "' rel='bookmark' title='Permanent Link to " . remove_square_brackets($catpost->post_title) . "' >" . remove_square_brackets($catpost->post_title) . "</a>" : remove_square_brackets($catpost->post_title); // v3.78 v3.84 v6.77 $html .= "<p class='title " . ($has_reveal ? 'reveal_head' : '') . "'>" . $title . "</p>\n"; //v5.18 if (function_exists('insert_post_extras')) { // v3.53 $html .= insert_post_extras($custom_fields, $params); // v3.53 eg: SoP featured videos v3.63 added $params } $html .= $img_html; // v3.53 if ($params['type'] !== 'titles') { $html .= "<div class='entry " . ($has_reveal ? 'reveal_tail' : '') . "'>\n"; // v5.18 $html .= Wf_Widget::get_excerpt_or_full($catpost, $params['type'], $list); // 3.31 $list = true 3.39 $html .= "</div>\n"; // class = 'entry' } $html .= "</div>\n"; // class = 'post' } //foreach $html .= "</div>\n"; // class = 'posts' added for carplus v3.15 $html .= List_widget::wf_paginate_list($args, $widget_query->found_posts); $post = $post_store; 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; }