LLMS_Generator::generate()
When called, generates raw content based on the defined generator
Return Return
(void)
Source Source
File: includes/class.llms.generator.php
public function generate() {
if ( empty( $this->generator ) ) {
return $this->error->add( 'missing-generator', __( 'No generator supplied.', 'lifterlms' ) );
}
global $wpdb;
$wpdb->hide_errors();
$wpdb->query( 'START TRANSACTION' ); // db call ok; no-cache ok.
/**
* Action run immediately prior to a LifterLMS Generator running.
*
* @since 3.30.2
*
* @param LLMS_Generator $generator The generator instance.
*/
do_action( 'llms_generator_before_generate', $this );
try {
call_user_func( $this->generator, $this->raw );
} catch ( Exception $exception ) {
$this->error->add( $this->get_error_code( $exception->getCode(), $this->generator[0] ), $exception->getMessage(), $exception->getTrace() );
}
/**
* Action run immediately after a LifterLMS Generator running.
*
* @since 3.30.2
*
* @param LLMS_Generator $generator The generator instance.
*/
do_action( 'llms_generator_after_generate', $this );
if ( $this->is_error() ) {
$wpdb->query( 'ROLLBACK' ); // db call ok; no-cache ok.
} else {
$wpdb->query( 'COMMIT' ); // db call ok; no-cache ok.
}
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 4.7.0 | Return early if not generator is set. |
| 3.30.2 | Add before and after generation hooks. |
| 3.3.0 | Introduced. |