| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Integrations\Admin; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Conditionals\No_Conditionals; |
| 6 |
use Yoast\WP\SEO\Helpers\Options_Helper; |
| 7 |
use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 8 |
|
| 9 |
/** |
| 10 |
* Indexables_Exclude_Taxonomy_Integration class |
| 11 |
*/ |
| 12 |
class Indexables_Exclude_Taxonomy_Integration implements Integration_Interface { |
| 13 |
|
| 14 |
use No_Conditionals; |
| 15 |
|
| 16 |
/** |
| 17 |
* The options helper. |
| 18 |
* |
| 19 |
* @var Options_Helper |
| 20 |
*/ |
| 21 |
private $options_helper; |
| 22 |
|
| 23 |
/** |
| 24 |
* Indexables_Exclude_Taxonomy_Integration constructor. |
| 25 |
* |
| 26 |
* @param Options_Helper $options_helper The options helper. |
| 27 |
*/ |
| 28 |
public function __construct( Options_Helper $options_helper ) { |
| 29 |
$this->options_helper = $options_helper; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* {@inheritDoc} |
| 34 |
*/ |
| 35 |
public function register_hooks() { |
| 36 |
\add_filter( 'wpseo_indexable_excluded_taxonomies', [ $this, 'exclude_taxonomies_for_indexation' ] ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Exclude the taxonomy from the indexable table. |
| 41 |
* |
| 42 |
* @param array $excluded_taxonomies The excluded taxonomies. |
| 43 |
* |
| 44 |
* @return array The excluded taxonomies, including specific taxonomies. |
| 45 |
*/ |
| 46 |
public function exclude_taxonomies_for_indexation( $excluded_taxonomies ) { |
| 47 |
$taxonomies_to_exclude = \array_merge( $excluded_taxonomies, [ 'wp_pattern_category' ] ); |
| 48 |
|
| 49 |
if ( $this->options_helper->get( 'disable-post_format', false ) ) { |
| 50 |
return \array_merge( $taxonomies_to_exclude, [ 'post_format' ] ); |
| 51 |
} |
| 52 |
|
| 53 |
return $taxonomies_to_exclude; |
| 54 |
} |
| 55 |
} |
| 56 |
|