LLMS_Generator::set_generator( string $generator = null )
Sets the generator to use for the current instance
Parameters Parameters
- $generator
-
(string) (Optional) Generator string, eg: "LifterLMS/SingleCourseExporter"
Default value: null
Return Return
(string|WP_Error) Name of the generator on success, otherwise an error object.
Source Source
File: includes/class.llms.generator.php
public function set_generator( $generator = null ) { // Interpret the generator from the raw data. if ( empty( $generator ) ) { // No generator can be interpreted. if ( ! isset( $this->raw['_generator'] ) ) { $this->error->add( 'missing-generator', __( 'The supplied file cannot be processed by the importer.', 'lifterlms' ) ); return $this->error; } // Set the generator using the interpreted data. return $this->set_generator( $this->raw['_generator'] ); } // Invalid generator. if ( ! $this->is_generator_valid( $generator ) ) { $this->error->add( 'invalid-generator', __( 'The supplied generator is invalid.', 'lifterlms' ) ); return $this->error; } // Set the generator. $generators = $this->get_generators(); $this->generator = $generators[ $generator ]; // Return the generator name. return $generator; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.36.3 | Fix error causing null to be returned instead of expected WP_Error . Return the generator name on success instead of void. |
3.3.0 | Introduced. |