Ejemplo n.º 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']);
 }
Ejemplo n.º 2
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));
 }