PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.2
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
wordpress-seo / src / integrations / admin / indexables-exclude-taxonomy-integration.php

indexables-exclude-taxonomy-integration.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.2, at src/integrations/admin/indexables-exclude-taxonomy-integration.php

56 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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