*/ if (version_compare($this->currentVersion, '14.10', '<') && (Option::get('link_tracker') || Option::get('download_tracker'))) { Option::saveByAddon([ 'link_tracker' => Option::get('link_tracker'), 'download_tracker' => Option::get('download_tracker'), 'latest_visitors_metabox' => '1', ], 'data_plus'); } // Clear not used scheduled. if (function_exists('wp_clear_scheduled_hook')) { // Remove unused cron job for purging high hit count visitors daily wp_clear_scheduled_hook('wp_statistics_dbmaint_visitor_hook'); // Remove referral db update cron wp_clear_scheduled_hook('wp_statistics_referrals_db_hook'); } /** * Update old excluded URLs to the new structure with explicit wildcards. * * @version 14.10.3 */ if (version_compare($this->currentVersion, '14.10.3', '<') && Option::get('excluded_urls')) { $updatedExcludedUrls = $this->updateOldExcludedUrls(); if (!empty($updatedExcludedUrls)) { Option::update('excluded_urls', implode("\n", $updatedExcludedUrls)); } } if (!Option::get('schedule_dbmaint') && version_compare($this->currentVersion, '14.15.5', '<')) { Option::update('schedule_dbmaint_days', '0'); } if (Option::get('schedule_dbmaint') && version_compare($this->currentVersion, '14.15.5', '<')) { Event::reschedule('wp_statistics_dbmaint_hook', 'daily', DateTime::get('tomorrow midnight', 'U')); } } /** * Updates old excluded URLs to the new structure with explicit wildcards. * * @return array updated URLs. */ private function updateOldExcludedUrls() { $updatedUrls = []; foreach (explode("\n", Option::get('excluded_urls')) as $url) { $url = wp_make_link_relative($url); $url = trim($url); // If the URL contains a query string, strip it $url = explode('?', $url)[0]; // Trim leading/trailing slashes $url = trim($url, '/\\'); // If the URL doesn't end with an asterisk (*), add one and make it a wildcard if (substr($url, -1) !== '*') { $url .= '*'; } // Add the URL to the new list if it's not similar to others if (!in_array($url, $updatedUrls)) { $updatedUrls[] = $url; } } return $updatedUrls; } }