' ){ return; } else{ $links = str_replace('(', '', $links); $links = str_replace(')', '', $links); } return $links; } add_filter( 'wp_list_categories', 'amaaaze_list_categories_output_change' ); /* Save Posts views */ function amaaaze_save_post_views( $postID ){ $metaKey = 'amaaaze_post_views'; $views = get_post_meta( $postID, $metaKey, true ); $count = ( empty($views) ? 0 : $views ); $count++; update_post_meta( $postID, $metaKey, $count ); } //remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); /* Popular posts widget */ class amaaaze_Popular_Posts_Widget extends WP_Widget{ public function __construct(){ $widget_ops = array( 'classname' => 'amaaaze-popular-posts-widget', 'description' => esc_html__('Popular Posts Widget','amaaaze') ); parent::__construct( 'amaaaze_popular_posts', esc_html__('amaaaze Popular Posts','amaaaze'), $widget_ops ); } //back-end display of widget public function form( $instance ){ $title = ( !empty( $instance['title'] ) ? $instance['title'] : esc_html__('Popular Posts','amaaaze') ); $tot = ( !empty( $instance['tot'] ) ? absint( $instance['tot'] ) : 4 ); $output = '

'; $output .= ''; $output .= 'get_field_id('tot') ) .'">'. esc_html__('Number of Posts:','amaaaze') .''; $output .= ' 'post', 'posts_per_page' => $tot, 'meta_key' => 'amaaaze_post_views', 'orderby' => 'meta_value_num', 'order' => 'DESC' ); $posts_query = new WP_Query( $posts_args ); echo $args['before_widget']; if( !empty( $instance['title'] ) ): echo $args['before_title']. apply_filters('widget_title', $instance['title']) . $args['after_title']; endif; if( $posts_query->have_posts() ) : while( $posts_query->have_posts() ): $posts_query->the_post(); $archive_year = get_the_time('Y'); $archive_month = get_the_time('m'); $archive_day = get_the_time('d'); $posted_on = ''. get_the_date() .''; echo '

'; echo '
'; echo '
' . get_the_title() . '
'; echo '
  • ' .get_the_author_posts_link() .'
  • ' ; echo '
  • ' . $posted_on .'
' ; echo '
'; echo '
'; the_post_thumbnail(); echo '
'; echo '
'; endwhile; endif; echo $args['after_widget']; } } $archive_year = get_the_time('Y'); $archive_month = get_the_time('m'); $archive_day = get_the_time('d'); $posted_on = ''. get_the_date() .''; function amaaaze_register_popular_posts_widget_init() { register_widget( 'amaaaze_Popular_Posts_Widget' ); } add_action( 'widgets_init', 'amaaaze_register_popular_posts_widget_init');