class.llms.shortcode.registration.php 1.36 KB
Newer Older
cyrille's avatar
cyrille committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
<?php
/**
 * LifterLMS Registration Shortcode
 *
 * [lifterlms_registration]
 *
 * @package LifterLMS/Classes/Shortcodes
 *
 * @since 3.0.0
 * @version 5.0.2
 */

defined( 'ABSPATH' ) || exit;

/**
 * LLMS_Shortcode_Registration
 *
 * @since 3.0.0
 * @since 3.4.3 Migrated to utilize `LLMS_Shortcode` abstract.
 */
class LLMS_Shortcode_Registration extends LLMS_Shortcode {

	/**
	 * Shortcode tag
	 *
	 * @var string
	 */
	public $tag = 'lifterlms_registration';

	/**
	 * Retrieve the actual content of the shortcode
	 *
	 * The variables `$atts` & `$content` are both filtered before being passed to get_output()
	 * output is filtered so the return of get_output() doesn't need its own filter.
	 *
	 * @since 3.4.3
	 * @since 5.0.0 Remove password strength enqueue script.
	 * @since 5.0.2 Added select enqueue script and inline script for address info.
	 *
	 * @return string
	 */
	protected function get_output() {
		/**
		 * Enqueue select2 scripts and styles.
		 */
		llms()->assets->enqueue_script( 'llms-select2' );
		llms()->assets->enqueue_style( 'llms-select2-styles' );
		wp_add_inline_script(
			'llms',
			"window.llms.address_info = '" . wp_json_encode( llms_get_countries_address_info() ) . "';"
		);

		ob_start();
		include llms_get_template_part_contents( 'global/form', 'registration' );
		return ob_get_clean();

	}

}

return LLMS_Shortcode_Registration::instance();