| 61 | * Retrieve the currently-queried objects. Wrapper for $wp_query->get_queried_objects() |
| 62 | * |
| 63 | * @uses WP_Query::get_queried_objects |
| 64 | * |
| 65 | * @since 3.7.0 |
| 66 | * @access public |
| 67 | * |
| 68 | * @return object |
| 69 | */ |
| 70 | function get_queried_objects() { |
| 71 | global $wp_query; |
| 72 | return $wp_query->get_queried_objects(); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Retrieve IDs of the current queried objects. Wrapper for $wp_query->get_queried_object_ids() |
| 77 | * |
| 78 | * @uses WP_Query::get_queried_object_ids() |
| 79 | * |
| 80 | * @since 3.7.0 |
| 81 | * @access public |
| 82 | * |
| 83 | * @return int |
| 84 | */ |
| 85 | function get_queried_object_ids() { |
| 86 | global $wp_query; |
| 87 | return $wp_query->get_queried_object_ids(); |
| 88 | } |
| 89 | |
| 90 | /** |
| 3041 | * Retrieve queried objects. |
| 3042 | * |
| 3043 | * If queried objects is not set, then the queried object will be set from |
| 3044 | * the categories, tags, taxonomies, posts page, single post, page, or author |
| 3045 | * query variable. After it is set up, it will be returned. |
| 3046 | * |
| 3047 | * @since 3.7.0 |
| 3048 | * @access public |
| 3049 | * |
| 3050 | * @return array |
| 3051 | */ |
| 3052 | function get_queried_objects() { |
| 3053 | if ( isset( $this->queried_objects ) ) |
| 3054 | return $this->queried_objects; |
| 3055 | |
| 3056 | $terms = array(); |
| 3057 | $this->queried_objects = array(); |
| 3058 | $this->queried_object_ids = array(); |
| 3059 | |
| 3060 | if ( $this->is_category || $this->is_tag || $this->is_tax ) { |
| 3061 | $tax_query_in_and = wp_list_filter( $this->tax_query->queries, array( 'operator' => 'NOT IN' ), 'NOT' ); |
| 3062 | |
| 3063 | foreach ( $tax_query_in_and as $query ) { |
| 3064 | if ( 'term_id' == $query['field'] ) { |
| 3065 | foreach ( $query['terms'] as $term ) { |
| 3066 | if ( ! empty( $term ) && ! is_wp_error( $term ) ) |
| 3067 | $terms[] = get_term( $term, $query['taxonomy'] ); |
| 3068 | } |
| 3069 | } elseif ( $query['terms'] ) { |
| 3070 | foreach ( $query['terms'] as $term ) { |
| 3071 | if ( ! empty( $term ) && ! is_wp_error( $term ) ) |
| 3072 | $terms[] = get_term_by( $query['field'], $term, $query['taxonomy'] ); |
| 3073 | } |
| 3074 | } |
| 3075 | } |
| 3076 | |
| 3077 | if ( ! empty( $terms ) ) { |
| 3078 | foreach ( $terms as $term ) { |
| 3079 | if ( 'category' === $term->taxonomy ) |
| 3080 | _make_cat_compat( $term ); |
| 3081 | |
| 3082 | $this->queried_objects[] = $term; |
| 3083 | $this->queried_object_ids[] = (int) $term->term_id; |
| 3084 | } |
| 3085 | } |
| 3086 | |
| 3087 | } else { |
| 3088 | $this->queried_objects = array( $this->get_queried_object() ); |
| 3089 | $this->queried_object_ids = array( $this->get_queried_object_id() ); |
| 3090 | } |
| 3091 | |
| 3092 | return $this->queried_objects; |
| 3093 | } |
| 3094 | |
| 3095 | /** |