LLMS_Blocks_Instructors_Block

Course syllabus block class.


Source Source

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

class LLMS_Blocks_Instructors_Block extends LLMS_Blocks_Abstract_Block {

	/**
	 * Block ID.
	 *
	 * @var string
	 */
	protected $id = 'instructors';

	/**
	 * Is block dynamic (rendered in PHP).
	 *
	 * @var bool
	 */
	protected $is_dynamic = true;

	/**
	 * Add actions attached to the render function action.
	 *
	 * @since 1.0.0
	 * @since 1.1.0 Unknown.
	 * @since 1.11.1 Add support for memberships.
	 *
	 * @param array  $attributes Optional. Block attributes. Default empty array.
	 * @param string $content    Optional. Block content. Default empty string.
	 * @return void
	 */
	public function add_hooks( $attributes = array(), $content = '' ) {

		switch ( get_post_type() ) {
			case 'course':
				$func = 'lifterlms_template_course_author';
				break;

			case 'llms_membership':
				$func = 'llms_template_membership_instructors';
				break;

			default:
				return;
		}

		add_action( $this->get_render_hook(), $func, 10 );

	}

	/**
	 * Retrieve custom block attributes.
	 *
	 * Necessary to override when creating ServerSideRender blocks.
	 *
	 * @since 1.0.0
	 *
	 * @return array
	 */
	public function get_attributes() {
		return array_merge(
			parent::get_attributes(),
			array(
				'post_id' => array(
					'type'    => 'int',
					'default' => 0,
				),
			)
		);
	}

	/**
	 * Output a message when no HTML was rendered
	 *
	 * @since 1.0.0
	 * @since 1.8.0 Fixed spelling error.
	 *
	 * @return string
	 */
	public function get_empty_render_message() {
		return __( 'No visible instructors were found.', 'lifterlms' );
	}

}


Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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