LLMS_Abstract_Generator_Posts::insert_resuable_block( int $block_id, array $block )
Insert a reusable block into the database
Parameters Parameters
- $block_id
-
(int) (Required) WP_Post ID of the block being imported. This will be the ID as found on the original site.
- $block
-
(array) (Required) Array of block data.<br>
- 'title'
(string) Title of the reusable block.<br> - 'content'
(string) Content of the reusable block.<br>
- 'title'
Return Return
(int) WP_Post ID on success or `0 on error.
Source Source
File: includes/abstracts/llms-abstract-generator-posts.php
protected function insert_resuable_block( $block_id, $block ) {
$id = wp_insert_post(
array(
'post_content' => $block['content'],
'post_title' => $block['title'],
'post_type' => 'wp_block',
'post_status' => 'publish',
)
);
if ( $id ) {
$this->reusable_blocks[ $block_id ] = $id;
/**
* Triggered when a new reusable block is created during an import
*
* @since 4.7.0
*
* @param int $id WP_Post ID of the block.
* @param array $block Array of block information from the import.
*/
do_action( 'llms_generator_new_reusable_block', $id, $block );
}
return $id;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |