LLMS_Processors::load_processor( string $name )

Load a single processor


Parameters Parameters

$name

(string) (Required) Name of the processor.


Top ↑

Return Return

(LLMS_Abstract_Processor|boolean) Instance of the processor if found and not yet included, false if the processor can't be found, and true if it has already been included.


Top ↑

Source Source

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

	public function load_processor( $name ) {

		/**
		 * Filter the path of a processor class.
		 *
		 * If the returned path isn't the full path to a PHP file the file will be attempted to be
		 * loaded from the LifterLMS core's processor directory by replacing underscores with dashes
		 * and prepending `class-llms-processor-` and appending `.php`.
		 *
		 * @since 5.0.0
		 *
		 * @see LLMS_Processors::load_all() For the `llms_load_processors` filter used to register custom processors.
		 *
		 * @param string $name Processor class name ID/slug.
		 */
		$path = apply_filters( 'llms_load_processor_path', $name );

		// Try loading the filtered processor path.
		if ( $path !== $name ) {
			return file_exists( $name ) ? require_once $name : false;
		}

		$file = 'class-llms-processor-' . str_replace( '_', '-', $name ) . '.php';
		$path = LLMS_PLUGIN_DIR . 'includes/processors/';

		// Try loading a LifterLMS processor with a dashed file name.
		if ( file_exists( $path . $file ) ) {
			return require_once $path . $file;
		}

		// Try loading a LifterLMS processor with a dotted file name.
		$file = str_replace( '-', '.', $file );
		if ( file_exists( $path . $file ) ) {
			return require_once $path . $file;
		}

		return false;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Added the ability to load processor class files with dashes in their file name.
3.15.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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