Beispiel #1
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);
 }
Beispiel #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['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));
     }
 }