| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/wordpress-seo/inc/ |
Upload File : |
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
/**
* Class to load assets required for structured data blocks.
*/
class WPSEO_Structured_Data_Blocks implements WPSEO_WordPress_Integration {
/**
* An instance of the WPSEO_Admin_Asset_Manager class.
*
* @var WPSEO_Admin_Asset_Manager
*/
protected $asset_manager;
/**
* Registers hooks for Structured Data Blocks with WordPress.
*/
public function register_hooks() {
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
add_filter( 'block_categories', array( $this, 'add_block_category' ) );
}
/**
* Checks whether the Structured Data Blocks are disabled.
*
* @return boolean
*/
private function check_enabled() {
/**
* Filter: 'wpseo_enable_structured_data_blocks' - Allows disabling Yoast's schema blocks entirely.
*
* @api bool If false, our structured data blocks won't show.
*/
$enabled = apply_filters( 'wpseo_enable_structured_data_blocks', true );
return $enabled;
}
/**
* Enqueue Gutenberg block assets for backend editor.
*/
public function enqueue_block_editor_assets() {
if ( ! $this->check_enabled() ) {
return;
}
if ( ! $this->asset_manager ) {
$this->asset_manager = new WPSEO_Admin_Asset_Manager();
}
$this->asset_manager->enqueue_script( 'structured-data-blocks' );
$this->asset_manager->enqueue_style( 'structured-data-blocks' );
}
/**
* Adds the structured data blocks category to the Gutenberg categories.
*
* @param array $categories The current categories.
*
* @return array The updated categories.
*/
public function add_block_category( $categories ) {
if ( $this->check_enabled() ) {
$categories[] = array(
'slug' => 'yoast-structured-data-blocks',
'title' => sprintf(
/* translators: %1$s expands to Yoast. */
__( '%1$s Structured Data Blocks', 'wordpress-seo' ),
'Yoast'
),
);
}
return $categories;
}
}