Esempio n. 1
0
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $instance = wp_parse_args($instance, $this->widget_defaults());
     extract($instance, EXTR_SKIP);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     if ($random_post) {
         $sortby = 'rand';
     } else {
         $sortby = '';
     }
     if ($sticky_post) {
         $sticky = array();
     } else {
         $sticky = get_option('sticky_posts');
     }
     global $xinwp_display_excerpt, $xinwp_entry_meta;
     $xinwp_display_excerpt = $display_excerpt;
     $xinwp_entry_meta = $entry_meta;
     $query_str = array('order' => 'DESC', 'orderby' => $sortby, 'posts_per_page' => $number, 'post_status' => 'publish', 'post_type' => $posttype, 'ignore_sticky_posts' => 1, 'no_found_rows' => 1);
     if ('post' == $posttype) {
         $query_str['category__in'] = $category;
         $query_str['post__not_in'] = $sticky;
     }
     if (!empty($customquery)) {
         $custom_query = wp_parse_args($customquery, NULL);
         foreach ($custom_query as $key => $query) {
             if (strpos($key, '__') && strpos($query, ',')) {
                 $query_str[$key] = explode(',', $query);
             } else {
                 $query_str[$key] = $query;
             }
         }
     }
     $recent_posts = new WP_Query($query_str);
     if ($recent_posts->have_posts()) {
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title;
             echo $title;
             // Can set this with a widget option, or omit altogether
             echo $after_title;
             if (!empty($category_link) && $category) {
                 printf('<a href="%1$s" title="%2$s" class="xinwp_recent_post_link btn btn-small btn-transparent">%3$s</a>', get_category_link($category), get_the_category_by_ID($category), $category_link);
             }
         }
         global $xinwp_thumbnail;
         $xinwp_thumbnail = xinwp_thumbnail_size($thumbnail, $thumbnail_x, $thumbnail_y);
         $col = 0;
         while ($recent_posts->have_posts()) {
             $recent_posts->the_post();
             $div_class = '';
             if ($column > 1 && $col == 0) {
                 echo '<div class="row">';
             }
             if ($column == 2) {
                 $div_class = "large-6 columns";
                 $col = $col + 1;
                 if ($col == 2) {
                     $col = 0;
                 }
             } elseif ($column == 3) {
                 $div_class = "large-4 columns";
                 $col = $col + 1;
                 if ($col == 3) {
                     $col = 0;
                 }
             } elseif ($column == 4) {
                 $div_class = "large-3 columns";
                 $col = $col + 1;
                 if ($col == 4) {
                     $col = 0;
                 }
             }
             if ($column > 1) {
                 echo '<div class="' . $div_class . '">';
             }
             get_template_part('content', 'summary');
             if ($column > 1) {
                 echo '</div>';
                 if ($col == 0) {
                     echo '</div>';
                 }
             }
         }
         if ($col > 0) {
             echo '</div>';
         }
         echo $after_widget;
         // Reset the post globals as this query will have stomped on it
         wp_reset_postdata();
     }
 }
Esempio n. 2
0
global $xinwp_thumbnail, $xinwp_display_excerpt, $xinwp_entry_meta;
if (have_posts() && is_page()) {
    the_post();
    $pt_category = get_post_meta($post->ID, '_xinmag_category', true);
    $column = get_post_meta($post->ID, '_xinmag_column', true);
    if ('' == $column) {
        $column = 3;
    }
    $postperpage = get_post_meta($post->ID, '_xinmag_postperpage', true);
    if ($postperpage < $column) {
        $postperpage = 12;
    }
    $pt_thumbnail = get_post_meta($post->ID, '_xinmag_thumbnail', true);
    $pt_size_x = get_post_meta($post->ID, '_xinmag_size_x', true);
    $pt_size_y = get_post_meta($post->ID, '_xinmag_size_y', true);
    $xinwp_thumbnail = xinwp_thumbnail_size($pt_thumbnail, $pt_size_x, $pt_size_y);
    $xinwp_display_excerpt = get_post_meta($post->ID, '_xinmag_intro', true);
    if ('' == $xinwp_display_excerpt) {
        $xinwp_display_excerpt = 1;
    }
    $xinwp_entry_meta = get_post_meta($post->ID, '_xinmag_disp_meta', true);
    $sidebar = get_post_meta($post->ID, '_xinmag_sidebar', true);
    xinmag_template_intro();
} else {
    $pt_category = '';
    $xinwp_display_excerpt = 1;
    $column = 1;
    $postperpage = 0;
    $xinwp_thumbnail = 'thumbnail';
    $xinwp_entry_meta = 1;
    $sidebar = 1;