views/noticias/wp-content/themes/supermag/acmethemes/sidebar-widget/acme-col-posts.php
/**

         * Function to Creating widget front-end. This is where the action happens

         *

         * @access public

         * @since 1.0.0

         *

         * @param array $args widget setting

         * @param array $instance saved values

         * @return void

         *

         */
Function to Creating widget front-end. This is where the action happens



@param array $args widget setting
@param array $instance saved values
@return void
Function to Creating widget front - end . This is where the action happens @param array $args widget setting @param array $instance saved values @return void
public function widget($args, $instance) {
            if( isset( $args['id'] ) ){
                $supermag_sidebar_id = $args['id'];
            }
            else{
                $supermag_sidebar_id = 'supermag-home';
            }
            $instance = wp_parse_args( (array) $instance, $this->defaults );
            $supermag_selected_cat = esc_attr( $instance['supermag_cat'] );
            $supermag_col_posts_title = !empty( $instance['supermag_cat_title'] ) ? esc_attr( $instance['supermag_cat_title'] ) : get_cat_name($supermag_selected_cat);
            $supermag_col_posts_title = apply_filters( 'widget_title', $supermag_col_posts_title, $instance, $this->id_base );
            $supermag_enable_first_featured = esc_attr( $instance['supermag_enable_first_featured'] );
            if( 1 == $supermag_enable_first_featured ){
                $supermag_number = 4;
            }
            else{
                $supermag_number = 6;
            }
            $supermag_other_class = '';
            if( 'supermag-home' != $supermag_sidebar_id ){
                if( 1 != $supermag_enable_first_featured ){
                    $supermag_number = 3;
                }
                if( 'supermag-sidebar')
                $supermag_other_class = 'supermag-except-home';
            }
            else{
                $supermag_other_class = '';
            }
            $supermag_post_col_layout = absint( $instance['supermag_post_col_layout'] );
            $supermag_post_col_first_featured_image_layout = esc_attr( $instance['supermag_post_col_first_featured_image_layout'] );
            $supermag_post_col_normal_image_layout = esc_attr( $instance['supermag_post_col_normal_image_layout'] );
            $sticky = get_option( 'sticky_posts' );
            $supermag_cat_post_args = array(
                'posts_per_page'      => $supermag_number,
                'no_found_rows'       => true,
                'post_status'         => 'publish',
                'ignore_sticky_posts' => true,
                'post__not_in' => $sticky
            );
            if( -1 != $supermag_selected_cat ){
                $supermag_cat_post_args['cat'] = $supermag_selected_cat;
            }
            $supermag_featured_query = new WP_Query($supermag_cat_post_args);
            if ($supermag_featured_query->have_posts()) :
                echo $args['before_widget'];
                if ( !empty( $supermag_col_posts_title ) ){
	                if( -1 != $supermag_selected_cat ){
		                echo "<div class='at-cat-color-wrap-".$supermag_selected_cat."'>";
	                }
                    echo $args['before_title'] . $supermag_col_posts_title . $args['after_title'];
	                if( -1 != $supermag_selected_cat ){
		                echo "</div>";
	                }
                }
                $supermag_post_col_layout_class ='';
                if( 1 == $supermag_post_col_layout ){
                    $supermag_post_col_layout_class = 'sm-col-post-type-2';
                }
                ?>
                <ul class="<?php echo esc_attr( $supermag_post_col_layout_class ); ?> featured-entries-col featured-entries <?php echo esc_attr( $supermag_other_class ); ?> featured-col-posts <?php echo esc_attr( $supermag_sidebar_id ); ?>">
                    <?php
                    $supermag_featured_index = 1;
                    while ( $supermag_featured_query->have_posts() ) :$supermag_featured_query->the_post();
                        if( 1 == $supermag_featured_index && 1 == $supermag_enable_first_featured ){
                            $thumb = $supermag_post_col_first_featured_image_layout;
                            $supermag_list_classes = 'acme-col-3 featured-post-main';
                            $supermag_words = 48;
                        }
                        else{
                            $thumb = $supermag_post_col_normal_image_layout;
                            $supermag_list_classes = 'acme-col-3';
                            $supermag_words = 16;
                            if( 1 == $supermag_post_col_layout ){
                                $supermag_words = 8;
                            }
                        }
                        ?>
                        <li class="<?php echo esc_attr( $supermag_list_classes ); ?>">
                            <figure class="widget-image">
                                <a href="<?php the_permalink(); ?>">
                                    <?php
                                    if( has_post_thumbnail() ):
                                        the_post_thumbnail( $thumb );
                                    else:
                                        ?>
                                        <div class="no-image-widgets">
                                            <?php
                                            the_title( sprintf( '<h2 class="caption-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
                                            if( !get_the_title() ){
                                                the_date( '', sprintf( '<h2 class="caption-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
                                            }
                                            ?>
                                        </div>
                                        <?php
                                    endif;
                                    ?>
                                </a>
                            </figure>
                            <div class="featured-desc">
                                <div class="above-entry-meta">
                                    <?php
                                    $archive_year  = get_the_date('Y');
                                    $archive_month = get_the_date('m');
                                    $archive_day   = get_the_date('d');
                                    ?>
                                    <span>
                                        <a href="<?php echo esc_url(get_day_link( $archive_year, $archive_month, $archive_day ) ); ?>">
                                            <i class="fa fa-calendar"></i>
                                            <?php echo esc_html( get_the_date() ); ?>
                                        </a>
                                    </span>
                                    <span>
                                        <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" title="<?php echo esc_attr( get_the_author() ); ?>">
                                            <i class="fa fa-user"></i>
                                            <?php echo esc_html( get_the_author() ); ?>
                                        </a>
                                    </span>
                                    <span>
                                        <?php comments_popup_link( '<i class="fa fa-comment"></i>0', '<i class="fa fa-comment"></i>1', '<i class="fa fa-comment"></i>%' );?>
                                    </span>
                                </div>
                                <a href="<?php the_permalink()?>">
                                    <h4 class="title">
                                        <?php the_title(); ?>
                                    </h4>
                                </a>
                                <?php
                                $content = supermag_words_count( get_the_excerpt(), $supermag_words );
                                echo '<div class="details">'.esc_html( $content ).'</div>';
                                ?>
                                <div class="below-entry-meta">
                                    <?php supermag_list_category(); ?>
                                </div>
                            </div>
                        </li>
                    <?php
                        if( 1 == $supermag_enable_first_featured ){
                            if( 1 == $supermag_featured_index ){
                                if( 1 == $supermag_post_col_layout ){
                                    echo '<div class="sm-col-post-type-2-beside">';
                                }
                                else{
                                    echo '<div class="clearfix"></div>';
                                }
                            }
                            if( ($supermag_featured_index - 1) % 3 == 0 ){
                                echo '<div class="clearfix visible-lg"></div>';
                            }
                            if( ( $supermag_featured_index - 1 ) % 2 == 0 ){
                                echo '<div class="clearfix visible-sm"></div>';
                            }
                        }
                        else{
                            if( $supermag_featured_index % 3 == 0 ){
                                echo '<div class="clearfix visible-lg"></div>';
                            }
                            if( $supermag_featured_index % 2 == 0 ){
                                echo '<div class="clearfix visible-sm"></div>';
                            }
                        }
                        $supermag_featured_index++;
                    endwhile;
                    if( 1 == $supermag_post_col_layout && 1 == $supermag_enable_first_featured){
                        echo '</div>';
                    }
                    ?>
                </ul>
                <?php echo $args['after_widget'];
                echo "<div class='clearfix'></div>";
                wp_reset_postdata();
            endif;
        }
public function widget ( $ args , $ instance ) { if ( isset ( $ args [ 'id' ] ) ) { $ supermag_sidebar_id = $ args [ 'id' ] ; } else { $ supermag_sidebar_id = 'supermag-home' ; } $ instance = wp_parse_args ( ( array ) $ instance , $ this -> defaults ) ; $ supermag_selected_cat = esc_attr ( $ instance [ 'supermag_cat' ] ) ; $ supermag_col_posts_title = ! empty ( $ instance [ 'supermag_cat_title' ] ) ? esc_attr ( $ instance [ 'supermag_cat_title' ] ) : get_cat_name ( $ supermag_selected_cat ) ; $ supermag_col_posts_title = apply_filters ( 'widget_title' , $ supermag_col_posts_title , $ instance , $ this -> id_base ) ; $ supermag_enable_first_featured = esc_attr ( $ instance [ 'supermag_enable_first_featured' ] ) ; if ( 1 == $ supermag_enable_first_featured ) { $ supermag_number = 4 ; } else { $ supermag_number = 6 ; } $ supermag_other_class = '' ; if ( 'supermag-home' != $ supermag_sidebar_id ) { if ( 1 != $ supermag_enable_first_featured ) { $ supermag_number = 3 ; } if ( 'supermag-sidebar' ) $ supermag_other_class = 'supermag-except-home' ; } else { $ supermag_other_class = '' ; } $ supermag_post_col_layout = absint ( $ instance [ 'supermag_post_col_layout' ] ) ; $ supermag_post_col_first_featured_image_layout = esc_attr ( $ instance [ 'supermag_post_col_first_featured_image_layout' ] ) ; $ supermag_post_col_normal_image_layout = esc_attr ( $ instance [ 'supermag_post_col_normal_image_layout' ] ) ; $ sticky = get_option ( 'sticky_posts' ) ; $ supermag_cat_post_args = array ( 'posts_per_page' => $ supermag_number , 'no_found_rows' => true , 'post_status' => 'publish' , 'ignore_sticky_posts' => true , 'post__not_in' => $ sticky ) ; if ( - 1 != $ supermag_selected_cat ) { $ supermag_cat_post_args [ 'cat' ] = $ supermag_selected_cat ; } $ supermag_featured_query = new WP_Query ( $ supermag_cat_post_args ) ; if ( $ supermag_featured_query -> have_posts ( ) ) : echo $ args [ 'before_widget' ] ; if ( ! empty ( $ supermag_col_posts_title ) ) { if ( - 1 != $ supermag_selected_cat ) { echo " <div class='at-cat-color-wrap- " . $ supermag_selected_cat . " '> " ; } echo $ args [ 'before_title' ] . $ supermag_col_posts_title . $ args [ 'after_title' ] ; if ( - 1 != $ supermag_selected_cat ) { echo " </div> " ; } } $ supermag_post_col_layout_class = '' ; if ( 1 == $ supermag_post_col_layout ) { $ supermag_post_col_layout_class = 'sm-col-post-type-2' ; } ?> <ul class=" <?php echo esc_attr ( $ supermag_post_col_layout_class ) ; ?> featured-entries-col featured-entries  <?php echo esc_attr ( $ supermag_other_class ) ; ?> featured-col-posts  <?php echo esc_attr ( $ supermag_sidebar_id ) ; ?> ">

                     <?php $ supermag_featured_index = 1 ; while ( $ supermag_featured_query -> have_posts ( ) ) : $ supermag_featured_query -> the_post ( ) ; if ( 1 == $ supermag_featured_index && 1 == $ supermag_enable_first_featured ) { $ thumb = $ supermag_post_col_first_featured_image_layout ; $ supermag_list_classes = 'acme-col-3 featured-post-main' ; $ supermag_words = 48 ; } else { $ thumb = $ supermag_post_col_normal_image_layout ; $ supermag_list_classes = 'acme-col-3' ; $ supermag_words = 16 ; if ( 1 == $ supermag_post_col_layout ) { $ supermag_words = 8 ; } } ?> <li class=" <?php echo esc_attr ( $ supermag_list_classes ) ; ?> ">

                            <figure class="widget-image">

                                <a href=" <?php the_permalink ( ) ; ?> ">

                                     <?php if ( has_post_thumbnail ( ) ) : the_post_thumbnail ( $ thumb ) ; else : ?> <div class="no-image-widgets">

                                             <?php the_title ( sprintf ( '<h2 class="caption-title"><a href="%s" rel="bookmark">' , esc_url ( get_permalink ( ) ) ) , '</a></h2>' ) ; if ( ! get_the_title ( ) ) { the_date ( '' , sprintf ( '<h2 class="caption-title"><a href="%s" rel="bookmark">' , esc_url ( get_permalink ( ) ) ) , '</a></h2>' ) ; } ?> </div>

                                         <?php endif ; ?> </a>

                            </figure>

                            <div class="featured-desc">

                                <div class="above-entry-meta">

                                     <?php $ archive_year = get_the_date ( 'Y' ) ; $ archive_month = get_the_date ( 'm' ) ; $ archive_day = get_the_date ( 'd' ) ; ?> <span>

                                        <a href=" <?php echo esc_url ( get_day_link ( $ archive_year , $ archive_month , $ archive_day ) ) ; ?> ">

                                            <i class="fa fa-calendar"></i>

                                             <?php echo esc_html ( get_the_date ( ) ) ; ?> </a>

                                    </span>

                                    <span>

                                        <a href=" <?php echo esc_url ( get_author_posts_url ( get_the_author_meta ( 'ID' ) ) ) ; ?> " title=" <?php echo esc_attr ( get_the_author ( ) ) ; ?> ">

                                            <i class="fa fa-user"></i>

                                             <?php echo esc_html ( get_the_author ( ) ) ; ?> </a>

                                    </span>

                                    <span>

                                         <?php comments_popup_link ( '<i class="fa fa-comment"></i>0' , '<i class="fa fa-comment"></i>1' , '<i class="fa fa-comment"></i>%' ) ; ?> </span>

                                </div>

                                <a href=" <?php the_permalink ( ) ?> ">

                                    <h4 class="title">

                                         <?php the_title ( ) ; ?> </h4>

                                </a>

                                 <?php $ content = supermag_words_count ( get_the_excerpt ( ) , $ supermag_words ) ; echo '<div class="details">' . esc_html ( $ content ) . '</div>' ; ?> <div class="below-entry-meta">

                                     <?php supermag_list_category ( ) ; ?> </div>

                            </div>

                        </li>

                     <?php if ( 1 == $ supermag_enable_first_featured ) { if ( 1 == $ supermag_featured_index ) { if ( 1 == $ supermag_post_col_layout ) { echo '<div class="sm-col-post-type-2-beside">' ; } else { echo '<div class="clearfix"></div>' ; } } if ( ( $ supermag_featured_index - 1 ) % 3 == 0 ) { echo '<div class="clearfix visible-lg"></div>' ; } if ( ( $ supermag_featured_index - 1 ) % 2 == 0 ) { echo '<div class="clearfix visible-sm"></div>' ; } } else { if ( $ supermag_featured_index % 3 == 0 ) { echo '<div class="clearfix visible-lg"></div>' ; } if ( $ supermag_featured_index % 2 == 0 ) { echo '<div class="clearfix visible-sm"></div>' ; } } $ supermag_featured_index ++ ; endwhile ; if ( 1 == $ supermag_post_col_layout && 1 == $ supermag_enable_first_featured ) { echo '</div>' ; } ?> </ul>

                 <?php echo $ args [ 'after_widget' ] ; echo " <div class='clearfix'></div> " ; wp_reset_postdata ( ) ; endif ; }
Function to Creating widget front-end.
Function to Creating widget front - end .
/*defaults values*/ /*selected cat*/ /*Main title*/ /*Enable first featured*/ /*column layout*/ /*first featured post layout*/ /*normal featured image*/ /**

             * Filter the arguments for the Recent Posts widget.

             *

             * @since 1.0.0

             *

             * @see WP_Query

             *

             */ // Reset the global $the_post as this query will have stomped on it