Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Form_Templates::create_reusable_block( string $field_id )
Create a wp_block (resuable block) post for a given field id
Description Description
This method will attempt to use an existing reusable block field if it already exists and will only create it if one isn’t found.
Parameters Parameters
- $field_id
-
(string) (Required) The field's identifier as found in the block schema list returned by LLMS_Form_Templates::get_reusable_block_schema().
Return Return
(int) Returns the WP_Post ID of the the wp_block post type or 0
on failure.
Source Source
File: includes/forms/class-llms-form-templates.php
private static function create_reusable_block( $field_id ) { $existing = self::find_reusable_block( $field_id ); if ( $existing ) { return $existing->ID; } $block_data = self::get_block_data( $field_id ); $args = array( 'post_title' => $block_data['title'], 'post_content' => wp_slash( serialize_blocks( $block_data['block'] ) ), 'post_status' => 'publish', 'post_type' => 'wp_block', 'meta_input' => array( '_is_llms_field' => 'yes', '_llms_field_id' => $field_id, ), ); return wp_insert_post( $args ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.1.1 | Run serialized block content through wp_slash() to preserve special characters converted to character codes. |
5.0.0 | Introduced. |