golden hour
/home/doctorbruno/.trash/insulingate2026.com/wp-content/plugins_old/post-views-counter/includes
⬆️ Go Up
Upload
File/Folder
Size
Actions
.htaccess
237 B
Del
OK
class-admin.php
5.7 KB
Del
OK
class-columns-modal.php
11.19 KB
Del
OK
class-columns.php
13.37 KB
Del
OK
class-counter.php
70.31 KB
Del
OK
class-crawler-detect.php
33.62 KB
Del
OK
class-cron.php
2.97 KB
Del
OK
class-dashboard.php
22.24 KB
Del
OK
class-emails-mailer.php
29.59 KB
Del
OK
class-emails-period.php
5.9 KB
Del
OK
class-emails-query.php
18.75 KB
Del
OK
class-emails-scheduler.php
6.38 KB
Del
OK
class-emails-template.php
60.77 KB
Del
OK
class-emails.php
4.08 KB
Del
OK
class-frontend.php
7.62 KB
Del
OK
class-functions.php
4.5 KB
Del
OK
class-import.php
54.36 KB
Del
OK
class-integration-gutenberg.php
7.82 KB
Del
OK
class-integrations.php
13.38 KB
Del
OK
class-query.php
17.83 KB
Del
OK
class-settings-api.php
42.72 KB
Del
OK
class-settings-display.php
18.46 KB
Del
OK
class-settings-emails.php
29.43 KB
Del
OK
class-settings-general.php
29.12 KB
Del
OK
class-settings-integrations.php
3.3 KB
Del
OK
class-settings-other.php
16.59 KB
Del
OK
class-settings-reports.php
1.91 KB
Del
OK
class-settings.php
36.85 KB
Del
OK
class-toolbar.php
5.31 KB
Del
OK
class-traffic-signals.php
9.46 KB
Del
OK
class-update.php
11.49 KB
Del
OK
class-widgets.php
13.03 KB
Del
OK
functions.php
32.24 KB
Del
OK
Edit: class-cron.php
<?php // exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; /** * Post_Views_Counter_Cron class. * * @class Post_Views_Counter_Cron */ class Post_Views_Counter_Cron { /** * Class constructor. * * @return void */ public function __construct() { // actions add_action( 'init', [ $this, 'check_cron' ] ); add_action( 'pvc_reset_counts', [ $this, 'reset_counts' ] ); // filters add_filter( 'cron_schedules', [ $this, 'cron_time_intervals' ] ); } /** * Reset daily counts. * * @global object $wpdb * * @return void */ public function reset_counts() { global $wpdb; $counter = [ 'days' => 1, 'weeks' => 7, 'months' => 30, 'years' => 365 ]; // get main instance $pvc = Post_Views_Counter(); // default where clause $where = [ 'type = 0', 'CAST( period AS SIGNED ) < CAST( ' . date( 'Ymd', strtotime( '-' . ( (int) ( $counter[$pvc->options['general']['reset_counts']['type']] * $pvc->options['general']['reset_counts']['number'] ) ) . ' days' ) ) . ' AS SIGNED)' ]; // update where clause $where = apply_filters( 'pvc_reset_counts_where_clause', $where ); // delete views $wpdb->query( 'DELETE FROM ' . $wpdb->prefix . 'post_views WHERE ' . implode( ' AND ', $where ) ); } /** * Add new cron interval from settings. * * @param array $schedules * @return array */ public function cron_time_intervals( $schedules ) { // get main instance $pvc = Post_Views_Counter(); $display = 'Post Views Counter reset daily counts interval'; if ( did_action( 'init' ) ) $display = __( 'Post Views Counter reset daily counts interval', 'post-views-counter' ); $schedules['post_views_counter_interval'] = [ 'interval' => DAY_IN_SECONDS, 'display' => $display ]; return $schedules; } /** * Check whether WP Cron needs to add new task. * * @return void */ public function check_cron() { // only for backend if ( ! is_admin() ) return; // get main instance $pvc = Post_Views_Counter(); // set wp cron task if ( $pvc->options['general']['cron_run'] ) { // not set or need to be updated? if ( ! wp_next_scheduled( 'pvc_reset_counts' ) || $pvc->options['general']['cron_update'] ) { // task is added but need to be updated if ( $pvc->options['general']['cron_update'] ) { // remove old schedule wp_clear_scheduled_hook( 'pvc_reset_counts' ); // set update to false $general = $pvc->options['general']; $general['cron_update'] = false; // update settings update_option( 'post_views_counter_settings_general', $general ); } // set schedule wp_schedule_event( current_time( 'timestamp', true ) + DAY_IN_SECONDS, 'post_views_counter_interval', 'pvc_reset_counts' ); } } else { // remove schedule wp_clear_scheduled_hook( 'pvc_reset_counts' ); remove_action( 'pvc_reset_counts', [ $this, 'reset_counts' ] ); } } }
Save