Cách mở rộng Visual Composer với các phần tử nội dung tuỳ biến

shortcode_atts

https://developer.wordpress.org/reference/functions/shortcode_atts/
shortcode_atts( array $pairs, array $atts, string $shortcode = '' )
(mảng) (Bắt buộc) Toàn bộ danh sách các thuộc tính được hỗ trợ và mặc định của chúng.
(mảng) (Bắt buộc) Thuộc tính do người dùng xác định trong thẻ shortcode.
(chuỗi) (Tùy chọn) Tên của shortcode, được cung cấp cho ngữ cảnh để cho phép lọc
(mảng) Danh sách thuộc tính kết hợp và được lọc.
function wpb_js_remove_wpautop( $content, $autop = false ) {
	if ( $autop ) { // Possible to use !preg_match('('.WPBMap::getTagsRegexp().')', $content)
		$content = wpautop( preg_replace( '/<\/?p\>/', "\n", $content ) . "\n" );
	}
	return do_shortcode( shortcode_unautop( $content ) );
}
Ví dụ:
wpb_js_remove_wpautop( $content );
$content: [vc_column_text]I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.[/vc_column_text]
Kết quả: wpb_js_remove_wpautop( $content );
I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo
Link: https://github.com/openfoodfoundation/openfoodnetwork-wp/blob/master/wp-content/plugins/js_composer/include/helpers/helpers.php

Last updated