/
abstract-exclude-post-type.php
46 lines (40 loc) · 1.14 KB
/
abstract-exclude-post-type.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Yoast\WP\SEO\Integrations;
/**
* Abstract class for excluding certain post types from being indexed.
*/
abstract class Abstract_Exclude_Post_Type implements Integration_Interface {
/**
* Initializes the integration.
*
* @return void
*/
public function register_hooks() {
\add_filter( 'wpseo_indexable_excluded_post_types', [ $this, 'exclude_post_types' ] );
}
/**
* Exclude the post type from the indexable table.
*
* @param array $excluded_post_types The excluded post types.
*
* @return array The excluded post types, including the specific post type.
*/
public function exclude_post_types( $excluded_post_types ) {
return \array_merge( $excluded_post_types, $this->get_post_type() );
}
/**
* This integration is only active when the child class's conditionals are met.
*
* @return array|string[] The conditionals.
*/
public static function get_conditionals() {
return [];
}
/**
* Returns the names of the post types to be excluded.
* To be used in the wpseo_indexable_excluded_post_types filter.
*
* @return array The names of the post types.
*/
abstract public function get_post_type();
}