LLMS_Blocks_PHP_Template_Block::output( array $attributes = array() )

Output the template.


Parameters Parameters

$attributes

(array) (Optional) Block attributes.

Default value: array()


Top ↑

Return Return

(void)


Top ↑

Source Source

File: libraries/lifterlms-blocks/includes/blocks/class-llms-blocks-php-template-block.php

	public function output( $attributes = array() ) {

		if ( empty( $attributes['template'] ) ) {
			return;
		}

		/**
		 * Filters the php templates that can be render via this block.
		 *
		 * @since 2.3.0
		 *
		 * @param array $templates Templates map, where the keys are the template attribute value and the values are the php file names (w/o extension).
		 */
		$templates = apply_filters( 'llms_blocks_php_templates_block', $this->templates );

		if ( ! array_key_exists( $attributes['template'], $templates ) ) {
			return;
		}

		ob_start();

		llms_get_template( "{$templates[$attributes['template']]}.php" );

		$block_content = ob_get_clean();

		/**
		 * Filters the block html.
		 *
		 * @since 2.3.0
		 *
		 * @param string                         $block_content The block's html.
		 * @param array                          $attributes    The block's array of attributes.
		 * @param array                          $template      The template file basename to be rendered.
		 * @param LLMS_Blocks_PHP_Template_Block $block         This block object.
		 */
		$block_content = apply_filters( 'llms_blocks_render_php_template_block', $block_content, $attributes, $templates[ $attributes['template'] ], $this );

		if ( $block_content ) {
			echo $block_content;
		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
2.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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