* @license GPL 2+ GNU GPL licence above 2+ * @link http://anspress.io * @since 2.0.0-alpha2 */ // If this file is called directly, abort. if ( ! defined( 'WPINC' ) ) { wp_die(); } class AnsPress_Stats_Widget extends WP_Widget { /** * Initialize the class */ public function __construct() { parent::__construct( 'ap_status_widget', __( '(AnsPress) Question Stats', 'anspress-question-answer' ), array( 'description' => __( 'Shows question stats in single question page.', 'anspress-question-answer' ) ) ); } public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', @$instance['title'] ); echo $args['before_widget']; if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } $ans_count = ap_question_get_the_answer_count(); $last_active = ap_question_get_the_active_ago(); $total_subs = ap_question_get_the_subscriber_count(); $view_count = ap_question_get_the_view_count(); echo '
'; if ( is_question() ) { echo ''; } else { _e( 'This widget can only be used in single question page', 'anspress-question-answer' ); } echo '
'; echo $args['after_widget']; } public function form( $instance ) { if ( isset( $instance[ 'title' ] ) ) { $title = $instance[ 'title' ]; } else { $title = __( 'Question stats', 'anspress-question-answer' ); } ?>