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

			$args = array(
				'ID'           => $post->get( 'id' ),
				'post_content' => str_replace( $find, $replace, $post->get( 'content', true ) ),
			);
			return wp_update_post( $args ) ? true : false;
		}

		return false;

	}

	/**
	 * Insert a reusable block into the database
	 *
	 * @since 4.7.0
	 *
	 * @param int   $block_id WP_Post ID of the block being imported. This will be the ID as found on the original site.
	 * @param array $block    {
	 *     Array of block data.
	 *
	 *     @type string $title   Title of the reusable block.
	 *     @type string $content Content of the reusable block.
	 * }
	 * @return int WP_Post ID on success or `0 on error.
	 */
	protected function insert_resuable_block( $block_id, $block ) {

		$id = wp_insert_post(
			array(
				'post_content' => $block['content'],


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.