public static function print_footer_scripts() { $content = '<h3>' . __('New Feature: WPeC Add-Ons') . '</h3>'; $content .= '<p>' . __('Ever wanted to be able to find an extension for your e-commerce store, purchase, install and activate it right from WordPress? Now you can!', 'wpsc') . '</p>'; $content .= '<p>' . __('Find the latest and greatest free and premium plugins from the WP E-Commerce community in our <a href="' . Sputnik_Admin::build_url() . '">Add-Ons page</a>.', 'wpsc') . '</p>'; ?> <script type="text/javascript">// <![CDATA[ jQuery(document).ready(function($) { var wpsc_target; $('#menu-posts-wpsc-product div ul li a[href$="page=sputnik"]').attr( 'id', 'marketplace-link' ); wpsc_target = $('#menu-posts-wpsc-product').hasClass('wp-has-current-submenu') ? $('#marketplace-link') : $('#menu-posts-wpsc-product'); wpsc_target.pointer({ content: '<?php echo $content; ?> ', position: { edge: 'left', align: 'center' }, close: function() { $.post( ajaxurl, { pointer: 'wpsc_marketplace_pointer', action: 'dismiss-wp-pointer' }); } }).pointer('open'); }); // ]]></script> <?php }
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 after() { $plugin_file = $this->upgrader->plugin_info(); $install_actions = array(); $from = isset($_GET['from']) ? stripslashes($_GET['from']) : 'plugins'; // One-Click flow if (!empty($_GET['also']) && $_GET['also'] == 'activate') { if (!$this->result || is_wp_error($this->result)) { show_message(__('Cannot activate plugin.', 'wpsc')); } else { show_message(__('Activating the plugin…', 'wpsc')); echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=0&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '"></iframe>'; } } else { $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin', 'wpsc') . '" target="_parent">' . __('Activate Plugin', 'wpsc') . '</a>'; if (is_multisite() && current_user_can('manage_network_plugins')) { $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network', 'wpsc') . '" target="_parent">' . __('Network Activate', 'wpsc') . '</a>'; unset($install_actions['activate_plugin']); } } $install_actions['store'] = '<a href="' . Sputnik_Admin::build_url() . '" title="' . esc_attr__('Return to Store', 'wpsc') . '" target="_parent" class="close">' . __('Return to Store', 'wpsc') . '</a>'; if (!$this->result || is_wp_error($this->result)) { unset($install_actions['activate_plugin']); unset($install_actions['network_activate']); } $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file); if (!empty($install_actions)) { $this->feedback(implode(' | ', (array) $install_actions)); } }
public function get_view_url($view) { $bits = array('tab' => $view); if ($this->view->id !== 'grid') { $bits['view'] = $this->view->id; } return Sputnik_Admin::build_url($bits); }
public function no_items() { global $tab; echo '<p>'; if ($tab === 'yours') { _e("You haven't created any plugins yet. Check out our <a href='http://developer.renku.me/'>developer documentation</a> to find out how!", 'wp-e-commerce'); } else { printf(__("You haven't purchased any plugins yet. Why not <a href='%s'>buy some</a>?", 'wp-e-commerce'), Sputnik_Admin::build_url()); } echo '</p>'; }
public function render() { if (isset($_GET['auth']) && $_GET['auth'] == 'denied') { Sputnik_Admin::add_message(__('Account linking cancelled. Please note that you need to link your account in order to access the store.', 'wp-e-commerce')); } $this->header(); $oauth_url = Sputnik_Admin::build_url(array('oauth' => 'request')); ?> <div id="sputnik-auth"> <iframe src="<?php echo $oauth_url; ?> "></iframe> </div> <?php $this->footer(); }
protected static function display_as_grid($plugin, $style) { $name = strip_tags($plugin->name); $action_links = array(); $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true)) . '" class="thickbox button info" title="' . esc_attr(sprintf(__('More information about %s', 'wp-e-commerce'), $name)) . '">' . __('Details', 'wp-e-commerce') . '</a>'; $purchase_link = $plugin->price; if (current_user_can('install_plugins') || current_user_can('update_plugins')) { $status = Sputnik_Admin::install_status($plugin); switch ($status['status']) { case 'purchase': if ($status['url']) { $purchase_link = '<a id="' . $plugin->slug . '" class="button-primary buy status" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Buy %s', 'wp-e-commerce'), $name)) . '">' . __('Buy Now', 'wp-e-commerce') . '</a>'; } break; case 'install': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']); $purchase_link = '<a class="button install status" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Install %s', 'wp-e-commerce'), $name)) . '">' . __('Install', 'wp-e-commerce') . '</a>'; } else { $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wp-e-commerce') . '">' . __('Install', 'wp-e-commerce') . '</span>'; } break; case 'update_available': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']); $purchase_link = '<a class="button install" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Update to version %s', 'wp-e-commerce'), $status['version'])) . '">' . __('Update', 'wp-e-commerce') . '</a>'; } else { $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wp-e-commerce') . '">' . __('Update', 'wp-e-commerce') . '</span>'; } break; case 'latest_installed': case 'newer_installed': $purchase_link = '<span class="status" title="' . esc_attr__('This plugin is already installed and is up to date', 'wp-e-commerce') . ' ">' . __('Installed', 'wp-e-commerce') . '</span>'; break; } } $action_links = apply_filters('sputnik_install_grid_action_links', $action_links, $plugin); $thumb = ''; if (!empty($plugin->thumb)) { $thumb = $plugin->thumb; } $thumb = apply_filters('wpsc_marketplace_plugin_thumbnail_img_src', $thumb, $plugin); ?> <div> <div class="sputnik-plugin<?php if (!empty($plugin->thumb)) { echo ' has-thumb'; } ?> "> <div class="sputnik-card"> <h4><?php echo $name; ?> <span class="price"><?php echo $plugin->price; ?> </span></h4> <?php if (!empty($thumb)) { ?> <div class="sputnik-plugin-thumb"> <img src="<?php echo esc_url($thumb); ?> " alt="<?php echo esc_attr($name); ?> Thumbnail"> </div> <?php } ?> <div class="sputnik-plugin-details"> <p><?php echo $plugin->description; ?> </p> <?php if (isset($plugin->rating) && isset($plugin->rating->count)) { ?> <div class="footer" style="display:none"> <div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'wp-e-commerce'), number_format_i18n($plugin->rating->count)); ?> "> <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average); ?> px"></div> <?php $color = get_user_option('admin_color'); if (empty($color) || 'fresh' == $color) { $star_url = admin_url('images/stars.png?v=20110615'); } else { $star_url = admin_url('images/stars.png?v=20110615'); } // 'Classic' Blue star ?> <div class="star star5"><img src="<?php echo $star_url; ?> " alt="" /></div> <div class="star star4"><img src="<?php echo $star_url; ?> " alt="" /></div> <div class="star star3"><img src="<?php echo $star_url; ?> " alt="" /></div> <div class="star star2"><img src="<?php echo $star_url; ?> " alt="" /></div> <div class="star star1"><img src="<?php echo $star_url; ?> " alt="" /></div> </div> </div> <?php } ?> </div> </div> <div class="sputnik-plugin-actions"> <?php if (!empty($action_links)) { echo implode(' ', $action_links); } ?> <?php echo $purchase_link; ?> </div> </div> </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'); }
protected function display_row($plugin, $style) { $name = strip_tags($plugin->name . ' ' . $plugin->version); $action_links = array(); $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true)) . '" class="button thickbox info" title="' . esc_attr(sprintf(__('More information about %s', 'wpsc'), $name)) . '">' . __('Details') . '</a>'; $purchase_link = $plugin->price; if ($plugin->slug === '__add_new') { $status = 'addown'; $style['name'] .= ' class="addown"'; $action_links = array(); $action_links[] = '<a href="http://developer.renku.me/" class="thickbox button info">' . __('Documentation', 'wpsc') . '</a>'; $purchase_link = '<a class="button-primary addown" href="' . Sputnik::SITE_BASE . '/plugins/add/" title="Add New Plugin">' . esc_html__('Add Now', 'wpsc') . '</a>'; } elseif (current_user_can('install_plugins') || current_user_can('update_plugins')) { $status = Sputnik_Admin::install_status($plugin); switch ($status['status']) { case 'purchase': if ($status['url']) { $purchase_link = '<a id="' . $plugin->slug . '" class="button-primary buy" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Buy %s', 'wpsc'), $name)) . '">' . sprintf(__('<span>%s</span> Buy Now</a>', 'wpsc'), $plugin->price); } break; case 'install': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']); $purchase_link = '<a class="button install" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Install %s', 'wpsc'), $name)) . '">' . __('Install', 'wpsc') . '</a>'; } else { $purchase_link = '<span title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc') . '">' . __('Install', 'wpsc') . '</span>'; } break; case 'update_available': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']); $purchase_link = '<a class="button install" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Update to version %s', 'wpsc'), $status['version'])) . '">' . __('Update', 'wpsc') . '</a>'; } else { $purchase_link = '<span title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc') . '">' . __('Update', 'wpsc') . '</span>'; } break; case 'latest_installed': case 'newer_installed': $purchase_link = '<span title="' . esc_attr__('This plugin is already installed and is up to date', 'wpsc') . ' ">' . __('Installed', 'wpsc') . '</span>'; break; } } $action_links = apply_filters('sputnik_install_row_action_links', $action_links, $plugin); ?> <tr> <td class="name column-name"<?php echo $style['name']; ?> ><strong><?php echo $plugin->name; ?> </strong> <div class="action-links"><?php if (!empty($action_links)) { echo implode(' ', $action_links); } ?> </div> </td> <td class="vers column-version"<?php echo $style['version']; ?> ><?php echo $plugin->version; ?> </td> <td class="vers column-price"<?php echo $style['price']; ?> ><?php echo $purchase_link; ?> </td> <td class="vers column-rating"<?php echo $style['rating']; ?> > <div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'wpsc'), number_format_i18n($plugin->rating->count)); ?> "> <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average); ?> px"></div> </div> </td> <td class="desc column-description"<?php echo $style['description']; ?> ><?php echo $plugin->description, $plugin->author; ?> </td> </tr> <?php }
protected function display_row($plugin, $style) { $name = strip_tags($plugin->name . ' ' . $plugin->version); $action_links = array(); $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true)) . '" class="thickbox button info" title="' . esc_attr(sprintf(__('More information about %s', 'sputnik'), $name)) . '">' . __('Details', 'sputnik') . '</a>'; $purchase_link = $plugin->price; if ($plugin->slug === '__add_new') { $status = 'addown'; $name = $plugin->name; $action_links = array(); $action_links[] = '<a href="http://developer.renku.me/" class="thickbox button info">' . __('Documentation', 'sputnik') . '</a>'; $purchase_link = '<a class="button-primary addown status" href="' . Sputnik::SITE_BASE . '/plugins/add/">' . esc_html__('Add Now', 'sputnik') . '</a>'; } elseif (current_user_can('install_plugins') || current_user_can('update_plugins')) { $status = Sputnik_Admin::install_status($plugin); switch ($status['status']) { case 'purchase': if ($status['url']) { $purchase_link = '<a id="' . $plugin->slug . '" class="button-primary buy status" href="' . $status['url'] . '" title="' . esc_attr(sprintf(__('Buy %s', 'sputnik'), $name)) . '">' . __('Buy Now', 'sputnik') . '</a>'; } break; case 'install': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), $status['url']); $purchase_link = '<a class="button install status" href="' . $status['url'] . '" title="' . esc_attr(sprintf(__('Install %s', 'sputnik'), $name)) . '">' . __('Install', 'sputnik') . '</a>'; } else { $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'sputnik') . '">' . __('Install', 'sputnik') . '</span>'; } break; case 'update_available': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), $status['url']); $purchase_link = '<a class="button install" href="' . $status['url'] . '" title="' . esc_attr(sprintf(__('Update to version %s', 'sputnik'), $status['version'])) . '">' . __('Update', 'sputnik') . '</a>'; } else { $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'sputnik') . '">' . __('Update', 'sputnik') . '</span>'; } break; case 'latest_installed': case 'newer_installed': $purchase_link = '<span class="status" title="' . esc_attr__('This plugin is already installed and is up to date', 'sputnik') . ' ">' . __('Installed', 'sputnik') . '</span>'; break; } } $action_links = apply_filters('sputnik_install_grid_action_links', $action_links, $plugin); $thumb = false; if (isset($plugin->thumb) && $plugin->thumb !== false) { $thumb = $plugin->thumb; } ?> <div> <div class="sputnik-plugin<?php if ($thumb !== false) { echo ' has-thumb'; } if ($status === 'addown') { echo ' addown'; } ?> "> <div class="sputnik-card"> <?php if ($thumb !== false) { ?> <div class="sputnik-plugin-thumb"> <img src="<?php echo esc_url($thumb); ?> " alt="<?php echo esc_attr($name); ?> Thumbnail"> </div> <?php } ?> <div class="sputnik-plugin-details"> <h4><?php echo $name; ?> </h4> <span class="price"><?php echo $plugin->price; ?> </span> <p><?php echo $plugin->description; ?> </p> <div class="footer"> <div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'sputnik'), number_format_i18n($plugin->rating->count)); ?> "> <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average); ?> px"></div> </div> </div> </div> </div> </div> <div class="sputnik-plugin-actions"> <?php if (!empty($action_links)) { echo implode(' ', $action_links); } ?> <?php echo $purchase_link; ?> </div> </div> <?php }
public static function get_checkout_token($product) { self::authenticate(); $url = '/purchase/get_checkout_token/' . $product->client_product_id; $request = self::$auth->sign($url, 'GET', array('redirect_uri' => Sputnik_Admin::build_url(array('_wpnonce' => wp_create_nonce('sputnik_install-plugin_' . $product->slug))))); $response = self::request($request->to_url(), array(), array('timeout' => 25)); return $response; }