/** * @return array */ public function query_args() { global $gmCore; $args['status'] = $gmCore->_get('status'); $args['page'] = $gmCore->_get('pager', 1); $args['number'] = $gmCore->_get('per_page', $this->user_options["per_page_{$this->taxonomy}"]); $args['offset'] = ($args['page'] - 1) * $args['number']; $args['global'] = parent::filter_by_author($gmCore->_get('author')); $args['include'] = $gmCore->_get('include'); $args['search'] = $gmCore->_get('s'); $args['orderby'] = $gmCore->_get('orderby', $this->user_options["orderby_{$this->taxonomy}"]); $args['order'] = $gmCore->_get('order', $this->user_options["sortorder_{$this->taxonomy}"]); $args['hide_empty'] = $gmCore->_get('hide_empty'); if ($args['search'] && '#' == substr($args['search'], 0, 1)) { $args['include'] = substr($args['search'], 1); $args['search'] = false; } if ('selected' == $gmCore->_req('filter') && !empty($this->selected_items)) { $args['include'] = $this->selected_items; $args['orderby'] = $gmCore->_get('orderby', 'include'); $args['order'] = $gmCore->_get('order', 'ASC'); } $query_args = apply_filters('gmedia_terms_query_args', $args); foreach ($query_args as $key => $val) { if (empty($val) && '0' !== $val && 0 !== $val) { unset($query_args[$key]); } } return $query_args; }
/** * @return array */ public function query_args() { global $gmCore, $gmDB, $gmGallery; if ($this->edit_term) { $per_page = $this->user_options["per_page_{$this->taxonomy}_edit"]; if ('album' === $this->taxterm) { $alb_meta = $gmDB->get_metadata('gmedia_term', $this->edit_term); $orderby = !empty($alb_meta['_orderby'][0]) ? $alb_meta['_orderby'][0] : $gmGallery->options['in_album_orderby']; $order = !empty($alb_meta['_order'][0]) ? $alb_meta['_order'][0] : $gmGallery->options['in_album_order']; } elseif ('category' === $this->taxterm) { $cat_meta = $gmDB->get_metadata('gmedia_term', $this->edit_term); $orderby = !empty($cat_meta['_orderby'][0]) ? $cat_meta['_orderby'][0] : $gmGallery->options['in_category_orderby']; $order = !empty($cat_meta['_order'][0]) ? $cat_meta['_order'][0] : $gmGallery->options['in_category_order']; } elseif ('tag' === $this->taxterm) { $orderby = $gmGallery->options['in_tag_orderby']; $order = $gmGallery->options['in_tag_order']; } else { $orderby = $this->user_options['orderby_gmedia']; $order = $this->user_options['sortorder_gmedia']; } } else { $per_page = $this->user_options["per_page_gmedia"]; $orderby = $this->user_options['orderby_gmedia']; $order = $this->user_options['sortorder_gmedia']; } $args['mime_type'] = $gmCore->_get('mime_type'); $args['status'] = $gmCore->_get('status'); $args['page'] = $gmCore->_get('pager'); $args['per_page'] = $gmCore->_get('per_page', $per_page); $args['author__in'] = parent::filter_by_author($gmCore->_get('author')); $args['alb'] = $gmCore->_get('alb'); $args['album__in'] = $gmCore->_get('album__in'); $args['album__not_in'] = $gmCore->_get('album__not_in'); $args['tag_id'] = $gmCore->_get('tag_id'); $args['tag__in'] = $gmCore->_get('tag__in'); $args['tag__not_in'] = $gmCore->_get('tag__not_in'); $args['cat'] = $gmCore->_get('cat'); $args['category__in'] = $gmCore->_get('category__in'); $args['category__not_in'] = $gmCore->_get('category__not_in'); $args['category__and'] = $gmCore->_get('category__and'); $args['gmedia__in'] = $gmCore->_get('gmedia__in'); $args['s'] = $gmCore->_get('s'); $args['orderby'] = $gmCore->_get('orderby', $orderby); $args['order'] = $gmCore->_get('order', $order); if ('duplicates' === $args['gmedia__in']) { $duplicates = $gmDB->get_duplicates(); if (!empty($duplicates['duplicate_ids'])) { $args['gmedia__in'] = $duplicates['duplicate_ids']; $args['orderby'] = 'gmedia__in'; setcookie(self::$cookie_key, implode('.', $duplicates['duplicate_select'])); $_COOKIE[self::$cookie_key] = implode('.', $duplicates['duplicate_select']); $this->selected_items = $duplicates['duplicate_select']; } else { unset($args['gmedia__in']); $this->msg[] = __('No duplicates in Gmedia Library', 'grand-media'); } } if ($args['s'] && '#' == substr($args['s'], 0, 1)) { $args['gmedia__in'] = substr($args['s'], 1); $args['s'] = false; } $show_stack = false; if ('show' == $gmCore->_req('stack') && !empty($this->stack_items)) { $args['gmedia__in'] = $this->stack_items; $args['orderby'] = $gmCore->_get('orderby', 'gmedia__in'); $args['order'] = $gmCore->_get('order', 'ASC'); $show_stack = true; } if ('selected' == $gmCore->_req('filter') && !empty($this->selected_items)) { if ($show_stack) { $stack_items = wp_parse_id_list($this->stack_items); $selected_items = wp_parse_id_list($this->selected_items); $gmedia_in = array_intersect($stack_items, $selected_items); $args['gmedia__in'] = $gmedia_in; } else { $args['gmedia__in'] = $this->selected_items; $args['orderby'] = $gmCore->_get('orderby', 'gmedia__in'); $args['order'] = $gmCore->_get('order', 'ASC'); } } $query_args = apply_filters('gmedia_library_query_args', $args); foreach ($query_args as $key => $val) { if (empty($val) && '0' !== $val && 0 !== $val) { unset($query_args[$key]); } } if (!empty($query_args['author__in']) && $gmCore->caps['gmedia_show_others_media']) { $authors_names = $query_args['author__in']; foreach ($authors_names as $i => $id) { if ((int) $id) { $authors_names[$i] = get_the_author_meta('display_name', $id); } } $this->filters['filter_author'] = array('title' => __('Filter Author', 'grand-media'), 'filter' => $authors_names); } $gmDB->gmedias_album_stuff($query_args); if (!empty($query_args['album__in'])) { if (isset($query_args['within_album'])) { $filter_title = __('Exclude Album', 'grand-media'); $albums_names = array(); if (!empty($query_args['with_album__not_in'])) { $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $args['author__in'], 'include' => $query_args['with_album__not_in'])); } array_push($albums_names, __('Hide items without album', 'grand-media')); } else { $filter_title = __('Filter Album', 'grand-media'); $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $args['author__in'], 'include' => $query_args['album__in'])); } if (!empty($albums_names)) { $this->filters['filter_albums'] = array('title' => $filter_title, 'filter' => $albums_names); } } if (!empty($query_args['album__not_in'])) { if (isset($query_args['without_album'])) { $filter_title = __('Filter Album', 'grand-media'); $albums_names = array(); if (!empty($query_args['with_album__in'])) { $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $args['author__in'], 'include' => $query_args['with_album__in'])); } array_push($albums_names, __('Show items without album', 'grand-media')); } else { $filter_title = __('Exclude Album', 'grand-media'); $albums_names = $gmDB->get_terms('gmedia_album', array('fields' => 'names', 'global' => $args['author__in'], 'include' => $query_args['album__not_in'])); } if (!empty($albums_names)) { $this->filters['exclude_albums'] = array('title' => $filter_title, 'filter' => $albums_names); } } $gmDB->gmedias_category_stuff($query_args); if (!empty($query_args['category__in'])) { if (isset($query_args['within_category'])) { $filter_title = __('Exclude Category', 'grand-media'); $category_names = array(); if (!empty($query_args['with_category__not_in'])) { $category_names = $gmDB->get_terms('gmedia_category', array('fields' => 'names', 'include' => $query_args['with_category__not_in'])); } $category_names = array_push($category_names, __('Hide items without categories', 'grand-media')); } else { $filter_title = __('Filter Category', 'grand-media'); $category_names = $gmDB->get_terms('gmedia_category', array('fields' => 'names', 'include' => $query_args['category__in'])); } if (!empty($category_names)) { $this->filters['filter_categories'] = array('title' => $filter_title, 'filter' => $category_names); } } if (!empty($query_args['category__not_in'])) { if (isset($query_args['without_category'])) { $filter_title = __('Filter Category', 'grand-media'); $category_names = array(); if (!empty($query_args['with_category__in'])) { $category_names = $gmDB->get_terms('gmedia_category', array('fields' => 'names', 'include' => $query_args['with_category__in'])); } $category_names = array_push($category_names, __('Show items without categories', 'grand-media')); } else { $filter_title = __('Exclude Category', 'grand-media'); $category_names = $gmDB->get_terms('gmedia_category', array('fields' => 'names', 'include' => $query_args['category__not_in'])); } if (!empty($category_names)) { $this->filters['exclude_categories'] = array('title' => $filter_title, 'filter' => $category_names); } } $gmDB->gmedias_tag_stuff($query_args); if (!empty($query_args['tag__in'])) { $tag_names = $gmDB->get_terms('gmedia_tag', array('fields' => 'names', 'include' => $query_args['tag__in'])); if (!empty($tag_names)) { $this->filters['filter_tags'] = array('title' => __('Filter Tag', 'grand-media'), 'filter' => $tag_names); } } if (!empty($query_args['tag__not_in'])) { $tag_names = $gmDB->get_terms('gmedia_tag', array('fields' => 'names', 'include' => $query_args['tag__not_in'])); if (!empty($tag_names)) { $this->filters['exclude_tags'] = array('title' => __('Exclude Tag', 'grand-media'), 'filter' => $tag_names); } } return $query_args; }