Exemplo n.º 1
0
 if (!empty($_GET['post_type']) && $_GET['post_type'] == 'cause') {
     global $wp_query;
     if (!empty($theme_option['archive-cause-num-excerpt'])) {
         global $gdlr_excerpt_length;
         $gdlr_excerpt_length = $theme_option['archive-cause-num-excerpt'];
         add_filter('excerpt_length', 'gdlr_set_excerpt_length');
     }
     if ($theme_option['archive-cause-style'] == 'medium') {
         echo gdlr_get_cause_medium($wp_query, $theme_option['archive-cause-thumbnail-size'], $theme_option['archive-cause-num-excerpt']);
     } else {
         if ($theme_option['archive-cause-style'] == 'full') {
             echo gdlr_get_cause_full($wp_query, $theme_option['archive-cause-thumbnail-size'], $theme_option['archive-cause-num-excerpt']);
         } else {
             $gdlr_excerpt_read_more = false;
             $theme_option['archive-cause-style'] = str_replace('1/', '', $theme_option['archive-cause-style']);
             echo gdlr_get_cause_grid($wp_query, $theme_option['archive-cause-style'], $theme_option['archive-cause-thumbnail-size'], 'fitRows', $theme_option['archive-cause-num-excerpt']);
             $gdlr_excerpt_read_more = true;
         }
     }
     remove_filter('excerpt_length', 'gdlr_set_excerpt_length');
 } else {
     // set the excerpt length
     if (!empty($theme_option['archive-num-excerpt'])) {
         global $gdlr_excerpt_length;
         $gdlr_excerpt_length = $theme_option['archive-num-excerpt'];
         add_filter('excerpt_length', 'gdlr_set_excerpt_length');
     }
     global $wp_query, $gdlr_post_settings;
     $gdlr_lightbox_id++;
     $gdlr_post_settings['excerpt'] = intval($theme_option['archive-num-excerpt']);
     $gdlr_post_settings['thumbnail-size'] = $theme_option['archive-thumbnail-size'];
 function gdlr_print_cause_item($settings = array())
 {
     $item_id = empty($settings['page-item-id']) ? '' : ' id="' . $settings['page-item-id'] . '" ';
     global $gdlr_spaces, $gdlr_excerpt_read_more;
     $margin = !empty($settings['margin-bottom']) && $settings['margin-bottom'] != $gdlr_spaces['bottom-blog-item'] ? 'margin-bottom: ' . $settings['margin-bottom'] . ';' : '';
     $margin_style = !empty($margin) ? ' style="' . $margin . '" ' : '';
     $settings['title-type'] = empty($settings['title-type']) ? 'none' : $settings['title-type'];
     $settings['title'] = empty($settings['title']) ? '' : $settings['title'];
     $settings['caption'] = empty($settings['caption']) ? '' : $settings['caption'];
     $settings['icon'] = empty($settings['icon']) ? '' : $settings['icon'];
     $right_text = '';
     $right_text_class = '';
     $carousel = false;
     $settings['right-text'] = empty($settings['right-text']) ? '' : $settings['right-text'];
     $settings['right-text-link'] = empty($settings['right-text-link']) ? '' : $settings['right-text-link'];
     if (!empty($settings['right-text-link']) && !empty($settings['right-text'])) {
         $right_text_class = 'gdlr-right-text ';
         $right_text .= '<a class="gdlr-right-text-link" href="' . $settings['right-text-link'] . '" >' . $settings['right-text'] . '</a>';
     }
     if ($settings['cause-style'] == 'grid' && $settings['cause-layout'] == 'carousel') {
         $carousel = true;
         $right_text_class .= 'gdlr-nav-container ';
     }
     $ret = gdlr_get_item_title(array('title' => $settings['title'], 'caption' => $settings['caption'], 'icon' => $settings['icon'], 'type' => $settings['title-type'], 'carousel' => $carousel, 'additional_class' => $right_text_class, 'additional_html' => $right_text));
     $ret .= '<div class="cause-item-wrapper" ' . $item_id . $margin_style . ' >';
     // query posts section
     $args = array('post_type' => 'cause', 'suppress_filters' => false);
     $args['posts_per_page'] = empty($settings['num-fetch']) ? '5' : $settings['num-fetch'];
     if ($settings['orderby'] == 'nearly') {
         $args['meta_key'] = 'gdlr-donation-percent';
         $args['meta_compare'] = '>';
         $args['meta_value'] = '100';
         $args['orderby'] = 'meta_value_num';
         $args['order'] = 'desc';
     } else {
         if ($settings['orderby'] == 'finish') {
             $args['meta_key'] = 'gdlr-donation-percent';
             $args['meta_compare'] = '=';
             $args['meta_value'] = '100';
             $args['orderby'] = empty($settings['orderby']) ? 'post_date' : $settings['orderby'];
             $args['order'] = empty($settings['order']) ? 'desc' : $settings['order'];
         } else {
             $args['orderby'] = empty($settings['orderby']) ? 'post_date' : $settings['orderby'];
             $args['order'] = empty($settings['order']) ? 'desc' : $settings['order'];
         }
     }
     $args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1;
     if (!empty($settings['category'])) {
         $args['tax_query'] = array(array('terms' => explode(',', $settings['category']), 'taxonomy' => 'cause_category', 'field' => 'slug'));
     }
     $query = new WP_Query($args);
     // excerpt number
     if (!empty($settings['num-excerpt'])) {
         global $gdlr_excerpt_length;
         $gdlr_excerpt_length = $settings['num-excerpt'];
         add_filter('excerpt_length', 'gdlr_set_excerpt_length');
     }
     $ret .= '<div class="cause-item-holder">';
     if ($settings['cause-style'] == 'grid') {
         $gdlr_excerpt_read_more = false;
         $settings['cause-size'] = str_replace('1/', '', $settings['cause-size']);
         $ret .= gdlr_get_cause_grid($query, $settings['cause-size'], $settings['thumbnail-size'], $settings['cause-layout'], $settings['num-excerpt']);
         $gdlr_excerpt_read_more = true;
     } else {
         if ($settings['cause-style'] == 'medium') {
             $ret .= gdlr_get_cause_medium($query, $settings['thumbnail-size'], $settings['num-excerpt']);
         } else {
             if ($settings['cause-style'] == 'full') {
                 $ret .= gdlr_get_cause_full($query, $settings['thumbnail-size'], $settings['num-excerpt']);
             }
         }
     }
     $ret .= '<div class="clear"></div>';
     $ret .= '</div>';
     // create pagination
     if ($settings['pagination'] == 'enable') {
         $ret .= gdlr_get_pagination($query->max_num_pages, $args['paged']);
     }
     remove_filter('excerpt_length', 'gdlr_set_excerpt_length');
     $ret .= '</div>';
     // cause-item-wrapper
     return $ret;
 }