private function displayStatus() { echo '<h3>Status</h3>'; echo '<table class="puc-debug-data">'; $state = $this->updateChecker->getUpdateState(); $checkNowButton = ''; if (function_exists('get_submit_button')) { $checkNowButton = get_submit_button('Check Now', 'secondary', 'puc-check-now-button', false, array('id' => 'puc-check-now-button-' . $this->updateChecker->slug)); } if (isset($state, $state->lastCheck)) { $this->row('Last check', $this->formatTimeWithDelta($state->lastCheck) . ' ' . $checkNowButton . $this->responseBox); } else { $this->row('Last check', 'Never'); } $nextCheck = wp_next_scheduled($this->updateChecker->scheduler->getCronHookName()); $this->row('Next automatic check', $this->formatTimeWithDelta($nextCheck)); if (isset($state, $state->checkedVersion)) { $this->row('Checked version', htmlentities($state->checkedVersion)); $this->row('Cached update', $state->update); } $this->row('Update checker class', htmlentities(get_class($this->updateChecker))); echo '</table>'; }
/** * Check for updates if the configured check interval has already elapsed. * Will use a shorter check interval on certain admin pages like "Dashboard -> Updates" or when doing cron. * * You can override the default behaviour by using the "puc_check_now-$slug" filter. * The filter callback will be passed three parameters: * - Current decision. TRUE = check updates now, FALSE = don't check now. * - Last check time as a Unix timestamp. * - Configured check period in hours. * Return TRUE to check for updates immediately, or FALSE to cancel. * * This method is declared public because it's a hook callback. Calling it directly is not recommended. */ public function maybeCheckForUpdates() { if (empty($this->checkPeriod)) { return; } $state = $this->updateChecker->getUpdateState(); $shouldCheck = empty($state) || !isset($state->lastCheck) || time() - $state->lastCheck >= $this->getEffectiveCheckPeriod(); //Let plugin authors substitute their own algorithm. $shouldCheck = apply_filters('puc_check_now-' . $this->updateChecker->slug, $shouldCheck, !empty($state) && isset($state->lastCheck) ? $state->lastCheck : 0, $this->checkPeriod); if ($shouldCheck) { $this->updateChecker->checkForUpdates(); } }