← All changes
|
includes/classes/Feature/RelatedPosts/RelatedPosts.php
+22
-23
5.0.0
→
5.3.5
View file →
| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | namespace ElasticPress\Feature\RelatedPosts; |
| 10 | 10 | |
| 11 | -use \WP_Query; | |
| 11 | +use WP_Query; | |
| 12 | 12 | use ElasticPress\Elasticsearch; |
| 13 | 13 | use ElasticPress\Feature; |
| 14 | 14 | use ElasticPress\REST; |
| 15 | 15 | use ElasticPress\Utils; |
| @@ -25,17 +25,27 @@ | ||
| 25 | 25 | */ |
| 26 | 26 | public function __construct() { |
| 27 | 27 | $this->slug = 'related_posts'; |
| 28 | 28 | |
| 29 | - $this->title = esc_html__( 'Related Posts', 'elasticpress' ); | |
| 29 | + $this->group = 'core-search'; | |
| 30 | 30 | |
| 31 | - $this->summary = '<p>' . __( 'Instantly deliver engaging and precise related content with no impact on site performance. Output related content using our block or directly in your theme using our <a href="https://elasticpress.zendesk.com/hc/en-us/articles/16671825423501-Features#related-posts">API functions</a>.', 'elasticpress' ) . '</p>'; | |
| 31 | + $this->requires_install_reindex = false; | |
| 32 | 32 | |
| 33 | - $this->docs_url = __( 'https://elasticpress.zendesk.com/hc/en-us/articles/360050447492-Configuring-ElasticPress-via-the-Plugin-Dashboard#related-posts', 'elasticpress' ); | |
| 33 | + parent::__construct(); | |
| 34 | + } | |
| 34 | 35 | |
| 35 | - $this->requires_install_reindex = false; | |
| 36 | + /** | |
| 37 | + * Sets i18n strings. | |
| 38 | + * | |
| 39 | + * @return void | |
| 40 | + * @since 5.2.0 | |
| 41 | + */ | |
| 42 | + public function set_i18n_strings(): void { | |
| 43 | + $this->title = esc_html__( 'Related Posts', 'elasticpress' ); | |
| 36 | 44 | |
| 37 | - parent::__construct(); | |
| 45 | + $this->summary = '<p>' . __( 'Instantly deliver engaging and precise related content with no impact on site performance. Output related content using our block or directly in your theme using our <a href="https://www.elasticpress.io/resources/articles/related-posts-api/">API functions</a>.', 'elasticpress' ) . '</p>'; | |
| 46 | + | |
| 47 | + $this->docs_url = __( 'https://www.elasticpress.io/resources/articles/configuring-elasticpress-via-the-plugin-dashboard/#related-posts', 'elasticpress' ); | |
| 38 | 48 | } |
| 39 | 49 | |
| 40 | 50 | /** |
| 41 | 51 | * Format args for related posts |
| @@ -113,16 +123,16 @@ | ||
| 113 | 123 | /** |
| 114 | 124 | * Search Elasticsearch for related content |
| 115 | 125 | * |
| 116 | 126 | * @param int $post_id Post ID |
| 117 | - * @param int $return Return code | |
| 127 | + * @param int $post_return Number of posts to return | |
| 118 | 128 | * @since 4.1.0 |
| 119 | 129 | * @return WP_Query |
| 120 | 130 | */ |
| 121 | - public function get_related_query( $post_id, $return = 5 ) { | |
| 131 | + public function get_related_query( $post_id, $post_return = 5 ) { | |
| 122 | 132 | $args = array( |
| 123 | 133 | 'more_like' => $post_id, |
| 124 | - 'posts_per_page' => $return, | |
| 134 | + 'posts_per_page' => $post_return, | |
| 125 | 135 | 'ep_integrate' => true, |
| 126 | 136 | 'ignore_sticky_posts' => true, |
| 127 | 137 | ); |
| 128 | 138 | |
| @@ -140,9 +150,9 @@ | ||
| 140 | 150 | /** |
| 141 | 151 | * Search Elasticsearch for related content |
| 142 | 152 | * |
| 143 | 153 | * @param int $post_id Post ID |
| 144 | - * @param int $return Return code | |
| 154 | + * @param int $post_return Number of posts to return | |
| 145 | 155 | * |
| 146 | 156 | * @since 2.1 |
| 147 | 157 | * @uses get_related_query |
| 148 | 158 | * |
| @@ -147,10 +157,10 @@ | ||
| 147 | 157 | * @uses get_related_query |
| 148 | 158 | * |
| 149 | 159 | * @return array|bool |
| 150 | 160 | */ |
| 151 | - public function find_related( $post_id, $return = 5 ) { | |
| 152 | - $query = $this->get_related_query( $post_id, $return ); | |
| 161 | + public function find_related( $post_id, $post_return = 5 ) { | |
| 162 | + $query = $this->get_related_query( $post_id, $post_return ); | |
| 153 | 163 | |
| 154 | 164 | if ( ! $query->have_posts() ) { |
| 155 | 165 | return false; |
| 156 | 166 | } |
| @@ -273,17 +283,6 @@ | ||
| 273 | 283 | public function hide_legacy_widget( $widgets ) { |
| 274 | 284 | $widgets[] = 'ep-related-posts'; |
| 275 | 285 | |
| 276 | 286 | return $widgets; |
| 277 | - } | |
| 278 | - | |
| 279 | - /** | |
| 280 | - * Output feature box long | |
| 281 | - * | |
| 282 | - * @since 2.1 | |
| 283 | - */ | |
| 284 | - public function output_feature_box_long() { | |
| 285 | - ?> | |
| 286 | - <p><?php echo wp_kses_post( __( 'Output related content using our Widget or directly in your theme using our <a href="https://elasticpress.zendesk.com/hc/en-us/articles/16671825423501-Features#related-posts">API functions.</a>', 'elasticpress' ) ); ?></p> | |
| 287 | - <?php | |
| 288 | 287 | } |
| 289 | 288 | } |