芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/wp-statistics/includes/class-wp-statistics-schedule.php
setTimezone($timezone); // Determine the day name based on the start of the week setting $start_day_name = DateTime::getStartOfWeek(); // Daily schedule $daily = clone $datetime; $daily->modify('tomorrow')->setTime(8, 0); // Weekly schedule $weekly = clone $datetime; $weekly->modify("next {$start_day_name}")->setTime(8, 0); // BiWeekly schedule $biweekly = clone $datetime; $biweekly->modify("next {$start_day_name} +1 week")->setTime(8, 0); // Monthly schedule $monthly = clone $datetime; $monthly->modify('first day of next month')->setTime(8, 0); // Random monthly schedule $randomMonthly = clone $datetime; $randomMonthly->modify('first day of next month')->setTime($randomHour, $randomMinute); $schedules = [ 'daily' => [ 'interval' => DAY_IN_SECONDS, 'display' => __('Daily', 'wp-statistics'), 'start' => wp_date('Y-m-d', strtotime("-1 day")), 'end' => wp_date('Y-m-d', strtotime("-1 day")), 'next_schedule' => $daily->getTimestamp() ], 'weekly' => [ 'interval' => WEEK_IN_SECONDS, 'display' => __('Weekly', 'wp-statistics'), 'start' => wp_date('Y-m-d', strtotime("-7 days")), 'end' => wp_date('Y-m-d', strtotime("-1 day")), 'next_schedule' => $weekly->getTimestamp() ], 'biweekly' => [ 'interval' => 2 * WEEK_IN_SECONDS, 'display' => __('Bi-Weekly', 'wp-statistics'), 'start' => wp_date('Y-m-d', strtotime("-14 days")), 'end' => wp_date('Y-m-d', strtotime("-1 day")), 'next_schedule' => $biweekly->getTimestamp() ], 'monthly' => [ 'interval' => MONTH_IN_SECONDS, 'display' => __('Monthly', 'wp-statistics'), 'start' => wp_date('Y-m-d', strtotime('First day of previous month')), 'end' => wp_date('Y-m-d', strtotime('Last day of previous month')), 'next_schedule' => $monthly->getTimestamp() ], 'random_monthly' => [ 'interval' => MONTH_IN_SECONDS, 'display' => __('Monthly - Random Time', 'wp-statistics'), 'start' => wp_date('Y-m-d', strtotime('First day of previous month')), 'end' => wp_date('Y-m-d', strtotime('Last day of previous month')), 'next_schedule' => $randomMonthly->getTimestamp() ] ]; return apply_filters('wp_statistics_cron_schedules', $schedules); } public static function check_licenses_status() { LicenseHelper::checkLicensesStatus(); } /** * Define New Cron Schedules Time in WordPress * * @param array $schedules * @return mixed */ static function define_schedules_time($schedules) { // Adds once weekly to the existing schedules. $wpsSchedules = self::getSchedules(); foreach ($wpsSchedules as $key => $val) { if (!array_key_exists($key, $schedules)) { $schedules[$key] = [ 'interval' => $val['interval'], 'display' => $val['display'] ]; } } return $schedules; } public static function getNextScheduledTime($event) { return wp_next_scheduled($event); } /** * Updates the GeoIP database from MaxMind. */ public function geoip_event() { GeolocationFactory::downloadDatabase(); } /** * Purges old records on a schedule based on age. */ public function dbmaint_event() { $purge_days = intval(Option::get('schedule_dbmaint_days', false)); Purge::purge_data($purge_days); } public function getEmailSubject() { $schedule = Option::get('time_report', false); $subject = __('Your WP Statistics Report', 'wp-statistics'); if ($schedule && array_key_exists($schedule, self::getSchedules())) { $schedule = self::getSchedules()[$schedule]; if ($schedule['start'] === $schedule['end']) { $subject .= sprintf(__('for %s', 'wp-statistics'), $schedule['start']); } else { $subject .= sprintf(__('for %s to %s', 'wp-statistics'), $schedule['start'], $schedule['end']); } } return $subject; } /** * Send WP Statistics Report */ public function send_report() { // apply Filter ShortCode for email content $email_content = Option::get('content_report'); // Support ShortCode $email_content = do_shortcode($email_content); // Type Send Report $type = Option::get('send_report'); // If Email if ($type == 'mail') { /** * Filter for email template content * @usage wp-statistics-advanced-reporting */ $final_report_text = apply_filters('wp_statistics_final_text_report_email', $email_content); /** * Filter to modify email subject */ $email_subject = apply_filters('wp_statistics_report_email_subject', self::getEmailSubject()); /** * Filter for enable/disable sending email by template. */ $email_template = apply_filters('wp_statistics_report_email_template', true); /** * Email receivers */ $email_receivers = apply_filters('wp_statistics_report_email_receivers', Option::getEmailNotification()); /** * Send Email */ $result_email = Helper::send_mail( $email_receivers, $email_subject, $final_report_text, $email_template ); /** * Fire actions after sending email */ do_action('wp_statistics_after_report_email', $result_email, $email_receivers, $final_report_text); } // If SMS if ($type == 'sms' and !empty($email_content) and function_exists('wp_sms_send') and class_exists('\WP_SMS\Option')) { $adminMobileNumber = \WP_SMS\Option::getOption('admin_mobile_number'); wp_sms_send($adminMobileNumber, $email_content); } } /** * @deprecated Use WP_Statistics\Components\Event::reschedule() instead */ public static function rescheduleEvent($event, $newTime, $prevTime) { Event::reschedule($event, $newTime); } /** * Calls `LicenseMigration->migrateOldLicenses()` and migrates old licenses to the new structure. * * @return void */ public function migrateOldLicenses() { $apiCommunicator = new ApiCommunicator(); $licenseMigration = new LicenseMigration($apiCommunicator); $licenseMigration->migrateOldLicenses(); } } new Schedule;