public function update() { $this->init(); require_once $GLOBALS['ithemes_updater_path'] . '/updates.php'; Ithemes_Updater_Updates::run_update(); }
public static function get_response($action, $args, $cache) { require_once $GLOBALS['ithemes_updater_path'] . '/server.php'; require_once $GLOBALS['ithemes_updater_path'] . '/updates.php'; if (isset($args['packages'])) { $args['packages'] = self::get_request_package_details($args['packages']); } $response = false; $source = ''; $cached = true; $md5 = substr(md5(serialize($args)), 0, 5); $time = time(); $cache_var = "it-updater-{$action}-{$md5}"; if ($cache) { if (isset($GLOBALS[$cache_var])) { $response = $GLOBALS[$cache_var]; $source = 'GLOBALS'; } else { if (false !== ($transient = get_site_transient($cache_var))) { $response = $transient; $source = 'transient'; } } } if (false === $response) { $response = call_user_func_array(array('Ithemes_Updater_Server', $action), $args); $source = 'server'; if (is_wp_error($response)) { return $response; } $cache_length = 86400 * $GLOBALS['ithemes-updater-settings']->get_option('timeout-multiplier'); set_site_transient($cache_var, $response, $cache_length); $cached = false; } Ithemes_Updater_Updates::process_server_response($response, $cached); $GLOBALS[$cache_var] = $response; return $response; }
public static function get_response($action, $args, $cache = false) { if (!isset($GLOBALS[self::$clear_cache_index])) { $GLOBALS[self::$clear_cache_index] = false; } require_once $GLOBALS['ithemes_updater_path'] . '/server.php'; require_once $GLOBALS['ithemes_updater_path'] . '/updates.php'; if (isset($args['packages'])) { $args['packages'] = self::get_request_package_details($args['packages']); } $response = false; $source = ''; if (false !== $cache) { $cache_var = "ithemes-updater-{$action}"; $cache_length = $GLOBALS['ithemes-updater-settings']->get_option('server-cache'); $md5 = substr(md5(serialize($args)), 0, 5); $time = time(); if (!$GLOBALS[self::$clear_cache_index]) { if (isset($GLOBALS[$cache_var])) { $response = $GLOBALS[$cache_var]; $source = 'GLOBALS'; } else { if (false !== ($transient = get_site_transient($cache_var))) { if (isset($transient['md5']) && isset($transient['res']) && isset($transient['time']) && $md5 == $transient['md5'] && $time < $transient['time'] + $cache_length) { $response = $transient['res']; $source = 'transient'; } } } } if (false === $response) { $GLOBALS[self::$clear_cache_index] = false; } } else { $GLOBALS[self::$clear_cache_index] = true; } if (false === $response) { $response = call_user_func_array(array('Ithemes_Updater_Server', $action), $args); $source = 'server'; if (is_wp_error($response)) { return $response; } if (false !== $cache) { $GLOBALS[$cache_var] = $response; $transient = array('time' => $time, 'md5' => $md5, 'res' => $response); set_site_transient($cache_var, $transient, $cache_length); } } Ithemes_Updater_Updates::process_server_response($response); return $response; }