Esempio n. 1
0
        function widget($args, $instance)
        {
            extract($args);
            $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
            $post_category = !empty($instance['post_category']) ? $instance['post_category'] : 0;
            $show_more_icon = !empty($instance['show_more_icon']) ? true : false;
            $featured_image = !empty($instance['featured_image']) ? $instance['featured_image'] : 'magzimum-thumb';
            $excerpt_length_main = !empty($instance['excerpt_length_main']) ? $instance['excerpt_length_main'] : 40;
            $disable_excerpt_main = !empty($instance['disable_excerpt_main']) ? true : false;
            $disable_date_main = !empty($instance['disable_date_main']) ? $instance['disable_date_main'] : false;
            $disable_comment_main = !empty($instance['disable_comment_main']) ? $instance['disable_comment_main'] : false;
            $disable_category_main = !empty($instance['disable_category_main']) ? true : false;
            $post_number = !empty($instance['post_number']) ? $instance['post_number'] : 3;
            $thumbnail_size = !empty($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 80;
            $excerpt_length_side = !empty($instance['excerpt_length_side']) ? $instance['excerpt_length_side'] : 10;
            $disable_excerpt_side = !empty($instance['disable_excerpt_side']) ? true : false;
            $disable_date_side = !empty($instance['disable_date_side']) ? $instance['disable_date_side'] : false;
            $disable_comment_side = !empty($instance['disable_comment_side']) ? $instance['disable_comment_side'] : false;
            $disable_category_side = !empty($instance['disable_category_side']) ? true : false;
            $custom_class = apply_filters('widget_custom_class', empty($instance['custom_class']) ? '' : $instance['custom_class'], $instance, $this->id_base);
            // Add Custom class
            if ($custom_class) {
                $before_widget = str_replace('class="', 'class="' . $custom_class . ' ', $before_widget);
            }
            echo $before_widget;
            // Title
            if ($title) {
                echo $before_title . $title;
                if (absint($post_category) > 0 && true == $show_more_icon) {
                    $cat_obj = get_the_category_by_ID($post_category);
                    $cat_obj = get_term_by('id', $post_category, 'category');
                    if ($cat_obj) {
                        $more_link = get_term_link($cat_obj);
                        $more_title = __('View more from', 'magzimum') . ' ' . $cat_obj->name;
                        echo '<span class="category-more">';
                        echo '<a href="' . esc_url($more_link) . '" title="' . esc_attr($more_title) . '"><i class="fa fa-folder-open"></i></a>';
                        echo '</span>';
                    }
                }
                echo $after_title;
            }
            global $post;
            //
            ?>

          <div class="categorized-news-widget">

            <div class="row">
              <div class="col-sm-6">

                <?php 
            $qargs = array('posts_per_page' => 1, 'no_found_rows' => true);
            if (absint($post_category) > 0) {
                $qargs['category'] = $post_category;
            }
            $all_posts = get_posts($qargs);
            // nspre($all_posts);
            ?>
                <?php 
            if (!empty($all_posts)) {
                ?>
                  <?php 
                $post = $all_posts[0];
                setup_postdata($post);
                ?>
                  <?php 
                if (has_post_thumbnail()) {
                    ?>
                    <a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title_attribute();
                    ?>
">
                      <?php 
                    $thumb_args = array('class' => 'aligncenter');
                    the_post_thumbnail($featured_image, $thumb_args);
                    ?>
                    </a>
                  <?php 
                }
                ?>
                  <h3 class="categorized-news-title">
                    <a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
">
                      <?php 
                the_title();
                ?>
                    </a>
                  </h3><!-- .categorized-news-title -->
                  <?php 
                if (false == $disable_excerpt_main) {
                    ?>
                    <p><?php 
                    echo magzimum_get_the_excerpt($excerpt_length_main, $post);
                    ?>
</p>
                  <?php 
                }
                ?>

                  <ul class="news-meta">

                    <?php 
                if (false == $disable_date_main) {
                    ?>
                      <li class="date-meta"><?php 
                    the_time(get_option('date_format'));
                    ?>
</li><!-- .categorized-news-date -->
                    <?php 
                }
                ?>

                      <?php 
                if (false == $disable_comment_main) {
                    ?>
                        <?php 
                    echo '<li class="comment-meta">';
                    comments_popup_link('<span class="leave-reply">' . __('No Comment', 'magzimum') . '</span>', __('1 Comment', 'magzimum'), __('% Comments', 'magzimum'));
                    echo '</li>';
                    ?>
                      <?php 
                }
                ?>

                      <?php 
                if (false == $disable_category_main) {
                    ?>
                        <li class="category-meta"><?php 
                    magzimum_the_category_uno($post->ID);
                    ?>
</li><!-- .category-meta -->
                      <?php 
                }
                ?>

                  </ul><!-- .categorized-news-meta -->

                  <?php 
                // Reset
                wp_reset_postdata();
                ?>
                <?php 
            }
            ?>


              </div><!-- .col-sm-6 -->
              <div class="col-sm-6">

                <?php 
            $qargs = array('posts_per_page' => $post_number, 'no_found_rows' => true, 'offset' => 1);
            if (absint($post_category) > 0) {
                $qargs['category'] = $post_category;
            }
            $all_posts = get_posts($qargs);
            ?>

                <?php 
            if (!empty($all_posts)) {
                ?>


                  <?php 
                global $post;
                ?>

                  <div class="categorized-news-right">


                    <?php 
                foreach ($all_posts as $key => $post) {
                    ?>
                      <?php 
                    setup_postdata($post);
                    ?>

                      <div class="categorized-news-item">

                      <?php 
                    if (has_post_thumbnail()) {
                        ?>
                        <div class="categorized-news-thumb">
                          <a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        the_title_attribute();
                        ?>
">
                            <?php 
                        $img_attributes = array();
                        if (absint($thumbnail_size) > 0) {
                            $img_attributes['style'] = 'max-width: ' . esc_attr(absint($thumbnail_size)) . 'px;';
                        }
                        the_post_thumbnail('thumbnail', $img_attributes);
                        ?>
                          </a>
                        </div><!-- .categorized-news-thumb -->
                      <?php 
                    }
                    ?>
                      <div class="categorized-news-text-wrap">
                        <h3 class="categorized-news-title">
                          <a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title_attribute();
                    ?>
"><?php 
                    the_title();
                    ?>
</a>
                        </h3><!-- .categorized-news-title -->

                        <?php 
                    if (false == $disable_excerpt_side) {
                        ?>
                          <p><?php 
                        echo magzimum_get_the_excerpt($excerpt_length_side, $post);
                        ?>
</p>
                        <?php 
                    }
                    ?>

                        <?php 
                    if (false == $disable_date_side || false == $disable_comment_side && comments_open($post->ID)) {
                        ?>
                          <ul class="news-meta">

                            <?php 
                        if (false == $disable_date_side) {
                            ?>
                              <li class="date-meta"><?php 
                            the_time(get_option('date_format'));
                            ?>
</li>
                            <?php 
                        }
                        ?>

                            <?php 
                        if (false == $disable_comment_side) {
                            ?>
                              <?php 
                            echo '<li class="comment-meta">';
                            comments_popup_link('<span class="leave-reply">' . __('No Comment', 'magzimum') . '</span>', __('1 Comment', 'magzimum'), __('% Comments', 'magzimum'));
                            echo '</li>';
                            ?>
                            <?php 
                        }
                        ?>

                            <?php 
                        if (false == $disable_category_side) {
                            ?>
                              <li class="category-meta"><?php 
                            magzimum_the_category_uno($post->ID);
                            ?>
</li><!-- .category-meta -->
                            <?php 
                        }
                        ?>


                          </ul><!-- .categorized-news-meta -->
                        <?php 
                    }
                    ?>

                      </div><!-- .categorized-news-text-wrap -->

                      </div><!-- .categorized-news-item .col-sm-3 -->

                    <?php 
                }
                ?>

                  </div><!-- .categorized-news-right -->

                  <?php 
                wp_reset_postdata();
                // Reset
                ?>

                <?php 
            }
            // end if all_posts
            ?>


              </div><!-- .col-sm-6 -->
            </div><!-- .row -->

          </div><!-- .categorized-news-widget -->

        <?php 
            //
            echo $after_widget;
        }
Esempio n. 2
0
 function magzimum_get_slider_details($input)
 {
     $featured_slider_type = magzimum_get_option('featured_slider_type');
     switch ($featured_slider_type) {
         case 'featured-category':
             $featured_slider_number = magzimum_get_option('featured_slider_number');
             $featured_slider_category = magzimum_get_option('featured_slider_category');
             $qargs = array('posts_per_page' => esc_attr($featured_slider_number), 'no_found_rows' => true, 'meta_query' => array(array('key' => '_thumbnail_id')));
             if (absint($featured_slider_category) > 0) {
                 $qargs['category'] = esc_attr($featured_slider_category);
             }
             // Fetch posts
             $all_posts = get_posts($qargs);
             $slides = array();
             if (!empty($all_posts)) {
                 $cnt = 0;
                 foreach ($all_posts as $key => $post) {
                     if (has_post_thumbnail($post->ID)) {
                         $image_array = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'magzimum-slider');
                         $slides[$cnt]['images'] = $image_array;
                         $slides[$cnt]['title'] = esc_html($post->post_title);
                         $slides[$cnt]['url'] = esc_url(get_permalink($post->ID));
                         $slides[$cnt]['excerpt'] = magzimum_get_the_excerpt(20, $post);
                         $cnt++;
                     }
                 }
             }
             if (!empty($slides)) {
                 $input = $slides;
             }
             break;
         default:
             break;
     }
     return $input;
 }