Advertisement
Guest User

magazine.php

a guest
Aug 20th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.64 KB | None | 0 0
  1. <?php
  2. /**
  3. * Magazine
  4. *
  5. * Display entries in a magazine like fashion
  6. * Element is in Beta and by default disabled. Todo: test with layerslider elements. currently throws error bc layerslider is only included if layerslider element is detected which is not the case with the post/page element
  7. */
  8. if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly
  9.  
  10.  
  11. if ( !class_exists( 'avia_sc_magazine' ))
  12. {
  13. class avia_sc_magazine extends aviaShortcodeTemplate
  14. {
  15.  
  16. /**
  17. * Create the config array for the shortcode button
  18. */
  19. function shortcode_insert_button()
  20. {
  21. $this->config['self_closing'] = 'yes';
  22.  
  23. $this->config['name'] = __('Magazine', 'avia_framework' );
  24. $this->config['tab'] = __('Content Elements', 'avia_framework' );
  25. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-magazine.png";
  26. $this->config['order'] = 39;
  27. $this->config['target'] = 'avia-target-insert';
  28. $this->config['shortcode'] = 'av_magazine';
  29. $this->config['tooltip'] = __('Display entries in a magazine like fashion', 'avia_framework' );
  30. $this->config['drag-level'] = 3;
  31. $this->config['preview'] = 1;
  32. $this->config['disabling_allowed'] = true;
  33. }
  34.  
  35. function extra_assets()
  36. {
  37. //load css
  38. wp_enqueue_style( 'avia-module-magazine' , AviaBuilder::$path['pluginUrlRoot'].'avia-shortcodes/magazine/magazine.css' , array('avia-layout'), false );
  39.  
  40. //load js
  41. wp_enqueue_script( 'avia-module-magazine' , AviaBuilder::$path['pluginUrlRoot'].'avia-shortcodes/magazine/magazine.js' , array('avia-shortcodes'), false, TRUE );
  42.  
  43.  
  44. }
  45.  
  46. /**
  47. * Popup Elements
  48. *
  49. * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  50. * opens a modal window that allows to edit the element properties
  51. *
  52. * @return void
  53. */
  54. function popup_elements()
  55. {
  56. $this->elements = array(
  57. array(
  58. "type" => "tab_container", 'nodescription' => true
  59. ),
  60.  
  61. array(
  62. "type" => "tab",
  63. "name" => __("Content" , 'avia_framework'),
  64. 'nodescription' => true
  65. ),
  66.  
  67. array(
  68. "name" => __("Which Entries?", 'avia_framework' ),
  69. "desc" => __("Select which entries should be displayed by selecting a taxonomy", 'avia_framework' ),
  70. "id" => "link",
  71. "fetchTMPL" => true,
  72. "type" => "linkpicker",
  73. "subtype" => array( __('Display Entries from:', 'avia_framework' )=>'taxonomy'),
  74. "multiple" => 6,
  75. "std" => "category"
  76. ),
  77.  
  78. array(
  79. "name" => __("Number of entries", 'avia_framework' ),
  80. "desc" => __("How many entries should be displayed?", 'avia_framework' ),
  81. "id" => "items",
  82. "type" => "select",
  83. "std" => "5",
  84. "subtype" => AviaHtmlHelper::number_array(1,40,1, array('All'=>'-1'))),
  85.  
  86. array(
  87. "name" => __("Offset Number", 'avia_framework' ),
  88. "desc" => __("The offset determines where the query begins pulling posts. Useful if you want to remove a certain number of posts because you already query them with another blog or magazine element.", 'avia_framework' ),
  89. "id" => "offset",
  90. "type" => "select",
  91. "std" => "0",
  92. "subtype" => AviaHtmlHelper::number_array(1,100,1, array(__('Deactivate offset','avia_framework')=>'0', __('Do not allow duplicate posts on the entire page (set offset automatically)', 'avia_framework' ) =>'no_duplicates'))),
  93.  
  94.  
  95.  
  96. array(
  97. "name" => __("Display Tabs for each category selected above?", 'avia_framework' ),
  98. "desc" => __("If checked and you have selected more than one taxonomy above, a tab will be displayed for each of them", 'avia_framework' ) ."</small>" ,
  99. "id" => "tabs",
  100. "std" => "true",
  101. "type" => "checkbox"),
  102.  
  103.  
  104. array(
  105. "name" => __("Display Thumbnails?", 'avia_framework' ),
  106. "desc" => __("If checked all entries that got a feature image will show it", 'avia_framework' ) ."</small>" ,
  107. "id" => "thumbnails",
  108. "std" => "true",
  109. "type" => "checkbox"),
  110.  
  111. array(
  112. "name" => __("Display Element Heading?", 'avia_framework' ),
  113. "desc" => __("If checked you can enter a title with link for this element", 'avia_framework' ) ."</small>" ,
  114. "id" => "heading_active",
  115. "std" => "",
  116. "type" => "checkbox"),
  117.  
  118. array(
  119. "name" => __("Heading Text", 'avia_framework' ),
  120. "id" => "heading",
  121. "required"=> array('heading_active','not',''),
  122. "std" => "",
  123. "type" => "input"),
  124.  
  125. array(
  126. "name" => __("Heading Link?", 'avia_framework' ),
  127. "desc" => __("Where should the heading link to?", 'avia_framework' ),
  128. "id" => "heading_link",
  129. "type" => "linkpicker",
  130. "required"=> array('heading_active','not',''),
  131. "fetchTMPL" => true,
  132. "subtype" => array(
  133. __('Set Manually', 'avia_framework' ) =>'manually',
  134. __('Single Entry', 'avia_framework' ) =>'single',
  135. __('Taxonomy Overview Page', 'avia_framework' ) =>'taxonomy',
  136. ),
  137. "std" => ""),
  138.  
  139. array(
  140. "name" => __("Heading Area Color", 'avia_framework' ),
  141. "desc" => __("Choose a color for your heading area here", 'avia_framework' ),
  142. "id" => "heading_color",
  143. "type" => "select",
  144. "std" => "theme-color",
  145. "required"=> array('heading_active','not',''),
  146. "subtype" => array(
  147. __('Theme Color', 'avia_framework' )=>'theme-color',
  148. __('Blue', 'avia_framework' )=>'blue',
  149. __('Red', 'avia_framework' )=>'red',
  150. __('Green', 'avia_framework' )=>'green',
  151. __('Orange', 'avia_framework' )=>'orange',
  152. __('Aqua', 'avia_framework' )=>'aqua',
  153. __('Teal', 'avia_framework' )=>'teal',
  154. __('Purple', 'avia_framework' )=>'purple',
  155. __('Pink', 'avia_framework' )=>'pink',
  156. __('Silver', 'avia_framework' )=>'silver',
  157. __('Grey', 'avia_framework' )=>'grey',
  158. __('Black', 'avia_framework' )=>'black',
  159. __('Custom Color', 'avia_framework' )=>'custom',
  160. )),
  161.  
  162. array(
  163. "name" => __("Custom Font Color", 'avia_framework' ),
  164. "desc" => __("Select a custom font color for your Heading area here", 'avia_framework' ),
  165. "id" => "heading_custom_color",
  166. "type" => "colorpicker",
  167. "std" => "#ffffff",
  168. "required" => array('heading_color','equals','custom')
  169. ),
  170.  
  171.  
  172. array(
  173. "name" => __("Should the first entry be displayed bigger?", 'avia_framework' ),
  174. "desc" => __("If checked the first entry will stand out with big image", 'avia_framework' ) ."</small>" ,
  175. "id" => "first_big",
  176. "std" => "",
  177. "type" => "checkbox"),
  178.  
  179. array(
  180. "name" => __("First entry position", 'avia_framework' ),
  181. "desc" => __("Where do you want to display the first entry?", 'avia_framework' ),
  182. "id" => "first_big_pos",
  183. "type" => "select",
  184. "std" => "top",
  185. "required"=> array('first_big','not',''),
  186. "subtype" => array( __('Display the first entry at the top of the others','avia_framework' ) =>'top',
  187. __('Display the first entry beside the others','avia_framework' ) =>'left')),
  188.  
  189.  
  190.  
  191. array(
  192. "type" => "close_div",
  193. 'nodescription' => true
  194. ),
  195.  
  196.  
  197. array(
  198. "type" => "tab",
  199. "name" => __("Screen Options",'avia_framework' ),
  200. 'nodescription' => true
  201. ),
  202.  
  203.  
  204. array(
  205. "name" => __("Element Visibility",'avia_framework' ),
  206. "desc" => __("Set the visibility for this element, based on the device screensize.", 'avia_framework' ),
  207. "type" => "heading",
  208. "description_class" => "av-builder-note av-neutral",
  209. ),
  210.  
  211. array(
  212. "desc" => __("Hide on large screens (wider than 990px - eg: Desktop)", 'avia_framework'),
  213. "id" => "av-desktop-hide",
  214. "std" => "",
  215. "container_class" => 'av-multi-checkbox',
  216. "type" => "checkbox"),
  217.  
  218. array(
  219.  
  220. "desc" => __("Hide on medium sized screens (between 768px and 989px - eg: Tablet Landscape)", 'avia_framework'),
  221. "id" => "av-medium-hide",
  222. "std" => "",
  223. "container_class" => 'av-multi-checkbox',
  224. "type" => "checkbox"),
  225.  
  226. array(
  227.  
  228. "desc" => __("Hide on small screens (between 480px and 767px - eg: Tablet Portrait)", 'avia_framework'),
  229. "id" => "av-small-hide",
  230. "std" => "",
  231. "container_class" => 'av-multi-checkbox',
  232. "type" => "checkbox"),
  233.  
  234. array(
  235.  
  236. "desc" => __("Hide on very small screens (smaller than 479px - eg: Smartphone Portrait)", 'avia_framework'),
  237. "id" => "av-mini-hide",
  238. "std" => "",
  239. "container_class" => 'av-multi-checkbox',
  240. "type" => "checkbox"),
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247. array(
  248. "type" => "close_div",
  249. 'nodescription' => true
  250. ),
  251.  
  252.  
  253.  
  254.  
  255. array(
  256. "type" => "close_div",
  257. 'nodescription' => true
  258. ),
  259.  
  260.  
  261.  
  262.  
  263. );
  264.  
  265.  
  266. if(current_theme_supports('add_avia_builder_post_type_option'))
  267. {
  268. $element = array(
  269. "name" => __("Select Post Type", 'avia_framework' ),
  270. "desc" => __("Select which post types should be used. Note that your taxonomy will be ignored if you do not select an assign post type.
  271. If you don't select post type all registered post types will be used", 'avia_framework' ),
  272. "id" => "post_type",
  273. "type" => "select",
  274. "multiple" => 6,
  275. "std" => "",
  276. "subtype" => AviaHtmlHelper::get_registered_post_type_array()
  277. );
  278.  
  279. array_splice($this->elements, 2, 0, array($element));
  280. }
  281.  
  282. }
  283.  
  284. /**
  285. * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  286. * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  287. * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  288. *
  289. *
  290. * @param array $params this array holds the default values for $content and $args.
  291. * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  292. */
  293. function editor_element($params)
  294. {
  295. $params['innerHtml'] = "<img src='".$this->config['icon']."' title='".$this->config['name']."' />";
  296. $params['innerHtml'].= "<div class='avia-element-label'>".$this->config['name']."</div>";
  297. $params['content'] = NULL; //remove to allow content elements
  298. return $params;
  299. }
  300.  
  301.  
  302.  
  303. /**
  304. * Frontend Shortcode Handler
  305. *
  306. * @param array $atts array of attributes
  307. * @param string $content text within enclosing form of shortcode element
  308. * @param string $shortcodename the shortcode found, when == callback name
  309. * @return string $output returns the modified html string
  310. */
  311. function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
  312. {
  313.  
  314. $atts['class'] = $meta['el_class'];
  315. $atts['custom_markup'] = $meta['custom_markup'];
  316.  
  317. $mag = new avia_magazine($atts);
  318. $mag -> query_entries();
  319. return $mag->html();
  320.  
  321. }
  322.  
  323. }
  324. }
  325.  
  326.  
  327.  
  328.  
  329.  
  330. if ( !class_exists( 'avia_magazine' ) )
  331. {
  332. class avia_magazine
  333. {
  334. static $magazine = 0;
  335. protected $atts;
  336. protected $entries;
  337.  
  338. function __construct($atts = array())
  339. {
  340. $this->screen_options = AviaHelper::av_mobile_sizes($atts);
  341.  
  342. self::$magazine += 1;
  343. $this->atts = shortcode_atts(array( 'class' => '',
  344. 'custom_markup' => "",
  345. 'items' => '16',
  346. 'tabs' => false,
  347. 'thumbnails' => true,
  348. 'heading_active' => false,
  349. 'heading' => "",
  350. 'heading_link' => "",
  351. 'heading_color' => "",
  352. 'heading_custom_color' => "",
  353. 'first_big' => false,
  354. 'first_big_pos' => 'top',
  355. 'taxonomy' => 'category',
  356. 'link' => '',
  357. 'categories' => array(),
  358. 'post_type' => array(),
  359. 'extra_categories' => array(),
  360. 'offset' => 0,
  361. 'image_size' => array( 'small'=> 'thumbnail', 'big' => 'magazine')
  362.  
  363. ), $atts, 'av_magazine');
  364.  
  365. // fetch the taxonomy and the taxonomy ids
  366. $this->extract_terms();
  367.  
  368. //convert checkbox to true/false
  369. $this->atts['tabs'] = $this->atts['tabs'] === "aviaTBtabs" ? true : false;
  370. $this->atts['thumbnails'] = $this->atts['thumbnails'] === "aviaTBthumbnails" ? true : false;
  371.  
  372.  
  373. //filter the attributes
  374. $this->atts = apply_filters('avf_magazine_settings', $this->atts, self::$magazine);
  375.  
  376. //set small or big
  377. if(empty($this->atts['first_big'])) $this->atts['first_big_pos'] = "";
  378.  
  379. //set heading text
  380. if(empty($this->atts['heading_active'])) $this->atts['heading'] = "";
  381.  
  382. //set if top bar is active
  383. $this->atts['top_bar'] = !empty($this->atts['heading']) || !empty($this->atts['tabs']) ? "av-magazine-top-bar-active" : "";
  384. }
  385.  
  386. function extract_terms()
  387. {
  388. if(isset($this->atts['link']))
  389. {
  390. $this->atts['link'] = explode(',', $this->atts['link'], 2 );
  391. $this->atts['taxonomy'] = $this->atts['link'][0];
  392.  
  393. if(isset($this->atts['link'][1]))
  394. {
  395. $this->atts['categories'] = $this->atts['link'][1];
  396. }
  397. else
  398. {
  399. $this->atts['categories'] = array();
  400. }
  401. }
  402. }
  403.  
  404. function sort_buttons()
  405. {
  406. $sort_terms = get_terms( $this->atts['taxonomy'] , array('hide_empty'=>true) );
  407.  
  408. $current_page_terms = array();
  409. $term_count = array();
  410. $display_terms = is_array($this->atts['categories']) ? $this->atts['categories'] : array_filter(explode(',',$this->atts['categories']));
  411.  
  412. $output = "<div class='av-magazine-sort ' data-magazine-id='".self::$magazine."' >";
  413.  
  414. $first_item_name = apply_filters('avf_magazine_sort_first_label', __('All','avia_framework' ), $this->atts);
  415. $output .= "<div class='av-sort-by-term'>";
  416. $output .= '<a href="#" data-filter="sort_all" class="all_sort_button active_sort"><span class="inner_sort_button"><span>'.$first_item_name.'</span></span></a>';
  417.  
  418. foreach($sort_terms as $term)
  419. {
  420. if (!in_array($term->term_id, $display_terms)) continue;
  421.  
  422. if(!isset($term_count[$term->term_id])) $term_count[$term->term_id] = 0;
  423. $term->slug = str_replace('%', '', $term->slug);
  424.  
  425. $output .= "<span class='text-sep {$term->slug}_sort_sep'>/</span>";
  426. $output .= '<a href="#" data-filter="sort_'.$term->term_id.'" class="'.$term->slug.'_sort_button " ><span class="inner_sort_button">';
  427. $output .= "<span>".esc_html(trim($term->name))."</span>";
  428. $output .= "</span>";
  429. $output .= "</a>";
  430.  
  431. $this->atts['extra_categories'][] = $term->term_id;
  432. }
  433.  
  434. $output .= "</div></div>";
  435.  
  436. if(count($this->atts['extra_categories']) <= 1) return "";
  437.  
  438. return $output;
  439.  
  440.  
  441. }
  442.  
  443. //fetch new entries
  444. public function query_entries($params = array(), $return = false)
  445. {
  446. global $avia_config;
  447.  
  448. if(empty($params)) $params = $this->atts;
  449.  
  450. if(empty($params['custom_query']))
  451. {
  452. $query = array();
  453.  
  454. if(!empty($params['categories']))
  455. {
  456. //get the portfolio categories
  457. $terms = explode(',', $params['categories']);
  458. }
  459.  
  460. $page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : get_query_var( 'page' );
  461. if(!$page ) $page = 1;
  462.  
  463. //if we find no terms for the taxonomy fetch all taxonomy terms
  464. if(empty($terms[0]) || is_null($terms[0]) || $terms[0] === "null")
  465. {
  466. $terms = array();
  467. $allTax = get_terms( $params['taxonomy']);
  468. foreach($allTax as $tax)
  469. {
  470. $terms[] = $tax->term_id;
  471. }
  472. }
  473.  
  474. if($params['offset'] == 'no_duplicates')
  475. {
  476. $params['offset'] = 0;
  477. if(empty($params['ignore_dublicate_rule'])) $no_duplicates = true;
  478. }
  479.  
  480.  
  481.  
  482. if(empty($params['post_type'])) $params['post_type'] = get_post_types();
  483. if(is_string($params['post_type'])) $params['post_type'] = explode(',', $params['post_type']);
  484.  
  485. $query = array( 'orderby' => 'date',
  486. 'order' => 'DESC',
  487. 'paged' => $page,
  488. 'post_type' => $params['post_type'],
  489. 'post__not_in' => (!empty($no_duplicates)) ? $avia_config['posts_on_current_page'] : array(),
  490. 'offset' => $params['offset'],
  491. 'posts_per_page' => $params['items'],
  492. 'tax_query' => array( array( 'taxonomy' => $params['taxonomy'],
  493. 'field' => 'id',
  494. 'terms' => $terms,
  495. 'operator' => 'IN')));
  496.  
  497.  
  498.  
  499.  
  500. }
  501. else
  502. {
  503. $query = $params['custom_query'];
  504. }
  505.  
  506.  
  507. $query = apply_filters('avf_magazine_entries_query', $query, $params);
  508. $entries = get_posts( $query );
  509.  
  510. if(!empty($entries) && empty($params['ignore_dublicate_rule']))
  511. {
  512. foreach($entries as $entry)
  513. {
  514. $avia_config['posts_on_current_page'][] = $entry->ID;
  515. }
  516. }
  517.  
  518. if($return)
  519. {
  520. return $entries;
  521. }
  522. else
  523. {
  524. $this->entries = $entries;
  525. }
  526. }
  527.  
  528. function html()
  529. {
  530. $output = "";
  531. $class = !empty($this->atts['first_big_pos']) ? " av-magazine-hero-".$this->atts['first_big_pos'] : "";
  532. $class .= " ".$this->atts['top_bar'];
  533. if(!empty($this->atts['tabs'])) $class .= " av-magazine-tabs-active";
  534.  
  535.  
  536. extract($this->screen_options); //return $av_font_classes, $av_title_font_classes and $av_display_classes
  537.  
  538.  
  539. $output .= "<div id='av-magazine-".self::$magazine."' class='av-magazine {$av_display_classes} ".$this->atts['class']." {$class}' >";
  540.  
  541. if($this->atts['top_bar'])
  542. {
  543. $link = AviaHelper::get_url($this->atts['heading_link']);
  544. $heading = $this->atts['heading'];
  545. $b_class = "";
  546. $b_style = "";
  547.  
  548. if($this->atts['heading_color'] != "theme-color")
  549. {
  550. if($this->atts['heading_color'] == "custom") $b_style = "style='color: ".$this->atts['heading_custom_color'].";'";
  551. $b_class .= "avia-font-color-".$this->atts['heading_color']." avia-inherit-font-color";
  552. }
  553.  
  554. $output .= "<div class='av-magazine-top-bar {$b_class}' {$b_style}>";
  555.  
  556. if($heading)
  557. {
  558. $output .= "<a href='{$link}' class='av-magazine-top-heading'>{$heading}</a>";
  559. }
  560.  
  561. if(!empty($this->atts['tabs']))
  562. {
  563. $output .= $this->sort_buttons();
  564. }
  565.  
  566. $output .="</div>";
  567. }
  568.  
  569.  
  570. //magazine main loop
  571. $output .= $this->magazine_loop($this->entries);
  572.  
  573.  
  574. //magazine sub loops
  575. $output .= $this->magazine_sub_loop();
  576.  
  577.  
  578. $output .="</div>";
  579. return $output;
  580. }
  581.  
  582.  
  583. function magazine_sub_loop()
  584. {
  585. $output = "";
  586.  
  587. if(!empty($this->atts['extra_categories']) && count($this->atts['extra_categories']) > 1)
  588. {
  589. foreach($this->atts['extra_categories'] as $category)
  590. {
  591. $params = $this->atts;
  592. $params['ignore_dublicate_rule'] = true;
  593. $params['categories'] = $category;
  594. $params['sort_var'] = $category;
  595.  
  596. $entries = $this->query_entries($params, true);
  597. $output .= $this->magazine_loop($entries, $params);
  598.  
  599. }
  600. }
  601.  
  602. return $output;
  603. }
  604.  
  605.  
  606.  
  607.  
  608. function magazine_loop($entries, $params = array())
  609. {
  610. $output = "";
  611. $loop = 0;
  612. $grid = $this->atts['first_big_pos'] == "left" ? "flex_column av_one_half " : "";
  613. $html = !empty($this->atts['first_big_pos']) ? array("before"=>"<div class='av-magazine-hero first {$grid}'>","after"=>'</div>') : array("before"=>'',"after"=>'');
  614. $css = empty($params['sort_var']) ? "sort_all" : "av-hidden-mag sort_".$params['sort_var'];
  615.  
  616. if(!empty($entries))
  617. {
  618. $output .= "<div class='av-magazine-group {$css}'>";
  619.  
  620. foreach($entries as $entry)
  621. {
  622. $loop ++;
  623. $entry->loop = $loop;
  624.  
  625. $style = ($loop === 1 && !empty($this->atts['first_big'])) ? "big" : "small";
  626. if($loop == 2 && !empty($html['before'])) $html = array("before"=>"<div class='av-magazine-sideshow {$grid}'>","after"=>'');
  627. if($loop == 3) $html = array("before"=>'',"after"=>'');
  628.  
  629.  
  630. $output .= $html['before'];
  631. $output .= $this->render_entry($entry, $style);
  632. $output .= $html['after'];
  633. }
  634.  
  635. if($loop !== 1 && !empty($this->atts['first_big_pos'])) $output .= "</div>";
  636.  
  637. $output .= "</div>";
  638. }
  639.  
  640. return $output;
  641. }
  642.  
  643.  
  644.  
  645. function render_entry($entry, $style)
  646. {
  647.  
  648. $output = "";
  649. $image = get_the_post_thumbnail( $entry->ID, $this->atts['image_size'][$style] );
  650. $link = get_post_meta( $entry->ID ,'_portfolio_custom_link', true ) != "" ? get_post_meta( $entry->ID ,'_portfolio_custom_link_url', true ) : get_permalink( $entry->ID );
  651. $titleAttr = "title='".__('Link to:','avia_framework')." ".the_title_attribute(array('echo' => 0, 'post' => $entry->ID))."'";
  652. $title = "<a href='{$link}' {$titleAttr}>". apply_filters( 'avf_magazine_title', get_the_title( $entry->ID ), $entry ) ."</a>";
  653. $titleTag = "h3";
  654. $excerpt = "";
  655. $time = get_the_time(get_option('date_format'), $entry->ID);
  656. $separator = "<span class='av-magazine-text-sep text-sep-date'>/</span>";
  657.  
  658. $author_link = get_author_posts_url($entry->post_author);
  659. $author_name = apply_filters('avf_author_name', get_the_author_meta('display_name', $entry->post_author), $entry->post_author);
  660. $author = '<a href='.$author_link.' title="'.__('by','avia_framework').' '.$author_name.'" rel="author">'.$author_name.'</a>';
  661. $author_output = '<span class="av-magazine-author minor-meta">'.__('by','avia_framework')." ";
  662. $author_output .= '<span class="av-magazine-author-link" '.avia_markup_helper(array('context' => 'author_name','echo'=>false)).'>';
  663. $author_output .= "<span class='av-magazine-author meta-color vcard author'><span class='fn'>";
  664. $author_output .= $author;
  665. $author_output .= '</span></span>';
  666. $author_output .= '</span>';
  667. $author_output .= '</span>';
  668.  
  669. $markupEntry = avia_markup_helper(array('context' => 'entry','echo'=>false, 'id'=>$entry->ID, 'custom_markup'=>$this->atts['custom_markup']));
  670. $markupTitle = avia_markup_helper(array('context' => 'entry_title','echo'=>false, 'id'=>$entry->ID, 'custom_markup'=>$this->atts['custom_markup']));
  671. $markupContent = avia_markup_helper(array('context' => 'entry_content','echo'=>false, 'id'=>$entry->ID, 'custom_markup'=>$this->atts['custom_markup']));
  672. $markupTime = avia_markup_helper(array('context' => 'entry_time','echo'=>false, 'id'=>$entry->ID, 'custom_markup'=>$this->atts['custom_markup']));
  673. $format = get_post_format($entry->ID) ? get_post_format($entry->ID) : 'standard';
  674. $type = get_post_type($entry->ID);
  675. $icontype = $type == 'post' ? $format : $type;
  676. $icon = "<a href='{$link}' {$titleAttr} class='iconfont av-magazine-entry-icon' ".av_icon_string($icontype)."></a>";
  677. $extraClass = "";
  678.  
  679. if($style == 'small')
  680. {
  681. if(empty($this->atts['thumbnails']))
  682. {
  683. $image = "";
  684. $extraClass = "av-magazine-no-thumb";
  685. }
  686. }
  687. else
  688. {
  689. $excerpt = !empty($entry->post_excerpt) ? $entry->post_excerpt : avia_backend_truncate($entry->post_content, apply_filters( 'avf_magazine_excerpt_length' , 60) , apply_filters( 'avf_magazine_excerpt_delimiter' , " "), "…", true, '');
  690. }
  691.  
  692.  
  693.  
  694. $output .= "<article class='hentry av-magazine-entry av-magazine-entry-id-".$entry->ID." av-magazine-format-{$format} av-magazine-type-{$type} av-magazine-entry-".$entry->loop." av-magazine-entry-".$style." {$extraClass}' {$markupEntry}>";
  695.  
  696. if($this->atts['thumbnails'] || ($style == 'big' && $image))
  697. {
  698. $output .="<div class='av-magazine-thumbnail'>";
  699. if($image) $output .="<a href='{$link}' {$titleAttr} class='av-magazine-thumbnail-link '>{$image}</a>";
  700. if(!$image) $output .= $icon;
  701. $output .="</div>";
  702. }
  703.  
  704. $output .= "<div class='av-magazine-content-wrap'>";
  705. $output .= "<header class='entry-content-header'>";
  706. $output .= "<time class='av-magazine-time updated' {$markupTime}>".$time."</time>";
  707. $output .= $separator.$author_output;
  708. $output .= "<{$titleTag} class='av-magazine-title entry-title' {$markupTitle}>{$title}</{$titleTag}>";
  709. $output .= "</header>";
  710. if($excerpt)$output .= "<div class='av-magazine-content entry-content' {$markupContent}>{$excerpt}</div>";
  711. $output .= "</div>";
  712. $output .= "<footer class='entry-footer'></footer>";
  713. $output .= "</article>";
  714.  
  715. return $output;
  716. }
  717. }
  718. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement