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.

  • 'title'
    (string) Title of the reusable block.
  • 'content'
    (string) Content of the reusable block.


Top ↑

Return Return

(int) WP_Post ID on success or `0 on error.


Top ↑

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;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.