← All changes
|
src/presentations/indexable-term-archive-presentation.php
+18
-10
19.0
→
trunk
View file →
| @@ -38,12 +38,9 @@ | ||
| 38 | 38 | * |
| 39 | 39 | * @param WP_Query_Wrapper $wp_query_wrapper The wp query wrapper. |
| 40 | 40 | * @param Taxonomy_Helper $taxonomy The Taxonomy helper. |
| 41 | 41 | */ |
| 42 | - public function __construct( | |
| 43 | - WP_Query_Wrapper $wp_query_wrapper, | |
| 44 | - Taxonomy_Helper $taxonomy | |
| 45 | - ) { | |
| 42 | + public function __construct( WP_Query_Wrapper $wp_query_wrapper, Taxonomy_Helper $taxonomy ) { | |
| 46 | 43 | $this->wp_query_wrapper = $wp_query_wrapper; |
| 47 | 44 | $this->taxonomy = $taxonomy; |
| 48 | 45 | } |
| 49 | 46 | |
| @@ -60,19 +57,18 @@ | ||
| 60 | 57 | if ( $this->model->canonical ) { |
| 61 | 58 | return $this->model->canonical; |
| 62 | 59 | } |
| 63 | 60 | |
| 64 | - $permalink = $this->get_permalink(); | |
| 65 | - if ( ! $permalink ) { | |
| 61 | + if ( ! $this->permalink ) { | |
| 66 | 62 | return ''; |
| 67 | 63 | } |
| 68 | 64 | |
| 69 | 65 | $current_page = $this->pagination->get_current_archive_page_number(); |
| 70 | 66 | if ( $current_page > 1 ) { |
| 71 | - return $this->pagination->get_paginated_url( $permalink, $current_page ); | |
| 67 | + return $this->pagination->get_paginated_url( $this->permalink, $current_page ); | |
| 72 | 68 | } |
| 73 | 69 | |
| 74 | - return $permalink; | |
| 70 | + return $this->permalink; | |
| 75 | 71 | } |
| 76 | 72 | |
| 77 | 73 | /** |
| 78 | 74 | * Generates the meta description. |
| @@ -92,9 +88,13 @@ | ||
| 92 | 88 | * |
| 93 | 89 | * @return array The source. |
| 94 | 90 | */ |
| 95 | 91 | public function generate_source() { |
| 96 | - return \get_term( $this->model->object_id, $this->model->object_sub_type ); | |
| 92 | + if ( ! empty( $this->model->object_id ) || \get_queried_object() === null ) { | |
| 93 | + return \get_term( $this->model->object_id, $this->model->object_sub_type ); | |
| 94 | + } | |
| 95 | + | |
| 96 | + return \get_term( \get_queried_object()->term_id, \get_queried_object()->taxonomy ); | |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Generates the Open Graph description. |
| @@ -148,9 +148,9 @@ | ||
| 148 | 148 | /** |
| 149 | 149 | * First we get the no index option for this taxonomy, because it can be overwritten the indexable value for |
| 150 | 150 | * this specific term. |
| 151 | 151 | */ |
| 152 | - if ( ! $this->taxonomy->is_indexable( $this->source->taxonomy ) ) { | |
| 152 | + if ( \is_wp_error( $this->source ) || ! $this->taxonomy->is_indexable( $this->source->taxonomy ) ) { | |
| 153 | 153 | $robots['index'] = 'noindex'; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
| @@ -172,8 +172,12 @@ | ||
| 172 | 172 | if ( $this->model->title ) { |
| 173 | 173 | return $this->model->title; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | + if ( \is_wp_error( $this->source ) ) { | |
| 177 | + return $this->model->title; | |
| 178 | + } | |
| 179 | + | |
| 176 | 180 | // Get the SEO title as entered in Search Appearance. |
| 177 | 181 | $title = $this->options->get( 'title-tax-' . $this->source->taxonomy ); |
| 178 | 182 | if ( $title ) { |
| 179 | 183 | return $title; |
| @@ -202,8 +206,12 @@ | ||
| 202 | 206 | protected function is_multiple_terms_query() { |
| 203 | 207 | $query = $this->wp_query_wrapper->get_query(); |
| 204 | 208 | |
| 205 | 209 | if ( ! isset( $query->tax_query ) ) { |
| 210 | + return false; | |
| 211 | + } | |
| 212 | + | |
| 213 | + if ( \is_wp_error( $this->source ) ) { | |
| 206 | 214 | return false; |
| 207 | 215 | } |
| 208 | 216 | |
| 209 | 217 | $queried_terms = $query->tax_query->queried_terms; |