have_posts() ) : $r->the_post(); $page_title = get_the_title(); echo '
'; echo '' . esc_html( $page_title ) . ''; if ( $type === 'popular' ) { /* translators: %s: number of comments */ $comments_string = sprintf( __( '%s comment(s)', 'apollo13-framework-extensions' ), get_comments_number() ); echo '' . esc_html( $comments_string ) . ''; } else { echo function_exists('apollo13framework_posted_on') ? apollo13framework_posted_on() : ''; } //if user want excerpt also and post is not password protected if ( ! empty( $instance['content'] ) && ! post_password_required() ) { echo ''; $text = get_the_content( '' ); $text = strip_shortcodes( $text ); $text = wp_trim_words( $text, 30, '' ); echo esc_html($text); echo ''; } echo '
'; endwhile; } /** * Adds post widgets: Recent, Popular, Related * @since 1.2.0 */ function a13fe_register_posts_widgets(){ class A13fe_Widget_Recent_Posts extends WP_Widget { function __construct() { $widget_ops = array( 'classname' => 'widget_recent_posts widget_about_posts', 'description' => esc_html__( 'The most recent posts on your site', 'apollo13-framework-extensions' ) ); parent::__construct( 'recent-posts', esc_html__( 'Apollo13Themes', 'apollo13-framework-extensions' ) . ' - ' . esc_html__( 'Recent Posts', 'apollo13-framework-extensions' ), $widget_ops ); $this->alt_option_name = 'widget_recent_entries'; add_action( 'save_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'deleted_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'switch_theme', array( &$this, 'flush_midget_cache' ) ); } function widget( $args, $instance ) { $before_widget = $after_widget = $before_title = $after_title = ''; $cache = wp_cache_get( 'widget_recent_entries', 'widget' ); if ( ! is_array( $cache ) ) { $cache = array(); } if ( isset( $cache[ $args['widget_id'] ] ) ) { print $cache[ $args['widget_id'] ]; return; } ob_start(); extract( $args ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? esc_html__( 'Recent Posts', 'apollo13-framework-extensions' ) : $instance['title'], $instance, $this->id_base ); if ( ! $number = absint( $instance['number'] ) ) { $number = 10; } $r = new WP_Query( array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ); if ( $r->have_posts() ) : print $before_widget; if ( $title ) { print $before_title . $title . $after_title; } a13fe_widget_posts( $r, $instance ); print $after_widget; // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); endif; $cache[ $args['widget_id'] ] = ob_get_flush(); wp_cache_set( 'widget_recent_entries', $cache, 'widget' ); } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['number'] = (int) $new_instance['number']; $instance['content'] = isset( $new_instance['content'] ); $this->flush_midget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset( $alloptions['widget_recent_entries'] ) ) { delete_option( 'widget_recent_entries' ); } return $instance; } function flush_midget_cache() { wp_cache_delete( 'widget_recent_entries', 'widget' ); } function form( $instance ) { $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; ?>

/> 

'widget_popular_entries widget_about_posts', 'description' => esc_html__( 'The most popular posts on your site', 'apollo13-framework-extensions' ) ); parent::__construct( 'popular-posts', esc_html__( 'Apollo13Themes', 'apollo13-framework-extensions' ) . ' - ' . esc_html__( 'Popular Posts', 'apollo13-framework-extensions' ), $widget_ops ); $this->alt_option_name = 'widget_popular_entries'; add_action( 'save_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'deleted_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'switch_theme', array( &$this, 'flush_midget_cache' ) ); } function widget( $args, $instance ) { $before_widget = $after_widget = $before_title = $after_title = ''; $cache = wp_cache_get( 'widget_popular_entries', 'widget' ); if ( ! is_array( $cache ) ) { $cache = array(); } if ( isset( $cache[ $args['widget_id'] ] ) ) { print $cache[ $args['widget_id'] ]; return; } ob_start(); extract( $args ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? esc_html__( 'Popular Posts', 'apollo13-framework-extensions' ) : $instance['title'], $instance, $this->id_base ); if ( ! $number = absint( $instance['number'] ) ) { $number = 10; } $r = new WP_Query( array( 'posts_per_page' => $number, 'no_found_rows' => true, 'orderby' => 'comment_count', 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ); if ( $r->have_posts() ) : print $before_widget; if ( $title ) { print $before_title . $title . $after_title; } a13fe_widget_posts( $r, $instance, 'popular' ); print $after_widget; // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); endif; $cache[ $args['widget_id'] ] = ob_get_flush(); wp_cache_set( 'widget_popular_entries', $cache, 'widget' ); } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['number'] = (int) $new_instance['number']; $instance['content'] = isset( $new_instance['content'] ); $this->flush_midget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset( $alloptions['widget_popular_entries'] ) ) { delete_option( 'widget_popular_entries' ); } return $instance; } function flush_midget_cache() { wp_cache_delete( 'widget_popular_entries', 'widget' ); } function form( $instance ) { $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; ?>

/> 

'widget_related_entries widget_about_posts', 'description' => esc_html__( 'Related posts to current post', 'apollo13-framework-extensions' ) ); parent::__construct( 'related-posts', esc_html__( 'Apollo13Themes', 'apollo13-framework-extensions' ) . ' - ' . esc_html__( 'Related Posts', 'apollo13-framework-extensions' ), $widget_ops ); $this->alt_option_name = 'widget_related_entries'; add_action( 'save_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'deleted_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'switch_theme', array( &$this, 'flush_midget_cache' ) ); } function widget( $args, $instance ) { $before_widget = $after_widget = $before_title = $after_title = ''; $cache = wp_cache_get( 'widget_related_entries', 'widget' ); if ( ! is_array( $cache ) ) { $cache = array(); } if ( isset( $cache[ $args['widget_id'] ] ) ) { print $cache[ $args['widget_id'] ]; return; } ob_start(); extract( $args ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? esc_html__( 'Related Posts', 'apollo13-framework-extensions' ) : $instance['title'], $instance, $this->id_base ); if ( ! $number = absint( $instance['number'] ) ) { $number = 10; } global $post; $__search = wp_get_post_tags( $post->ID ); $search_string = 'tags__in'; //if no tags try categories if ( ! count( $__search ) ) { $__search = wp_get_post_categories( $post->ID ); $search_string = 'category__in'; } if ( count( $__search ) ) { $r = new WP_Query( array( $search_string => $__search, 'post__not_in' => array( $post->ID ), 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ); if ( $r->have_posts() ) : print $before_widget; if ( $title ) { print $before_title . $title . $after_title; } a13fe_widget_posts( $r, $instance ); print $after_widget; // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); endif; } $cache[ $args['widget_id'] ] = ob_get_flush(); wp_cache_set( 'widget_related_entries', $cache, 'widget' ); } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['number'] = (int) $new_instance['number']; $instance['content'] = isset( $new_instance['content'] ); $this->flush_midget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset( $alloptions['widget_related_entries'] ) ) { delete_option( 'widget_related_entries' ); } return $instance; } function flush_midget_cache() { wp_cache_delete( 'widget_related_entries', 'widget' ); } function form( $instance ) { $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; ?>

/>