static function get_article_format_mapping($item, $config, $generator, $i) { // base item data $art_URL = $item['URL']; $art_title = GK_NSP_Widget_Helpers::cut_text('article_title', $item['title'], $config['article_title_len_type'], $config['article_title_len']); $art_text = GK_NSP_Widget_Helpers::cut_text('article_text', $item['text'], $config['article_text_len_type'], $config['article_text_len']); // parsing shortcodes if ($config['parse_shortcodes'] == 'on') { $art_text = do_shortcode($art_text); } else { $art_text = preg_replace('@\\[.+?\\]@mis', '', $art_text); } // images $art_image = $item['image']; // categories $art_categories = $item['category']; // author data $art_author_name = $item['author_name']; $art_author_URL = $item['author_URL']; // date $art_date = date($config['article_info_date_format'], strtotime($item['date'])); // comments $art_comment_count = $item['comment_count']; $art_comment = $item['comment_link']; // put the results to an array: return array("{URL}" => $art_URL, "{TITLE}" => $art_title, "{TITLE_ESC}" => esc_attr($art_title), "{TEXT}" => $art_text, "{IMAGE}" => $art_image, "{IMAGE_MARGIN}" => $config['image_block_padding'], "{CATEGORIES}" => $art_categories, "{AUTHOR_NAME}" => $art_author_name, "{AUTHOR_URL}" => $art_author_URL, "{DATE}" => $art_date, "{RATING}" => $generator->art_rating($item), "{DATE_W3C}" => date(DATE_W3C, strtotime($item['date'])), "{COMMENT_COUNT}" => $art_comment_count, "{COMMENTS}" => $art_comment); }
static function get_article_format_mapping($item, $config, $generator, $i) { // base item data $art_ID = $item->ID; $art_URL = get_permalink($art_ID); $art_title = GK_NSP_Widget_Helpers::cut_text('article_title', $item->post_title, $config['article_title_len_type'], $config['article_title_len']); $art_text = GK_NSP_Widget_Helpers::cut_text('article_text', $item->post_content, $config['article_text_len_type'], $config['article_text_len']); // parsing shortcodes if ($config['parse_shortcodes'] == 'on') { $art_text = do_shortcode($art_text); } else { $art_text = preg_replace('@\\[.+?\\]@mis', '', $art_text); } // images $art_image_full = wp_get_attachment_image_src(get_post_thumbnail_id($art_ID), 'full'); $art_image_full = $art_image_full[0]; $art_image_large = wp_get_attachment_image_src(get_post_thumbnail_id($art_ID), 'large'); $art_image_large = $art_image_large[0]; $art_image_medium = wp_get_attachment_image_src(get_post_thumbnail_id($art_ID), 'medium'); $art_image_medium = $art_image_medium[0]; $art_image_thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($art_ID), 'thumbnail'); $art_image_thumbnail = $art_image_thumbnail[0]; // categories $art_categories = ''; $categories = get_the_category($art_ID); if (count($categories) > 0) { foreach ($categories as $cat) { $art_categories .= ' <a href="' . get_category_link($cat->term_id) . '" class="gk-nsp-category">' . $cat->name . '</a> '; } } // author data $art_author_ID = $item->post_author; $art_author_name = get_the_author_meta('display_name', $art_author_ID); $art_author_URL = get_author_posts_url($art_author_ID); // date $art_date = get_the_time($config['article_info_date_format'], $art_ID); // comments $comment_phrase = ''; $art_comment_count = $item->comment_count; if ($art_comment_count == 0) { $comment_phrase = __('No comments', 'gk-nsp'); } else { if ($art_comment_count >= 1) { $comment_phrase = __('Comments ', 'gk-nsp') . '(' . $art_comment_count . ')'; } } $art_comment = '<a href="' . get_permalink($art_ID) . '#comments">' . $comment_phrase . '</a>'; if (is_sticky($art_ID)) { $featured = '<strong class="is-featured">' . __(' Featured', 'gk-nsp') . '</strong>'; } else { $featured = ''; } // put the results to an array: return array("{ID}" => $art_ID, "{URL}" => $art_URL, "{TITLE}" => $art_title, "{TITLE_ESC}" => esc_attr($art_title), "{TEXT}" => $art_text, "{IMAGE}" => $generator->art_image($i, true), "{IMAGE_MARGIN}" => $config['image_block_padding'], "{IMAGE_FULL}" => $art_image_full, "{IMAGE_LARGE}" => $art_image_large, "{IMAGE_MEDIUM}" => $art_image_medium, "{IMAGE_THUMBNAIL}" => $art_image_thumbnail, "{CATEGORIES}" => $art_categories, "{AUTHOR_ID}" => $art_author_ID, "{AUTHOR_NAME}" => $art_author_name, "{AUTHOR_URL}" => $art_author_URL, "{DATE}" => $art_date, "{RATING}" => $generator->art_rating($art_ID), "{DATE_W3C}" => get_the_time('c', $art_ID), "{COMMENT_COUNT}" => $art_comment_count, "{COMMENTS}" => $art_comment, "{STARS}" => $generator->art_rating($art_ID), "{ART_PRICE}" => $generator->art_price($art_ID), "{FEATURED}" => $featured); }
static function get_article_format_mapping($item, $config, $generator, $i) { // base item data $art_URL = $item->get_permalink(); $art_title = GK_NSP_Widget_Helpers::cut_text('article_title', $item->get_title(), $config['article_title_len_type'], $config['article_title_len']); $art_text = GK_NSP_Widget_Helpers::cut_text('article_text', $item->get_content(), $config['article_text_len_type'], $config['article_text_len']); // parsing shortcodes if ($config['parse_shortcodes'] == 'on') { $art_text = do_shortcode($art_text); } else { $art_text = preg_replace('@\\[.+?\\]@mis', '', $art_text); } // images $art_image = ''; // try to receive the image from the feed data if ($enclosure = $this->parent->wdgt_results[$i]->get_enclosure()) { $art_image = $enclosure->get_thumbnail(); if ($art_image == '') { $art_image = $enclosure->get_link(); } } // if the image in the feed data doesn't exist - try to get it from the content text if ($art_image == '') { $art_text = $this->parent->wdgt_results[$i]->get_content(); // find the first <img> tag if (preg_match('/\\<img.*src=.*?\\>/', $art_text)) { $img_start_pos = strpos($art_text, 'src="'); if ($img_start_pos) { $img_end_pos = strpos($art_text, '"', $img_start_pos + 5); } if ($img_start_pos > 0) { $art_image = substr($art_text, $img_start_pos + 5, $img_end_pos - ($img_start_pos + 5)); } } } // category $art_category = $item->get_category()->get_term(); // date $art_date = $item->get_date($config['article_info_date_format']); // put the results to an array: return array("{URL}" => $art_URL, "{TITLE}" => $art_title, "{TITLE_ESC}" => esc_attr($art_title), "{TEXT}" => $art_text, "{CATEGORY}" => $art_category, "{IMAGE}" => $art_image, "{IMAGE_MARGIN}" => $config['image_block_padding'], "{DATE}" => $art_date, "{DATE_W3C}" => $item->get_date('c')); }
static function article_title($i, $generator, $results, $len) { $art_title = $results[$i]->post_title; $art_title = GK_NSP_Widget_Helpers::cut_text('article_title', $art_title, 'chars', $len); return $art_title; }
function link_text($i) { if (isset($this->parent->wdgt_results[$i]->text)) { $art_text = $this->parent->wdgt_results[$i]->text; $art_text = GK_NSP_Widget_Helpers::cut_text('links_text', $art_text, $this->parent->config['links_text_len_type'], $this->parent->config['links_text_len']); $art_text = preg_replace('@\\[.+?\\]@mis', '', $art_text); $output = '<p class="gk-nsp-link-text">' . $art_text . '</p>'; return apply_filters('gk_nsp_link_text', $output); } else { return false; } }