function feedwordpress_update_magic_url() { // Explicit update request in the HTTP request (e.g. from a cron job) if (FeedWordPress::update_requested()) { $feedwordpress = new FeedWordPress(); // need to include includes/bookmark.php for wp link functions require_once ABSPATH . 'wp-admin/includes/bookmark.php'; $feedwordpress->update(FeedWordPress::update_requested_url()); // Magic URL should return nothing but a 200 OK header packet // when successful. exit; } }
function diagnostic($level, $out, $persist = NULL, $since = NULL, $mostRecent = NULL) { global $feedwordpress_admin_footer; $output = get_option('feedwordpress_diagnostics_output', array()); $dlog = get_option('feedwordpress_diagnostics_log', array()); $diagnostic_nesting = count(explode(":", $level)); if (FeedWordPress::diagnostic_on($level)) { foreach ($output as $method) { switch ($method) { case 'echo': if (!FeedWordPress::update_requested()) { echo "<div><pre><strong>Diag" . str_repeat('====', $diagnostic_nesting - 1) . '|</strong> ' . $out . "</pre></div>"; } break; case 'echo_in_cronjob': if (FeedWordPress::update_requested()) { echo FeedWordPress::log_prefix() . " " . $out . "\n"; } break; case 'admin_footer': $feedwordpress_admin_footer[] = $out; break; case 'error_log': error_log(FeedWordPress::log_prefix() . ' ' . $out); break; case 'email': if (is_null($persist)) { $sect = 'occurrent'; $hook = isset($dlog['mesg'][$sect]) ? count($dlog['mesg'][$sect]) : 0; $line = array("Time" => time(), "Message" => $out); } else { $sect = 'persistent'; $hook = md5($level . "\n" . $persist); $line = array("Since" => $since, "Message" => $out, "Most Recent" => $mostRecent); } if (!isset($dlog['mesg'])) { $dlog['mesg'] = array(); } if (!isset($dlog['mesg'][$sect])) { $dlog['mesg'][$sect] = array(); } $dlog['mesg'][$sect][$hook] = $line; } } } update_option('feedwordpress_diagnostics_log', $dlog); }
function stale() { if (get_option('feedwordpress_automatic_updates')) { $last = get_option('feedwordpress_last_update_all'); // If we haven't updated all yet, give it a time window if (false === $last) { $ret = false; update_option('feedwordpress_last_update_all', time()); // Otherwise, check against freshness interval } elseif (is_numeric($last)) { // Expect a timestamp $freshness = get_option('feedwordpress_freshness'); if (false === $freshness) { // Use default $freshness = FEEDWORDPRESS_FRESHNESS_INTERVAL; } $ret = time() - $last > $freshness; // This should never happen. } else { FeedWordPress::critical_bug('FeedWordPress::stale::last', $last, __LINE__); } // Explicit request for an update (e.g. from a cron job). } elseif (FeedWordPress::update_requested()) { $ret = true; } else { $ret = false; } return $ret; }