PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.4
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 / blocks / block-categories.php

block-categories.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.4, at src/integrations/blocks/block-categories.php

78 lines 1.8 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\Blocks;
4
5 use Yoast\WP\SEO\Helpers\Wordpress_Helper;
6 use Yoast\WP\SEO\Integrations\Integration_Interface;
7
8 /**
9 * Internal_Linking_Category block class.
10 */
11 class Internal_Linking_Category implements Integration_Interface {
12
13 /**
14 * Represents the WordPress helper.
15 *
16 * @var Wordpress_Helper
17 */
18 protected $wordpress_helper;
19
20 /**
21 * Internal_Linking_Category constructor.
22 *
23 * @param Wordpress_Helper $wordpress_helper The WordPress helper.
24 */
25 public function __construct( Wordpress_Helper $wordpress_helper ) {
26 $this->wordpress_helper = $wordpress_helper;
27 }
28
29 /**
30 * {@inheritDoc}
31 */
32 public static function get_conditionals() {
33 return [];
34 }
35
36 /**
37 * {@inheritDoc}
38 */
39 public function register_hooks() {
40 $wordpress_version = $this->wordpress_helper->get_wordpress_version();
41
42 // The 'block_categories' filter has been deprecated in WordPress 5.8 and replaced by 'block_categories_all'.
43 if ( \version_compare( $wordpress_version, '5.8-beta0', '<' ) ) {
44 \add_filter( 'block_categories', [ $this, 'add_block_categories' ] );
45 }
46 else {
47 \add_filter( 'block_categories_all', [ $this, 'add_block_categories' ] );
48 }
49 }
50
51 /**
52 * Adds Yoast block categories.
53 *
54 * @param array $categories The categories.
55 * @return array The filtered categories.
56 */
57 public function add_block_categories( $categories ) {
58 $categories[] = [
59 'slug' => 'yoast-structured-data-blocks',
60 'title' => \sprintf(
61 /* translators: %1$s expands to Yoast. */
62 \__( '%1$s Structured Data Blocks', 'wordpress-seo' ),
63 'Yoast'
64 ),
65 ];
66 $categories[] = [
67 'slug' => 'yoast-internal-linking-blocks',
68 'title' => \sprintf(
69 /* translators: %1$s expands to Yoast. */
70 \__( '%1$s Internal Linking Blocks', 'wordpress-seo' ),
71 'Yoast'
72 ),
73 ];
74
75 return $categories;
76 }
77 }
78