예제 #1
0
파일: blog.php 프로젝트: Jiersone/mac
 /**
  * Frontend Shortcode Handler
  *
  * @param array $atts array of attributes
  * @param string $content text within enclosing form of shortcode element
  * @param string $shortcodename the shortcode found, when == callback name
  * @return string $output returns the modified html string
  */
 function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
 {
     global $avia_config;
     if (empty($atts['categories'])) {
         $atts['categories'] = "";
     }
     if (isset($atts['link']) && isset($atts['blog_type']) && $atts['blog_type'] == 'taxonomy') {
         $atts['link'] = explode(',', $atts['link'], 2);
         $atts['taxonomy'] = $atts['link'][0];
         if (!empty($atts['link'][1])) {
             $atts['categories'] = $atts['link'][1];
         } else {
             if (!empty($atts['taxonomy'])) {
                 $taxonomy_terms_obj = get_terms($atts['taxonomy']);
                 foreach ($taxonomy_terms_obj as $taxonomy_term) {
                     $atts['categories'] .= $taxonomy_term->term_id . ',';
                 }
             }
         }
     }
     $atts = shortcode_atts(array('blog_style' => '', 'columns' => 3, 'blog_type' => 'posts', 'items' => '16', 'paginate' => 'yes', 'categories' => '', 'preview_mode' => 'auto', 'image_size' => 'portfolio', 'taxonomy' => 'category', 'post_type' => get_post_types(), 'contents' => 'excerpt', 'content_length' => 'content', 'offset' => '0'), $atts);
     if ($atts['blog_style'] == "blog-grid") {
         $atts['class'] = $meta['el_class'];
         $atts['type'] = 'grid';
         //using the post slider with inactive js will result in displaying a nice post grid
         $slider = new avia_post_slider($atts);
         $slider->query_entries();
         return $slider->html();
     }
     $this->query_entries($atts);
     $avia_config['blog_style'] = $atts['blog_style'];
     $avia_config['preview_mode'] = $atts['preview_mode'];
     $avia_config['image_size'] = $atts['image_size'];
     $avia_config['blog_content'] = $atts['content_length'];
     $avia_config['remove_pagination'] = $atts['paginate'] === "yes" ? false : true;
     $more = 0;
     ob_start();
     //start buffering the output instead of echoing it
     get_template_part('includes/loop', 'index');
     $output = ob_get_clean();
     wp_reset_query();
     avia_set_layout_array();
     if ($output) {
         $markup = avia_markup_helper(array('context' => 'blog', 'echo' => false));
         $output = "<div class='template-blog' {$markup}>{$output}</div>";
     }
     return $output;
 }
예제 #2
0
 function avia_layout_class($key, $echo = true)
 {
     global $avia_config;
     if (!isset($avia_config['layout']['current']['main'])) {
         avia_set_layout_array();
     }
     $return = $avia_config['layout']['current'][$key];
     if ($echo == true) {
         echo $return;
     } else {
         return $return;
     }
 }