*/ if ( ! defined( 'ABSPATH' ) ) { exit; // If this file is called directly, abort. } /** * Popular Posts Widget * * Class Aarambha_Kits_Block_Widget_5 */ class Aarambha_Kits_Block_Widget_5 extends Base_WP_Widget { /** * Constructor. */ public function __construct() { $this->widget_cssclass = 'widget_block widget-aarambha-kits'; $this->widget_description = esc_html__( 'Displays the most popular posts with number of post views.', 'aarambha-kits' ); $this->widget_name = esc_html__( 'Aarambha Kits: Block Popular Posts', 'aarambha-kits' ); $this->settings = array( 'title' => array( 'type' => 'text', 'default' => '', 'label' => esc_html__( 'Title', 'aarambha-kits' ), ), 'limit' => array( 'type' => 'number', 'default' => 5, 'label' => esc_html__( 'Posts Limit', 'aarambha-kits' ), 'input_attrs' => array( 'min' => 0, 'max' => 6, ), ), ); parent::__construct(); } /** * Output widget. * * @see WP_Widget * * @param array $args Arguments. * @param array $instance Widget instance. */ public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' ); $limit = isset( $instance['limit'] ) ? $instance['limit'] : 5; $wp_args = aarambha_kits_query_agrs( array( 'base_posts_limit' => absint( $limit ) ), 1 ); $wp_args = wp_parse_args( array( 'orderby' => 'meta_value_num', 'order' => 'DESC', 'meta_key' => 'aarambha_kits_total_views', ), $wp_args ); $the_query = new WP_Query( $wp_args ); $this->widget_start( $args ); ?>
widget_title( $title ); ?> have_posts() ) { $counter = 1; ?>
widget_end( $args ); } }