/** * Constructor */ public function __construct() { $this->_recent_posts = PF_Recent_Posts_init(); $this->_featured_posts = PF_Featured_Posts_init(); $this->_popular_posts = PF_Popular_Posts_init(); $this->_related_posts = PF_Related_Posts_init(); add_shortcode(self::RECENT_POSTS_SC, array(&$this, 'process_recent_posts_sc')); add_shortcode(self::POPULAR_POSTS_SC, array(&$this, 'process_popular_posts_sc')); add_shortcode(self::FEATURED_POSTS_SC, array(&$this, 'process_featured_posts_sc')); add_shortcode(self::RELATED_POSTS_SC, array(&$this, 'process_related_posts_sc')); }
{ global $post; $this->_post = $post; $post_types = array('post'); if (in_array($this->_post->post_type, $post_types)) { $value = get_post_meta($this->_post->ID, 'pf_view_count', true); if (!$value) { $value = 0; } $value++; update_post_meta($this->_post->ID, 'pf_view_count', $value); } } public function get_popular_posts($args) { if ($args['method'] == 'comment_count') { $args['orderby'] = 'comment_count'; } else { $args['orderby'] = 'meta_value_num'; $args['meta_key'] = 'pf_view_count'; } $args['ignore_sticky_posts'] = 1; return apply_filters('pf_recent_posts_result', new WP_Query($args), $args); } } function PF_Popular_Posts_init() { return PF_Popular_Posts::get_instance(); } $pf_popular_posts = PF_Popular_Posts_init(); }