ont end and editor style handles. * * @since 6.1.0 * @var string[] */ public $style_handles = array(); /** * Block type front end only style handles. * * @since 6.5.0 * @var string[] */ public $view_style_handles = array(); /** * Deprecated block type properties for script and style handles. * * @since 6.1.0 * @var string[] */ private $deprecated_properties = array( 'editor_script', 'script', 'view_script', 'editor_style', 'style', ); /** * Attributes supported by every block. * * @since 6.0.0 Added `lock`. * @since 6.5.0 Added `metadata`. * @var array */ const GLOBAL_ATTRIBUTES = array( 'lock' => array( 'type' => 'object' ), 'metadata' => array( 'type' => 'object' ), ); /** * Constructor. * * Will populate object properties from the provided arguments. * * @since 5.0.0 * @since 5.5.0 Added the `title`, `category`, `parent`, `icon`, `description`, * `keywords`, `textdomain`, `styles`, `supports`, `example`, * `uses_context`, and `provides_context` properties. * @since 5.6.0 Added the `api_version` property. * @since 5.8.0 Added the `variations` property. * @since 5.9.0 Added the `view_script` property. * @since 6.0.0 Added the `ancestor` property. * @since 6.1.0 Added the `editor_script_handles`, `script_handles`, `view_script_handles`, * `editor_style_handles`, and `style_handles` properties. * Deprecated the `editor_script`, `script`, `view_script`, `editor_style`, and `style` properties. * @since 6.3.0 Added the `selectors` property. * @since 6.4.0 Added the `block_hooks` property. * @since 6.5.0 Added the `allowed_blocks`, `variation_callback`, and `view_style_handles` properties. * * @see register_block_type() * * @param string $block_type Block type name including namespace. * @param array|string $args { * Optional. Array or string of arguments for registering a block type. Any arguments may be defined, * however the ones described below are supported by default. Default empty array. * * @type string $api_version Block API version. * @type string $title Human-readable block type label. * @type string|null $category Block type category classification, used in * search interfaces to arrange block types by category. * @type string[]|null $parent Setting parent lets a block require that it is only * available when nested within the specified blocks. * @type string[]|null $ancestor Setting ancestor makes a block available only inside the specified * block types at any position of the ancestor's block subtree. * @type string[]|null $allowed_blocks Limits which block types can be inserted as children of this block type. * @type string|null $icon Block type icon. * @type string $description A detailed block type description. * @type string[] $keywords Additional keywords to produce block type as * result in search interfaces. * @type string|null $textdomain The translation textdomain. * @type array[] $styles Alternative block styles. * @type array[] $variations Block variations. * @type array $selectors Custom CSS selectors for theme.json style generation. * @type array|null $supports Supported features. * @type array|null $example Structured data for the block preview. * @type callable|null $render_callback Block type render callback. * @type callable|null $variation_callback Block type variations callback. * @type array|null $attributes Block type attributes property schemas. * @type string[] $uses_context Context values inherited by blocks of this type. * @type string[]|null $provides_context Context provided by blocks of this type. * @type string[] $block_hooks Block hooks. * @type string[] $editor_script_handles Block type editor only script handles. * @type string[] $script_handles Block type front end and editor script handles. * @type string[] $view_script_handles Block type front end only script handles. * @type string[] $editor_style_handles Block type editor only style handles. * @type string[] $style_handles Block type front end and editor style handles. * @type string[] $view_style_handles Block type front end only style handles. * } */ public function __construct( $block_type, $args = array() ) { $this->name = $block_type; $this->set_props( $args ); } /** * Proxies getting values for deprecated properties for script and style handles for backward compatibility. * Gets the value for the corresponding new property if the first item in the array provided. * * @since 6.1.0 * * @param string $name Deprecated property name. * * @return string|string[]|null|void The value read from the new property if the first item in the array provided, * null when value not found, or void when unknown property name provided. */ public function __get( $name ) { if ( 'variations' === $name ) { return $this->get_variations(); } if ( 'uses_context' === $name ) { return $this->get_uses_context(); } if ( ! in_array( $name, $this->deprecated_properties, true ) ) { return; } $new_name = $name . '_handles'; if ( ! property_exists( $this, $new_name ) || ! is_array( $this->{$new_name} ) ) { return null; } if ( count( $this->{$new_name} ) > 1 ) { return $this->{$new_name}; } return isset( $this->{$new_name}[0] ) ? $this->{$new_name}[0] : null; } /** * Proxies checking for deprecated properties for script and style handles for backward compatibility. * Checks whether the corresponding new property has the first item in the array provided. * * @since 6.1.0 * * @param string $name Deprecated property name. * * @return bool Returns true when for the new property the first item in the array exists, * or false otherwise. */ public function __isset( $name ) { if ( in_array( $name, array( 'variations', 'uses_context' ), true ) ) { return true; } if ( ! in_array( $name, $this->deprecated_properties, true ) ) { return false; } $new_name = $name . '_handles'; return isset( $this->{$new_name}[0] ); } /** * Proxies setting values for deprecated properties for script and style handles for backward compatibility. * Sets the value for the corresponding new property as the first item in the array. * It also allows setting custom properties for backward compatibility. * * @since 6.1.0 * * @param string $name Property name. * @param mixed $value Property value. */ public function __set( $name, $value ) { if ( ! in_array( $name, $this->deprecated_properties, true ) ) { $this->{$name} = $value; return; } $new_name = $name . '_handles'; if ( is_array( $value ) ) { $filtered = array_filter( $value, 'is_string' ); if ( count( $filtered ) !== count( $value ) ) { _doing_it_wrong( __METHOD__, sprintf( /* translators: %s: The '$value' argument. */ __( 'The %s argument must be a string or a string array.' ), '$value' ), '6.1.0' ); } $this->{$new_name} = array_values( $filtered ); return; } if ( ! is_string( $value ) ) { return; } $this->{$new_name} = array( $value ); } /** * Renders the block type output for given attributes. * * @since 5.0.0 * * @param array $attributes Optional. Block attributes. Default empty array. * @param string $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 string[] */ public function get_uses_context() { /** * Filters the registered uses context for a block type. * * @since 6.5.0 * * @param string[] $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 ); } } ength, $start_offset + $token_length, $leading_html_start ) ); $this->offset = $start_offset + $token_length; return true; case 'block-closer': /* * if we're missing an opener we're in trouble * This is an error */ if ( 0 === $stack_depth ) { /* * we have options * - assume an implicit opener * - assume _this_ is the opener * - give up and close out the document */ $this->add_freeform(); return false; } // if we're not nesting then this is easy - close the block. if ( 1 === $stack_depth ) { $this->add_block_from_stack( $start_offset ); $this->offset = $start_offset + $token_length; return true; } /* * otherwise we're nested and we have to close out the current * block and add it as a new innerBlock to the parent */ $stack_top = array_pop( $this->stack ); $html = substr( $this->document, $stack_top->prev_offset, $start_offset - $stack_top->prev_offset ); $stack_top->block->innerHTML .= $html; $stack_top->block->innerContent[] = $html; $stack_top->prev_offset = $start_offset + $token_length; $this->add_inner_block( $stack_top->block, $stack_top->token_start, $stack_top->token_length, $start_offset + $token_length ); $this->offset = $start_offset + $token_length; return true; default: // This is an error. $this->add_freeform(); return false; } } /** * Scans the document from where we last left off * and finds the next valid token to parse if it exists * * Returns the type of the find: kind of find, block information, attributes * * @internal * @since 5.0.0 * @since 4.6.1 fixed a bug in attribute parsing which caused catastrophic backtracking on invalid block comments * @return array */ public function next_token() { $matches = null; /* * aye the magic * we're using a single RegExp to tokenize the block comment delimiters * we're also using a trick here because the only difference between a * block opener and a block closer is the leading `/` before `wp:` (and * a closer has no attributes). we can trap them both and process the * match back in PHP to see which one it was. */ $has_match = preg_match( '/).)*+)?}\s+)?(?P\/)?-->/s', $this->document, $matches, PREG_OFFSET_CAPTURE, $this->offset ); // if we get here we probably have catastrophic backtracking or out-of-memory in the PCRE. if ( false === $has_match ) { return array( 'no-more-tokens', null, null, null, null ); } // we have no more tokens. if ( 0 === $has_match ) { return array( 'no-more-tokens', null, null, null, null ); } list( $match, $started_at ) = $matches[0]; $length = strlen( $match ); $is_closer = isset( $matches['closer'] ) && -1 !== $matches['closer'][1]; $is_void = isset( $matches['void'] ) && -1 !== $matches['void'][1]; $namespace = $matches['namespace']; $namespace = ( isset( $namespace ) && -1 !== $namespace[1] ) ? $namespace[0] : 'core/'; $name = $namespace . $matches['name'][0]; $has_attrs = isset( $matches['attrs'] ) && -1 !== $matches['attrs'][1]; /* * Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays * are associative arrays. If we use `array()` we get a JSON `[]` */ $attrs = $has_attrs ? json_decode( $matches['attrs'][0], /* as-associative */ true ) : array(); /* * This state isn't allowed * This is an error */ if ( $is_closer && ( $is_void || $has_attrs ) ) { // we can ignore them since they don't hurt anything. } if ( $is_void ) { return array( 'void-block', $name, $attrs, $started_at, $length ); } if ( $is_closer ) { return array( 'block-closer', $name, null, $started_at, $length ); } return array( 'block-opener', $name, $attrs, $started_at, $length ); } /** * Returns a new block object for freeform HTML * * @internal * @since 3.9.0 * * @param string $inner_html HTML content of block. * @return WP_Block_Parser_Block freeform block object. */ public function freeform( $inner_html ) { return new WP_Block_Parser_Block( null, array(), array(), $inner_html, array( $inner_html ) ); } /** * Pushes a length of text from the input document * to the output list as a freeform block. * * @internal * @since 5.0.0 * @param null $length how many bytes of document text to output. */ public function add_freeform( $length = null ) { $length = $length ? $length : strlen( $this->document ) - $this->offset; if ( 0 === $length ) { return; } $this->output[] = (array) $this->freeform( substr( $this->document, $this->offset, $length ) ); } /** * Given a block structure from memory pushes * a new block to the output list. * * @internal * @since 5.0.0 * @param WP_Block_Parser_Block $block The block to add to the output. * @param int $token_start Byte offset into the document where the first token for the block starts. * @param int $token_length Byte length of entire block from start of opening token to end of closing token. * @param int|null $last_offset Last byte offset into document if continuing form earlier output. */ public function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) { $parent = $this->stack[ count( $this->stack ) - 1 ]; $parent->block->innerBlocks[] = (array) $block; $html = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset ); if ( ! empty( $html ) ) { $parent->block->innerHTML .= $html; $parent->block->innerContent[] = $html; } $parent->block->innerContent[] = null; $parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length; } /** * Pushes the top block from the parsing stack to the output list. * * @internal * @since 5.0.0 * @param int|null $end_offset byte offset into document for where we should stop sending text output as HTML. */ public function add_block_from_stack( $end_offset = null ) { $stack_top = array_pop( $this->stack ); $prev_offset = $stack_top->prev_offset; $html = isset( $end_offset ) ? substr( $this->document, $prev_offset, $end_offset - $prev_offset ) : substr( $this->document, $prev_offset ); if ( ! empty( $html ) ) { $stack_top->block->innerHTML .= $html; $stack_top->block->innerContent[] = $html; } if ( isset( $stack_top->leading_html_start ) ) { $this->output[] = (array) $this->freeform( substr( $this->document, $stack_top->leading_html_start, $stack_top->token_start - $stack_top->leading_html_start ) ); } $this->output[] = (array) $stack_top->block; } } /** * WP_Block_Parser_Block class. * * Required for backward compatibility in WordPress Core. */ require_once __DIR__ . '/class-wp-block-parser-block.php'; /** * WP_Block_Parser_Frame class. * * Required for backward compatibility in WordPress Core. */ require_once __DIR__ . '/class-wp-block-parser-frame.php';
Fatal error: Uncaught Error: Class "WP_Block_Parser" not found in /htdocs/accraonline.info/wp-includes/blocks.php:2225 Stack trace: #0 /htdocs/accraonline.info/wp-includes/blocks.php(1820): parse_blocks('ChromeNews') #1 /htdocs/accraonline.info/wp-includes/formatting.php(5200): filter_block_content('ChromeNews', Array, Array) #2 /htdocs/accraonline.info/wp-includes/class-wp-hook.php(324): wp_pre_kses_block_attributes('ChromeNews', Array, Array) #3 /htdocs/accraonline.info/wp-includes/plugin.php(205): WP_Hook->apply_filters('ChromeNews', Array) #4 /htdocs/accraonline.info/wp-includes/kses.php(946): apply_filters('pre_kses', 'ChromeNews', Array, Array) #5 /htdocs/accraonline.info/wp-includes/kses.php(754): wp_kses_hook('ChromeNews', Array, Array) #6 /htdocs/accraonline.info/wp-includes/class-wp-theme.php(961): wp_kses('ChromeNews', Array) #7 /htdocs/accraonline.info/wp-includes/class-wp-theme.php(893): WP_Theme->sanitize_header('Name', 'ChromeNews') #8 /htdocs/accraonline.info/wp-content/themes/chromenews/admin-dashboard/admin_dashboard.php(36): WP_Theme->get('Name') #9 /htdocs/accraonline.info/wp-content/themes/chromenews/admin-dashboard/admin_dashboard.php(167): AF_themes_info->__construct() #10 /htdocs/accraonline.info/wp-content/themes/chromenews/inc/init.php(27): require('/htdocs/accraon...') #11 /htdocs/accraonline.info/wp-content/themes/chromenews/functions.php(337): require('/htdocs/accraon...') #12 /htdocs/accraonline.info/wp-settings.php(672): include('/htdocs/accraon...') #13 /htdocs/accraonline.info/wp-config.php(106): require_once('/htdocs/accraon...') #14 /htdocs/accraonline.info/wp-load.php(50): require_once('/htdocs/accraon...') #15 /htdocs/accraonline.info/wp-blog-header.php(13): require_once('/htdocs/accraon...') #16 /htdocs/accraonline.info/index.php(17): require('/htdocs/accraon...') #17 {main} thrown in /htdocs/accraonline.info/wp-includes/blocks.php on line 2225