PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.1
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.1
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 / structured-data-blocks.php

structured-data-blocks.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.1, at src/integrations/blocks/structured-data-blocks.php

60 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\Blocks;
4
5 use WPSEO_Admin_Asset_Manager;
6 use Yoast\WP\SEO\Integrations\Integration_Interface;
7
8 /**
9 * Class to load assets required for structured data blocks.
10 */
11 class Structured_Data_Blocks implements Integration_Interface {
12
13 /**
14 * An instance of the WPSEO_Admin_Asset_Manager class.
15 *
16 * @var WPSEO_Admin_Asset_Manager
17 */
18 protected $asset_manager;
19
20 /**
21 * {@inheritDoc}
22 */
23 public static function get_conditionals() {
24 return [];
25 }
26
27 /**
28 * Structured_Data_Blocks constructor.
29 *
30 * @param WPSEO_Admin_Asset_Manager $asset_manager The asset manager.
31 */
32 public function __construct( WPSEO_Admin_Asset_Manager $asset_manager ) {
33 $this->asset_manager = $asset_manager;
34 }
35
36 /**
37 * Registers hooks for Structured Data Blocks with WordPress.
38 */
39 public function register_hooks() {
40 \add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_block_editor_assets' ] );
41 }
42
43 /**
44 * Enqueue Gutenberg block assets for backend editor.
45 */
46 public function enqueue_block_editor_assets() {
47 /**
48 * Filter: 'wpseo_enable_structured_data_blocks' - Allows disabling Yoast's schema blocks entirely.
49 *
50 * @api bool If false, our structured data blocks won't show.
51 */
52 if ( ! \apply_filters( 'wpseo_enable_structured_data_blocks', true ) ) {
53 return;
54 }
55
56 $this->asset_manager->enqueue_script( 'structured-data-blocks' );
57 $this->asset_manager->enqueue_style( 'structured-data-blocks' );
58 }
59 }
60