示例#1
0
 public function categories()
 {
     if (!current_user_can('shopp_categories')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $per_page_option = get_current_screen()->get_option('per_page');
     $defaults = array('paged' => 1, 'per_page' => 20, 's' => '', 'a' => '');
     $args = array_merge($defaults, $_GET);
     if (false !== ($user_per_page = get_user_option($per_page_option['option']))) {
         $args['per_page'] = $user_per_page;
     }
     extract($args, EXTR_SKIP);
     if ('arrange' == $a) {
         $this->init_positions();
         $per_page = 300;
     }
     $paged = absint($paged);
     $start = $per_page * ($paged - 1);
     $end = $start + $per_page;
     $url = add_query_arg(array_merge($_GET, array('page' => ShoppAdmin::pagename('categories'))), admin_url('admin.php'));
     $taxonomy = 'shopp_category';
     $filters = array('hide_empty' => 0, 'fields' => 'id=>parent');
     add_filter('get_shopp_category', array($this, 'load_category'), 10, 2);
     // $filters['limit'] = "$start,$per_page";
     if (!empty($s)) {
         $filters['search'] = $s;
     }
     $Categories = array();
     $count = 0;
     $terms = get_terms($taxonomy, $filters);
     if (empty($s)) {
         $children = _get_term_hierarchy($taxonomy);
         ProductCategory::tree($taxonomy, $terms, $children, $count, $Categories, $paged, $per_page);
         $this->categories = $Categories;
     } else {
         foreach ($terms as $id => $parent) {
             $Categories[$id] = get_term($id, $taxonomy);
         }
     }
     $ids = array_keys($Categories);
     return $ids;
 }
示例#2
0
 /**
  * Interface processor for the category list manager
  *
  * @author Jonathan Davis
  * @since 1.0
  * @return void
  **/
 public function categories($workflow = false)
 {
     if (!current_user_can('shopp_categories')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $per_page_option = get_current_screen()->get_option('per_page');
     $defaults = array('paged' => 1, 'per_page' => 20, 's' => '', 'a' => '');
     $args = array_merge($defaults, $_GET);
     if (false !== ($user_per_page = get_user_option($per_page_option['option']))) {
         $args['per_page'] = $user_per_page;
     }
     extract($args, EXTR_SKIP);
     if ('arrange' == $a) {
         $this->init_positions();
         $per_page = 300;
     }
     $paged = absint($paged);
     $start = $per_page * ($paged - 1);
     $end = $start + $per_page;
     $url = add_query_arg(array_merge($_GET, array('page' => $this->Admin->pagename('categories'))), admin_url('admin.php'));
     $taxonomy = 'shopp_category';
     $filters = array('hide_empty' => 0, 'fields' => 'id=>parent');
     add_filter('get_shopp_category', array($this, 'load_category'), 10, 2);
     // $filters['limit'] = "$start,$per_page";
     if (!empty($s)) {
         $filters['search'] = $s;
     }
     $Categories = array();
     $count = 0;
     $terms = get_terms($taxonomy, $filters);
     if (empty($s)) {
         $children = _get_term_hierarchy($taxonomy);
         ProductCategory::tree($taxonomy, $terms, $children, $count, $Categories, $paged, $per_page);
         $this->categories = $Categories;
     } else {
         foreach ($terms as $id => $parent) {
             $Categories[$id] = get_term($id, $taxonomy);
         }
     }
     $ids = array_keys($Categories);
     if ($workflow) {
         return $ids;
     }
     $meta = ShoppDatabaseObject::tablename(ShoppMetaObject::$table);
     if (!empty($ids)) {
         sDB::query("SELECT * FROM {$meta} WHERE parent IN (" . join(',', $ids) . ") AND context='category' AND type='meta'", 'array', array($this, 'metaloader'));
     }
     $count = wp_count_terms('shopp_category');
     $num_pages = ceil($count / $per_page);
     $ListTable = ShoppUI::table_set_pagination($this->screen, $count, $num_pages, $per_page);
     $action = esc_url(add_query_arg(array_merge(stripslashes_deep($_GET), array('page' => $this->Admin->pagename('categories'))), admin_url('admin.php')));
     include $this->ui('categories.php');
 }