Automattic\WooCommerce\Blocks
BlockTemplatesController::prevent_shortcodes_html_breakage()
Prevents shortcodes in templates having their HTML content broken by wpautop.
Метод класса: BlockTemplatesController{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$BlockTemplatesController = new BlockTemplatesController(); $BlockTemplatesController->prevent_shortcodes_html_breakage( $settings, $metadata );
- $settings(массив) (обязательный)
- Array of determined settings for registering a block type.
- $metadata(массив) (обязательный)
- Metadata provided for registering a block type.
Заметки
- Смотрите: https://core.trac.wordpress.org/ticket/58366 for more info.
Код BlockTemplatesController::prevent_shortcodes_html_breakage() BlockTemplatesController::prevent shortcodes html breakage WC 9.3.3
public function prevent_shortcodes_html_breakage( $settings, $metadata ) { if ( isset( $metadata['name'], $settings['render_callback'] ) && 'core/shortcode' === $metadata['name'] ) { $settings['original_render_callback'] = $settings['render_callback']; $settings['render_callback'] = function ( $attributes, $content ) use ( $settings ) { // The shortcode has already been rendered, so look for the cart/checkout HTML. if ( strstr( $content, 'woocommerce-cart-form' ) || strstr( $content, 'wc-empty-cart-message' ) || strstr( $content, 'woocommerce-checkout-form' ) ) { // Return early before wpautop runs again. return $content; } $render_callback = $settings['original_render_callback']; return $render_callback( $attributes, $content ); }; } return $settings; }