Guest User

Untitled

a guest
Oct 21st, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.83 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class td_module_blog extends td_module {
  5.  
  6. var $td_post_theme_settings;
  7.  
  8. var $is_single; //true if we are on a single page
  9.  
  10.  
  11.  
  12. function __construct($post = '') {
  13. // construct the class without the post object, used in the author template for the box
  14. if (empty($post)) {
  15. return;
  16. }
  17.  
  18. parent::__construct($post);
  19.  
  20. //read post settings
  21. $this->td_post_theme_settings = get_post_meta($post->ID, 'td_post_theme_settings', true);
  22.  
  23. $this->is_single = is_single();
  24. }
  25.  
  26.  
  27.  
  28.  
  29.  
  30. function get_social_sharing() {
  31. $social_sharing = 1;
  32. $closing_class_tags = 'td-tags-and-social-wrapper-box-bottom-line';
  33.  
  34. if (!$this->is_single) {
  35. return;
  36. }
  37.  
  38. $buffy = $this_post_tags = $wrapper_post_tags = '';
  39.  
  40. if (td_util::get_option('tds_social_show') == 'hide') {
  41. $social_sharing = 0;
  42. } else {
  43. $closing_class_tags = '';
  44. }
  45.  
  46. //if the post has tags
  47. $this_post_tags = $this->get_the_tags();
  48. if(!empty($this_post_tags)) {
  49. $wrapper_post_tags = '<div class="td-tags-and-social-wrapper-box ' . $closing_class_tags . '"> ' . $this_post_tags . '</div>';
  50. }
  51.  
  52.  
  53. $buffy .= '
  54. <div class="td-social-sharing">
  55. ' . $wrapper_post_tags;
  56.  
  57. if($social_sharing == 1) {
  58.  
  59. $image = wp_get_attachment_image_src( get_post_thumbnail_id( $this->post->ID ), 'single-post-thumbnail' );
  60.  
  61. $twetter_user = td_util::get_option('tds_tweeter_username');
  62.  
  63. $buffy .= '
  64. <div class="td-tags-and-social-wrapper-box td-tags-and-social-wrapper-box-bottom-line">
  65. <a class="td-social-sharing-buttons td-social-twitter" href="https://twitter.com/intent/tweet?text=' . urlencode($this->title) . '&url=' . urlencode(get_permalink()) . '&via=' . urlencode($twetter_user ? $twetter_user : get_bloginfo('name')) .'" onclick="if(!document.getElementById(\'td_social_networks_buttons\')){window.open(this.href, \'mywin\',
  66. \'left=50,top=50,width=600,height=350,toolbar=0\'); return false;}" ><div class="td-sp td-sp-share-twitter"></div><div class="td-social-but-text">Twitter</div></a>
  67. <a class="td-social-sharing-buttons td-social-facebook" href="http://www.facebook.com/sharer.php?u=' . urlencode(get_permalink()) . '" onclick="window.open(this.href, \'mywin\',
  68. \'left=50,top=50,width=600,height=350,toolbar=0\'); return false;"><div class="td-sp td-sp-share-facebook"></div><div class="td-social-but-text">Facebook</div></a>
  69. <a class="td-social-sharing-buttons td-social-google" href="http://plus.google.com/share?url=' . get_permalink() . '" onclick="window.open(this.href, \'mywin\',
  70. \'left=50,top=50,width=600,height=350,toolbar=0\'); return false;"><div class="td-sp td-sp-share-google"></div><div class="td-social-but-text">Google +</div></a>
  71. <a class="td-social-sharing-buttons td-social-pinterest" href="http://pinterest.com/pin/create/button/?url=' . get_permalink() . '&amp;media=' . (!empty($image[0]) ? $image[0] : '') . '" onclick="window.open(this.href, \'mywin\',
  72. \'left=50,top=50,width=600,height=350,toolbar=0\'); return false;"><div class="td-sp td-sp-share-pinterest"></div><div class="td-social-but-text">Pinterest</div></a>
  73. </div>';
  74. }
  75.  
  76. return $buffy . '</div>';
  77. }
  78.  
  79.  
  80.  
  81.  
  82. function get_social_like_tweet() {
  83. if (!$this->is_single) {
  84. return;
  85. }
  86.  
  87. if (td_util::get_option('tds_like_tweet_show') != 'show') {
  88. return;
  89. }
  90.  
  91. $buffy = '';
  92. $buffy .= '<div id="td_social_networks_buttons" class="td-social-like-tweet">';
  93. $buffy .= '<ul>';
  94. $buffy .= '<li class="td-like-tweet-twitter">';
  95. $buffy .= '<a href="https://twitter.com/share" class="twitter-share-button" data-url="' . $this->href . '" data-text="' . $this->title . '" data-via="' . td_util::get_option('tds_' . 'social_twitter') . '" data-lang="en">tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>';
  96. $buffy .= '</li>';
  97.  
  98. $buffy .= '<li class="td-like-tweet-facebook">';
  99. $buffy .= '<iframe src="http://www.facebook.com/plugins/like.php?href=' . $this->href . '&amp;layout=button_count&amp;show_faces=false&amp;width=105&amp;action=like&amp;colorscheme=light&amp;height=21" style="border:none; overflow:hidden; width:105px; height:21px; background-color:transparent;"></iframe>';
  100. $buffy .= '</li>';
  101.  
  102. $buffy .= '<li class="td-like-tweet-google">';
  103. $buffy .= '
  104. <div class="g-plusone" data-size="medium" data-href="' . $this->href . '"></div>
  105. <script type="text/javascript">
  106. (function() {
  107. var po = document.createElement("script"); po.type = "text/javascript"; po.async = true;
  108. po.src = "https://apis.google.com/js/plusone.js";
  109. var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);
  110. })();
  111. </script>
  112. ';
  113. $buffy .= '</li>';
  114. $buffy .= '</ul>';
  115. $buffy .= '</div>';
  116. return $buffy;
  117. }
  118.  
  119.  
  120.  
  121.  
  122.  
  123. function get_post_pagination() {
  124. if (!$this->is_single) {
  125. return;
  126. }
  127.  
  128.  
  129. return wp_link_pages(array(
  130. 'before' => '<div class="page-nav page-nav-post">',
  131. 'after' => '</div>',
  132. 'link_before' => '<span>',
  133. 'link_after' => '</span>',
  134. 'echo' => false,
  135. 'nextpagelink' => ' ' . __td('Next') . ' <img width="6" class="td-retina right-arrow" src="' . get_template_directory_uri() . '/images/icons/similar-right.png" alt=""/>',
  136. 'previouspagelink' => '<img width="6" class="td-retina left-arrow" src="' . get_template_directory_uri() . '/images/icons/similar-left.png" alt=""/> ' . __td('Prev')
  137. ));
  138. }
  139.  
  140. function get_title($excerpt_lenght = '') {
  141. //just use h1 instead of h3
  142. $var_single = 0;
  143. if (is_single()) {
  144. $var_single = 1;
  145. }
  146.  
  147. $buffy = '';
  148. $buffy .= '<h1 itemprop="name" class="entry-title">';
  149.  
  150. if ($var_single == 0) {
  151. $buffy .='<a itemprop="url" href="' . $this->href . '" rel="bookmark" title="' . $this->title_attribute . '">';
  152. }
  153.  
  154. $buffy .= $this->title;
  155.  
  156. if ($var_single == 0) {
  157. $buffy .='</a>';
  158. }
  159.  
  160. $buffy .= '</h1>';
  161. return $buffy;
  162. }
  163.  
  164. //$show_stars_on_review - not used
  165. function get_author($show_stars_on_review = '') {
  166. $buffy = '';
  167. $buffy .='<div class="td-clear-author"></div>';
  168. $buffy .= parent::get_author(false);
  169. return $buffy;
  170. }
  171.  
  172.  
  173.  
  174.  
  175.  
  176. /**
  177. * get_image v010 - modified on wp_010 - returns the featured image of a single post
  178. * @param $thumbType
  179. * @return string
  180. */
  181. function get_image($thumbType) {
  182. global $page;
  183.  
  184. //show only on the first page when we have posts with pages
  185. if (!empty($page) and $page > 1) {
  186. return;
  187. }
  188.  
  189. //do not show the featured image if the global setting is set to hide - show the video preview regardless of the setting
  190. if (td_util::get_option('tds_show_featured_image') == 'hide' and get_post_format($this->post->ID) != 'video') {
  191. return;
  192. }
  193.  
  194. //do not show the featured image on gallery post format
  195. if (get_post_format($this->post->ID) == 'gallery') {
  196. return;
  197. }
  198.  
  199. //handle video post format
  200. if (get_post_format($this->post->ID) == 'video') {
  201. //if it's a video post...
  202. $td_post_video = get_post_meta($this->post->ID, 'td_post_video', true);
  203. $td_video_support = new td_video_support();
  204.  
  205. //render the video if the post has a video in the featured video section of the post
  206. if (!empty($td_post_video['td_video'])) {
  207. return $td_video_support->renderVideo($td_post_video['td_video']);
  208. }
  209. } else {
  210. //if it's a normal post, show the default thumb
  211.  
  212. if ($this->post_has_thumb) {
  213. //get the featured image id + full info about the 640px wide one
  214. $featured_image_id = get_post_thumbnail_id($this->post->ID);
  215. $featured_image_info = td_util::attachment_get_full_info($featured_image_id, $thumbType);
  216.  
  217. //get the full size for the popup
  218. $featured_image_full_size_src = td_util::attachment_get_src($featured_image_id, 'full');
  219.  
  220. $buffy = '';
  221.  
  222. $show_td_modal_image = td_util::get_option('tds_featured_image_view_setting') ;
  223.  
  224. if (is_single()) {
  225. if ($show_td_modal_image != 'no_modal') {
  226. //wrap the image_html with a link + add td-modal-image class
  227. $image_html = '<a href="' . $featured_image_full_size_src['src'] . '" data-caption="' . htmlentities($featured_image_info['caption'], ENT_QUOTES) . '">';
  228. $image_html .= '<img width="' . $featured_image_info['width'] . '" height="' . $featured_image_info['height'] . '" itemprop="image" class="entry-thumb td-modal-image" src="' . $featured_image_info['src'] . '" alt="' . $featured_image_info['alt'] . '" title="' . $featured_image_info['title'] . '"/>';
  229. $image_html .= '</a>';
  230. } else { //no_modal
  231. $image_html = '<img width="' . $featured_image_info['width'] . '" height="' . $featured_image_info['height'] . '" itemprop="image" class="entry-thumb" src="' . $featured_image_info['src'] . '" alt="' . $featured_image_info['alt'] . '" title="' . $featured_image_info['title'] . '"/>';
  232. }
  233. } else {
  234. //on blog index page
  235. $image_html = '<a href="' . $this->href . '"><img width="' . $featured_image_info['width'] . '" height="' . $featured_image_info['height'] . '" itemprop="image" class="entry-thumb" src="' . $featured_image_info['src'] . '" alt="' . $featured_image_info['alt'] . '" title="' . $featured_image_info['title'] . '"/></a>';
  236. }
  237.  
  238.  
  239. $buffy .= '<div class="td-post-featured-image">';
  240.  
  241. // caption - put html5 wrapper on when we have a caption
  242. if (!empty($featured_image_info['caption'])) {
  243. $buffy .= '<figure>';
  244. $buffy .= $image_html;
  245.  
  246. $buffy .= '<figcaption class="wp-caption-text">' . htmlentities($featured_image_info['caption'], ENT_QUOTES) . '</figcaption>';
  247. $buffy .= '</figure>';
  248. } else {
  249. $buffy .= $image_html;
  250. }
  251.  
  252. $buffy .= '</div>';
  253.  
  254.  
  255. return $buffy;
  256. } else {
  257. return ''; //the post has no thumb
  258. }
  259. }
  260. }
  261.  
  262.  
  263. function get_category() {
  264.  
  265. $buffy = '';
  266.  
  267. $buffy .= '<ul class="td-category">';
  268. $categories = get_the_category($this->post->ID);
  269. $cat_array = array();
  270.  
  271. if($categories){
  272. foreach($categories as $category) {
  273. if ($category->name != TD_FEATURED_CAT) { //ignore the featured category name
  274. //get the parent of this cat
  275. $td_parent_cat_obj = get_category($category->category_parent);
  276.  
  277. //if we have a parent, shot it first
  278. if (!empty($td_parent_cat_obj->name)) {
  279. $tax_meta__color_parent = td_util::get_category_option($td_parent_cat_obj->cat_ID,'tdc_color');//swich by RADU A, get_tax_meta($td_parent_cat_obj->cat_ID,'tdc_color');
  280. $tax_meta__hide_on_post_parent = td_util::get_category_option($td_parent_cat_obj->cat_ID,'tdc_hide_on_post');//swich by RADU A, get_tax_meta($td_parent_cat_obj->cat_ID,'tdc_hide_on_post');
  281. $cat_array[$td_parent_cat_obj->name] = array(
  282. 'color' => $tax_meta__color_parent,
  283. 'link' => get_category_link($td_parent_cat_obj->cat_ID),
  284. 'hide_on_post' => $tax_meta__hide_on_post_parent
  285. );
  286. }
  287.  
  288. //show the category, only if we didn't already showed the parent
  289. $tax_meta_color = td_util::get_category_option($category->cat_ID,'tdc_color');//swich by RADU A, get_tax_meta($category->cat_ID,'tdc_color');
  290. $tax_meta__hide_on_post_parent = td_util::get_category_option($category->cat_ID,'tdc_hide_on_post');//swich by RADU A, get_tax_meta($category->cat_ID,'tdc_hide_on_post');
  291. $cat_array[$category->name] = array(
  292. 'color' => $tax_meta_color,
  293. 'link' => get_category_link($category->cat_ID),
  294. 'hide_on_post' => $tax_meta__hide_on_post_parent
  295. );
  296. }
  297. }
  298. }
  299.  
  300. foreach ($cat_array as $td_cat_name => $td_cat_parms) {
  301. if ($td_cat_parms['hide_on_post'] == 'hide') {
  302. continue;
  303. }
  304.  
  305. if (!empty($td_cat_parms['color'])) {
  306. $td_cat_color = ' style="background-color:' . $td_cat_parms['color'] . ';"';
  307. } else {
  308. $td_cat_color = '';
  309. }
  310.  
  311.  
  312. $buffy .= '<li class="entry-category"><a ' . $td_cat_color . ' href="' . $td_cat_parms['link'] . '">' . $td_cat_name . '</a></li>';
  313. }
  314. $buffy .= '</ul>';
  315.  
  316. return $buffy;
  317. }
  318.  
  319.  
  320.  
  321.  
  322. function get_item_scope() {
  323. //show the review meta only on single posts that are reviews, the rest have to be article (in article lists)
  324. if (td_review::has_review($this->td_review) and is_single()) {
  325. return 'itemscope itemtype="http://schema.org/Review"';
  326. } else {
  327. return 'itemscope itemtype="http://schema.org/Article"';
  328. }
  329. }
  330.  
  331.  
  332. function get_item_scope_meta() {
  333. $buffy = ''; //the vampire slayer
  334.  
  335.  
  336. $author_id = $this->post->post_author;
  337.  
  338. $buffy .= '<meta itemprop="author" content = "' . get_the_author_meta('display_name', $author_id) . '">';
  339.  
  340. $authorMetaGoogle = get_the_author_meta('googleplus', $author_id);
  341. if (!empty($authorMetaGoogle)) {
  342. echo '<a href="' . $authorMetaGoogle . '?rel=author"></a>';
  343. }
  344.  
  345.  
  346. if (td_review::has_review($this->td_review) and is_single()) { //show the review meta only on single posts that are reviews, the rest have to be article (in article lists)
  347. $td_article_date_unix = get_the_time('U', $this->post->ID);
  348.  
  349. if (!empty($this->td_review['review'])) {
  350. $buffy .= '<meta itemprop="about" content = "' . $this->td_review['review'] . '">';
  351. } else {
  352. //we have no review :|
  353. $buffy .= '<meta itemprop="about" content = "' . $this->get_excerpt(25) . '">';
  354. }
  355.  
  356. $buffy .= '<meta itemprop="itemreviewed" content = "' . $this->title . '">';
  357. $buffy .= '<meta itemprop="datePublished" content="' . date(DATE_W3C, $td_article_date_unix) . '">';
  358.  
  359.  
  360.  
  361.  
  362.  
  363. //$buffy .= '<meta itemprop="url" rel="author" content = "' . get_author_posts_url($author_id) . '">';
  364.  
  365. $buffy .= '<span class="td-page-meta" itemprop="reviewRating" itemscope itemtype="' . td_global::$http_or_https . '://schema.org/Rating">';
  366. $buffy .= '<meta itemprop="worstRating" content = "1">';
  367. $buffy .= '<meta itemprop="bestRating" content = "5">';
  368. $buffy .= '<meta itemprop="ratingValue" content = "' . td_review::calculate_total_stars($this->td_review) . '">';
  369. $buffy .= ' </span>';
  370. }
  371. return $buffy;
  372. }
  373.  
  374.  
  375.  
  376.  
  377. function get_content() {
  378.  
  379.  
  380.  
  381. /* ----------------------------------------------------------------------------
  382. Prepare the content
  383. */
  384. $content = get_the_content(__td('Continue', TD_THEME_NAME));
  385. $content = apply_filters('the_content', $content);
  386. $content = str_replace(']]>', ']]&gt;', $content);
  387.  
  388.  
  389.  
  390. /* ----------------------------------------------------------------------------
  391. Smart list support @todo reorganizare partea asta
  392. */
  393. $td_smart_list = get_post_meta($this->post->ID, 'td_smart_list', true);
  394. if (!empty($td_smart_list['smart_list_template'])) {
  395.  
  396. switch ($td_smart_list['smart_list_template']) {
  397. case 'td_smart_list_1':
  398. $td_smart_list_obj = new td_smart_list_1();
  399. break;
  400.  
  401. case 'td_smart_list_2':
  402. $td_smart_list_obj = new td_smart_list_2();
  403. break;
  404.  
  405. case 'td_smart_list_3':
  406. $td_smart_list_obj = new td_smart_list_3();
  407. break;
  408.  
  409. case 'td_smart_list_4':
  410. $td_smart_list_obj = new td_smart_list_4();
  411. break;
  412.  
  413. }
  414.  
  415.  
  416.  
  417. if (isset($td_smart_list_obj)) {
  418. return $td_smart_list_obj->render_from_post_content($content);
  419. } else {
  420. //there was an error?
  421. }
  422. }
  423. /* ----------------------------------------------------------------------------
  424. end smart list - if we have a list, the function returns above
  425. */
  426.  
  427.  
  428.  
  429.  
  430.  
  431. /* ----------------------------------------------------------------------------
  432. ad support on content
  433. */
  434.  
  435.  
  436.  
  437. $tds_inline_ad_paragraph = td_util::get_option('tds_inline_ad_paragraph');
  438. $tds_inline_ad_align = td_util::get_option('tds_inline_ad_align');
  439.  
  440. if (td_util::is_ad_spot_enabled('content_inline') and is_single() ) {
  441.  
  442. if (empty($tds_inline_ad_paragraph)) {
  443. $tds_inline_ad_paragraph = 0;
  444. }
  445.  
  446.  
  447. $content_buffer = ''; // we replace the content with this buffer at the end
  448.  
  449. $content_parts = preg_split('/(<p.*>)/U', $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  450.  
  451. //print_r($content_parts);
  452. //die;
  453. //$content_parts = explode('<p>', $content);
  454. foreach ($content_parts as $content_part_index => $content_part) {
  455. if (!empty($content_part)) {
  456.  
  457. if ($tds_inline_ad_paragraph == $content_part_index / 2) { //we have 0 = > <p> 1 => content - that's why we have to divide by 2
  458. //it's time to show the ad
  459. switch ($tds_inline_ad_align) {
  460. case 'left':
  461. $content_buffer .= td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'content_inline', 'align' => 'left'));
  462. break;
  463.  
  464. case 'right':
  465. $content_buffer .= td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'content_inline', 'align' => 'right'));
  466. break;
  467.  
  468. default:
  469. $content_buffer .= td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'content_inline'));
  470. break;
  471. }
  472.  
  473. }
  474. $content_buffer .= $content_part;
  475. }
  476. } //end foreach
  477. $content = $content_buffer;
  478. }
  479.  
  480. //add the top ad
  481. if (td_util::is_ad_spot_enabled('content_top') and is_single()) {
  482. $content = td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'content_top')) . $content;
  483. }
  484.  
  485.  
  486. //add bottom ad
  487. if (td_util::is_ad_spot_enabled('content_bottom') and is_single()) {
  488. $content = $content . td_global_blocks::get_instance('td_ad_box')->render(array('spot_id' => 'content_bottom'));
  489. }
  490.  
  491.  
  492. return $content;
  493. }
  494.  
  495.  
  496. /* ----------------------------------------------------------------------------
  497. Single page
  498. */
  499. function get_review() {
  500. if (!$this->is_single) {
  501. return;
  502. }
  503.  
  504. if (td_review::has_review($this->td_review)) {
  505. //print_r($this->td_review);
  506. $buffy = '';
  507. $buffy .= td_review::render_table($this->td_review);
  508.  
  509.  
  510.  
  511. return $buffy;
  512. }
  513. }
  514.  
  515. function get_source_and_via() {
  516. if (!$this->is_single) {
  517. return;
  518. }
  519.  
  520.  
  521. $buffy ='';
  522.  
  523. //via and sourcet
  524. if (!empty($this->td_post_theme_settings['td_source']) or !empty($this->td_post_theme_settings['td_source_2']) or !empty($this->td_post_theme_settings['td_via']) or !empty($this->td_post_theme_settings['td_via_2'])) {
  525. $buffy .= '<div class="post-source-via">';
  526.  
  527. if (!empty($this->td_post_theme_settings['td_via']) or !empty($this->td_post_theme_settings['td_via_2'])) {
  528. $buffy .= '<div class="post-via"><span>' . __td('VIA') . '</span>';
  529. if (!empty($this->td_post_theme_settings['td_via'])) {
  530. $buffy .= ' <a rel="nofollow" href="' . $this->td_post_theme_settings['td_via_url'] . '" target="_blank">' . $this->td_post_theme_settings['td_via'] . '</a>';
  531. }
  532. if (!empty($this->td_post_theme_settings['td_via_2'])) {
  533. $buffy .= ' <a rel="nofollow" href="' . $this->td_post_theme_settings['td_via_2_url'] . '" target="_blank">' . $this->td_post_theme_settings['td_via_2'] . '</a>';
  534. }
  535.  
  536. $buffy .= '</div>';
  537. }
  538.  
  539. if (!empty($this->td_post_theme_settings['td_source']) or !empty($this->td_post_theme_settings['td_source_2'])) {
  540. $buffy .= '<div class="post-via"><span>' . __td('SOURCE') . '</span>';
  541. if (!empty($this->td_post_theme_settings['td_source'])) {
  542. $buffy .= ' <a rel="nofollow" href="' . $this->td_post_theme_settings['td_source_url'] . '" target="_blank">' . $this->td_post_theme_settings['td_source'] . '</a>';
  543. }
  544. if (!empty($this->td_post_theme_settings['td_source_2'])) {
  545. $buffy .= ' <a rel="nofollow" href="' . $this->td_post_theme_settings['td_source_2_url'] . '" target="_blank">' . $this->td_post_theme_settings['td_source_2'] . '</a>';
  546. }
  547.  
  548. $buffy .= '</div>';
  549. }
  550.  
  551. $buffy .= '</div>';
  552. }
  553.  
  554.  
  555. return $buffy;
  556. }
  557.  
  558.  
  559. function get_the_tags() {
  560. if (!$this->is_single) {
  561. return;
  562. }
  563.  
  564. if (td_util::get_option('tds_show_tags') == 'hide') {
  565. return;
  566. }
  567.  
  568.  
  569. $buffy = '';
  570.  
  571. $td_post_tags = get_the_tags();
  572. if ($td_post_tags) {
  573. $buffy .= '<ul class="td-tags clearfix"><li><span class="td-tag-black">' . __td('TAGS') . '</span></li>';
  574. foreach ($td_post_tags as $tag) {
  575. $buffy .= '<li><a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a></li>';
  576. }
  577. $buffy .= '</ul>';
  578. }
  579.  
  580. return $buffy;
  581. }
  582.  
  583. function get_next_prev_posts() {
  584. if (!$this->is_single) {
  585. return;
  586. }
  587.  
  588. if (td_util::get_option('tds_show_next_prev') == 'hide') {
  589. return;
  590. }
  591.  
  592. $buffy = '';
  593.  
  594. $next_post = get_next_post();
  595. $prev_post = get_previous_post();
  596.  
  597.  
  598. if (!empty($next_post) or !empty($prev_post)) {
  599. $buffy .= '<div class="wpb_row row-fluid next-prev">';
  600. if (!empty($prev_post)) {
  601. $buffy .= '<div class="span6 prev-post">';
  602. $buffy .= '<div><img width="6" class="td-retina" src="' . get_template_directory_uri() .
  603. '/images/icons/similar-left.png" alt=""/>' . __td('Previous article', TD_THEME_NAME) . '</div>';
  604. $buffy .= '<a href="' . get_permalink($prev_post->ID) . '">' . get_the_title($prev_post->ID) . '</a>';
  605. $buffy .= '</div>';
  606. } else {
  607. $buffy .= '<div class="span6 prev-post">';
  608. $buffy .= '</div>';
  609. }
  610.  
  611. if (!empty($next_post)) {
  612. $buffy .= '<div class="span6 next-post">';
  613. $buffy .= '<div>' . __td('Next article', TD_THEME_NAME) . '<img width="6" class="td-retina" src="' .
  614. get_template_directory_uri() . '/images/icons/similar-right.png" alt=""/></div>';
  615. $buffy .= '<a href="' . get_permalink($next_post->ID) . '">' . get_the_title($next_post->ID) . '</a>';
  616. $buffy .= '</div>';
  617. }
  618. $buffy .= '</div>'; //end fluid row
  619. }
  620.  
  621. return $buffy;
  622. }
  623.  
  624. function get_author_box($author_id = '') {
  625.  
  626. if (!$this->is_single) {
  627. return;
  628. }
  629.  
  630. if (td_util::get_option('tds_show_author_box') == 'hide') {
  631. $buffy = '<div class="td-author-name vcard author" style="display: none"><span class="fn">';
  632. $buffy .= '<a href="' . get_author_posts_url($author_id) . '">' . get_the_author_meta('display_name', $author_id) . '</a>' ;
  633. $buffy .= '</span></div>';
  634. return $buffy;
  635. }
  636.  
  637. if (empty($author_id)) {
  638. $author_id = $this->post->post_author;
  639. }
  640.  
  641.  
  642. $buffy = '';
  643.  
  644. $authorDescription = get_the_author_meta('description');
  645. $hideAuthor = td_util::get_option('hide_author');
  646.  
  647. if (empty($hideAuthor)) {
  648.  
  649. $buffy .= '<div class="author-box-wrap">';
  650. $buffy .= '<a href="' . get_author_posts_url($author_id) . '">' ;
  651. $buffy .= get_avatar(get_the_author_meta('email', $author_id), '106');
  652. $buffy .= '</a>';
  653.  
  654.  
  655. $buffy .= '<div class="desc">';
  656. $buffy .= '<div class="td-author-name vcard author"><span class="fn">';
  657. $buffy .= '<a href="' . get_author_posts_url($author_id) . '">' . get_the_author_meta('display_name', $author_id) . '</a>' ;
  658. $buffy .= '</span></div>';
  659.  
  660.  
  661.  
  662. $buffy .= '<div>';
  663. $buffy .= get_the_author_meta('description', $author_id);
  664. $buffy .= '</div>';
  665.  
  666.  
  667. $buffy .= '<div class="td-author-social">';
  668. foreach (td_social_icons::$td_social_icons_array as $td_social_id => $td_social_name) {
  669. //echo get_the_author_meta($td_social_id) . '<br>';
  670. $authorMeta = get_the_author_meta($td_social_id);
  671. if (!empty($authorMeta)) {
  672.  
  673. //the theme can use the twitter id instead of the full url. This avoids problems with yoast plugin
  674. if ($td_social_id == 'twitter') {
  675. if(filter_var($authorMeta, FILTER_VALIDATE_URL)){
  676.  
  677. } else {
  678. $authorMeta = str_replace('@', '', $authorMeta);
  679. $authorMeta = 'http://twitter.com/' . $authorMeta;
  680. }
  681. }
  682. $buffy .= td_social_icons::get_icon($authorMeta, $td_social_id, 4, 16);
  683. }
  684. }
  685. $buffy .= '</div>';
  686.  
  687.  
  688.  
  689. $buffy .= '<div class="clearfix"></div>';
  690.  
  691. $buffy .= '</div>'; ////desc
  692. $buffy .= '</div>'; //author-box-wrap
  693. }
  694.  
  695.  
  696. return $buffy;
  697. }
  698.  
  699.  
  700. function related_posts() {
  701.  
  702. global $post; //this is used by the loop down
  703.  
  704. if (!$this->is_single) {
  705. return;
  706. }
  707.  
  708.  
  709. if (td_util::get_option('tds_similar_articles') == 'hide') {
  710. return;
  711. }
  712.  
  713. if (td_util::get_option('tds_similar_articles_count') == '') {
  714. $tds_similar_articles_count = 2;
  715. } else {
  716. $tds_similar_articles_count = td_util::get_option('tds_similar_articles_count');
  717. }
  718.  
  719. if (td_global::$cur_single_template_sidebar_pos == 'no_sidebar') {
  720. $tds_similar_articles_count = 3;
  721. }
  722.  
  723.  
  724.  
  725. $buffy = '';
  726. $buffy .= '<div class="art-img-text-down similar-articles">';
  727.  
  728.  
  729. $args = array();
  730.  
  731. switch (td_util::get_option('tds_similar_articles_type')) {
  732.  
  733. //by tag
  734. case 'by_tag':
  735. $tags = wp_get_post_tags($this->post->ID);
  736. if ($tags) {
  737. $taglist = array();
  738. for ($i = 0; $i <= 4; $i++) {
  739. if (!empty($tags[$i])) {
  740. $taglist[] = $tags[$i]->term_id;
  741. } else {
  742. break;
  743. }
  744. }
  745. $args = array(
  746. 'tag__in' => $taglist,
  747. 'post__not_in' => array($this->post->ID),
  748. 'showposts' => $tds_similar_articles_count,
  749. 'ignore_sticky_posts' => 1
  750. );
  751. }
  752. break;
  753.  
  754.  
  755. //by title
  756. case 'by_auth':
  757. $args = array(
  758. 'author' => $this->post->post_author,
  759. 'post__not_in' => array($this->post->ID),
  760. 'showposts' => $tds_similar_articles_count,
  761. 'ignore_sticky_posts' => 1
  762. );
  763. break;
  764.  
  765.  
  766. //by category
  767. default:
  768. $args = array(
  769. 'category__in' => wp_get_post_categories($this->post->ID),
  770. 'post__not_in' => array($this->post->ID),
  771. 'showposts' => $tds_similar_articles_count,
  772. 'ignore_sticky_posts' => 1
  773. );
  774. break;
  775. }
  776.  
  777.  
  778.  
  779. if (!empty($args)) {
  780. //do the query
  781. $my_query = new WP_Query($args);
  782. if ($my_query->have_posts()) {
  783. $buffy .= '<h4 class="block-title"><span>' . __td('SIMILAR ARTICLES') . '</span></h4>';
  784.  
  785. $td_template_layout = new td_template_layout(''); //invalid sidebar position, it will default to 2 + 1
  786.  
  787. if (td_global::$cur_single_template_sidebar_pos == 'no_sidebar') {
  788. $td_template_layout->set_columns(3);
  789. } else {
  790. $td_template_layout->set_columns(2);
  791. }
  792.  
  793.  
  794. while ($my_query->have_posts()) : $my_query->the_post();
  795.  
  796. $buffy .= $td_template_layout->layout_open_element();
  797. $td_module_6 = new td_module_6($post);
  798. $buffy .= $td_module_6->render();
  799. $buffy .= $td_template_layout->layout_close_element();
  800.  
  801. $td_template_layout->layout_next();
  802. endwhile;
  803.  
  804. $buffy .= $td_template_layout->close_all_tags();
  805. }
  806. }
  807.  
  808.  
  809.  
  810.  
  811. $buffy .= '</div>';
  812.  
  813. wp_reset_query();
  814.  
  815. return $buffy;
  816. }
  817.  
  818.  
  819.  
  820.  
  821. }
Advertisement
Add Comment
Please, Sign In to add comment