LLMS_Generator::generate()

When called, generates raw content based on the defined generator


Return Return

(void)


Top ↑

Source Source

File: includes/class.llms.generator.php

116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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.
    }
 
}


Top ↑

Changelog 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.

Top ↑

User Contributed Notes User Contributed Notes

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