_Block_Type_Registry::get_instance()->get_registered( $parsed_block['blockName'] ); $element_block_styles = $parsed_block['attrs']['style']['elements'] ?? null; if ( ! $element_block_styles ) { return $parsed_block; } $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' ); $skip_heading_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'heading' ); $skip_button_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'button' ); $skips_all_element_color_serialization = $skip_link_color_serialization && $skip_heading_color_serialization && $skip_button_color_serialization; if ( $skips_all_element_color_serialization ) { return $parsed_block; } $options = array( 'button' => array( 'skip' => $skip_button_color_serialization ), 'link' => array( 'skip' => $skip_link_color_serialization ), 'heading' => array( 'skip' => $skip_heading_color_serialization ), ); if ( ! gutenberg_should_add_elements_class_name( $parsed_block, $options ) ) { return $parsed_block; } $class_name = wp_get_elements_class_name( $parsed_block ); $updated_class_name = isset( $parsed_block['attrs']['className'] ) ? $parsed_block['attrs']['className'] . " $class_name" : $class_name; _wp_array_set( $parsed_block, array( 'attrs', 'className' ), $updated_class_name ); // Generate element styles based on selector and store in style engine for enqueuing. $element_types = array( 'button' => array( 'selector' => ".$class_name .wp-element-button, .$class_name .wp-block-button__link", 'skip' => $skip_button_color_serialization, ), 'link' => array( // :where(:not) matches theme.json selector. 'selector' => ".$class_name a:where(:not(.wp-element-button))", 'hover_selector' => ".$class_name a:where(:not(.wp-element-button)):hover", 'skip' => $skip_link_color_serialization, ), 'heading' => array( 'selector' => ".$class_name h1, .$class_name h2, .$class_name h3, .$class_name h4, .$class_name h5, .$class_name h6", 'skip' => $skip_heading_color_serialization, 'elements' => array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ), ), ); foreach ( $element_types as $element_type => $element_config ) { if ( $element_config['skip'] ) { continue; } $element_style_object = _wp_array_get( $element_block_styles, array( $element_type ), null ); // Process primary element type styles. if ( $element_style_object ) { gutenberg_style_engine_get_styles( $element_style_object, array( 'selector' => $element_config['selector'], 'context' => 'block-supports', ) ); if ( isset( $element_style_object[':hover'] ) ) { gutenberg_style_engine_get_styles( $element_style_object[':hover'], array( 'selector' => $element_config['hover_selector'], 'context' => 'block-supports', ) ); } } // Process related elements e.g. h1-h6 for headings. if ( isset( $element_config['elements'] ) ) { foreach ( $element_config['elements'] as $element ) { $element_style_object = _wp_array_get( $element_block_styles, array( $element ), null ); if ( $element_style_object ) { gutenberg_style_engine_get_styles( $element_style_object, array( 'selector' => ".$class_name $element", 'context' => 'block-supports', ) ); } } } } return $parsed_block; } /** * Ensure the elements block support class name generated, and added to * block attributes, in the `render_block_data` filter gets applied to the * block's markup. * * @see gutenberg_render_elements_support_styles * * @param string $block_content Rendered block content. * @param array $block Block object. * * @return string Filtered block content. */ function gutenberg_render_elements_class_name( $block_content, $block ) { $class_string = $block['attrs']['className'] ?? ''; preg_match( '/\bwp-elements-\S+\b/', $class_string, $matches ); if ( empty( $matches ) ) { return $block_content; } $tags = new WP_HTML_Tag_Processor( $block_content ); if ( $tags->next_tag() ) { $tags->add_class( $matches[0] ); } return $tags->get_updated_html(); } // Remove deprecated WordPress core filters. remove_filter( 'render_block', 'wp_render_elements_support', 10, 2 ); remove_filter( 'pre_render_block', 'wp_render_elements_support_styles', 10, 2 ); // Remove WordPress core filters to avoid rendering duplicate elements stylesheet & attaching classes twice. remove_filter( 'render_block', 'wp_render_elements_class_name', 10, 2 ); remove_filter( 'render_block_data', 'wp_render_elements_support_styles', 10, 1 ); add_filter( 'render_block', 'gutenberg_render_elements_class_name', 10, 2 ); add_filter( 'render_block_data', 'gutenberg_render_elements_support_styles', 10, 1 ); eturn bool */ protected function should_show_search_engines_discouraged_notification() { return $this->search_engines_are_discouraged() && $this->options_helper->get( 'ignore_search_engines_discouraged_notice', false ) === false; } /** * Remove the search engines discouraged notification if it exists. * * @return void */ protected function remove_search_engines_discouraged_notification_if_exists() { $this->notification_center->remove_notification_by_id( self::NOTIFICATION_ID ); } /** * Add the search engines discouraged notification if it does not exist yet. * * @return void */ protected function maybe_add_search_engines_discouraged_notification() { if ( ! $this->notification_center->get_notification_by_id( self::NOTIFICATION_ID ) ) { $notification = $this->notification(); $this->notification_helper->restore_notification( $notification ); $this->notification_center->add_notification( $notification ); } } /** * Checks whether search engines are discouraged from indexing the site. * * @return bool Whether search engines are discouraged from indexing the site. */ protected function search_engines_are_discouraged() { return (string) \get_option( 'blog_public' ) === '0'; } /** * Whether the search engines notice should be shown. * * @return bool */ protected function should_show_search_engines_discouraged_notice() { $pages_to_show_notice = [ 'index.php', 'plugins.php', 'update-core.php', ]; return ( $this->search_engines_are_discouraged() && $this->capability_helper->current_user_can( 'manage_options' ) && $this->options_helper->get( 'ignore_search_engines_discouraged_notice', false ) === false && ( $this->current_page_helper->is_yoast_seo_page() || \in_array( $this->current_page_helper->get_current_admin_page(), $pages_to_show_notice, true ) ) && $this->current_page_helper->get_current_yoast_seo_page() !== 'wpseo_dashboard' ); } /** * Show the search engines discouraged notice. * * @return void */ protected function show_search_engines_discouraged_notice() { \printf( '
%1$s
', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output from present() is considered safe. $this->presenter->present() ); } /** * Returns an instance of the notification. * * @return Yoast_Notification The notification to show. */ protected function notification() { return new Yoast_Notification( $this->presenter->present(), [ 'type' => Yoast_Notification::ERROR, 'id' => self::NOTIFICATION_ID, 'capabilities' => 'wpseo_manage_options', 'priority' => 1, ] ); } /** * Should restore the ignore option for the search engines discouraged notice. * * @return void */ public function restore_ignore_option() { if ( ! $this->search_engines_are_discouraged() ) { $this->options_helper->set( 'ignore_search_engines_discouraged_notice', false ); } } } * * @param array $attributes Block attributes. * @param string $content Block content. * @param WP_Block $block Block instance. * * @return string Rendered block output. */ protected function render( $attributes, $content, $block ) { $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); $account_link = get_option( 'woocommerce_myaccount_page_id' ) ? wc_get_account_endpoint_url( 'dashboard' ) : wp_login_url(); $allowed_svg = array( 'svg' => array( 'class' => true, 'xmlns' => true, 'width' => true, 'height' => true, 'viewbox' => true, ), 'path' => array( 'd' => true, 'fill' => true, 'fill-rule' => true, 'clip-rule' => true, ), 'circle' => array( 'cx' => true, 'cy' => true, 'r' => true, 'stroke' => true, 'stroke-width' => true, 'fill' => true, ), ); // Only provide aria-label if the display style is icon only. $aria_label = self::ICON_ONLY === $attributes['displayStyle'] ? 'aria-label="' . esc_attr( $this->render_label() ) . '"' : ''; $label_markup = self::ICON_ONLY === $attributes['displayStyle'] ? '' : '' . wp_kses( $this->render_label(), array() ) . ''; return "
" . wp_kses( $this->render_icon( $attributes ), $allowed_svg ) . $label_markup . '
'; } /** * Gets the icon to render depending on the iconStyle and displayStyle. * * @param array $attributes Block attributes. * * @return string Label to render on the block */ private function render_icon( $attributes ) { if ( self::TEXT_ONLY === $attributes['displayStyle'] ) { return ''; } if ( self::DISPLAY_LINE === $attributes['iconStyle'] ) { return ' '; } if ( self::DISPLAY_ALT === $attributes['iconStyle'] ) { return ' '; } return ' '; } /** * Gets the label to render depending on the displayStyle. * * @return string Label to render on the block. */ private function render_label() { return get_current_user_id() ? __( 'My Account', 'woocommerce' ) : __( 'Login', 'woocommerce' ); } /** * 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\CustomerAccount" not found in /htdocs/wp-content/plugins/woocommerce/src/Blocks/BlockTypesController.php:153 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(98): 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 153