Changeset 3453097
- Timestamp:
- 02/03/2026 05:14:32 PM (2 months ago)
- Location:
- post-views-counter/tags/1.7.5
- Files:
-
- 15 deleted
- 58 copied
-
. (copied) (copied from post-views-counter/trunk)
-
assets/chartjs/chart.min.css (deleted)
-
assets/chartjs/chart.min.js (copied) (copied from post-views-counter/trunk/assets/chartjs/chart.min.js)
-
assets/micromodal (copied) (copied from post-views-counter/trunk/assets/micromodal)
-
assets/microtip/microtip.css (deleted)
-
assets/microtip/microtip.min.css (copied) (copied from post-views-counter/trunk/assets/microtip/microtip.min.css)
-
blocks (copied) (copied from post-views-counter/trunk/blocks)
-
blocks/most-viewed-posts/block.json (copied) (copied from post-views-counter/trunk/blocks/most-viewed-posts/block.json)
-
blocks/most-viewed-posts/build (deleted)
-
blocks/most-viewed-posts/index.asset.php (copied) (copied from post-views-counter/trunk/blocks/most-viewed-posts/index.asset.php)
-
blocks/most-viewed-posts/index.js (copied) (copied from post-views-counter/trunk/blocks/most-viewed-posts/index.js)
-
blocks/most-viewed-posts/package-lock.json (deleted)
-
blocks/most-viewed-posts/package.json (deleted)
-
blocks/most-viewed-posts/src (deleted)
-
blocks/post-views/block.json (copied) (copied from post-views-counter/trunk/blocks/post-views/block.json)
-
blocks/post-views/build (deleted)
-
blocks/post-views/index.asset.php (copied) (copied from post-views-counter/trunk/blocks/post-views/index.asset.php)
-
blocks/post-views/index.js (copied) (copied from post-views-counter/trunk/blocks/post-views/index.js)
-
blocks/post-views/package-lock.json (deleted)
-
blocks/post-views/package.json (deleted)
-
blocks/post-views/src (deleted)
-
css/admin-columns.css (copied) (copied from post-views-counter/trunk/css/admin-columns.css)
-
css/admin-dashboard.css (copied) (copied from post-views-counter/trunk/css/admin-dashboard.css)
-
css/admin-post.css (copied) (copied from post-views-counter/trunk/css/admin-post.css)
-
css/admin-settings.css (copied) (copied from post-views-counter/trunk/css/admin-settings.css)
-
css/admin.css (deleted)
-
css/block-editor.css (copied) (copied from post-views-counter/trunk/css/block-editor.css)
-
css/block-editor.min.css (deleted)
-
css/frontend.css (copied) (copied from post-views-counter/trunk/css/frontend.css)
-
css/gutenberg.min.css (deleted)
-
css/page-reports.png (copied) (copied from post-views-counter/trunk/css/page-reports.png)
-
includes/class-admin.php (copied) (copied from post-views-counter/trunk/includes/class-admin.php)
-
includes/class-columns-modal.php (copied) (copied from post-views-counter/trunk/includes/class-columns-modal.php)
-
includes/class-columns.php (copied) (copied from post-views-counter/trunk/includes/class-columns.php) (1 diff)
-
includes/class-counter.php (copied) (copied from post-views-counter/trunk/includes/class-counter.php)
-
includes/class-crawler-detect.php (copied) (copied from post-views-counter/trunk/includes/class-crawler-detect.php)
-
includes/class-cron.php (copied) (copied from post-views-counter/trunk/includes/class-cron.php)
-
includes/class-dashboard.php (copied) (copied from post-views-counter/trunk/includes/class-dashboard.php)
-
includes/class-frontend.php (copied) (copied from post-views-counter/trunk/includes/class-frontend.php)
-
includes/class-functions.php (copied) (copied from post-views-counter/trunk/includes/class-functions.php)
-
includes/class-import.php (copied) (copied from post-views-counter/trunk/includes/class-import.php)
-
includes/class-integration-gutenberg.php (copied) (copied from post-views-counter/trunk/includes/class-integration-gutenberg.php)
-
includes/class-integrations.php (copied) (copied from post-views-counter/trunk/includes/class-integrations.php)
-
includes/class-query.php (copied) (copied from post-views-counter/trunk/includes/class-query.php)
-
includes/class-settings-api.php (copied) (copied from post-views-counter/trunk/includes/class-settings-api.php)
-
includes/class-settings-display.php (copied) (copied from post-views-counter/trunk/includes/class-settings-display.php)
-
includes/class-settings-general.php (copied) (copied from post-views-counter/trunk/includes/class-settings-general.php)
-
includes/class-settings-integrations.php (copied) (copied from post-views-counter/trunk/includes/class-settings-integrations.php)
-
includes/class-settings-other.php (copied) (copied from post-views-counter/trunk/includes/class-settings-other.php)
-
includes/class-settings-reports.php (copied) (copied from post-views-counter/trunk/includes/class-settings-reports.php)
-
includes/class-settings.php (copied) (copied from post-views-counter/trunk/includes/class-settings.php)
-
includes/class-toolbar.php (copied) (copied from post-views-counter/trunk/includes/class-toolbar.php)
-
includes/class-traffic-signals.php (copied) (copied from post-views-counter/trunk/includes/class-traffic-signals.php) (3 diffs)
-
includes/class-update.php (copied) (copied from post-views-counter/trunk/includes/class-update.php)
-
includes/class-widgets.php (copied) (copied from post-views-counter/trunk/includes/class-widgets.php)
-
includes/functions.php (copied) (copied from post-views-counter/trunk/includes/functions.php) (3 diffs)
-
js/admin-columns.js (copied) (copied from post-views-counter/trunk/js/admin-columns.js)
-
js/admin-dashboard.js (copied) (copied from post-views-counter/trunk/js/admin-dashboard.js)
-
js/admin-post.js (copied) (copied from post-views-counter/trunk/js/admin-post.js)
-
js/admin-quick-edit.js (copied) (copied from post-views-counter/trunk/js/admin-quick-edit.js)
-
js/admin-settings.js (copied) (copied from post-views-counter/trunk/js/admin-settings.js)
-
js/admin-theme.js (copied) (copied from post-views-counter/trunk/js/admin-theme.js)
-
js/admin-widgets.js (copied) (copied from post-views-counter/trunk/js/admin-widgets.js)
-
js/block-editor.js (copied) (copied from post-views-counter/trunk/js/block-editor.js)
-
js/block-editor.min.js (deleted)
-
js/counter.js (copied) (copied from post-views-counter/trunk/js/counter.js)
-
js/dummy.js (copied) (copied from post-views-counter/trunk/js/dummy.js)
-
js/frontend.js (copied) (copied from post-views-counter/trunk/js/frontend.js)
-
js/gutenberg.min.js (deleted)
-
js/integration-gutenberg.js (copied) (copied from post-views-counter/trunk/js/integration-gutenberg.js)
-
languages/post-views-counter.pot (copied) (copied from post-views-counter/trunk/languages/post-views-counter.pot)
-
post-views-counter.php (copied) (copied from post-views-counter/trunk/post-views-counter.php) (3 diffs)
-
readme.txt (copied) (copied from post-views-counter/trunk/readme.txt) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
post-views-counter/tags/1.7.5/includes/class-columns.php
r3452736 r3453097 184 184 // filters 185 185 add_filter( 'manage_' . $post_type . '_posts_columns', [ $this, 'add_new_column' ] ); 186 add_filter( 'manage_edit-' . $post_type . '_columns', [ $this, 'add_new_column' ], 20 ); 186 187 add_filter( 'manage_edit-' . $post_type . '_sortable_columns', [ $this, 'register_sortable_custom_column' ] ); 187 188 -
post-views-counter/tags/1.7.5/includes/class-traffic-signals.php
r3452736 r3453097 76 76 if ( $post_type !== 'attachment' ) { 77 77 add_filter( 'manage_' . $post_type . '_posts_columns', [ $this, 'add_traffic_signal_column' ], 10, 1 ); 78 add_filter( 'manage_edit-' . $post_type . '_columns', [ $this, 'add_traffic_signal_column' ], 20 ); 78 79 add_action( 'manage_' . $post_type . '_posts_custom_column', [ $this, 'render_traffic_signal_column' ], 10, 2 ); 79 80 } … … 160 161 // get current month views 161 162 $current_date = new DateTime(); 162 $current_year = $current_date->format( 'Y' ); 163 $current_month = $current_date->format( 'm' ); 164 165 $current_views = pvc_get_views( [ 166 'post_id' => $post_id, 167 'post_type' => get_post_type( $post_id ), 168 'fields' => 'date=>views', 169 'views_query' => [ 170 'year' => $current_year, 171 'month' => $current_month 172 ] 173 ] ); 174 175 $current_total = is_array( $current_views ) ? array_sum( $current_views ) : 0; 163 $current_period = $current_date->format( 'Ym' ); 164 165 $current_total = (int) pvc_get_post_views( $post_id, $current_period ); 176 166 177 167 // minimum views threshold … … 181 171 } 182 172 183 // get previous month views 173 // get previous month views (same number of days as current month-to-date) 184 174 $prev_date = clone $current_date; 185 175 $prev_date->modify( '-1 month' ); 186 176 $prev_year = $prev_date->format( 'Y' ); 187 177 $prev_month = $prev_date->format( 'm' ); 188 189 $prev_views = pvc_get_views( [ 190 'post_id' => $post_id, 191 'post_type' => get_post_type( $post_id ), 192 'fields' => 'date=>views', 193 'views_query' => [ 194 'year' => $prev_year, 195 'month' => $prev_month 178 $prev_last_day = (int) $prev_date->format( 't' ); 179 $current_day = (int) $current_date->format( 'd' ); 180 // compare against the same number of days from last month (clamp to last day) 181 $end_day = min( $current_day, $prev_last_day ); 182 183 $prev_start = (int) ( $prev_year . $prev_month . '01' ); 184 $prev_end = (int) ( $prev_year . $prev_month . str_pad( (string) $end_day, 2, '0', STR_PAD_LEFT ) ); 185 186 $prev_total = (int) pvc_get_post_views( 187 $post_id, 188 '', 189 [ 190 'type' => 0, 191 'period_range' => [ $prev_start, $prev_end ] 196 192 ] 197 ] ); 198 199 $prev_total = is_array( $prev_views ) ? array_sum( $prev_views ) : 0; 193 ); 200 194 201 195 // need both periods to compare -
post-views-counter/tags/1.7.5/includes/functions.php
r3452736 r3453097 20 20 * @param int|array $post_id 21 21 * @param string $period 22 * @param array $args Optional arguments to override period parsing 22 23 * 23 24 * @return int 24 25 */ 25 26 if ( ! function_exists( 'pvc_get_post_views' ) ) { 26 function pvc_get_post_views( $post_id = 0, $period = 'total' ) {27 function pvc_get_post_views( $post_id = 0, $period = 'total', $args = [] ) { 27 28 global $wpdb; 29 30 // ensure args is an array 31 if ( ! is_array( $args ) ) { 32 $args = []; 33 } 28 34 29 35 // sanitize period … … 46 52 $where = [ 'type' => 'type = 4' ]; 47 53 54 // override type if explicitly provided in args 55 if ( isset( $args['type'] ) ) { 56 $where['type'] = 'type = ' . (int) $args['type']; 57 if ( ! isset( $args['content'] ) ) 58 $where['content'] = 'content = 0'; 59 } elseif ( isset( $args['period_type'] ) ) { 60 $period_type = sanitize_key( $args['period_type'] ); 61 $type_map = [ 62 'day' => 0, 63 'week' => 1, 64 'month' => 2, 65 'year' => 3, 66 'total' => 4 67 ]; 68 if ( isset( $type_map[ $period_type ] ) ) { 69 $where['type'] = 'type = ' . $type_map[ $period_type ]; 70 if ( ! isset( $args['content'] ) ) 71 $where['content'] = 'content = 0'; 72 } 73 } 74 75 // optional period range (e.g., for day-based ranges within a month) 76 $range_from = null; 77 $range_to = null; 78 79 if ( isset( $args['period_range'] ) && is_array( $args['period_range'] ) ) { 80 $range = array_values( $args['period_range'] ); 81 if ( isset( $range[0], $range[1] ) ) { 82 $range_from = (int) $range[0]; 83 $range_to = (int) $range[1]; 84 } 85 } elseif ( isset( $args['period_from'], $args['period_to'] ) ) { 86 $range_from = (int) $args['period_from']; 87 $range_to = (int) $args['period_to']; 88 } 89 90 if ( $range_from && $range_to ) { 91 $range_min = min( $range_from, $range_to ); 92 $range_max = max( $range_from, $range_to ); 93 94 $where['period'] = 'CAST( period AS SIGNED ) <= ' . $range_max . ' AND CAST( period AS SIGNED ) >= ' . $range_min; 95 96 // default to day type when using explicit ranges and no type set 97 if ( ! isset( $where['type'] ) ) { 98 $where['type'] = 'type = 0'; 99 if ( ! isset( $args['content'] ) ) 100 $where['content'] = 'content = 0'; 101 } 102 } 103 48 104 // update where clause 49 $where = apply_filters( 'pvc_get_post_views_period_where', $where, $period, $post_id );105 $where = apply_filters( 'pvc_get_post_views_period_where', $where, $period, $post_id, $args ); 50 106 51 107 // updated where clause … … 120 176 } 121 177 122 return (int) apply_filters( 'pvc_get_post_views', $post_views, $post_id, $period );178 return (int) apply_filters( 'pvc_get_post_views', $post_views, $post_id, $period, $args ); 123 179 } 124 180 } -
post-views-counter/tags/1.7.5/post-views-counter.php
r3452736 r3453097 3 3 Plugin Name: Post Views Counter 4 4 Description: Post Views Counter allows you to collect and display how many times a post, page, or other content has been viewed in a simple, fast and reliable way. 5 Version: 1.7. 45 Version: 1.7.5 6 6 Author: dFactory 7 7 Author URI: https://dfactory.co/ … … 31 31 * 32 32 * @class Post_Views_Counter 33 * @version 1.7. 433 * @version 1.7.5 34 34 */ 35 35 final class Post_Views_Counter { … … 110 110 'integrations' => [] 111 111 ], 112 'version' => '1.7. 4'112 'version' => '1.7.5' 113 113 ]; 114 114 -
post-views-counter/tags/1.7.5/readme.txt
r3452736 r3453097 5 5 Requires PHP: 7.0 6 6 Tested up to: 6.9 7 Stable tag: 1.7. 47 Stable tag: 1.7.5 8 8 License: MIT License 9 9 License URI: http://opensource.org/licenses/MIT … … 93 93 == Changelog == 94 94 95 = 1.7.5 = 96 * Tweak: Optimize traffic signals database query performance. 97 * Tweak: Admin columns display priority and traffic signals comparison alignment. 98 95 99 = 1.7.4 = 96 100 * New: Month-over-Month anomaly detection traffic signals in admin columns. … … 446 450 == Upgrade Notice == 447 451 448 = 1.7. 4=449 Adds traffic signal anomaly detection, improves modal architecture.452 = 1.7.5 = 453 Optimizes traffic signals database performance and tweaks admin columns display.
Note: See TracChangeset
for help on using the changeset viewer.