PageRenderTime 51ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/wp-ui/inc/class-wpui-posts.php

https://gitlab.com/Blueprint-Marketing/interoccupy.net
PHP | 696 lines | 391 code | 138 blank | 167 comment | 119 complexity | 9f3db8430db8ef9436217470ddbd5cd2 MD5 | raw file
  1. <?php
  2. /**
  3. * Script: WP UI Posts
  4. *
  5. * WP UI posts handler class.
  6. *
  7. *
  8. * @since $Id$
  9. * @package wp-ui
  10. * @subpackage class-wpui-post
  11. **/
  12. /**
  13. * Class: WP UI Posts ( wpuiPosts )
  14. *
  15. * See also :
  16. * <wpui>
  17. *
  18. */
  19. class wpuiPosts
  20. {
  21. private $options, $direct, $instance;
  22. function __construct()
  23. {
  24. $this->wpuiPosts();
  25. }
  26. function wpuiPosts()
  27. {
  28. $this->options = get_option( 'wpUI_options' );
  29. if ( ! isset( $this->options ) ) return;
  30. }
  31. /**
  32. * Function: replace_tags
  33. * returns the template string, with replaced values.
  34. *
  35. * @since 0.7
  36. *
  37. * @param $template - HTML template as a string
  38. * @param $needles - array with values that are to be replaced in the HTML template.
  39. *
  40. *
  41. * @return string $template HTML
  42. */
  43. function replace_tags( $template, $needles ) {
  44. if ( ! $template ) return;
  45. if ( ! is_array( $needles ) ) return;
  46. $template = str_ireplace( '{$title}' , $needles[ 'title' ], $template );
  47. $template = str_ireplace( '{$thumbnail}' , $needles[ 'thumbnail' ], $template );
  48. $template = str_ireplace( '{$excerpt}' , $needles[ 'excerpt' ], $template );
  49. $template = str_ireplace( '{$content}' , $needles[ 'content' ], $template );
  50. if ( isset( $this->options[ 'relative_times' ] ) && $this->options[ 'relative_times' ] == 'on' )
  51. $template = str_ireplace( '{$date}' , $this->get_relative_time($needles[ 'date' ]), $template );
  52. else
  53. $template = str_ireplace( '{$date}' , $needles[ 'date' ], $template );
  54. $template = str_ireplace( '{$url}' , $needles[ 'url' ], $template );
  55. $template = str_ireplace( '{$author}' , $needles[ 'author' ], $template );
  56. $author_posts_link = '<a href="' . get_author_posts_url( $needles[ 'author' ] ) . '" target="_blank" />' . $needles[ 'author' ] . '</a>';
  57. $template = str_ireplace( '{$author_posts_link}', $author_posts_link, $template );
  58. $first_cat = explode( ', ', $needles[ 'meta' ]['cat'] );
  59. $first_cat = $first_cat[ 0 ];
  60. $template = str_ireplace( '{$cats}', $needles[ 'meta' ][ 'cat' ], $template );
  61. $template = str_ireplace( '{$cat}', $first_cat, $template );
  62. $template = str_ireplace( '{$tags}', $needles[ 'meta' ][ 'tag' ], $template );
  63. $template = str_ireplace( '{$num_comments}', $needles[ 'meta' ][ 'comments' ], $template );
  64. return $template;
  65. } // END method replace_tags
  66. /**
  67. * Function: get_excerpt
  68. *
  69. * Generate excerpt.
  70. *
  71. * @since 0.7
  72. *
  73. * @param $text to be trimmed.
  74. * @param $length to trim.
  75. * @return $text trimmed content
  76. */
  77. function get_excerpt( $text, $length ) {
  78. $text = apply_filters( 'the_content' , $text );
  79. $text = str_replace( '\]\]\>', ']]&gt;', $text );
  80. $text = preg_replace( '@<script[^>]*?>.*?</script>@si', '', $text );
  81. $text = strip_tags( $text, '<p><ul><ol><li><img/><h2><h3>' );
  82. if ( ! is_int( $length ) ) {
  83. if ( isset( $this->options[ 'excerpt_length' ] ) )
  84. $length = $this->options[ 'excerpt_length' ];
  85. else
  86. $length = 55;
  87. }
  88. $words = preg_split( '/ /', $text, $length + 1 );
  89. $words_limit = count($words);
  90. $words[ $words_limit -1 ] = preg_replace( '/([^\.]\.\s).+/sim' , '$1', $words[ $words_limit - 1] );
  91. if ( count( $words ) > $length ) {
  92. $text = implode( ' ', $words );
  93. }
  94. return $text;
  95. } // END method wpui_generate_excerpt
  96. /**
  97. * Function: wpui_get_post
  98. * Get individual posts.
  99. *
  100. * @since 0.7
  101. * @param $ID of the post
  102. * @param $args array.
  103. */
  104. function wpui_get_post( $ID , $length , $type='post' ) {
  105. if ( ! $ID ) return;
  106. if ( ! $length && isset( $this->options[ 'excerpt_length' ] ) )
  107. $length = $this->option[ 'excerpt_length' ];
  108. if ( $type == 'page' )
  109. $length = 55;
  110. if ( $type == 'page' ) {
  111. if ( is_numeric( $ID ) )
  112. $wpui_post = get_page( $ID );
  113. else
  114. $wpui_post = get_page_by_title( $ID );
  115. } else {
  116. $wpui_post = get_post( $ID );
  117. }
  118. if ( ! $wpui_post ) {
  119. return "Please verify the post/page ID. Check the spelling if using a name or title.";
  120. }
  121. $p_title = $wpui_post->post_title;
  122. $p_thumb = ( function_exists( 'get_the_post_thumbnail' ) ) ? get_the_post_thumbnail( $ID ) : '';
  123. $more_link = get_permalink( $ID );
  124. $check_more = preg_match( '/<!--more-->/im', $wpui_post->post_content);
  125. // die();
  126. if ( $length == 'more' && $check_more ) {
  127. $pos = stripos( $wpui_post->post_content , '<!--more-->' );
  128. $post_exc = substr( $wpui_post->post_content, 0 , $pos);
  129. } else {
  130. $length = intval( $length );
  131. $post_exc = $wpui_post->post_content;
  132. $post_exc = $this->get_excerpt( $post_exc, $length );
  133. }
  134. $post_date = mysql2date( get_option( 'date_format' ) , $wpui_post->post_date_gmt);
  135. if ( $type != 'page' ) {
  136. $cats = get_the_category_list( ', ', '', $wpui_post->ID );
  137. $tags = $this->wpui_get_post_tags( $wpui_post->ID );
  138. } else {
  139. $cats = $tags = '';
  140. }
  141. // $so_content = $wpui_post->post_content;
  142. $so_content = apply_filters( 'the_content', $wpui_post->post_content );
  143. $so_content = str_replace(']]>', ']]&gt;', $so_content);
  144. $output = array(
  145. 'title' => $wpui_post->post_title,
  146. 'excerpt' => $post_exc,
  147. 'content' => $so_content,
  148. 'thumbnail' => $p_thumb,
  149. 'date' => $post_date,
  150. 'author' => get_the_author_meta('display_name', $wpui_post->post_author),
  151. 'url' => $more_link,
  152. 'meta' => array(
  153. 'cat' => $cats,
  154. 'tag' => $tags,
  155. 'comments' => $wpui_post->comment_count
  156. )
  157. );
  158. return $output;
  159. } // END method wpui_get_post.
  160. /**
  161. * Function wpui_get_posts
  162. * Get **multiple posts** with custom query.
  163. *
  164. * See also :
  165. * <wpui_get_post>
  166. *
  167. * @param $args array
  168. * @since 0.7
  169. * @uses WP_Query, wp_reset_postdata()
  170. * @return array $posts
  171. */
  172. function wpui_get_posts( $args='' ) {
  173. $defaults = array(
  174. 'get' => '',
  175. 'cat' => '',
  176. 'category_name' => '',
  177. 'tag' => '',
  178. 'tag_name' => '',
  179. 'post_type' => 'post',
  180. 'post_status' => 'publish',
  181. 'number' => '4',
  182. 'offset' => false,
  183. 'search' => '',
  184. 'exclude' => '',
  185. 'length' => 'more',
  186. 'excerpt' => true,
  187. 'thumbnail' => true,
  188. 'meta' => true,
  189. 'related' => 'category',
  190. );
  191. $r = wp_parse_args( $args, $defaults );
  192. $qquery = array();
  193. /**
  194. * Preference - Get > Cat > Tag
  195. */
  196. if ( $r[ 'get' ] != '' ) {
  197. // Get recent posts
  198. if ( $r['get'] == 'recent' ) {
  199. } else if ( $r[ 'get' ] == 'popular' ) {
  200. $qquery = array( 'orderby' => 'comment_count' );
  201. } elseif ( $r[ 'get' ] == 'random' ) {
  202. $qquery = array( 'orderby' => 'rand' );
  203. } elseif ( $r[ 'get' ] == 'related' ) {
  204. global $post;
  205. if ( $r[ 'related' ] == 'tags' ) {
  206. $rtags = wp_get_post_tags( $post->ID );
  207. if ( $rtags ) {
  208. $rels = array();
  209. foreach( $rtags as $tags ) $rels[] = $tags->term_id;
  210. $qquery[ 'tag__not_in' ] = $rels;
  211. }
  212. } else {
  213. $rcats = get_the_category( $post->ID );
  214. if ( $rcats ) {
  215. $rels = array();
  216. foreach( $rcats as $cats ) $rels = $cats->term_id;
  217. $qquery[ 'category__in' ] = $rels;
  218. }
  219. }
  220. }
  221. if ( $r[ 'exclude' ] != '' ) {
  222. $excl_array = explode( ',' , $r[ 'exclude' ] );
  223. if ( is_array( $excl_array ) )
  224. $qquery[ 'post__not_in' ] = $excl_array;
  225. }
  226. } else {
  227. /**
  228. * Categories and tags.
  229. */
  230. // Cats
  231. if ( $r[ 'cat' ] != '' || $r[ 'category_name' ] != '' ) {
  232. $r[ 'tag' ] = '';
  233. if ( $r[ 'category_name' ] != '' )
  234. $qquery[ 'category_name' ] = $r[ 'category_name' ];
  235. else
  236. $qquery[ 'cat' ] = $r[ 'cat' ];
  237. if ( $r[ 'exclude' ] != '' ) {
  238. $excl_array = explode( ',' , $r[ 'exclude' ] );
  239. if ( is_array( $excl_array ) )
  240. $qquery[ 'category__not_in' ] = $excl_array;
  241. }
  242. }
  243. // Tags
  244. if ( $r[ 'tag' ] != '' || $r[ 'tag_name' ] != '' ) {
  245. if ( $r[ 'tag_name' ] != '' ) {
  246. $qquery[ 'tag' ] = $r[ 'tag_name' ];
  247. } else {
  248. $tags_arr = explode( ',', $r[ 'tag' ] );
  249. $qquery[ 'tag__in' ] = $tags_arr;
  250. }
  251. if ( $r[ 'exclude' ] != '' ) {
  252. $excl_array = explode(',', $r[ 'exclude' ] );
  253. if ( is_array( $excl_array ) )
  254. $qquery[ 'tag__not_in' ] = $excl_array;
  255. }
  256. }
  257. }
  258. $qquery[ 'posts_per_page' ] = $r['number'];
  259. if ( $r[ 'post_type' ] != '' )
  260. $qquery[ 'post_type' ] = $r[ 'post_type' ];
  261. if ( $r['post_status' ] != 'publish' )
  262. $qquery[ 'post_status' ] = $r[ 'post_status' ];
  263. $get_posts = new WP_Query( $qquery );
  264. $post_count = 0;
  265. $post_basket = array();
  266. while ( $get_posts->have_posts() ) : $get_posts->the_post();
  267. $wost = array();
  268. $content = get_the_content();
  269. $wost['title'] = get_the_title();
  270. // $wost[ 'thumbnail' ] = ( function_exists( 'get_the_post_thumbnail' ) ) ? get_the_post_thumbnail( get_the_ID() ) : '';
  271. $wost[ 'thumbnail' ] = $this->get_thumbnail( get_the_ID() );
  272. $wost['content'] = $content;
  273. $check_more = preg_match( '/<!--more-->/im', $wost['content']);
  274. // if ( $r[ 'length' ] == 'more' && $check_more ) {
  275. // $pos = stripos( $content , '<!--more-->' );
  276. // $wost[ 'excerpt' ] = substr( $content, 0 , $pos);
  277. // } else {
  278. if ( $r[ 'length' ] == 'more' ) {
  279. $wost['excerpt'] = get_the_excerpt();
  280. } else {
  281. $elength = intval( $r[ 'length' ] );
  282. if ( ! is_int( $elength ) ) $elength = 55;
  283. $wost[ 'excerpt' ] = $this->get_excerpt( $content, $elength );
  284. }
  285. $wost[ 'meta' ] = array();
  286. $wost[ 'meta' ][ 'cat' ] = get_the_category_list( ',' );
  287. $wost[ 'meta' ][ 'tag' ] = get_the_tag_list('', ', ', '');
  288. $wost[ 'meta' ][ 'comments' ] = get_comments_number();
  289. // }
  290. $wost[ 'date' ] = get_the_date();
  291. $wost[ 'url' ] = get_permalink( get_the_ID() );
  292. $wost[ 'author' ] = get_the_author();
  293. // $post_basket
  294. $post_basket[ $post_count ] = $wost;
  295. $post_count++;
  296. endwhile; // end while get_posts loop
  297. wp_reset_postdata();
  298. if ( $post_basket )
  299. return $post_basket;
  300. } // END function wpui_get_posts
  301. /**
  302. * Function: get_relative_time
  303. * Get the relative time e.g, 5 days ago.
  304. *
  305. * @since 0.5.8
  306. * @uses mysql2date, human_time_diff
  307. * @param integer $time, post time in GMT.
  308. * @return string, relative time
  309. */
  310. function get_relative_time( $time )
  311. {
  312. $time = mysql2date( 'U' , $time );
  313. $time = human_time_diff( $time, current_time( 'timestamp' ) ) . __( ' ago', 'wp-ui' );
  314. return $time;
  315. } // END function get_relative_time
  316. /**
  317. * Function: wpui_get_post_tags
  318. * Get the tags from a post ID.
  319. *
  320. * @uses get_the_tags()
  321. * @since 0.7
  322. * @param $ID id of the post.
  323. * @param $separator string
  324. * @return $output long string of tags.
  325. */
  326. function wpui_get_post_tags( $pID='0' , $sep=', ' )
  327. {
  328. $get_tags = get_the_tags( $pID );
  329. $output = '';
  330. $total_tags = count( $get_tags );
  331. $present_tag = 1;
  332. if ( ! $get_tags ) return;
  333. foreach( $get_tags as $tag ) {
  334. if ( $present_tag == $total_tags ) $sep = '';
  335. $output .= '<a href="' . get_tag_link( $tag->term_id ) . '">' . $tag->name . '</a>' . $sep;
  336. $present_tag++;
  337. }
  338. return $output;
  339. } // END function wpui_get_post_tags
  340. /**
  341. * Function: wpui_get_feeds
  342. * Get a feed and output the array.
  343. *
  344. * @param $args array.
  345. * @return $items array
  346. */
  347. function wpui_get_feeds( $args='' )
  348. {
  349. $defaults = array(
  350. 'url' => '',
  351. 'number' => 5,
  352. 'length' => 55
  353. );
  354. $r = wp_parse_args( $args, $defaults );
  355. // Fix URLS with special characters.
  356. $feed = fetch_feed( wp_specialchars_decode(esc_url( $r[ 'url' ] ) ) );
  357. if ( is_wp_error( $feed ) )
  358. return false;
  359. $number = $feed->get_item_quantity( $r[ 'number' ] );
  360. $items = $feed->get_items( 0, $number );
  361. $lists = array();
  362. $itera = 0;
  363. $format_opt = get_option( 'date_format' );
  364. $date_format = ( $format_opt ) ? $format_opt : 'l, F jS, Y';
  365. foreach( $items as $item ) {
  366. $thisArr[ 'title' ] = $item->get_title();
  367. $thisArr['url'] = $item->get_permalink();
  368. $thisArr[ 'date' ] = $item->get_date( $date_format );
  369. $thisArrAuth = $item->get_author();
  370. $thisArr[ 'author' ] = ( $thisArrAuth ) ? $thisArrAuth->get_name() : '';
  371. $thisArr[ 'content' ] = $item->get_content();
  372. if ( strlen( $thisArr[ 'content' ] ) > intval( $r[ 'length' ] ) )
  373. $thisArr[ 'excerpt' ] = $this->get_excerpt( $thisArr[ 'content' ], $r[ 'length' ] );
  374. else
  375. $thisArr[ 'excerpt' ] = $thisArr[ 'content' ];
  376. $thisArr[ 'thumbnail' ] = $this->get_image_from_Content( $thisArr[ 'content' ] );
  377. $thisArr[ 'meta' ][ 'cat' ] = '';
  378. $thisCat = $item->get_category();
  379. if ( $thisCat )
  380. $thisArr[ 'meta' ][ 'cat' ] = $thisCat->get_term();
  381. $thisArr[ 'meta' ][ 'tag' ] = '';
  382. $thisArr[ 'meta' ][ 'comments' ] = '';
  383. $lists[ $itera ] = $thisArr;
  384. $itera++;
  385. }
  386. return $lists;
  387. } // END function wpui_get_feeds
  388. /**
  389. * Function: get_thumbnail
  390. * Get the thumbnail from a post using ID. Use the default image if there is none.
  391. *
  392. * @param $ID - integer ID of post.
  393. * @return $img HTML tag string
  394. */
  395. function get_thumbnail( $ID ) {
  396. $cache = ( isset( $this->options ) && isset( $this->options[ 'enable_cache' ] ) && $this->options[ 'enable_cache' ] == true ) ? true : false;
  397. $width = ( isset( $this->options['post_default_thumbnail' ] ) &&
  398. ( $this->options[ 'post_default_thumbnail' ][ 'width' ] != '' ) ) ?
  399. $this->options[ 'post_default_thumbnail']['width'] : get_option( 'thumbnail_size_w' );
  400. $height = ( isset( $this->options['post_default_thumbnail' ] ) &&
  401. ( $this->options[ 'post_default_thumbnail' ][ 'height' ] != '' ) ) ?
  402. $this->options[ 'post_default_thumbnail']['height'] : get_option( 'thumbnail_size_h' );
  403. $title = get_the_title( $ID );
  404. if ( function_exists( 'has_post_thumbnail' ) && has_post_thumbnail( $ID ) ) {
  405. // $thumbs = wp_get_attachment_image_src( get_post_thumbnail_id( $ID ), array( $width, $height ), true );
  406. $thumbs = get_the_post_thumbnail( $ID , array( $width, $height ), true );
  407. } else {
  408. $thumbs = ( isset( $this->options[ 'post_default_thumbnail' ] ) && $this->options[ 'post_default_thumbnail' ][ 'url' ] != '' ) ?
  409. $this->options['post_default_thumbnail']['url'] : false;
  410. $thumbs = '<img src="' . $thumbs . '" width="' . $width . '" height="' . $height . '" alt="' . $title . '" />';
  411. }
  412. if ( $thumbs ) {
  413. return $thumbs;
  414. }
  415. }
  416. /**
  417. * Function: get_image_from_content
  418. * Get the first image from a block of content.
  419. *
  420. * @param $content - HTML string
  421. * @return image.
  422. */
  423. function get_image_from_content( $content )
  424. {
  425. if ( ! $content ) return;
  426. $content = html_entity_decode( $content, ENT_QUOTES, 'UTF-8' );
  427. preg_match( '/<img[^>]+\>/i', $content, $matches );
  428. if ( empty( $matches ) && ! count( $matches ) > 0 )
  429. return;
  430. $thumb_width = get_option( 'thumbnail_size_w' );
  431. $thumb_height = get_option( 'thumbnail_size_h' );
  432. $image = $matches[ 0 ];
  433. $image = preg_replace( '|width="([^"]*)"|' , 'width="' . $thumb_width . '"', $image );
  434. $image = preg_replace( '|height="([^"]*)"|' , 'height="' . $thumb_height . '"', $image );
  435. return $image;
  436. } // END function get_image_from_content
  437. /**
  438. * Function: put_related_posts
  439. * Append related posts shortcode to the end of single post.
  440. *
  441. * @param $content
  442. * @return $content
  443. */
  444. function put_related_posts( $content ) {
  445. global $post, $wp_query;
  446. static $sinstance = 0;
  447. if ( ( $sinstance != 0 ) || ( ! is_singular() ) || ( $post->ID !== $wp_query->post->ID ) ) {
  448. return $content;
  449. } else {
  450. $sinstance++;
  451. }
  452. // echo $post->ID . ':::::::::::' . $wp_query->post->ID . '<br />';
  453. // $content .= do_shortcode( '[wpui_related_posts]' );
  454. $content .= '<style type="text/css">ul.wpui-related-posts{margin :10px 0px !important;padding :0px !important;float :none !important;overflow :hidden;list-style :none;}
  455. ul.wpui-related-posts li.row-first{border-left :none !important;}
  456. ul.wpui-related-posts li.row-last{border-right :none !important;}
  457. ul.wpui-related-posts li{padding:10px;vertical-align :top;font-size :12px;text-align :center;
  458. height :100%;opacity :0.7;float :left;-moz-transition :all 0.6s ease-out 0.2s;-webkit-transition :all 0.6s ease-out 0.2s;-o-transition :all 0.6s ease-out 0.2s;-ms-transition :all 0.6s ease-out 0.2s;-moz-border-radius :4px;-webkit-border-radius :4px;-o-border-radius :4px;border-radius :4px;}
  459. ul.wpui-related-posts li:hover{opacity :1;background :#EEE;-webkit-transition :all 0.6s ease-in 0.2s;-moz-transition :all 0.6s ease-in 0.2s;-o-transition :all 0.6s ease-in 0.2s;-ms-transition :all 0.6s ease-in 0.2s;}
  460. .wpui-related-posts .wpui-post-thumbnail a img{padding :10px;border :1px solid #888 !important;}
  461. .wpui-related-posts .wpui-rel-post-title{text-transform :uppercase;}
  462. .wpui-per_2 li .wpui-rel-post-thumbnail{float :left;width :100px;}
  463. .wpui-per_2 li .wpui-rel-post-meta{float :left;width :150px;}
  464. .wpui-per_2 li .wpui-rel-post-meta span{display :block;}</style>';
  465. $content .= '[wpui_related_posts]';
  466. return $content;
  467. } // END get_related_posts;
  468. function insert_related_posts( $atts, $content = null) {
  469. extract(shortcode_atts(array(
  470. 'type' => 'popular',
  471. 'number' => 4,
  472. 'per_row' => 4,
  473. 'title' => 'We recommend',
  474. 'singular' => 'true',
  475. 'settings' => 'true'
  476. ), $atts));
  477. if ( ! is_singular() && $singular == 'false' ) return $content;
  478. global $post;
  479. $pst_id = $post->ID;
  480. if ( $settings == true || isset( $this->options ) && is_array($this->options[ 'post_widget']) ) {
  481. $pst_wid = $this->options['post_widget'];
  482. } else {
  483. $pst_wid = array( 'title' => $title, 'number' => $number, 'per_row' => $per_row, 'type' => $type );
  484. }
  485. $num = $pst_wid[ 'number' ];
  486. $get = $pst_wid[ 'type' ];
  487. $rel_opts = array();
  488. $rel_opts['get'] = $get;
  489. $rel_opts['number'] = ( $get != 'related' ) ? $num - 1 : $num;
  490. $rel_opts[ 'exclude' ] = $pst_id;
  491. $rel_posts = $this->wpui_get_posts( $rel_opts );
  492. $output = '';
  493. $per_row = $pst_wid[ 'per_row' ];
  494. if ( $pst_wid['title' ] != '' )
  495. $output .= '<h3 class="wpui-related-posts-title">' . $pst_wid[ 'title' ] . '</h3>';
  496. if ( is_array( $rel_posts ) ) {
  497. $output .= '<ul class="wpui-related-posts wpui-per_' . $per_row . '">';
  498. foreach( $rel_posts as $rel=>$rpost ) {
  499. $classs = '';
  500. $classs .= ( ( ($rel + 1 ) % $per_row ) == 0 ) ? ' row-last' : '';
  501. $classs .= ( ( ($rel ) % $per_row) == 0 ) ? ' row-first' : '';
  502. $output .= "<li class='$classs'>";
  503. if ( $rpost[ 'thumbnail' ] != '' )
  504. $output .= '<div class="wpui-rel-post-thumbnail">';
  505. $output .= '<a href="' . $rpost[ 'url' ] . '" title="' . $rpost[ 'title' ] . '">';
  506. $output .= $rpost[ 'thumbnail' ];
  507. $output .= '</a>';
  508. $output .='</div>';
  509. $output .= '<div class="wpui-rel-post-meta"><span class="wpui-rel-post-title">' . $rpost[ 'title' ] . '</span>';
  510. if ( $per_row == 2 )
  511. $output .= '<span class="wpui-rel-post-author">' . $rpost['author'] .'</span><span class="wpui-rel-post-time">' . $rpost['date'] . '</span>';
  512. $output .= '</div>';
  513. $output .= '</li>';
  514. }
  515. $output .= '</ul>';
  516. }
  517. return $output;
  518. // return apply_filters( 'the_content', $content );
  519. }
  520. } // end class wpuiPosts;
  521. /*$wpui_posts = new wpuiPosts();
  522. $wpui_opts = get_option( 'wpUI_Options' );
  523. function wpui_get_my_post( $id=null, $template=1, $type="post" ) {
  524. if ( ! $id ) return;
  525. global $wpui_posts, $wpui_opts;
  526. $tmpl = $wpui_opts[ 'post_template_' . $template ];
  527. $post_content = $wpui_posts->wpui_get_post( $id, 'more', $type );
  528. $post_content = $wpui_posts->replace_tags( $post_content, $tmpl );
  529. echo do_shortcode( $post_content );
  530. }
  531. function wpui_get_my_posts_spoiler( $args ) {
  532. if ( ! $args || ( $args['cat'] == '' || $args['tag'] == '' ) ) return;
  533. global $wpui_posts, $wpui_opts;
  534. $defaults = array(
  535. 'cat' => '',
  536. 'tag' => '',
  537. 'number' => '5',
  538. 'template' => '1',
  539. 'length' =>
  540. );
  541. $args = wp_parse_args( $args, $defaults );
  542. $get_my_posts = $wpui_posts->wpui_get_posts( $args );
  543. foreach( $get_my_posts as $get=>$posts ) {
  544. }
  545. }
  546. */
  547. ?>