Linux 软件免费装
Banner图

Post Views Count (Support caching plugins!)

开发者 juliobox
更新时间 2015年10月8日 20:00
捐献地址: 去捐款
PHP版本: 3.1 及以上
WordPress版本: 4.4

标签

widget stats views view count popular popular post

下载

详情介绍:

IMPORTANT: 3.0 supports cahing plugins! When someone visits a post or page (not a search engine bot crawler), it adds 1 count views to its counter. But this is not all, the counters are split in days, weeks, months, years, so you can see stats and display any stat day. Then you can display this views with the provided shortcode [post_view] or use the widget to display a top (or less) posts list. You can also use [most_view] in a post/page to get a top (or less) post most viewed. If you were using another kind of plugin before and don't want to lose your counters, this plugin can keep them!

安装:

  1. Upload the "baw-post-views-count" to the "/wp-content/plugins/" directory
  2. Activate the plugin through the "Plugins" menu in WordPress
  3. Go to settings page
  4. You can add the [post_view] shortcode to your theme template or directly in a post/page or add the widget.
  5. You can also use [most_view] in a post/page to get a top (or less, see FAQ) post most viewed

屏幕截图:

  • Shortcodes in post edition
  • Result in front end post with [post_view]
  • Widget demo
  • Shortcode [most_view] demo, in a page
  • Settings page
  • Meta box in each post type
  • Same but i clicked on a value, i can cheat on it!
  • Column in post list, each post type too

升级注意事项:

None

常见问题:

How to use/display it?

  1. [post_view] will display the counter for the actual post, custom post or page.
  2. [post_view id="123"] will display the counter for the post/page ID "123".
  3. [post_view time="day"] will display the count view of the day. So same for "week" will display count view for this week.
  4. [post_view time="day" date="20120213"] will display the count view for this particular day: 13th, feb 2012. "date" can not be use alone, always use "time" in the same time.
  5. [post_view time="month" date="201102"] will display the count view for the last year february. This mean you can play with date in your template, kind of :
  6. echo do_shortcode( '[post_view time="month" date="' . date( 'Ym', mktime( 0, 0, 0, date("n")-1, date("j"), date("Y") ) . '"]' ); // This will always display the count views of the month of last year.
  7. A shortcode named "most_view" (or "most_views" or "most_viewed") is available. Same as [post_view], you can set "time" and "date" but also this parameters:
  8. "before": A text before the list; default is empty
  9. "after": A text after the list; default is empty
  10. "show": Do we show counters ? 1= yes, 0=no; default is 1.
  11. "number": How many posts to display ?; default is 10.
  12. "ul_class": A CSS class
  13. "li_class": A CSS class
  14. "order": 'desc' or 'asc'
  15. "author": an author ID or author name.
  16. "post_type": post types list, comma separated, default=settings Example:
  17. [most_view number="3" show="0" before="Top 3!"] Will display the top 3 posts, no counters displayed, with title "Top 3!"

What are the hooks ?

  1. baw_count_views_timings: apply_filters( 'baw_count_views_timings', array( 'all'=>'', 'day'=>'Ymd', 'week'=>'YW', 'month'=>'Ym', 'year'=>'Y' ) ); You can add/remove timings with this filter, so if you do not need stats, or just do not need Year stat, you can remove them to avoid the creation of meta data unused in DB. Example: function remove_timing_for_bawpvc( $timings ) { unset( $timings['year'] ); // remove Year stat/meta return $timings; } add_filter( 'baw_count_views_timings', 'remove_timing_for_bawpvc' ); or function remove_timing_for_bawpvc( $timings ) { return array( 'all' => '' ); // keep only all counts, no other stats } add_filter( 'baw_count_views_timings', 'remove_timing_for_bawpvc' );
  2. baw_count_views_meta_key: apply_filters( 'baw_count_views_meta_key', '_count-views_' . $time . $date, $time, $date ); This hook is present to give compatibility with any old count plugins that had already record some counts for your blog. Example of use with wp-postviews: Its meta_key is "views" so i do this: function modify_metakey_for_bawpvc( $data, $time ) { return $time == 'all' ? 'views' : $data; } add_filter( 'baw_count_views_meta_key', 'modify_metakey_for_bawpvc', 10, 2 ); This return "views" if the selected stats count is "all" ! You can also play with $time and $date to do some checkings.
  3. baw_count_views_count: apply_filters( 'baw_count_views_count', $count, $meta_key, $time, $date, $id ); You can modify the $count value here, depending on time, date or meta_key. I added this in case of ... You can avoid recording count on different date or cheat on counting x)
  4. baw_count_views_count_action: do_action( 'baw_count_views_count', $count, $meta_key, $time, $date, $id ); Same as above, you can run your own code here.
  5. widget_title This is a WordPress hook, see codex or core code.
  6. baw_count_views_capa_role: apply_filters( 'baw_count_views_capa_role', 'edit_posts' ); You can modify the capatibility or rolle needed to see and modify the posts views stats. Example: `function bawpv_count_views_capa_role( $capa ) { return 'administrator'; // or // return 'manage_options'; }
  7. baw_count_views_render_post_columns: apply_filters( 'baw_count_views_render_post_columns', $post_id ); You can add (or remove?) more then only the "all" count stats in post page list in admin panel. Example: `function baw_count_views_render_post_columns( $post_id ) { echo ''; echo 'Month: ' . (int)get_post_meta( $post_id, '_count-views_month-'.date(mY), true ); } Will display the month stats below the default "all" count.
  8. baw_count_views_widget_post_types: apply_filters( 'baw_count_views_widget_post_types', $post_types ); You can hack the post types displayed in widget, whatever the settings.

更新日志:

3.0.2 3.0.1 3.0 2.19.13 2.19.12 2.19.11 2.19.10 2.19.9 2.19.8 2.19.7 2.19.6 2.19.5 2.19.4 2.19.3 2.19.2 2.19.1 2.19 2.18 2.18 2.17 2.16.1 2.16 2.15 2.14 2.13 2.12 2.11 2.10 2.9.1 2.9 2.8.2 2.8.1 2.8 2.7.1 2.7 2.6.4 2.6.3 2.6.1 2.6 2.5 2.4 2.3 2.2 2.1 1.0