PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | src/helpers/post-helper.php +22 -4 18.428.5 View file →
@@ -17,8 +17,15 @@
17 17 */
18 18 private $string;
19 19
20 20 /**
21 + * Holds the Post_Type_Helper instance.
22 + *
23 + * @var Post_Type_Helper
24 + */
25 + private $post_type;
26 +
27 + /**
21 28 * Represents the indexables repository.
22 29 *
23 30 * @var Indexable_Repository
24 31 */
@@ -28,12 +35,14 @@
28 35 * Post_Helper constructor.
29 36 *
30 37 * @codeCoverageIgnore It only sets dependencies.
31 38 *
32 - * @param String_Helper $string_helper The string helper.
39 + * @param String_Helper $string_helper The string helper.
40 + * @param Post_Type_Helper $post_type_helper The string helper.
33 41 */
34 - public function __construct( String_Helper $string_helper ) {
35 - $this->string = $string_helper;
42 + public function __construct( String_Helper $string_helper, Post_Type_Helper $post_type_helper ) {
43 + $this->string = $string_helper;
44 + $this->post_type = $post_type_helper;
36 45 }
37 46
38 47 /**
39 48 * Sets the indexable repository. Done to avoid circular dependencies.
@@ -40,8 +49,10 @@
40 49 *
41 50 * @required
42 51 *
43 52 * @param Indexable_Repository $repository The indexable repository.
53 + *
54 + * @return void
44 55 */
45 56 public function set_indexable_repository( Indexable_Repository $repository ) {
46 57 $this->repository = $repository;
47 58 }
@@ -163,8 +174,15 @@
163 174 *
164 175 * @return bool True if the post can be indexed.
165 176 */
166 177 public function is_post_indexable( $post_id ) {
178 + // Don't index posts which are not public (i.e. viewable).
179 + $post_type = \get_post_type( $post_id );
180 +
181 + if ( ! $this->post_type->is_of_indexable_post_type( $post_type ) ) {
182 + return false;
183 + }
184 +
167 185 // Don't index excluded post statuses.
168 186 if ( \in_array( \get_post_status( $post_id ), $this->get_excluded_post_statuses(), true ) ) {
169 187 return false;
170 188 }
@@ -199,9 +217,9 @@
199 217 public function get_public_post_statuses() {
200 218 /**
201 219 * Filter: 'wpseo_public_post_statuses' - List of public post statuses.
202 220 *
203 - * @api array $post_statuses Post status list, defaults to array( 'publish' ).
221 + * @param array $post_statuses Post status list, defaults to array( 'publish' ).
204 222 */
205 223 return \apply_filters( 'wpseo_public_post_statuses', [ 'publish' ] );
206 224 }
207 225 }