Example #1
0
    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 
    }
Example #2
0
 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')));
     }
 }
Example #3
0
 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&#8230;', '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&amp;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&amp;networkwide=1&amp;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));
     }
 }
 /**
  * Register everything we need
  */
 public static function bootstrap()
 {
     spl_autoload_register(array(get_class(), 'autoload'));
     self::$installed = get_option('sputnik_installed', array());
     self::$suspended = get_option('sputnik_suspended', array());
     //add_action('activated_plugin', array(get_class(), 'clear_installed'));
     //add_action('deactivated_plugin', array(get_class(), 'clear_installed'));
     // 'deactivated_plugin' runs before saving, so we have to do this instead:
     add_action('update_option_active_plugins', array(get_class(), 'clear_installed'));
     add_action('plugins_loaded', array(get_class(), 'loaded'));
     add_action('init', array(get_class(), 'init'));
     add_action('init', array(get_class(), 'check_for_saas_push'));
     add_action('init', array(get_class(), 'thumbnails'));
     add_action('init', array(get_class(), 'credentials'));
     add_action('wp', array(get_class(), 'show_login_form'));
     add_filter('extra_plugin_headers', array(get_class(), 'extra_headers'));
     add_filter('extra_theme_headers', array(get_class(), 'extra_headers'));
     add_action('wpsc_update_purchase_log_status', array(get_class(), 'push_sales_data'), 10, 4);
     add_action('init', array(get_class(), 'sales_data_postback'));
     add_filter('wpsc_purchase_log_customer_notification_raw_message', array(get_class(), 'add_download_link'), 10, 2);
     add_action('wpsc_transaction_results_shutdown', array(get_class(), 'add_download_link_page'), 10, 3);
     Sputnik_Admin::bootstrap();
     Sputnik_Updater::bootstrap();
     Sputnik_Pointers::bootstrap();
 }
Example #5
0
 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);
 }
Example #6
0
 public function get_views()
 {
     global $tabs, $tab;
     $display_tabs = array();
     foreach ((array) $tabs as $action => $text) {
         $class = $action == $tab ? ' class="current"' : '';
         $bits = array('tab' => $action);
         if ($this->view !== 'grid') {
             $bits['view'] = $this->view;
         }
         $href = Sputnik_Admin::build_account_url($bits);
         $display_tabs['plugin-install-' . $action] = "<a href='{$href}'{$class}>{$text}</a>";
     }
     return $display_tabs;
 }
Example #7
0
    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();
    }
Example #8
0
    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 
    }
Example #9
0
    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 account()
    {
        self::$page = 'account';
        $account = false;
        try {
            $account = Sputnik::get_account();
        } catch (Exception $e) {
            if ($e->getCode() === 1) {
                $GLOBALS['tab'] = 'auth';
                return self::other_pages();
            } elseif ($e->getCode() === 401) {
                delete_option('sputnik_oauth_access');
                delete_option('sputnik_oauth_request');
                $GLOBALS['tab'] = 'auth';
                return self::other_pages();
            } else {
                self::header('Account', $account);
                echo '<p>' . sprintf(__('Problem: %s', 'wpsc'), $e->getMessage()) . '</p>';
                return;
            }
        }
        self::header('Account', $account);
        ?>
		<div class="account-card">
			<div class="block">
				<?php 
        echo get_avatar($account->email);
        ?>
				<p class="lead-in">Logged in as</p>
				<h3><?php 
        echo esc_html($account->name);
        ?>
</h3>
				<p><?php 
        printf(__('<a href="%s">Log out</a> of your account', 'wpsc'), self::build_url(array('oauth' => 'reset')));
        ?>
</p>
			</div>
			<div class="block">
				<p>Email: <code><?php 
        echo $account->email;
        ?>
</code></p>
				<p class="stat"><?php 
        printf(__('<strong>%d</strong> <abbr title="Plugins you can install right now">Available</abbr>', 'wpsc'), count($account->purchased));
        ?>
</p>
				<p class="stat"><?php 
        printf(__('<strong>%d</strong> <abbr title="Plugins you have bought from the store">Purchased</abbr>', 'wpsc'), count(self::$list_table->items));
        ?>
</p>
			</div>
		</div>

<?php 
        self::$list_table->views();
        self::$list_table->display();
    }
