Guest User

Untitled

a guest
May 19th, 2012
146
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /*-----------------------------------------------------------------------------------
  4.  
  5. TABLE OF CONTENTS
  6.  
  7. - Woo Tumblog Output Functions
  8. -- woo_tumblog_content()
  9. -- woo_tumblog_article_content()
  10. -- woo_tumblog_image_content()
  11. -- woo_tumblog_audio_content()
  12. -- woo_tumblog_video_content()
  13. -- woo_tumblog_quote_content()
  14. -- woo_tumblog_link_content()
  15. -- woo_tumblog_category_link()
  16. -- woo_tumblog_the_title()
  17. -- woo_tumblog_taxonomy_link()
  18.  
  19. -----------------------------------------------------------------------------------*/
  20.  
  21. /* Load the default BuddyPress javascript */
  22. if (get_option('woo_woo_tumblog_switch') == 'true')
  23. wp_enqueue_script( 'tumblog-js', get_template_directory_uri() . '/includes/tumblog/swfobject.js' );
  24.  
  25. /*-----------------------------------------------------------------------------------*/
  26. /* Woo Tumblog Output Functions */
  27. /*-----------------------------------------------------------------------------------*/
  28.  
  29. function woo_tumblog_content($output = 'Before', $return = false) {
  30. global $post;
  31. $post_id = $post->ID;
  32.  
  33. $content = ''; // Declare empty variable to prevent warning messages.
  34.  
  35. // Test for Post Formats
  36. if (get_option('woo_tumblog_content_method') == 'post_format') {
  37.  
  38. if ( has_post_format( 'aside' , $post_id )) {
  39. if ($output == get_option('woo_woo_tumblog_images_content')) {
  40. $content = woo_tumblog_article_content($post_id);
  41. }
  42. } elseif (has_post_format( 'image' , $post_id )) {
  43. if ($output == get_option('woo_woo_tumblog_images_content')) {
  44. $content = woo_tumblog_image_content($post_id);
  45. }
  46. } elseif (has_post_format( 'audio' , $post_id )) {
  47. if ($output == get_option('woo_woo_tumblog_audio_content')) {
  48. $content = woo_tumblog_audio_content($post_id);
  49. }
  50. } elseif (has_post_format( 'video' , $post_id )) {
  51. if ($output == get_option('woo_woo_tumblog_videos_content')) {
  52. $content = woo_tumblog_video_content($post_id);
  53. }
  54. } elseif (has_post_format( 'quote' , $post_id )) {
  55. if ($output == get_option('woo_woo_tumblog_quotes_content')) {
  56. $content = woo_tumblog_quote_content($post_id);
  57. }
  58. } elseif (has_post_format( 'link' , $post_id )) {
  59. $content = woo_tumblog_link_content($post_id);
  60. } else {
  61. $content = '';
  62. }
  63.  
  64. } else {
  65. //check if it is a tumblog post
  66.  
  67. //check which tumblog
  68. $tumblog_list = get_the_term_list( $post_id, 'tumblog', '' , '|' , '' );
  69.  
  70. $tumblog_array = explode('|', $tumblog_list);
  71.  
  72. $tumblog_items = array( 'articles' => get_option('woo_articles_term_id'),
  73. 'images' => get_option('woo_images_term_id'),
  74. 'audio' => get_option('woo_audio_term_id'),
  75. 'video' => get_option('woo_video_term_id'),
  76. 'quotes' => get_option('woo_quotes_term_id'),
  77. 'links' => get_option('woo_links_term_id')
  78. );
  79. //switch between tumblog taxonomies
  80. $tumblog_list = strip_tags($tumblog_list);
  81. $tumblog_array = explode('|', $tumblog_list);
  82. $tumblog_results = '';
  83. $sentinel = false;
  84.  
  85. foreach ($tumblog_array as $tumblog_item) {
  86. $tumblog_id = get_term_by( 'name', $tumblog_item, 'tumblog' );
  87. if ( $tumblog_items['articles'] == $tumblog_id->term_id && !$sentinel ) {
  88. $content = woo_tumblog_article_content($post_id);
  89. } elseif ($tumblog_items['images'] == $tumblog_id->term_id && !$sentinel ) {
  90. if ($output == get_option('woo_woo_tumblog_images_content')) {
  91. $content = woo_tumblog_image_content($post_id);
  92. }
  93. } elseif ($tumblog_items['audio'] == $tumblog_id->term_id && !$sentinel) {
  94. if ($output == get_option('woo_woo_tumblog_audio_content')) {
  95. $content = woo_tumblog_audio_content($post_id);
  96. }
  97. } elseif ($tumblog_items['video'] == $tumblog_id->term_id && !$sentinel) {
  98. if ($output == get_option('woo_woo_tumblog_videos_content')) {
  99. $content = woo_tumblog_video_content($post_id);
  100. }
  101. } elseif ($tumblog_items['quotes'] == $tumblog_id->term_id && !$sentinel) {
  102. if ($output == get_option('woo_woo_tumblog_quotes_content')) {
  103. $content = woo_tumblog_quote_content($post_id);
  104. }
  105. } elseif ($tumblog_items['links'] == $tumblog_id->term_id && !$sentinel) {
  106. $content = woo_tumblog_link_content($post_id);
  107. } else {
  108. $content = '';
  109. }
  110. }
  111. }
  112. // Return or echo the content
  113. if ( $return == TRUE )
  114. return $content;
  115. else
  116. echo $content; // Done
  117.  
  118. }
  119.  
  120. function woo_tumblog_article_content($post_id) {
  121.  
  122. $content_tumblog = '';
  123.  
  124. return $content_tumblog;
  125. }
  126.  
  127. function woo_tumblog_image_content($post_id) {
  128.  
  129. if(is_front_page()) {
  130. $woo_tumblog_image = woo_image('key=image&width='.$woo_options['woo_thumb_w'].'&height='.$woo_options['woo_thumb_h'].'&link=img&return=true');
  131. } else {
  132. $woo_tumblog_image = woo_image('key=image&width='.get_option('woo_tumblog_image_width').'px'.$height.'&link=img&return=true');
  133. }
  134.  
  135. if (get_option('woo_image_link_to') == 'image') {
  136. $content_tumblog = '<p><a href="'.get_post_meta($post_id, "image", true).'" title="image" rel="lightbox">'.$woo_tumblog_image.'</a></p>';
  137. } else {
  138. $content_tumblog = '<p><a href="'.get_permalink($post_id).'" title="image">'.$woo_tumblog_image.'</a></p>';
  139. }
  140.  
  141. return $content_tumblog;
  142. }
  143.  
  144. function woo_tumblog_audio_content( $post_id ) {
  145.  
  146. $link_url = get_post_meta( $post_id, 'audio', true );
  147.  
  148. if ( $link_url == '' ) {
  149.  
  150. //Post Args
  151. $args = array(
  152. 'post_type' => 'attachment',
  153. 'numberposts' => 1,
  154. 'post_status' => null,
  155. 'post_parent' => $post_id,
  156. 'post_mime_type' => 'audio/mpeg'
  157. );
  158. //Get attachements
  159. $attachments = get_posts( $args );
  160. if ( $attachments ) {
  161. foreach ( $attachments as $attachment ) {
  162. $link_url = $attachment->guid;
  163. }
  164. }
  165. }
  166.  
  167. if( ! empty( $link_url ) ) {
  168.  
  169. $content_tumblog = '<div class="audio"><div id="mediaspace' . $post_id . '"></div></div>';
  170.  
  171. $content_tumblog .= '<script type="text/javascript">
  172. var so = new SWFObject("' . get_template_directory_uri() . '/includes/tumblog/player.swf","mpl","' . get_option( 'woo_tumblog_audio_width' ) . '","32","9");
  173. so.addParam("allowfullscreen","true");
  174. so.addParam("allowscriptaccess","always");
  175. so.addParam("wmode","opaque");
  176. so.addParam("wmode","opaque");
  177. so.addVariable("skin", "' . get_template_directory_uri() . '/includes/tumblog/stylish_slim.swf");
  178. so.addVariable("file","'.$link_url.'");
  179. so.addVariable("backcolor","000000");
  180. so.addVariable("frontcolor","FFFFFF");
  181. so.write("mediaspace' . $post_id . '");
  182. </script>';
  183.  
  184. }
  185.  
  186. return $content_tumblog;
  187. }
  188.  
  189. function woo_tumblog_video_content($post_id) {
  190.  
  191. $content_tumblog = '<div class="video-wrap">'.woo_embed('key=video-embed&width='.get_option('woo_tumblog_video_width')).'</div>';
  192.  
  193. return $content_tumblog;
  194.  
  195. }
  196.  
  197. function woo_tumblog_quote_content($post_id) {
  198.  
  199. $content_tumblog = '<div class="quote"><blockquote>'.get_post_meta($post_id,'quote-copy',true).' </blockquote><cite><a href="'.get_post_meta($post_id,'quote-url',true).'" title="'.get_the_title($post_id).'">'.get_post_meta($post_id,'quote-author',true).'</a></cite></div>';
  200.  
  201. return $content_tumblog;
  202. }
  203.  
  204. function woo_tumblog_link_content($post_id) {
  205.  
  206. $content_tumblog = '';
  207.  
  208. return $content_tumblog;
  209. }
  210.  
  211. function woo_tumblog_category_link($post_id = 0, $type = 'articles') {
  212.  
  213. $category_link = '';
  214.  
  215. if (get_option('woo_tumblog_content_method') == 'post_format') {
  216.  
  217. $post_format = get_post_format();
  218. if ($post_format == '') {
  219. $category = get_the_category();
  220. $category_name = $category[0]->cat_name;
  221. // Get the ID of a given category
  222. $category_id = get_cat_ID( $category_name );
  223. // Get the URL of this category
  224. $category_link = get_category_link( $category_id );
  225. } else {
  226. $category_link = get_post_format_link( $post_format );
  227. }
  228.  
  229. } else {
  230. $tumblog_list = get_the_term_list( $post_id, 'tumblog', '' , '|' , '' );
  231. $tumblog_array = explode('|', $tumblog_list);
  232. ?>
  233. <?php $tumblog_items = array( 'articles' => get_option('woo_articles_term_id'),
  234. 'images' => get_option('woo_images_term_id'),
  235. 'audio' => get_option('woo_audio_term_id'),
  236. 'video' => get_option('woo_video_term_id'),
  237. 'quotes' => get_option('woo_quotes_term_id'),
  238. 'links' => get_option('woo_links_term_id')
  239. );
  240. ?>
  241. <?php
  242. // Get the ID of Tumblog Taxonomy
  243. $category_id = $tumblog_items[$type];
  244. $term = &get_term($category_id, 'tumblog');
  245. // Get the URL of Articles Tumblog Taxonomy
  246. $category_link = get_term_link( $term, 'tumblog' );
  247. }
  248.  
  249. return $category_link;
  250. }
  251.  
  252. function woo_tumblog_the_title($outer_element = 'h1', $class = 'title', $icon = true, $before = '', $after = '', $return = false) {
  253.  
  254. global $post;
  255. $post_id = $post->ID;
  256.  
  257. // Test for Post Formats
  258. if (get_option('woo_tumblog_content_method') == 'post_format') {
  259.  
  260. if ( has_post_format( 'aside' , $post_id )) {
  261.  
  262. if ($icon) {
  263. $icon_content = '<span class="post-icon article"><a href="'.woo_tumblog_category_link($post_id, 'articles').'" title="'.esc_attr( get_post_format_string( get_post_format() ) ).'">'.get_post_format_string( get_post_format() ).'</a></span>';
  264. } else {
  265. $icon_content = '';
  266. }
  267. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  268.  
  269. } elseif (has_post_format( 'image' , $post_id )) {
  270.  
  271. if ($icon) {
  272. $icon_content = '<span class="post-icon image"><a href="'.woo_tumblog_category_link($post_id, 'images').'" title="'.esc_attr( get_post_format_string( get_post_format() ) ).'">'.get_post_format_string( get_post_format() ).'</a></span>';
  273. } else {
  274. $icon_content = '';
  275. }
  276. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  277.  
  278. } elseif (has_post_format( 'audio' , $post_id )) {
  279.  
  280. if ($icon) {
  281. $icon_content = '<span class="post-icon audio"><a href="'.woo_tumblog_category_link($post_id, 'audio').'" title="'.esc_attr( get_post_format_string( get_post_format() ) ).'">'.get_post_format_string( get_post_format() ).'</a></span>';
  282. } else {
  283. $icon_content = '';
  284. }
  285. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  286.  
  287. } elseif (has_post_format( 'video' , $post_id )) {
  288.  
  289. if ($icon) {
  290. $icon_content = '<span class="post-icon video"><a href="'.woo_tumblog_category_link($post_id, 'video').'" title="'.esc_attr( get_post_format_string( get_post_format() ) ).'">'.get_post_format_string( get_post_format() ).'</a></span>';
  291. } else {
  292. $icon_content = '';
  293. }
  294. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  295.  
  296. } elseif (has_post_format( 'quote' , $post_id )) {
  297.  
  298. if ($icon) {
  299. $icon_content = '<span class="post-icon quote"><a href="'.woo_tumblog_category_link($post_id, 'quotes').'" title="'.esc_attr( get_post_format_string( get_post_format() ) ).'">'.get_post_format_string( get_post_format() ).'</a></span>';
  300. } else {
  301. $icon_content = '';
  302. }
  303. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  304.  
  305. } elseif (has_post_format( 'link' , $post_id )) {
  306.  
  307. if ($icon) {
  308. $icon_content = '<span class="post-icon link"><a href="'.woo_tumblog_category_link($post_id, 'links').'" title="'.esc_attr( get_post_format_string( get_post_format() ) ).'">'.get_post_format_string( get_post_format() ).'</a></span>';
  309. } else {
  310. $icon_content = '';
  311. }
  312. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_post_meta($post_id,'link-url',true).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark" target="_blank">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  313.  
  314. } else {
  315.  
  316. $content = $before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  317.  
  318. }
  319.  
  320. } else {
  321. //check if it is a tumblog post and which tumblog
  322. $tumblog_list = get_the_term_list( $post_id, 'tumblog', '' , '|' , '' );
  323.  
  324. $tumblog_array = explode('|', $tumblog_list);
  325.  
  326. $tumblog_items = array( 'articles' => get_option('woo_articles_term_id'),
  327. 'images' => get_option('woo_images_term_id'),
  328. 'audio' => get_option('woo_audio_term_id'),
  329. 'video' => get_option('woo_video_term_id'),
  330. 'quotes' => get_option('woo_quotes_term_id'),
  331. 'links' => get_option('woo_links_term_id')
  332. );
  333. //switch between tumblog taxonomies
  334. $tumblog_list = strip_tags($tumblog_list);
  335. $tumblog_array = explode('|', $tumblog_list);
  336. $tumblog_results = '';
  337. $sentinel = false;
  338. foreach ($tumblog_array as $tumblog_item) {
  339. $tumblog_id = get_term_by( 'name', $tumblog_item, 'tumblog' );
  340. if ( $tumblog_items['articles'] == $tumblog_id->term_id && !$sentinel ) {
  341. if ($icon) {
  342. $category_id = $tumblog_items['articles'];
  343. if ($category_id > 0) {
  344. $term = &get_term($category_id, 'tumblog');
  345. // Get the URL of Articles Tumblog Taxonomy
  346. $category_link = get_term_link( $term, 'tumblog' );
  347. } else {
  348. $category_link = '#';
  349. }
  350. $icon_content = '<span class="post-icon article"><a href="'.$category_link.'" title="'.$tumblog_id->name.'">'.$tumblog_id->name.'</a></span>';
  351. } else {
  352. $icon_content = '';
  353. }
  354. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  355. } elseif ($tumblog_items['images'] == $tumblog_id->term_id && !$sentinel ) {
  356. if ($icon) {
  357. $category_id = $tumblog_items['images'];
  358. if ($category_id > 0) {
  359. $term = &get_term($category_id, 'tumblog');
  360. // Get the URL of Images Tumblog Taxonomy
  361. $category_link = get_term_link( $term, 'tumblog' );
  362. } else {
  363. $category_link = '#';
  364. }
  365. $icon_content = '<span class="post-icon image"><a href="'.$category_link.'" title="'.$tumblog_id->name.'">'.$tumblog_id->name.'</a></span>';
  366. } else {
  367. $icon_content = '';
  368. }
  369. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  370. } elseif ($tumblog_items['audio'] == $tumblog_id->term_id && !$sentinel) {
  371. if ($icon) {
  372. $category_id = $tumblog_items['audio'];
  373. if ($category_id > 0) {
  374. $term = &get_term($category_id, 'tumblog');
  375. // Get the URL of Audio Tumblog Taxonomy
  376. $category_link = get_term_link( $term, 'tumblog' );
  377. } else {
  378. $category_link = '#';
  379. }
  380. $icon_content = '<span class="post-icon audio"><a href="'.$category_link.'" title="'.$tumblog_id->name.'">'.$tumblog_id->name.'</a></span>';
  381. } else {
  382. $icon_content = '';
  383. }
  384. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  385. } elseif ($tumblog_items['video'] == $tumblog_id->term_id && !$sentinel) {
  386. if ($icon) {
  387. $category_id = $tumblog_items['video'];
  388. if ($category_id > 0) {
  389. $term = &get_term($category_id, 'tumblog');
  390. // Get the URL of Video Tumblog Taxonomy
  391. $category_link = get_term_link( $term, 'tumblog' );
  392. } else {
  393. $category_link = '#';
  394. }
  395. $icon_content = '<span class="post-icon video"><a href="'.$category_link.'" title="'.$tumblog_id->name.'">'.$tumblog_id->name.'</a></span>';
  396. } else {
  397. $icon_content = '';
  398. }
  399. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  400. } elseif ($tumblog_items['quotes'] == $tumblog_id->term_id && !$sentinel) {
  401. if ($icon) {
  402. $category_id = $tumblog_items['quotes'];
  403. if ($category_id > 0) {
  404. $term = &get_term($category_id, 'tumblog');
  405. // Get the URL of Quotes Tumblog Taxonomy
  406. $category_link = get_term_link( $term, 'tumblog' );
  407. } else {
  408. $category_link = '#';
  409. }
  410. $icon_content = '<span class="post-icon quote"><a href="'.$category_link.'" title="'.$tumblog_id->name.'">'.$tumblog_id->name.'</a></span>';
  411. } else {
  412. $icon_content = '';
  413. }
  414. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  415. } elseif ($tumblog_items['links'] == $tumblog_id->term_id && !$sentinel) {
  416. if ($icon) {
  417. $category_id = $tumblog_items['links'];
  418. if ($category_id > 0) {
  419. $term = &get_term($category_id, 'tumblog');
  420. // Get the URL of Links Tumblog Taxonomy
  421. $category_link = get_term_link( $term, 'tumblog' );
  422. } else {
  423. $category_link = '#';
  424. }
  425. $icon_content = '<span class="post-icon link"><a href="'.$category_link.'" title="'.$tumblog_id->name.'">'.$tumblog_id->name.'</a></span>';
  426. } else {
  427. $icon_content = '';
  428. }
  429. $content = $icon_content.$before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_post_meta($post_id,'link-url',true).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark" target="_blank">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  430. } else {
  431. $content = $before.'<'.$outer_element.' class="'.$class.'"><a href="'.get_permalink($post_id).'" title="'.sprintf( esc_attr__( "Permalink to %s", "woothemes" ), get_the_title($post_id)).'" rel="bookmark">'.get_the_title($post_id).'</a></'.$outer_element.'>'.$after;
  432. }
  433. }
  434. }
  435. // Return or echo the content
  436. if ( $return == TRUE )
  437. return $content;
  438. else
  439. echo $content; // Done
  440.  
  441. }
  442.  
  443. function woo_tumblog_taxonomy_link($post_id, $return = true) {
  444.  
  445. // Test for Post Formats
  446. if (get_option('woo_tumblog_content_method') == 'post_format') {
  447.  
  448. if ( has_post_format( 'aside' , $id )) {
  449. $tumblog_results = 'articles';
  450. $sentinel = true;
  451. } elseif (has_post_format( 'image' , $id )) {
  452. $tumblog_results = 'images';
  453. $sentinel = true;
  454. } elseif (has_post_format( 'audio' , $id )) {
  455. $tumblog_results = 'audio';
  456. $sentinel = true;
  457. } elseif (has_post_format( 'video' , $id )) {
  458. $tumblog_results = 'video';
  459. $sentinel = true;
  460. } elseif (has_post_format( 'quote' , $id )) {
  461. $tumblog_results = 'quotes';
  462. $sentinel = true;
  463. } elseif (has_post_format( 'link' , $id )) {
  464. $tumblog_results = 'links';
  465. $sentinel = true;
  466. } else {
  467. $tumblog_results = 'articles';
  468. $sentinel = false;
  469. }
  470. $term_name = esc_attr( get_post_format_string( get_post_format() ) );
  471.  
  472. } else {
  473. $tumblog_list = get_the_term_list( $post_id, 'tumblog', '' , '|' , '' );
  474. $tumblog_array = explode('|', $tumblog_list);
  475.  
  476. $tumblog_items = array( 'articles' => get_option('woo_articles_term_id'),
  477. 'images' => get_option('woo_images_term_id'),
  478. 'audio' => get_option('woo_audio_term_id'),
  479. 'video' => get_option('woo_video_term_id'),
  480. 'quotes' => get_option('woo_quotes_term_id'),
  481. 'links' => get_option('woo_links_term_id')
  482. );
  483. //switch between tumblog taxonomies
  484. $tumblog_list = strip_tags($tumblog_list);
  485. $tumblog_array = explode('|', $tumblog_list);
  486. $tumblog_results = '';
  487. $sentinel = false;
  488. foreach ($tumblog_array as $tumblog_item) {
  489. $tumblog_id = get_term_by( 'name', $tumblog_item, 'tumblog' );
  490. if ( $tumblog_items['articles'] == $tumblog_id->term_id && !$sentinel ) {
  491. $tumblog_results = 'articles';
  492. $category_id = $tumblog_items['articles'];
  493. $sentinel = true;
  494. } elseif ($tumblog_items['images'] == $tumblog_id->term_id && !$sentinel ) {
  495. $tumblog_results = 'images';
  496. $category_id = $tumblog_items['images'];
  497. $sentinel = true;
  498. } elseif ($tumblog_items['audio'] == $tumblog_id->term_id && !$sentinel) {
  499. $tumblog_results = 'audio';
  500. $category_id = $tumblog_items['audio'];
  501. $sentinel = true;
  502. } elseif ($tumblog_items['video'] == $tumblog_id->term_id && !$sentinel) {
  503. $tumblog_results = 'video';
  504. $category_id = $tumblog_items['video'];
  505. $sentinel = true;
  506. } elseif ($tumblog_items['quotes'] == $tumblog_id->term_id && !$sentinel) {
  507. $tumblog_results = 'quotes';
  508. $category_id = $tumblog_items['quotes'];
  509. $sentinel = true;
  510. } elseif ($tumblog_items['links'] == $tumblog_id->term_id && !$sentinel) {
  511. $tumblog_results = 'links';
  512. $category_id = $tumblog_items['links'];
  513. $sentinel = true;
  514. } else {
  515. $tumblog_results = 'articles';
  516. $category_id = 0;
  517. $sentinel = false;
  518. }
  519. }
  520. }
  521.  
  522. $category_link = woo_tumblog_category_link($post_id, $tumblog_results);
  523.  
  524. if ( $return ) {
  525. echo '<a href="'.$category_link.'" title="'.$term_name.'">'.$term_name.'</a>';
  526. } else {
  527. return $category_link;
  528. }
  529. }
  530.  
  531. function woo_tumblog_test() {
  532.  
  533. global $post;
  534. $post_id = $post->ID;
  535.  
  536. // Test for Post Formats
  537. if (get_option('woo_tumblog_content_method') == 'post_format') {
  538.  
  539. if ( has_post_format( 'aside' , $post_id )) {
  540. $sentinel = true;
  541. } elseif (has_post_format( 'image' , $post_id )) {
  542. $sentinel = true;
  543. } elseif (has_post_format( 'audio' , $post_id )) {
  544. $sentinel = true;
  545. } elseif (has_post_format( 'video' , $post_id )) {
  546. $sentinel = true;
  547. } elseif (has_post_format( 'quote' , $post_id )) {
  548. $sentinel = true;
  549. } elseif (has_post_format( 'link' , $post_id )) {
  550. $sentinel = true;
  551. } else {
  552. $sentinel = false;
  553. }
  554.  
  555. } else {
  556. $tumblog_items = array( 'articles' => get_option('woo_articles_term_id'),
  557. 'images' => get_option('woo_images_term_id'),
  558. 'audio' => get_option('woo_audio_term_id'),
  559. 'video' => get_option('woo_video_term_id'),
  560. 'quotes' => get_option('woo_quotes_term_id'),
  561. 'links' => get_option('woo_links_term_id')
  562. );
  563.  
  564. //switch between tumblog taxonomies
  565. $tumblog_list = get_the_term_list( $post_id, 'tumblog', '' , '|' , '' );
  566. $tumblog_list = strip_tags($tumblog_list);
  567. $tumblog_array = explode('|', $tumblog_list);
  568. $sentinel = false;
  569. foreach ($tumblog_array as $location_item) {
  570. $tumblog_id = get_term_by( 'name', $location_item, 'tumblog' );
  571. if ( $tumblog_items['articles'] == $tumblog_id->term_id && !$sentinel ) {
  572. $sentinel = true;
  573. } elseif ($tumblog_items['images'] == $tumblog_id->term_id && !$sentinel ) {
  574. $sentinel = true;
  575. } elseif ($tumblog_items['audio'] == $tumblog_id->term_id && !$sentinel) {
  576. $sentinel = true;
  577. } elseif ($tumblog_items['video'] == $tumblog_id->term_id && !$sentinel) {
  578. $sentinel = true;
  579. } elseif ($tumblog_items['quotes'] == $tumblog_id->term_id && !$sentinel) {
  580. $sentinel = true;
  581. } elseif ($tumblog_items['links'] == $tumblog_id->term_id && !$sentinel) {
  582. $sentinel = true;
  583. } else {
  584. $sentinel = false;
  585. }
  586. }
  587. }
  588. return $sentinel;
  589. }
  590.  
  591.  
  592.  
  593.  
  594. /*-----------------------------------------------------------------------------------*/
  595. /* WooTumblog Custom RSS Feed Output */
  596. /*-----------------------------------------------------------------------------------*/
  597.  
  598. function woo_custom_tumblog_rss_output($content) {
  599. global $post;
  600. $post_id = $post->ID;
  601. $default_feed_option = get_option('woo_custom_rss');
  602. if ($default_feed_option == 'true') {
  603. //default content output to nothing
  604. $temp_content = $content;
  605. $content = '';
  606.  
  607. // Test for Post Formats
  608. if (get_option('woo_tumblog_content_method') == 'post_format') {
  609.  
  610. $content .= '<p>Posted in ';
  611. foreach((get_the_category($post_id)) as $category) {
  612. $category_link = get_category_link( $category->cat_ID );
  613. $content .= '<a href="'.$category_link.'" title="'.$category->cat_name.'">'.$category->cat_name.'</a>';
  614. }
  615. $content .= '</p>';
  616.  
  617. if ( has_post_format( 'aside' , $post_id )) {
  618. // Do Nothing
  619. } elseif (has_post_format( 'image' , $post_id )) {
  620.  
  621. if (get_option('woo_image_link_to') == 'image') {
  622. $content .= '<p><a href="'.get_post_meta($post_id, "image", true).'" title="image" rel="lightbox">'.woo_image('key=image&width='.get_option('woo_tumblog_image_width').'px'.'&link=img&return=true').'</a></p>';
  623. } else {
  624. $content .= '<p><a href="'.get_permalink($post_id).'" title="image">'.woo_image('key=image&width='.get_option('woo_tumblog_image_width').'px'.'&link=img&return=true').'</a></p>';
  625. }
  626.  
  627. } elseif (has_post_format( 'audio' , $post_id )) {
  628. //Post Args
  629. $args = array(
  630. 'post_type' => 'attachment',
  631. 'numberposts' => -1,
  632. 'post_status' => null,
  633. 'post_parent' => $post_id
  634. );
  635. //Get attachements
  636. $attachments = get_posts($args);
  637. if ($attachments) {
  638. foreach ($attachments as $attachment) {
  639. $link_url= $attachment->guid;
  640. }
  641. }
  642. else {
  643. $link_url = get_post_meta($post_id,'audio',true);
  644. }
  645. if(!empty($link_url)) {
  646. $content .= '<p><a href="'.$link_url.'" rel="bookmark" title="'.get_the_title($post_id).'" target="_blank">'.__('Play Audio', 'woothemes').'</a></p>';
  647. }
  648. } elseif (has_post_format( 'video' , $post_id )) {
  649. $content .= '<p>'.get_post_meta($post_id,'video-embed',true).'</p>';
  650. } elseif (has_post_format( 'quote' , $post_id )) {
  651. $content .= '<p><cite>'.get_post_meta($post_id,'quote-copy',true).__(' ~ ', 'woothemes').'<a href="'.get_post_meta($post_id,'quote-url',true).'" title="'.get_the_title($post_id).'">'.get_post_meta($post_id,'quote-author',true).'</a></cite></p>';
  652. } elseif (has_post_format( 'link' , $post_id )) {
  653. $content .= '<p><a href="'.get_post_meta($post_id,'link-url',true).'" rel="bookmark" title="'.get_the_title($post_id).'" target="_blank">'.get_post_meta($post_id,'link-url',true).'</a></p>';
  654. } else {
  655. // Do Nothing
  656. }
  657.  
  658. } else {
  659.  
  660. //check if it is a tumblog post
  661.  
  662. //check which tumblog
  663. $tumblog_list = get_the_term_list( $post_id, 'tumblog', '' , '|' , '' );
  664.  
  665. $tumblog_array = explode('|', $tumblog_list);
  666.  
  667. $tumblog_items = array( 'articles' => get_option('woo_articles_term_id'),
  668. 'images' => get_option('woo_images_term_id'),
  669. 'audio' => get_option('woo_audio_term_id'),
  670. 'video' => get_option('woo_video_term_id'),
  671. 'quotes' => get_option('woo_quotes_term_id'),
  672. 'links' => get_option('woo_links_term_id')
  673. );
  674. //switch between tumblog taxonomies
  675. $tumblog_list = strip_tags($tumblog_list);
  676. $tumblog_array = explode('|', $tumblog_list);
  677. $tumblog_results = '';
  678. $sentinel = false;
  679. foreach ($tumblog_array as $tumblog_item) {
  680. $tumblog_id = get_term_by( 'name', $tumblog_item, 'tumblog' );
  681. if ( $tumblog_items['articles'] == $tumblog_id->term_id && !$sentinel ) {
  682. $tumblog_results = 'article';
  683. $tumblog_name = $tumblog_id->name;
  684. $sentinel = true;
  685. } elseif ($tumblog_items['images'] == $tumblog_id->term_id && !$sentinel ) {
  686. $tumblog_results = 'image';
  687. $tumblog_name = $tumblog_id->name;
  688. $sentinel = true;
  689. } elseif ($tumblog_items['audio'] == $tumblog_id->term_id && !$sentinel) {
  690. $tumblog_results = 'audio';
  691. $tumblog_name = $tumblog_id->name;
  692. $sentinel = true;
  693. } elseif ($tumblog_items['video'] == $tumblog_id->term_id && !$sentinel) {
  694. $tumblog_results = 'video';
  695. $tumblog_name = $tumblog_id->name;
  696. $sentinel = true;
  697. } elseif ($tumblog_items['quotes'] == $tumblog_id->term_id && !$sentinel) {
  698. $tumblog_results = 'quote';
  699. $tumblog_name = $tumblog_id->name;
  700. $sentinel = true;
  701. } elseif ($tumblog_items['links'] == $tumblog_id->term_id && !$sentinel) {
  702. $tumblog_results = 'link';
  703. $tumblog_name = $tumblog_id->name;
  704. $sentinel = true;
  705. } else {
  706. $tumblog_results = 'default';
  707. $tumblog_name = 'Tumblog';
  708. $sentinel = false;
  709. }
  710. }
  711.  
  712. $taxonomy_link = woo_tumblog_taxonomy_link($post_id, false);
  713. if ($tumblog_name != 'Tumblog') {
  714. $content .= '<p>Posted in <a href="'.$taxonomy_link.'">'.$tumblog_name.'</a></p>';
  715. } else {
  716. $content .= '<p>Posted in ';
  717. foreach((get_the_category($post_id)) as $category) {
  718. $category_link = get_category_link( $category->cat_ID );
  719. $content .= '<a href="'.$category_link.'" title="'.$category->cat_name.'">'.$category->cat_name.'</a>';
  720. }
  721. $content .= '</p>';
  722. }
  723.  
  724. switch ($tumblog_results) {
  725.  
  726. case 'article':
  727. break;
  728. case 'image':
  729. if (get_option('woo_image_link_to') == 'image') {
  730. $content .= '<p><a href="'.get_post_meta($post_id, "image", true).'" title="image" rel="lightbox"><img src="'.get_post_meta($post_id, "image", true).'" alt="image" width="'.get_option('woo_tumblog_width').'" /></a></p>';
  731. } else {
  732. $content .= '<p><a href="'.get_permalink($post_id).'" title="image"><img src="'.get_post_meta($post_id, "image", true).'" alt="image" width="'.get_option('woo_tumblog_width').'" /></a></p>';
  733. }
  734. break;
  735. case 'audio':
  736. //Post Args
  737. $args = array(
  738. 'post_type' => 'attachment',
  739. 'numberposts' => -1,
  740. 'post_status' => null,
  741. 'post_parent' => $post_id
  742. );
  743. //Get attachements
  744. $attachments = get_posts($args);
  745. if ($attachments) {
  746. foreach ($attachments as $attachment) {
  747. $link_url= $attachment->guid;
  748. }
  749. }
  750. else {
  751. $link_url = get_post_meta($post_id,'audio',true);
  752. }
  753. if(!empty($link_url)) {
  754. $content .= '<p><a href="'.$link_url.'" rel="bookmark" title="'.get_the_title($post_id).'" target="_blank">'.__('Play Audio', 'woothemes').'</a></p>';
  755. }
  756. break;
  757. case 'video':
  758. $content .= '<p>'.get_post_meta($post_id,'video-embed',true).'</p>';
  759. break;
  760. case 'quote':
  761. $content .= '<p><cite>'.get_post_meta($post_id,'quote-copy',true).__(' ~ ', 'woothemes').'<a href="'.get_post_meta($post_id,'quote-url',true).'" title="'.get_the_title($post_id).'">'.get_post_meta($post_id,'quote-author',true).'</a></cite></p>';
  762. break;
  763. case 'link':
  764. $content .= '<p><a href="'.get_post_meta($post_id,'link-url',true).'" rel="bookmark" title="'.get_the_title($post_id).'" target="_blank">'.get_post_meta($post_id,'link-url',true).'</a></p>';
  765. break;
  766. default:
  767. break;
  768. }
  769.  
  770. }
  771.  
  772. //add original content back
  773. $content .= $temp_content;
  774. }
  775. return $content;
  776. }
  777.  
  778. ?>
RAW Paste Data