function replace_post_for_single_product_inner_block( $block, &$context ) { if ( $this->single_product_inner_blocks_names ) { $block_name = array_pop( $this->single_product_inner_blocks_names ); if ( $block_name === $block['blockName'] ) { /** * This is a temporary fix to ensure the Post Title and Excerpt blocks work as expected * until Gutenberg versions 15.2 and 15.6 are included in the core of WordPress. * * Important: the original post data is restored in the restore_global_post method. * * @see https://github.com/WordPress/gutenberg/pull/48001 * @see https://github.com/WordPress/gutenberg/pull/49495 */ if ( 'core/post-excerpt' === $block_name || 'core/post-title' === $block_name ) { global $post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited $post = get_post( $this->product_id ); if ( $post instanceof \WP_Post ) { setup_postdata( $post ); } } $context['postId'] = $this->product_id; $context['singleProduct'] = true; } } } /** * Get the frontend script handle for this block type. * * @param string $key Data to get, or default to everything. * * @return null This block has no frontend script. */ protected function get_block_type_script( $key = null ) { return null; } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Blocks\BlockTypes\SingleProduct" not found in /htdocs/wp-content/plugins/woocommerce/src/Blocks/BlockTypesController.php:106 Stack trace: #0 /htdocs/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Blocks\BlockTypesController->register_blocks('') #1 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #2 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #3 /htdocs/wp-settings.php(704): do_action('init') #4 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #5 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #6 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #7 /htdocs/index.php(17): require('/htdocs/wp-blog...') #8 {main} thrown in /htdocs/wp-content/plugins/woocommerce/src/Blocks/BlockTypesController.php on line 106