Advertisement
Guest User

Untitled

a guest
Jul 30th, 2013
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.44 KB | None | 0 0
  1. <?php
  2.  
  3. class OzySearchPage{
  4.  
  5. var $item_count;
  6.  
  7. var $orderby;
  8. var $post_status;
  9. var $order;
  10.  
  11. function ozySearchPageListing() {
  12.  
  13. $output = "";
  14.  
  15. global $myhelper;
  16.  
  17. global $wp_query;
  18.  
  19. global $paged;
  20.  
  21. global $more;
  22.  
  23. global $s;
  24.  
  25. $args = array(
  26. 'tax_query' => '',
  27. 'paged' => $paged,
  28. 'posts_per_page' => ( (int)$this->item_count <= 0 ? get_option('posts_per_page') : ((int)$this->item_count > 0 ? $this->item_count : 6) ),
  29. 's' => $s,
  30. 'orderby' => ( !empty($this->orderby) ? $this->orderby : 'date' ),
  31. 'post_status' => ( !empty($this->post_status) ? $this->post_status : 'publish' ),
  32. 'order' => ( !empty($this->order) ? $this->order : 'DESC' )
  33. );
  34.  
  35. $loop = new WP_Query( $args );
  36.  
  37. $counter = 0;
  38.  
  39. $no_view_more_types = array("quote", "link", "aside");
  40.  
  41. $script = "";
  42.  
  43. $output .= '<div class="blog-listing">' . PHP_EOL;
  44.  
  45. while ( $loop->have_posts() ) : $loop->the_post();
  46.  
  47. $category = get_the_category();
  48.  
  49. $view_more = true;
  50.  
  51. $more = 0;
  52.  
  53. $title_top_padding_style = "top-padding-40"; //when posts have no image or gallery we have to add 20px padding to title make it looking good
  54.  
  55. $output .= '<article id="post-' . get_the_ID() . '" class="classic-blog-listing-item" data-id="' . get_the_ID() . '">';
  56.  
  57. $format = get_post_format();
  58. if ( false === $format )
  59. $format = 'standard';
  60.  
  61. $output .= '<div class="post-badge-' . $format . ' highlight-bg"></div>' . PHP_EOL;
  62.  
  63. $post_date = get_the_date(ot_get_option("ic_blog_date_format"));
  64.  
  65. //Blog content part
  66. $output .= '<div class="blog-details-part">' . PHP_EOL;
  67.  
  68. $more = 0;
  69.  
  70. //Check if we need to add link into title
  71. if( in_array( get_post_format(), $no_view_more_types)) {
  72. $output .= ' <h1 class="blog-post-title '.$title_top_padding_style.'">' . get_the_title() .'</h1>';
  73. }else{
  74. $output .= ' <h1 class="blog-post-title '.$title_top_padding_style.'"><a href="' . get_permalink() . '">' . get_the_title() .'</a></h1>';
  75. }
  76.  
  77. //Posted On Dates & Category
  78. $output .= '<div class="blog-info-bar-details"><span>' . __('POSTED ON', 'ozy_frontend') . '</span>&nbsp;' . $post_date . '</div>' . PHP_EOL;
  79.  
  80. $output .= strip_shortcodes( get_the_content( __('', 'ozy_frontend') ) );
  81.  
  82. //Read More & Like Buttons
  83. $output .= '<div class="blog-info-footer-bar">' . PHP_EOL;
  84.  
  85. //Are you sure we need to show read more button?
  86. if( !in_array( get_post_format(), $no_view_more_types) ) {
  87. $output .= '<a href="' . get_permalink() . '" class="wpb_button_a"><span class="wpb_button wpb_ozy_auto wpb_regularsize">' . __('READ MORE &rarr;', 'ozy_frontend') . '</span></a>' . PHP_EOL;
  88. }
  89.  
  90. $output .= '</div>' . PHP_EOL;
  91.  
  92. $output .= '</div>' . PHP_EOL;
  93.  
  94. $output .= '</article>' . PHP_EOL;
  95.  
  96. $counter++;
  97.  
  98. endwhile;
  99.  
  100. $output .= '</div>' . PHP_EOL;
  101.  
  102. //call pagination
  103. $wp_query = null; $wp_query = $loop;
  104.  
  105. //render the pagination when available
  106. $output .= get_pagination('<div class="paging-wrapper blog-paging-wrapper">','</div>');
  107.  
  108. return $output;
  109. }
  110.  
  111. }
  112.  
  113. class OzyBlog{
  114.  
  115. var $item_count;
  116. var $category_name;
  117. var $tag;
  118. var $author;
  119.  
  120. var $orderby;
  121. var $post_status;
  122. var $order;
  123.  
  124. var $date_format; //verical timeline
  125. var $time_format; //verical timeline
  126. var $excerpt_length; //verical timeline
  127.  
  128. function blogListingClassic() {
  129.  
  130. $output = "";
  131.  
  132. global $myhelper;
  133.  
  134. global $wp_query;
  135.  
  136. global $paged;
  137.  
  138. global $more;
  139.  
  140. global $cat;
  141.  
  142. global $tag;
  143.  
  144. global $author;
  145.  
  146. $args = array(
  147. 'tax_query' => '',
  148. 'paged' => $paged,
  149. 'posts_per_page' => ( (int)$this->item_count <= 0 ? get_option("posts_per_page") : ((int)$this->item_count > 0 ? $this->item_count : 6) ),
  150. 'tag' => ( !empty($this->tag) ? $this->tag : $tag ),
  151. 'author_name' => ( !empty($this->author) ? $this->author : NULL ),
  152. 'category_name' => ( !empty($this->category_name) ? $this->category_name : NULL ),
  153. 'cat' => $cat,
  154. 'author' => $author,
  155. 'orderby' => ( !empty($this->orderby) ? $this->orderby : 'date' ),
  156. 'post_status' => ( !empty($this->post_status) ? $this->post_status : 'publish' ),
  157. 'order' => ( !empty($this->order) ? $this->order : 'DESC' )
  158. );
  159.  
  160. $loop = new WP_Query( $args );
  161.  
  162. $counter = 0;
  163.  
  164. $no_view_more_types = array("quote", "link", "aside");
  165.  
  166. $script = "";
  167.  
  168. $output .= '<div class="blog-listing">' . PHP_EOL;
  169.  
  170. while ( $loop->have_posts() ) : $loop->the_post();
  171.  
  172. $more = 0;
  173.  
  174. ob_start();
  175. the_content('');
  176. $content = ob_get_clean();
  177.  
  178. $category = get_the_category();
  179.  
  180. $view_more = true;
  181.  
  182. $video = "";
  183.  
  184. $title_top_padding_style = ""; //when posts have no image or gallery we have to add 20px padding to title make it looking good
  185.  
  186. $the_post_classes = get_post_class( 'classic-blog-listing-item' );
  187. $the_post_class_string = '';
  188. foreach( $the_post_classes as $post_class ) {
  189. $the_post_class_string .= $post_class . ' ';
  190. }
  191.  
  192. $output .= '<article id="post-' . get_the_ID() . '" class="' . $the_post_class_string . '" data-id="' . get_the_ID() . '">';
  193.  
  194. $format = get_post_format();
  195. if ( false === $format )
  196. $format = 'standard';
  197.  
  198. if( is_sticky() )
  199. $format = 'sticky';
  200.  
  201. $output .= '<div class="post-badge-' . $format . ' highlight-bg"></div>' . PHP_EOL;
  202.  
  203. switch($format) {
  204.  
  205. case "video":
  206. $video = $myhelper->video_object_from_url($myhelper->catch_that_video(), "100%", "420px", "", "");
  207.  
  208. if($video != '') $output .= $video;
  209.  
  210. $title_top_padding_style = ""; //top-padding-40
  211.  
  212. break;
  213.  
  214. case "gallery":
  215.  
  216. $img_ids = array(); $img_ids_str = "";
  217. $gallery_arr = get_children( array('post_parent' => get_the_ID(), 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
  218. foreach ($gallery_arr as $item)
  219. array_push($img_ids, $item->ID);
  220.  
  221. $img_ids_str = implode(",", $img_ids);
  222.  
  223. $output .= do_shortcode('[vc_gallery type="flexslider_fade" interval="10" onclick="link_image" img_size="post-thumb" images="' . $img_ids_str . '" custom_links_target="_self" el_position="first last"]');
  224. break;
  225.  
  226. default:
  227. //$thumb_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'post-thumb-short'); //thumb image by featured image
  228. $large_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'post-thumb'); //large image by featured image
  229. if(is_array($large_image) && count($large_image) > 0) {
  230. $output .= '<div class="blog-big-photo">' . PHP_EOL;
  231. $output .= ' <a href="' . $large_image[0] . '" title="' . get_the_title() . '" class="prettyphoto" rel="prettyPhoto">' . PHP_EOL;
  232. $output .= ' <img src="' . $large_image[0] . '" width="100%" alt="" class="blog-featured-big-photo" />' . PHP_EOL;
  233. $output .= ' <span><div class="generic-button icon-zoom-in"></div></span>' . PHP_EOL;
  234. $output .= ' </a>' . PHP_EOL;
  235. $output .= '</div>' . PHP_EOL;
  236. }else{
  237. $title_top_padding_style = "top-padding-40";
  238. }
  239. break;
  240. }
  241.  
  242. //Get Like Count, Read Count, Comment Count and Post Date
  243. $like_count = (int)$myhelper->read_meta_data ( get_post_meta(get_the_ID(),'ozy_post_like_count') );
  244. $read_count = (int)$myhelper->read_meta_data ( get_post_meta(get_the_ID(),'ozy_post_read_count') );
  245. $comment_count = get_comments_number();
  246. $post_date = get_the_date(ot_get_option("ic_blog_date_format"));
  247.  
  248. //Specific treat for some post formats
  249. if( $format === 'quote' || $format === 'aside') {
  250. $output .= '<blockquote class="blog-blockquote">' . $content . '</blockquote>' . PHP_EOL;
  251. $title_top_padding_style = "";
  252. }
  253. //else if( $format === 'image') {
  254. //$title_top_padding_style = "";
  255. //}
  256.  
  257. //Blog content part
  258. $output .= '<div class="blog-details-part">' . PHP_EOL;
  259.  
  260. //Check if we need to add link into title
  261. if( in_array( get_post_format(), $no_view_more_types)) {
  262. $more = 1;
  263. $output .= ' <h1 class="blog-post-title ' . $title_top_padding_style . '">' . get_the_title() .'</h1>';
  264. }else{
  265. $output .= ' <h1 class="blog-post-title ' . $title_top_padding_style . '"><a href="' . get_permalink() . '">' . get_the_title() .'</a></h1>';
  266. }
  267.  
  268. //Posted On Dates & Category
  269. $output .= '<div class="blog-info-bar-details"><span>' . __('POSTED ON', 'ozy_frontend') . '</span>&nbsp;' . $post_date;
  270. $output .= '&nbsp;<span>' . __(' - POSTED IN', 'ozy_frontend') . '</span>&nbsp;';
  271. //$output .= get_the_category(', ');
  272. $categories = get_the_category();
  273. $separator = ', '; $output_temp = '';
  274. if($categories) {
  275. foreach($categories as $category) {
  276. $output_temp .= '<a href="'.get_category_link($category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s", "ozy_frontend" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
  277. }
  278. $output .= trim($output_temp, $separator);
  279. }
  280.  
  281. $output .= '</div>' . PHP_EOL;
  282.  
  283. //Specific treat for some post formats
  284. if( $format !== 'quote' && $format !== 'aside') //&& $format !== 'image' && $format !== 'audio'
  285. $output .= $content; //get_the_content( __('', 'ozy_frontend') );
  286.  
  287. //Read More & Like Buttons
  288. $output .= '<div class="blog-info-footer-bar">' . PHP_EOL;
  289.  
  290. //Are you sure we need to show read more button?
  291. if( !in_array( get_post_format(), $no_view_more_types)) {
  292. $output .= '<a href="' . get_permalink() . '" class="wpb_button_a"><span class="generic-button wpb_button wpb_ozy_auto">' . __('READ MORE &rarr;', 'ozy_frontend') . '</span></a>&nbsp;&nbsp;' . PHP_EOL;
  293.  
  294. $output .= '<span class="icon-comments">&nbsp;</span><span>' . $comment_count . '</span>&nbsp;&nbsp;';
  295.  
  296. $output .= '<span class="icon-eye-open">&nbsp;</span><span>' . $read_count . '</span>&nbsp;&nbsp;';
  297. }
  298. $output .= '<span class="icon-heart" id="' . get_the_ID() . '">&nbsp;</span><span>' . $like_count . '</span>';
  299.  
  300. $output .= '</div>' . PHP_EOL;
  301.  
  302. $output .= '</div>' . PHP_EOL;
  303.  
  304. $output .= '</article>' . PHP_EOL;
  305.  
  306. $counter++;
  307.  
  308. endwhile;
  309.  
  310. $output .= '</div>' . PHP_EOL;
  311.  
  312. //call pagination
  313. $wp_query = null; $wp_query = $loop;
  314.  
  315. //render the pagination when available
  316. $output .= get_pagination('<div class="paging-wrapper blog-paging-wrapper">','</div>');
  317.  
  318. //The following lines usually called by visual composer but none of them are used here,
  319. pretty_photo_check();
  320.  
  321. return $output;
  322. }
  323.  
  324.  
  325. function blogListingLatest() {
  326.  
  327. $output = "";
  328.  
  329. global $myhelper;
  330.  
  331. global $wp_query;
  332.  
  333. global $paged;
  334.  
  335. global $more;
  336.  
  337. global $cat;
  338.  
  339. global $tag;
  340.  
  341. global $author;
  342.  
  343. $args = array(
  344. 'tax_query' => array(
  345. array(
  346. 'taxonomy' => 'post_format',
  347. 'field' => 'slug',
  348. 'terms' => array('post-format-quote', 'post-format-aside'),
  349. 'operator' => 'NOT IN'
  350. )
  351. ),
  352. 'post_type' => 'post',
  353. 'paged' => $paged,
  354. 'posts_per_page' => ( (int)$this->item_count <= 0 ? get_option("posts_per_page") : ((int)$this->item_count > 0 ? $this->item_count : 6) ),
  355. 'tag' => ( !empty($this->tag) ? $this->tag : $tag ),
  356. 'author_name' => ( !empty($this->author) ? $this->author : NULL ),
  357. 'category_name' => ( !empty($this->category_name) ? $this->category_name : NULL ),
  358. 'cat' => $cat,
  359. 'author' => $author,
  360. 'orderby' => ( !empty($this->orderby) ? $this->orderby : 'date' ),
  361. 'post_status' => ( !empty($this->post_status) ? $this->post_status : 'publish' ),
  362. 'order' => ( !empty($this->order) ? $this->order : 'DESC' )
  363. );
  364.  
  365. $loop = new WP_Query( $args );
  366.  
  367. $counter = 0;
  368.  
  369. $script = "";
  370.  
  371. $output .= '<ul class="blog-listing-latest">' . PHP_EOL;
  372.  
  373. while ( $loop->have_posts() ) : $loop->the_post();
  374.  
  375. $output .= '<li>';
  376.  
  377. $output .= '<div class="box-date"><span class="d">' . get_the_date('d') .'</span><span class="m">' . get_the_date('M') .'</span></div>' . PHP_EOL;
  378.  
  379. $output .= '<div class="box-wrapper">' . PHP_EOL;
  380.  
  381. $output .= '<h4>' . get_the_title() . '</h4>' . PHP_EOL; //<i class="icon-bell-alt"></i>&nbsp;
  382.  
  383. $output .= '<div class="info-bar">(' . strip_tags(get_the_category_list(', ')) . ')&nbsp;';
  384.  
  385. //get_comments_number returns only a numeric value
  386. $num_comments = get_comments_number();
  387. if ( comments_open() ) {
  388. if ( $num_comments == 0 ) {
  389. $comments = __('No Comments', 'ozy_frontend');
  390. } elseif ( $num_comments > 1 ) {
  391. $comments = $num_comments . __(' Comments', 'ozy_frontend');
  392. } else {
  393. $comments = __('1 Comment', 'ozy_frontend');
  394. }
  395. $output .= $comments;
  396. }
  397.  
  398. $output .= '</div>' . PHP_EOL;
  399.  
  400. $output .= $this->the_excerpt_max_charlength(130) . '&nbsp;&nbsp;<a href="' . get_permalink() . '">' . __('Read More &rarr;', 'ozy_frontend') . '</a>' . PHP_EOL;;
  401.  
  402. $output .= '</div>' . PHP_EOL;
  403.  
  404. $output .= '</li>' . PHP_EOL;
  405.  
  406. endwhile;
  407.  
  408. $output .= '</ul>' . PHP_EOL;
  409.  
  410. return $output;
  411. }
  412.  
  413.  
  414. function verticalTimeLine() {
  415.  
  416. $output = "";
  417.  
  418. global $myhelper;
  419.  
  420. global $wp_query;
  421.  
  422. global $paged;
  423.  
  424. global $more;
  425.  
  426. global $cat;
  427.  
  428. global $tag;
  429.  
  430. global $author;
  431.  
  432. $args = array(
  433. /*'tax_query' => array(
  434. array(
  435. 'taxonomy' => 'post_format',
  436. 'field' => 'slug',
  437. 'terms' => array('post-format-quote', 'post-format-aside'),
  438. 'operator' => 'NOT IN'
  439. )
  440. ),*/
  441. 'post_type' => 'post',
  442. 'paged' => $paged,
  443. 'posts_per_page' => ( (int)$this->item_count <= 0 ? get_option("posts_per_page") : ((int)$this->item_count > 0 ? $this->item_count : 6) ),
  444. 'tag' => ( !empty($this->tag) ? $this->tag : $tag ),
  445. 'author_name' => ( !empty($this->author) ? $this->author : NULL ),
  446. 'category_name' => ( !empty($this->category_name) ? $this->category_name : NULL ),
  447. 'cat' => $cat,
  448. 'author' => $author,
  449. 'orderby' => ( !empty($this->orderby) ? $this->orderby : 'date' ),
  450. 'post_status' => ( !empty($this->post_status) ? $this->post_status : 'publish' ),
  451. 'order' => ( !empty($this->order) ? $this->order : 'DESC' )
  452. );
  453.  
  454. $loop = new WP_Query( $args );
  455.  
  456. $counter = 0;
  457.  
  458. $script = "";
  459.  
  460. $output .= '<ul class="cbp_tmtimeline">' . PHP_EOL;
  461.  
  462. while ( $loop->have_posts() ) : $loop->the_post();
  463.  
  464. $linkable = true;
  465.  
  466. $format = get_post_format();
  467. if ( false === $format )
  468. $format = 'standard';
  469.  
  470. if( $format == "quote" || $format == "aside" ) $linkable = false;
  471.  
  472. $output .= '<li>';
  473.  
  474. $output .= '<time class="cbp_tmtime" datetime="' . get_the_date('r') . '"><span>' . get_the_date($this->date_format) . '</span><span>' . get_the_date($this->time_format) . '</span></time><div class="cbp_tmicon post-badge-' . $format . '"></div>';
  475.  
  476. $output .= '<div class="cbp_tmlabel">';
  477. $output .= '<h2>' . ($linkable ? '<a href="' . get_permalink() . '">' . get_the_title() . '</a>' : get_the_title()) . '</h2>';
  478. $output .= $this->the_excerpt_max_charlength($this->excerpt_length);//'<p>um aplicativo criado para debater com os amigos os recursos utilizados.</p>';
  479. //$output .= '&nbsp;&nbsp;<a href="' . get_permalink() . '">' . __('Read More &rarr;', 'ozy_frontend') . '</a>' . PHP_EOL;//'<a href="/labs/dev/arch/2013/05/04/ISPM-ToDo/" class="read-more">leia mais</a>';
  480. $output .= '</div>';
  481.  
  482. $output .= '</li>' . PHP_EOL;
  483.  
  484. endwhile;
  485.  
  486. $output .= '</ul>' . PHP_EOL;
  487.  
  488. return $output;
  489. }
  490.  
  491. function the_excerpt_max_charlength($charlength) {
  492. $excerpt = get_the_excerpt();
  493. $charlength++;
  494. $r = "";
  495. if ( mb_strlen( $excerpt ) > $charlength ) {
  496. $subex = mb_substr( $excerpt, 0, $charlength - 5 );
  497. $exwords = explode( ' ', $subex );
  498. $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
  499. if ( $excut < 0 ) {
  500. $r.= mb_substr( $subex, 0, $excut );
  501. } else {
  502. $r.= $subex;
  503. }
  504. $r.= '[...]';
  505. } else {
  506. $r.= $excerpt;
  507. }
  508.  
  509. return $r;
  510. }
  511. }
  512.  
  513.  
  514. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement