acf_validate_block_type()
Validates a block type ensuring all settings exist.
Хуков нет.
Возвращает
Массив
.
Использование
acf_validate_block_type( $block );
- $block(массив) (обязательный)
- The block settings.
Список изменений
С версии 5.8.0 | Введена. |
Код acf_validate_block_type() acf validate block type ACF 6.0.4
function acf_validate_block_type( $block ) { // Add default settings. $block = wp_parse_args( $block, array( 'name' => '', 'title' => '', 'description' => '', 'category' => 'common', 'icon' => '', 'mode' => 'preview', 'keywords' => array(), 'supports' => array(), 'post_types' => array(), 'uses_context' => array(), 'render_template' => false, 'render_callback' => false, 'enqueue_style' => false, 'enqueue_script' => false, 'enqueue_assets' => false, ) ); // Restrict keywords to 3 max to avoid JS error in older versions. if ( acf_version_compare( 'wp', '<', '5.2' ) ) { $block['keywords'] = array_slice( $block['keywords'], 0, 3 ); } // Generate name with prefix. if ( $block['name'] ) { $block['name'] = 'acf/' . acf_slugify( $block['name'] ); } // Add default 'supports' settings. $block['supports'] = wp_parse_args( $block['supports'], array( 'align' => true, 'html' => false, 'mode' => true, ) ); // Add default 'uses_context' settings. $block['uses_context'] = wp_parse_args( $block['uses_context'], array( 'postId', 'postType', ) ); // Correct "Experimental" flags. if ( isset( $block['supports']['__experimental_jsx'] ) ) { $block['supports']['jsx'] = $block['supports']['__experimental_jsx']; } // Return block. return $block; }