ing $content Optional. Block content. Default empty string.
* @return string Rendered block type output.
*/
public function render( $attributes = array(), $content = '' ) {
if ( ! $this->is_dynamic() ) {
return '';
}
$attributes = $this->prepare_attributes_for_render( $attributes );
return (string) call_user_func( $this->render_callback, $attributes, $content );
}
/**
* Returns true if the block type is dynamic, or false otherwise. A dynamic
* block is one which defers its rendering to occur on-demand at runtime.
*
* @since 5.0.0
*
* @return bool Whether block type is dynamic.
*/
public function is_dynamic() {
return is_callable( $this->render_callback );
}
/**
* Validates attributes against the current block schema, populating
* defaulted and missing values.
*
* @since 5.0.0
*
* @param array $attributes Original block attributes.
* @return array Prepared block attributes.
*/
public function prepare_attributes_for_render( $attributes ) {
// If there are no attribute definitions for the block type, skip
// processing and return verbatim.
if ( ! isset( $this->attributes ) ) {
return $attributes;
}
foreach ( $attributes as $attribute_name => $value ) {
// If the attribute is not defined by the block type, it cannot be
// validated.
if ( ! isset( $this->attributes[ $attribute_name ] ) ) {
continue;
}
$schema = $this->attributes[ $attribute_name ];
// Validate value by JSON schema. An invalid value should revert to
// its default, if one exists. This occurs by virtue of the missing
// attributes loop immediately following. If there is not a default
// assigned, the attribute value should remain unset.
$is_valid = rest_validate_value_from_schema( $value, $schema, $attribute_name );
if ( is_wp_error( $is_valid ) ) {
unset( $attributes[ $attribute_name ] );
}
}
// Populate values of any missing attributes for which the block type
// defines a default.
$missing_schema_attributes = array_diff_key( $this->attributes, $attributes );
foreach ( $missing_schema_attributes as $attribute_name => $schema ) {
if ( isset( $schema['default'] ) ) {
$attributes[ $attribute_name ] = $schema['default'];
}
}
return $attributes;
}
/**
* Sets block type properties.
*
* @since 5.0.0
*
* @param array|string $args Array or string of arguments for registering a block type.
* See WP_Block_Type::__construct() for information on accepted arguments.
*/
public function set_props( $args ) {
$args = wp_parse_args(
$args,
array(
'render_callback' => null,
)
);
$args['name'] = $this->name;
// Setup attributes if needed.
if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
$args['attributes'] = array();
}
// Register core attributes.
foreach ( static::GLOBAL_ATTRIBUTES as $attr_key => $attr_schema ) {
if ( ! array_key_exists( $attr_key, $args['attributes'] ) ) {
$args['attributes'][ $attr_key ] = $attr_schema;
}
}
/**
* Filters the arguments for registering a block type.
*
* @since 5.5.0
*
* @param array $args Array of arguments for registering a block type.
* @param string $block_type Block type name including namespace.
*/
$args = apply_filters( 'register_block_type_args', $args, $this->name );
foreach ( $args as $property_name => $property_value ) {
$this->$property_name = $property_value;
}
}
/**
* Get all available block attributes including possible layout attribute from Columns block.
*
* @since 5.0.0
*
* @return array Array of attributes.
*/
public function get_attributes() {
return is_array( $this->attributes ) ?
$this->attributes :
array();
}
/**
* Get block variations.
*
* @since 6.5.0
*
* @return array[]
*/
public function get_variations() {
if ( ! isset( $this->variations ) ) {
$this->variations = array();
if ( is_callable( $this->variation_callback ) ) {
$this->variations = call_user_func( $this->variation_callback );
}
}
/**
* Filters the registered variations for a block type.
*
* @since 6.5.0
*
* @param array $variations Array of registered variations for a block type.
* @param WP_Block_Type $block_type The full block type object.
*/
return apply_filters( 'get_block_type_variations', $this->variations, $this );
}
/**
* Get block uses context.
*
* @since 6.5.0
*
* @return array[]
*/
public function get_uses_context() {
/**
* Filters the registered uses context for a block type.
*
* @since 6.5.0
*
* @param array $uses_context Array of registered uses context for a block type.
* @param WP_Block_Type $block_type The full block type object.
*/
return apply_filters( 'get_block_type_uses_context', $this->uses_context, $this );
}
}
Fatal error: Uncaught Error: Class "WP_Block_Type" not found in /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-includes/class-wp-block-type-registry.php:94
Stack trace:
#0 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-includes/blocks.php(707): WP_Block_Type_Registry->register()
#1 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Blocks.php(75): register_block_type()
#2 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/Common/Breadcrumbs/Block.php(49): AIOSEO\Plugin\Common\Utils\Blocks->registerBlock()
#3 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/Common/Breadcrumbs/Block.php(30): AIOSEO\Plugin\Common\Breadcrumbs\Block->register()
#4 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/Common/Breadcrumbs/Breadcrumbs.php(66): AIOSEO\Plugin\Common\Breadcrumbs\Block->__construct()
#5 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php(285): AIOSEO\Plugin\Common\Breadcrumbs\Breadcrumbs->__construct()
#6 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php(97): AIOSEO\Plugin\AIOSEO->load()
#7 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php(76): AIOSEO\Plugin\AIOSEO->init()
#8 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php(414): AIOSEO\Plugin\AIOSEO::instance()
#9 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php(96): aioseo()
#10 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-settings.php(517): include_once('...')
#11 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-config.php(87): require_once('...')
#12 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-load.php(50): require_once('...')
#13 /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-blog-header.php(13): require_once('...')
#14 /var/www/vhosts/casainfotech.co.nz/httpdocs/index.php(17): require('...')
#15 {main}
thrown in /var/www/vhosts/casainfotech.co.nz/httpdocs/wp-includes/class-wp-block-type-registry.php on line 94