Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LifterLMS::define_constants()

Define LifterLMS Constants


Return Return

(void)


Top ↑

Source Source

File: class-lifterlms.php

	private function define_constants() {

		llms_maybe_define_constant( 'LLMS_VERSION', $this->version );
		llms_maybe_define_constant( 'LLMS_TEMPLATE_PATH', $this->template_path() );
		llms_maybe_define_constant( 'LLMS_PLUGIN_URL', plugin_dir_url( LLMS_PLUGIN_FILE ) );

		$upload_dir = wp_upload_dir();
		llms_maybe_define_constant( 'LLMS_LOG_DIR', $upload_dir['basedir'] . '/llms-logs/' );
		llms_maybe_define_constant( 'LLMS_TMP_DIR', $upload_dir['basedir'] . '/llms-tmp/' );

		// If we're loading in debug mode.
		$script_debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
		$wp_debug     = defined( 'WP_DEBUG' ) && WP_DEBUG;

		// If debugging, load the unminified version otherwise load minified.
		if ( ! defined( 'LLMS_ASSETS_SUFFIX' ) ) {
			define( 'LLMS_ASSETS_SUFFIX', $script_debug ? '' : '.min' );
		}

		// If debugging, use time for asset version otherwise use plugin version.
		if ( ! defined( 'LLMS_ASSETS_VERSION' ) ) {
			define( 'LLMS_ASSETS_VERSION', ( $script_debug || $wp_debug ) ? time() : $this->version );
		}

		$allowed_atts = array(
			'label'           => true,
			'align'           => true,
			'checked'         => true,
			'border'          => true,
			'decoding'        => true,
			'disabled'        => true,
			'required'        => true,
			'allowfullscreen' => true,
			'allow'           => true,
			'frameborder'     => true,
			'class'           => true,
			'type'            => true,
			'id'              => true,
			'dir'             => true,
			'lang'            => true,
			'style'           => true,
			'xml:lang'        => true,
			'src'             => true,
			'alt'             => true,
			'href'            => true,
			'rel'             => true,
			'rev'             => true,
			'onclick'         => true,
			'target'          => true,
			'novalidate'      => true,
			'value'           => true,
			'name'            => true,
			'tabindex'        => true,
			'action'          => true,
			'method'          => true,
			'for'             => true,
			'width'           => true,
			'height'          => true,
			'data-*'          => true,
			'aria-label'      => true,
			'aria-live'       => true,
			'aria-hidden'     => true,
			'aria-*'          => true,
			'title'           => true,
			'placeholder'     => true,
			'readonly'        => true,
			'rows'            => true,
			'cols'            => true,
			'minlength'       => true,
			'maxlength'       => true,
			'pattern'         => true,
			'enctype'         => true,
			'role'            => true,
			'selected'        => true,
			'srcset'          => true,
			'accept'          => true,
			'accept-charset'  => true,
			'accesskey'       => true,
			'autocomplete'    => true,
			'autofocus'       => true,
			'colspan'         => true,
			'contenteditable' => true,
			'contextmenu'     => true,
			'controls'        => true,
			'coords'          => true,
			'datetime'        => true,
			'dirname'         => true,
			'download'        => true,
			'draggable'       => true,
			'dropzone'        => true,
			'form'            => true,
			'formaction'      => true,
			'formenctype'     => true,
			'formmethod'      => true,
			'formnovalidate'  => true,
			'formtarget'      => true,
			'headers'         => true,
			'hidden'          => true,
			'high'            => true,
			'hreflang'        => true,
			'http-equiv'      => true,
			'ismap'           => true,
			'list'            => true,
			'loop'            => true,
			'low'             => true,
			'max'             => true,
			'media'           => true,
			'min'             => true,
			'multiple'        => true,
			'muted'           => true,
			'open'            => true,
			'optimum'         => true,
			'poster'          => true,
			'preload'         => true,
			'reversed'        => true,
			'rowspan'         => true,
			'scope'           => true,
			'shape'           => true,
			'size'            => true,
			'span'            => true,
			'spellcheck'      => true,
			'srcdoc'          => true,
			'srclang'         => true,
			'start'           => true,
			'step'            => true,
			'translate'       => true,
			'usemap'          => true,
			'wrap'            => true,
			'ping'            => true,
			'referrerpolicy'  => true,
			'sandbox'         => true,
			'sizes'           => true,
		);

		// For use in escaping and sanitizing.
		llms_maybe_define_constant(
			'LLMS_ALLOWED_HTML_PRICES',
			array(
				'div'    => $allowed_atts,
				'span'   => $allowed_atts,
				'strong' => $allowed_atts,
				'sup'    => $allowed_atts,
				'sub'    => $allowed_atts,
				'del'    => $allowed_atts,
				'ins'    => $allowed_atts,
				'em'     => $allowed_atts,
				'bdi'    => $allowed_atts,
				's'      => $allowed_atts,
				'u'      => $allowed_atts,
			)
		);

		// Defining ourselves rather than relying on wp_kses_allowed_html( 'post' ) because it could be filtered.
		$allowed_post_fields = array(
			'address'    => array(),
			'a'          => array(
				'href'     => true,
				'rel'      => true,
				'rev'      => true,
				'name'     => true,
				'target'   => true,
				'download' => array(
					'valueless' => 'y',
				),
			),
			'abbr'       => array(),
			'acronym'    => array(),
			'area'       => array(
				'alt'    => true,
				'coords' => true,
				'href'   => true,
				'nohref' => true,
				'shape'  => true,
				'target' => true,
			),
			'article'    => array(
				'align' => true,
			),
			'aside'      => array(
				'align' => true,
			),
			'audio'      => array(
				'autoplay' => true,
				'controls' => true,
				'loop'     => true,
				'muted'    => true,
				'preload'  => true,
				'src'      => true,
			),
			'b'          => array(),
			'bdo'        => array(),
			'big'        => array(),
			'blockquote' => array(
				'cite' => true,
			),
			'br'         => array(),
			'button'     => array(
				'disabled' => true,
				'name'     => true,
				'type'     => true,
				'value'    => true,
			),
			'caption'    => array(
				'align' => true,
			),
			'cite'       => array(),
			'code'       => array(),
			'col'        => array(
				'align'   => true,
				'char'    => true,
				'charoff' => true,
				'span'    => true,
				'valign'  => true,
				'width'   => true,
			),
			'colgroup'   => array(
				'align'   => true,
				'char'    => true,
				'charoff' => true,
				'span'    => true,
				'valign'  => true,
				'width'   => true,
			),
			'del'        => array(
				'datetime' => true,
			),
			'dd'         => array(),
			'dfn'        => array(),
			'details'    => array(
				'align' => true,
				'open'  => true,
			),
			'div'        => array(
				'align' => true,
			),
			'dl'         => array(),
			'dt'         => array(),
			'em'         => array(),
			'fieldset'   => array(),
			'figure'     => array(
				'align' => true,
			),
			'figcaption' => array(
				'align' => true,
			),
			'font'       => array(
				'color' => true,
				'face'  => true,
				'size'  => true,
			),
			'footer'     => array(
				'align' => true,
			),
			'h1'         => array(
				'align' => true,
			),
			'h2'         => array(
				'align' => true,
			),
			'h3'         => array(
				'align' => true,
			),
			'h4'         => array(
				'align' => true,
			),
			'h5'         => array(
				'align' => true,
			),
			'h6'         => array(
				'align' => true,
			),
			'header'     => array(
				'align' => true,
			),
			'hgroup'     => array(
				'align' => true,
			),
			'hr'         => array(
				'align'   => true,
				'noshade' => true,
				'size'    => true,
				'width'   => true,
			),
			'i'          => array(),
			'img'        => array(
				'alt'      => true,
				'align'    => true,
				'border'   => true,
				'height'   => true,
				'hspace'   => true,
				'loading'  => true,
				'longdesc' => true,
				'vspace'   => true,
				'src'      => true,
				'usemap'   => true,
				'width'    => true,
			),
			'ins'        => array(
				'datetime' => true,
				'cite'     => true,
			),
			'kbd'        => array(),
			'label'      => array(
				'for' => true,
			),
			'legend'     => array(
				'align' => true,
			),
			'li'         => array(
				'align' => true,
				'value' => true,
			),
			'main'       => array(
				'align' => true,
			),
			'map'        => array(
				'name' => true,
			),
			'mark'       => array(),
			'menu'       => array(
				'type' => true,
			),
			'nav'        => array(
				'align' => true,
			),
			'object'     => array(
				'data' => array(
					'required'       => true,
					'value_callback' => '_wp_kses_allow_pdf_objects',
				),
				'type' => array(
					'required' => true,
					'values'   => array( 'application/pdf' ),
				),
			),
			'p'          => array(
				'align' => true,
			),
			'pre'        => array(
				'width' => true,
			),
			'q'          => array(
				'cite' => true,
			),
			'rb'         => array(),
			'rp'         => array(),
			'rt'         => array(),
			'rtc'        => array(),
			'ruby'       => array(),
			's'          => array(),
			'samp'       => array(),
			'span'       => array(
				'align' => true,
			),
			'section'    => array(
				'align' => true,
			),
			'small'      => array(),
			'strike'     => array(),
			'strong'     => array(),
			'sub'        => array(),
			'summary'    => array(
				'align' => true,
			),
			'sup'        => array(),
			'table'      => array(
				'align'       => true,
				'bgcolor'     => true,
				'border'      => true,
				'cellpadding' => true,
				'cellspacing' => true,
				'rules'       => true,
				'summary'     => true,
				'width'       => true,
			),
			'tbody'      => array(
				'align'   => true,
				'char'    => true,
				'charoff' => true,
				'valign'  => true,
			),
			'td'         => array(
				'abbr'    => true,
				'align'   => true,
				'axis'    => true,
				'bgcolor' => true,
				'char'    => true,
				'charoff' => true,
				'colspan' => true,
				'headers' => true,
				'height'  => true,
				'nowrap'  => true,
				'rowspan' => true,
				'scope'   => true,
				'valign'  => true,
				'width'   => true,
			),
			'textarea'   => array(
				'cols'     => true,
				'rows'     => true,
				'disabled' => true,
				'name'     => true,
				'readonly' => true,
			),
			'tfoot'      => array(
				'align'   => true,
				'char'    => true,
				'charoff' => true,
				'valign'  => true,
			),
			'th'         => array(
				'abbr'    => true,
				'align'   => true,
				'axis'    => true,
				'bgcolor' => true,
				'char'    => true,
				'charoff' => true,
				'colspan' => true,
				'headers' => true,
				'height'  => true,
				'nowrap'  => true,
				'rowspan' => true,
				'scope'   => true,
				'valign'  => true,
				'width'   => true,
			),
			'thead'      => array(
				'align'   => true,
				'char'    => true,
				'charoff' => true,
				'valign'  => true,
			),
			'title'      => array(),
			'tr'         => array(
				'align'   => true,
				'bgcolor' => true,
				'char'    => true,
				'charoff' => true,
				'valign'  => true,
			),
			'track'      => array(
				'default' => true,
				'kind'    => true,
				'label'   => true,
				'src'     => true,
				'srclang' => true,
			),
			'tt'         => array(),
			'u'          => array(),
			'ul'         => array(
				'type' => true,
			),
			'ol'         => array(
				'start'    => true,
				'type'     => true,
				'reversed' => true,
			),
			'var'        => array(),
			'video'      => array(
				'autoplay'    => true,
				'controls'    => true,
				'height'      => true,
				'loop'        => true,
				'muted'       => true,
				'playsinline' => true,
				'poster'      => true,
				'preload'     => true,
				'src'         => true,
				'width'       => true,
			),
		);

		foreach ( $allowed_post_fields as $field => $attributes ) {
			if ( ! is_array( $attributes ) ) {
				continue;
			}
			$allowed_post_fields[ $field ] = array_merge( $attributes, $allowed_atts );
		}

		llms_maybe_define_constant(
			'LLMS_ALLOWED_HTML_FORM_FIELDS',
			array_merge(
				$allowed_post_fields,
				array(
					'bdi'      => $allowed_atts,
					'iframe'   => $allowed_atts,
					'form'     => $allowed_atts,
					'input'    => $allowed_atts,
					'select'   => $allowed_atts,
					'option'   => $allowed_atts,
					'checkbox' => $allowed_atts,
					'radio'    => $allowed_atts,
					'optgroup' => $allowed_atts,
					'datalist' => $allowed_atts,
					'output'   => $allowed_atts,
					'progress' => $allowed_atts,
					'meter'    => $allowed_atts,
					'source'   => $allowed_atts,
				)
			)
		);
		llms_maybe_define_constant( 'LLMS_CONFIRMATION_FIELDS', array( 'email_address_confirm', 'password_confirm' ) );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.7.0 Added LLMS_ALLOWED_HTML_PRICES constant.
7.2.0 Added LLMS_ASSETS_VERSION constant.
4.0.0 Moved definitions of LLMS_PLUGIN_FILE and LLMS_PLUGIN_DIR to the main lifterlms.php file.<br> Use llms_maybe_define_constant() to reduce code complexity.
3.17.8 Added LLMS_PLUGIN_URL && LLMS_ASSETS_SUFFIX.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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