Example #11
0
    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 
    }
Example #12
0
    public function display()
    {
        global $tab;
        require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
        $api = $this->api;
        $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'img' => array('src' => array(), 'class' => array(), 'alt' => array()));
        $plugins_section_titles = array('description' => _x('Description', 'Plugin installer section title', 'sputnik'), 'installation' => _x('Installation', 'Plugin installer section title', 'sputnik'), 'faq' => _x('FAQ', 'Plugin installer section title', 'sputnik'), 'screenshots' => _x('Screenshots', 'Plugin installer section title', 'sputnik'), 'changelog' => _x('Changelog', 'Plugin installer section title', 'sputnik'), 'other_notes' => _x('Other Notes', 'Plugin installer section title', 'sputnik'));
        //Sanitize HTML
        $api->sections = (array) $api->sections;
        $api->author = links_add_target($api->author, '_blank');
        foreach ($api->sections as $section_name => $content) {
            $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags);
        }
        $api->screenshots = (array) $api->screenshots;
        foreach ($api->screenshots as &$data) {
            if (!isset($data->caption) || !isset($data->location)) {
                continue;
            }
            $data->caption = wp_kses($data->caption, $plugins_allowedtags);
            $data->location = esc_url($data->location, array('http', 'https'));
        }
        unset($data);
        foreach (array('version', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key) {
            if (isset($api->{$key})) {
                $api->{$key} = wp_kses($api->{$key}, $plugins_allowedtags);
            }
        }
        $section = isset($_REQUEST['section']) ? stripslashes($_REQUEST['section']) : 'description';
        //Default to the Description tab, Do not translate, API returns English.
        if (empty($section) || !isset($api->sections[$section]) && ($section !== 'screenshots' || empty($api->screenshots))) {
            $section = array_shift($section_titles = array_keys((array) $api->sections));
        }
        ?>
		<div class="alignleft fyi">
			<h1><?php 
        echo $api->name;
        ?>
</h1>
			<?php 
        if (!empty($api->download_link) && (current_user_can('install_plugins') || current_user_can('update_plugins'))) {
            ?>
			<p class="action-button">
<?php 
            $status = Sputnik_Admin::install_status($api);
            switch ($status['status']) {
                case 'purchase':
                default:
                    if ($status['url']) {
                        echo '<a href="' . $status['url'] . '" target="_parent" class="button-primary buy">' . sprintf(__('<span>$%.2f</span> Buy &amp; Install', 'sputnik'), $api->price) . '</a>';
                    }
                    break;
                case 'install':
                    if ($status['url']) {
                        echo '<a href="' . $status['url'] . '" class="button-primary install" title="' . __('You have already purchased, install now', 'sputnik') . '">' . __('Install Now', 'sputnik') . '</a>';
                    }
                    break;
                case 'update_available':
                    if ($status['url']) {
                        echo '<a href="' . $status['url'] . '" class="button-primary install">' . __('Install Update Now', 'sputnik') . '</a>';
                    }
                    break;
                case 'newer_installed':
                    echo '<a>' . sprintf(__('Newer Version (%s) Installed', 'sputnik'), $status['version']) . '</a>';
                    break;
                case 'latest_installed':
                    echo '<a>' . __('Latest Version Installed', 'sputnik') . '</a>';
                    break;
            }
            ?>
			</p>
			<?php 
        }
        echo "<div id='plugin-information-header'>\n";
        echo "<ul id='sidemenu'>\n";
        foreach ((array) $api->sections as $section_name => $content) {
            if (isset($plugins_section_titles[$section_name])) {
                $title = $plugins_section_titles[$section_name];
            } else {
                $title = ucwords(str_replace('_', ' ', $section_name));
            }
            $class = $section_name == $section ? ' class="current"' : '';
            $href = add_query_arg(array('tab' => $tab, 'section' => $section_name));
            $href = esc_url($href);
            $san_section = esc_attr($section_name);
            echo "\t<li><a name='{$san_section}' href='{$href}'{$class}>{$title}</a></li>\n";
        }
        if (!empty($api->screenshots)) {
            $title = $plugins_section_titles['screenshots'];
            $class = 'screenshots' == $section ? ' class="current"' : '';
            $href = add_query_arg(array('tab' => $tab, 'section' => 'screenshots'));
            $href = esc_url($href);
            echo "\t<li><a name='screenshots' href='{$href}'{$class}>{$title}</a></li>\n";
        }
        echo "</ul>\n";
        echo "</div>\n";
        ?>
			<h2 class="mainheader"><?php 
        /* translators: For Your Information */
        _e('FYI', 'sputnik');
        ?>
</h2>
			<ul>
	<?php 
        if (!empty($api->version)) {
            ?>
				<li><strong><?php 
            _e('Version:', 'sputnik');
            ?>
</strong> <?php 
            echo $api->version;
            ?>
</li>
	<?php 
        }
        if (!empty($api->author)) {
            ?>
				<li><strong><?php 
            _e('Author:', 'sputnik');
            ?>
</strong> <?php 
            echo $api->author;
            ?>
</li>
	<?php 
        }
        if (!empty($api->last_updated)) {
            ?>
				<li><strong><?php 
            _e('Last Updated:', 'sputnik');
            ?>
</strong> <span title="<?php 
            echo $api->last_updated;
            ?>
"><?php 
            printf(__('%s ago', 'sputnik'), human_time_diff(strtotime($api->last_updated)));
            ?>
</span></li>
	<?php 
        }
        if (!empty($api->requires)) {
            ?>
				<li><strong><?php 
            _e('Requires WordPress Version:', 'sputnik');
            ?>
</strong> <?php 
            printf(__('%s or higher', 'sputnik'), $api->requires);
            ?>
</li>
	<?php 
        }
        if (!empty($api->tested)) {
            ?>
				<li><strong><?php 
            _e('Compatible up to:', 'sputnik');
            ?>
</strong> <?php 
            echo $api->tested;
            ?>
</li>
	<?php 
        }
        if (!empty($api->downloaded)) {
            ?>
				<li><strong><?php 
            _e('Downloaded:', 'sputnik');
            ?>
</strong> <?php 
            printf(_n('%s time', '%s times', $api->downloaded, 'sputnik'), number_format_i18n($api->downloaded));
            ?>
</li>
	<?php 
        }
        if (!empty($api->homepage)) {
            ?>
				<li><a target="_blank" href="<?php 
            echo $api->homepage;
            ?>
"><?php 
            _e('Plugin Homepage  &#187;', 'sputnik');
            ?>
</a></li>
	<?php 
        }
        ?>
			</ul>

		</div>
		<div id="section-holder" class="wrap">
		<?php 
        if (!empty($api->tested) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>')) {
            echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.', 'sputnik') . '</p></div>';
        } else {
            if (!empty($api->requires) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<')) {
                echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.', 'sputnik') . '</p></div>';
            }
        }
        foreach ($api->sections as $section_name => $content) {
            if (isset($plugins_section_titles[$section_name])) {
                $title = $plugins_section_titles[$section_name];
            } else {
                $title = ucwords(str_replace('_', ' ', $section_name));
            }
            $content = links_add_base_url($content, $api->permalink);
            $content = links_add_target($content, '_blank');
            $san_section = esc_attr($title);
            $display = $section_name == $section ? 'block' : 'none';
            echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
            echo "\t\t<h2 class='long-header'>{$title}</h2>";
            echo $content;
            echo "\t</div>\n";
        }
        if (!empty($api->screenshots)) {
            $display = 'screenshots' == $section ? 'block' : 'none';
            echo "\t<div id='section-screenshots' class='section' style='display: {$display};'>\n";
            echo "\t\t<h2 class='long-header'>Screenshots</h2>\n";
            echo "\t\t<ol>\n";
            foreach ($api->screenshots as $data) {
                echo "\t\t\t<li><img src='{$data->location}' class='screenshot' /><p>{$data->caption}</p></li>\n";
            }
            echo "\t\t</ol>\n";
            echo "\t</div>\n";
        }
        echo "</div>\n";
    }
Example #13
0
    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 
    }
Example #14
0
 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>';
 }
Example #15
0
 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;
 }