LLMS_Shortcodes::init()

Initialize shortcodes array.


Return Return

(void)


Top ↑

Source Source

File: includes/shortcodes/class.llms.shortcodes.php

	 */
	public static function init() {

		// New method.
		$scs = apply_filters(
			/**
			 * Filters the shortcodes to initialize.
			 *
			 * @since Unknown
			 *
			 * @param string[] $shortcodes Array of shortcode class names to initialize.
			 */
			'llms_load_shortcodes',
			array(
				'LLMS_Shortcode_Course_Author',
				'LLMS_Shortcode_Course_Continue',
				'LLMS_Shortcode_Course_Continue_Button',
				'LLMS_Shortcode_Course_Meta_Info',
				'LLMS_Shortcode_Course_Outline',
				'LLMS_Shortcode_Course_Prerequisites',
				'LLMS_Shortcode_Course_Reviews',
				'LLMS_Shortcode_Course_Syllabus',
				'LLMS_Shortcode_Courses',
				'LLMS_Shortcode_Hide_Content',
				'LLMS_Shortcode_Lesson_Mark_Complete',
				'LLMS_Shortcode_Membership_Link',
				'LLMS_Shortcode_My_Achievements',
				'LLMS_Shortcode_Registration',
				'LLMS_Shortcode_User_Info',
				'LLMS_Shortcode_Favorites',
			)
		);

		$hyphenated_file_classes = array(
			'LLMS_Shortcode_User_Info',
		);

		foreach ( $scs as $class ) {

			$separator = in_array( $class, $hyphenated_file_classes, true ) ? '-' : '.';
			$filename  = "class{$separator}" . strtolower( str_replace( '_', $separator, $class ) );
			/**
			 * Filters the path of the shortcode class file.
			 *
			 * @since Unknown
			 *
			 * @param string $file  The shortcode class file name.
			 * @param string $class The shortcode class name.
			 */
			$path = apply_filters( 'llms_load_shortcode_path', LLMS_PLUGIN_DIR . "includes/shortcodes/{$filename}.php", $class );

			if ( file_exists( $path ) ) {
				require_once $path;
			}
		}

		/**
		 * @deprecated 2.0.0
		 * @todo       deprecate
		 */
		add_shortcode( 'courses', array( LLMS_Shortcode_Courses::instance(), 'output' ) );

		// Old method.
		$shortcodes = array(
			'lifterlms_access_plan_button' => __CLASS__ . '::access_plan_button',
			'lifterlms_my_account'         => __CLASS__ . '::my_account',
			'lifterlms_checkout'           => __CLASS__ . '::checkout',
			'lifterlms_course_info'        => __CLASS__ . '::course_info',
			'lifterlms_course_progress'    => __CLASS__ . '::course_progress',
			'lifterlms_course_title'       => __CLASS__ . '::course_title',
			'lifterlms_related_courses'    => __CLASS__ . '::related_courses',
			'lifterlms_login'              => __CLASS__ . '::login',
			'lifterlms_pricing_table'      => __CLASS__ . '::pricing_table',
			'lifterlms_memberships'        => __CLASS__ . '::memberships',
		);

		foreach ( $shortcodes as $shortcode => $function ) {

			add_shortcode(
				/**
				 * Filters the shortcode tag.
				 *
				 * The dynamic portion of the hook name, `$shortcode` refers to the shortcode tag itself.
				 *
				 * @since Unknown
				 *
				 * @param string $shortcode The shortcode tag.
				 */
				apply_filters( "{$shortcode}_shortcode_tag", $shortcode ),
				$function
			);
		}


Top ↑

Changelog Changelog

Changelog
Version Description
6.4.0 Allowed LLMS_Shortcode_User_Info class to be filtered.
6.0.0 Removed loading of class files that don't instantiate their class in favor of autoloading.
4.0.0 Stop registering previously deprecated shortcode [courses] and [lifterlms_user_statistics].
3.11.1 Unknown.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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