protected function prepare() { include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; try { $this->api = $api = Sputnik::get_plugin($this->id); } catch (Exception $e) { status_header(500); $this->header(); echo '<p>' . $e->getMessage() . '</p>'; $this->footer(); return; } if (!Sputnik::is_purchased($this->api->slug)) { wp_redirect(Sputnik_Admin::build_url(array('buy' => $this->id))); die; } if (!current_user_can('install_plugins')) { wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'sputnik')); } check_admin_referer($this->nonce_prefix . $this->api->slug); include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $title = sprintf($this->title_format, $this->api->name . ' ' . $this->api->version); $nonce = $this->nonce_prefix . $this->id; $url = 'update.php?action=install-plugin&plugin=' . $this->id; if (isset($_GET['from'])) { $url .= '&from=' . urlencode(stripslashes($_GET['from'])); } $type = 'web'; //Install plugin type, From Web or an Upload. if ($this->api->is_theme) { $this->upgrader = new Sputnik_ThemeUpgrader(new Sputnik_View_Install_Skin(compact('title', 'url', 'nonce', 'plugin', 'api'))); } else { $this->upgrader = new Sputnik_Upgrader(new Sputnik_View_Install_Skin(compact('title', 'url', 'nonce', 'plugin', 'api'))); } }
function wpsc_beta_marketplace_bootstrap() { if (!class_exists('Sputnik')) { require_once dirname(__FILE__) . '/library/Sputnik.php'; Sputnik::$path = dirname(__FILE__); Sputnik::bootstrap(); } }
function wpec_beta_marketplace_bootstrap() { if (!get_option('_wpsc_enable_marketplace', false)) { return; } if (!class_exists('Sputnik')) { require_once dirname(__FILE__) . '/library/Sputnik.php'; Sputnik::$path = dirname(__FILE__); Sputnik::bootstrap(); } }
public function __construct() { parent::__construct(__('Plugin Information', 'sputnik')); $this->plugin = $_GET['info']; try { $account = Sputnik::get_account(); $this->api = Sputnik::get_plugin($this->plugin, $account->ID); } catch (Exception $e) { status_header(500); iframe_header(__('', 'sputnik')); echo $e->getMessage(); iframe_footer(); die; } }
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(); }
protected function header() { parent::header(); $account = Sputnik::get_account(); ?> <div class="account-card"> <div class="block"> <?php echo get_avatar($account->email); ?> <p class="lead-in"><?php _e('Logged in as', 'wp-e-commerce'); ?> </p> <h3><?php echo esc_html($account->name); ?> </h3> <p><?php printf(__('<a href="%s">Log out</a> of your account', 'wp-e-commerce'), Sputnik_Admin::build_url(array('oauth' => 'reset'))); ?> </p> </div> <div class="block"> <p><?php printf(__('Email: %s', 'wp-e-commerce'), '<code>' . $account->email . '</code>'); ?> </p> <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you can install right now">Available</abbr>', 'wp-e-commerce'), count($account->purchased)); ?> </p> <p class="stat"><?php printf(__('<strong>%d</strong> <abbr title="Plugins you have bought from the store">Purchased</abbr>', 'wp-e-commerce'), $this->count); ?> </p> </div> </div> <?php }
public function display_tablenav($which) { global $tab; if ($tab === 'account') { return; } if (!Sputnik::account_is_linked()) { return; } $account = Sputnik::get_account(); if ('top' == $which) { ?> <div class="tablenav top"> <div class="alignright actions"> <?php if (in_array($tab, array('dashboard', 'search'))) { ?> <?php Sputnik_Admin::search_form(); } switch ($this->view) { case 'list': $view = 'grid'; $name = __('Grid', 'wp-e-commerce'); break; case 'grid': $view = 'list'; $name = __('List', 'wp-e-commerce'); break; } ?> <!--<a href="<?php echo add_query_arg('view', $view); ?> " class="view-as-<?php echo $view; ?> button"><?php echo $name; ?> </a>--> </div> <?php $this->pagination($which); ?> <img src="<?php echo esc_url(wpsc_get_ajax_spinner()); ?> " class="ajax-loading list-ajax-loading" alt="" /> <br class="clear" /> </div> <?php } else { ?> <div class="tablenav bottom"> <?php $this->pagination($which); ?> <img src="<?php echo esc_url(wpsc_get_ajax_spinner()); ?> " class="ajax-loading list-ajax-loading" alt="" /> <br class="clear" /> </div> <?php } }
protected function header($title = false, $account = false) { if (func_num_args() !== 0) { debug_print_backtrace(); die; } $title = $this->title; $account = false; try { $account = Sputnik::get_account(); } catch (Exception $e) { // } if ($account !== false) { $tabs = array('dash' => __('Store', 'sputnik'), 'account' => __('Your Account', 'sputnik')); $hrefs = array('dash' => Sputnik_Admin::build_url(), 'account' => menu_page_url('sputnik-account', false)); $current = Sputnik_Admin::$page; } ?> <div class="wrap" id="sputnik-page"> <?php if ($account !== false) { ?> <?php screen_icon('sputnik'); ?> <h2 class="nav-tab-wrapper"> <?php foreach ($tabs as $page => $title) { ?> <a href="<?php echo $hrefs[$page]; ?> " class="nav-tab<?php if ($current === $page) { echo ' nav-tab-active'; } ?> "><?php echo $title; ?> </a> <?php } ?> </h2> <?php } elseif ($title !== false) { ?> <?php screen_icon('sputnik'); ?> <h2><?php echo $title; ?> </h2> <?php } ?> <?php do_action('sputnik_messages'); }
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; }
public static function mangle_update_themes($themes) { // WP saves once before checking, in case it fails static $tried = false; if (!$tried) { $tried = true; return $themes; } $ours = Sputnik::get_installed(true); if (empty($ours)) { return $themes; } $data = array(); $files = array(); foreach ($ours as $file => $theme) { // If something accidentally slipped in... if (empty($theme['Sputnik ID'])) { // ...ignore it. continue; } $name = $theme['Sputnik ID']; $files[$name] = $file; $data[$name] = $theme['Version']; } $url = Sputnik::API_BASE . '/version'; $options = array('headers' => array('X-WP-Domain' => self::domain()), 'user-agent' => 'WP eCommerce Marketplace: ' . WPSC_VERSION); $url = esc_url_raw(add_query_arg('themes', urlencode(json_encode($data)), $url)); $req = wp_safe_remote_get($url, $options); if (is_wp_error($req) || $req['response']['code'] !== 200) { return $themes; } $response = json_decode($req['body']); if (empty($response)) { return $themes; } foreach ($response as $name => $result) { $file = $files[$name]; if ($result->status === 410) { self::$suspended[$name] = $result; Sputnik::suspend_plugin($name, $file, $result); continue; } if ($result->status !== 200) { continue; } $info = (object) array('package' => $result->location, 'url' => $result->url, 'new_version' => $result->version, 'slug' => 'sputnik-' . $name, 'sputnik_id' => $name); $themes->response[$file] = $info; } return $themes; }
public function display_tablenav($which) { global $tab; if ($tab === 'account') { return; } $account = Sputnik::get_account(); if ('top' == $which) { ?> <div class="tablenav top"> <div class="alignright account"> <?php printf(__('Logged in as %s', 'wp-e-commerce'), '<a href="' . menu_page_url('sputnik-account', false) . '" class="account-link">' . $account->name . '</a>'); if ($tab === 'search') { ?> <?php Sputnik_Admin::search_form(); } ?> </div> <?php $this->pagination($which); ?> <img src="<?php echo esc_url(wpsc_get_ajax_spinner()); ?> " class="ajax-loading list-ajax-loading" alt="" /> <br class="clear" /> </div> <?php } else { ?> <div class="tablenav bottom"> <?php $this->pagination($which); ?> <img src="<?php echo esc_url(wpsc_get_ajax_spinner()); ?> " class="ajax-loading list-ajax-loading" alt="" /> <br class="clear" /> </div> <?php } }
public static function clear_installed() { delete_option('sputnik_installed'); self::$installed = self::load_installed(); }
public static function verify() { remove_action('all_admin_notices', array('Laika', 'report_error')); Sputnik::check(__FILE__, array('Laika', 'bootstrap')); }