示例#1
0
 public function get_data($tab)
 {
     global $paged;
     try {
         switch ($tab) {
             case 'search':
                 $term = isset($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : '';
                 $api = Sputnik_API::search($term);
                 break;
             case 'account':
                 $api = Sputnik_API::get_purchased();
                 break;
             case 'featured':
             case 'popular':
             case 'new':
             case 'updated':
             case 'price':
             default:
                 $api = Sputnik_API::get_all($paged, array('browse' => $tab));
                 break;
         }
     } catch (Exception $e) {
         $this->connect_error = true;
         return false;
     }
     return array('items' => $api['body'], 'pages' => $api['headers']['x-pagecount']);
 }
示例#2
0
 public function get_data($tab)
 {
     try {
         switch ($tab) {
             case 'yours':
                 add_filter('sputnik_install_row_action_links', array(__CLASS__, 'mangle_action_for_own'), 10, 2);
                 add_filter('sputnik_install_grid_action_links', array(__CLASS__, 'mangle_action_for_own'), 10, 2);
                 $api = Sputnik_API::get_own();
                 break;
             default:
             case 'purchased':
                 $api = Sputnik_API::get_purchased();
                 break;
         }
     } catch (Exception $e) {
         $this->connect_error = true;
         return false;
     }
     $this->count = count($api['body']);
     if ($tab === 'yours') {
         $api['body'][] = (object) array('slug' => '__add_new', 'name' => __('Add Your Plugin', 'wp-e-commerce'), 'description' => __('List your plugin on the WPEconomy store. Read our developer documentation and get started!', 'wp-e-commerce'), 'rating' => (object) array('average' => 0, 'count' => 0), 'price' => 0, 'version' => '', 'author' => '', 'author_slug' => '', 'thumb' => false);
     }
     $count = 1;
     if (!empty($api['headers']['x-pagecount'])) {
         $count = $api['headers']['x-pagecount'];
     }
     return array('items' => $api['body'], 'pages' => $count);
 }
示例#3
0
 public function prepare_items()
 {
     require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
     global $tabs, $tab, $paged, $type, $term;
     wp_reset_vars(array('tab'));
     $paged = $this->get_pagenum();
     // These are the tabs which are shown on the page
     $tabs = array();
     $tabs['purchased'] = __('Purchased Plugins', 'wp-e-commerce');
     $tabs['yours'] = __('Your Plugins', 'wp-e-commerce');
     $nonmenu_tabs = array();
     //Valid actions to perform which do not have a Menu item.
     $tabs = apply_filters('install_plugins_tabs', $tabs);
     $nonmenu_tabs = apply_filters('install_plugins_nonmenu_tabs', $nonmenu_tabs);
     // If a non-valid menu tab has been selected, and its not a non-menu action.
     if (empty($tab) || !isset($tabs[$tab]) && !in_array($tab, (array) $nonmenu_tabs)) {
         $tab = key($tabs);
     }
     $args = array();
     try {
         switch ($tab) {
             case 'yours':
                 add_filter('sputnik_install_row_action_links', array(__CLASS__, 'mangle_action_for_own'), 10, 2);
                 add_filter('sputnik_install_grid_action_links', array(__CLASS__, 'mangle_action_for_own'), 10, 2);
                 $api = Sputnik_API::get_own();
                 break;
             default:
             case 'purchased':
                 $api = Sputnik_API::get_purchased();
                 break;
         }
     } catch (Exception $e) {
         $this->connect_error = true;
         return false;
     }
     if (!empty($_REQUEST['view'])) {
         switch ($_REQUEST['view']) {
             case 'grid':
             case 'list':
                 $this->view = $_REQUEST['view'];
                 break;
             default:
                 $this->view = 'grid';
                 break;
         }
     } else {
         $this->view = 'grid';
     }
     $this->items = $api['body'];
     if (isset($api['headers']['x-pagecount'])) {
         $this->set_pagination_args(array('total_items' => $api['headers']['x-pagecount'], 'per_page' => 30));
     }
 }
示例#4
0
 public function prepare_items()
 {
     require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
     global $tabs, $tab, $paged, $type, $term;
     wp_reset_vars(array('tab'));
     $paged = $this->get_pagenum();
     // These are the tabs which are shown on the page
     $tabs = array();
     $tabs['dashboard'] = __('Search', 'wp-e-commerce');
     if (Sputnik::account_is_linked()) {
         $tabs['purchased'] = __('Purchased Plugins', 'wp-e-commerce');
     } elseif ($tab == 'purchased') {
         wp_redirect(Sputnik_Admin::build_url());
         exit;
     }
     if ('search' == $tab) {
         $tabs['search'] = __('Search Results', 'wp-e-commerce');
     }
     $tabs['featured'] = _x('Featured', 'Plugin Installer', 'wp-e-commerce');
     $tabs['popular'] = _x('Popular', 'Plugin Installer', 'wp-e-commerce');
     $tabs['new'] = _x('Newest', 'Plugin Installer', 'wp-e-commerce');
     $tabs['updated'] = _x('Recently Updated', 'Plugin Installer', 'wp-e-commerce');
     $tabs['price'] = _x('Lowest Priced', 'Plugin Installer', 'wp-e-commerce');
     $nonmenu_tabs = array('account');
     //Valid actions to perform which do not have a Menu item.
     $tabs = apply_filters('install_plugins_tabs', $tabs);
     $nonmenu_tabs = apply_filters('install_plugins_nonmenu_tabs', $nonmenu_tabs);
     // If a non-valid menu tab has been selected, and its not a non-menu action.
     if (empty($tab) || !isset($tabs[$tab]) && !in_array($tab, (array) $nonmenu_tabs)) {
         $tab = key($tabs);
     }
     $args = array();
     try {
         switch ($tab) {
             case 'purchased':
                 $api = Sputnik_API::get_purchased();
                 break;
             case 'search':
                 $term = isset($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : '';
                 $api = Sputnik_API::search(urlencode($term), array('browse' => $tab), $paged);
                 break;
             case 'account':
                 $api = Sputnik_API::get_purchased();
                 break;
             case 'featured':
             case 'popular':
             case 'new':
             case 'updated':
             case 'price':
             default:
                 $api = Sputnik_API::get_all($paged, array('browse' => $tab));
                 break;
         }
     } catch (Exception $e) {
         $this->connect_error = true;
         return false;
     }
     if (!empty($_REQUEST['view'])) {
         switch ($_REQUEST['view']) {
             case 'grid':
             case 'list':
                 $this->view = $_REQUEST['view'];
                 break;
             default:
                 $this->view = 'grid';
                 break;
         }
     } else {
         $this->view = 'grid';
     }
     $this->items = $api['body'];
     $total_items = isset($api['headers']['x-pagecount']) ? $api['headers']['x-pagecount'] : -1;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => 30));
 }
 /**
  * Get purchased plugins
  *
  * @return array Plugin slugs
  */
 public static function get_purchased()
 {
     // This should be cached in a transient
     if (self::$purchased === false) {
         $purchased = Sputnik_API::get_purchased();
         self::$purchased = $purchased['body'];
     }
     return self::$purchased;
 }