protected function prepare() { try { $this->file = $_GET['upgrade']; $data = Sputnik::get_from_file($file); if ($data === null) { throw new Exception(__('Plugin not found', 'sputnik')); } $this->id = $data['Sputnik ID']; } catch (Exception $e) { status_header(500); iframe_header(__('Update Plugin', 'sputnik')); echo $e->getMessage(); iframe_footer(); die; } parent::prepare(); }
public static function maybe_redirect_update() { if (empty($_GET['action']) || $_GET['action'] !== 'upgrade-plugin' || empty($_REQUEST['plugin'])) { return; } $file = trim($_REQUEST['plugin']); $data = Sputnik::get_from_file($file); if ($data === null || empty($data['Sputnik ID'])) { return; } $url = self::build_url(array('upgrade' => $file)); // wp_nonce_url also does a esc_html, so do it ourselves $url = add_query_arg('_wpnonce', wp_create_nonce('sputnik_upgrade-plugin_' . $file), $url); wp_redirect(esc_url_raw($url)); die; }