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.
LLMS_Certificates::generate_export( string $filepath, int $certificate_id )
Generate a downloadable HTML file for a certificate
Parameters Parameters
- $filepath
-
(string) (Required) Full path for the created file.
- $certificate_id
-
(int) (Required) WP_Post ID of the earned certificate.
Return Return
(mixed) WP_Error or full path to the generated export.
Source Source
File: includes/class.llms.certificates.php
private function generate_export( $filepath, $certificate_id ) { $html = $this->get_export_html( $certificate_id ); if ( is_wp_error( $html ) ) { return $html; } /** * Run actions prior to certificate export generation. * * @param string $filepath Full path where the created file will be stored. Passed as a reference. * @param string $html Certificate HTML. Passed as a reference. * @param int $certificate_id WP_Post ID of the earned certificate. */ do_action_ref_array( 'llms_certificate_generate_export', array( &$filepath, &$html, $certificate_id ) ); $file = fopen( $filepath, 'w' ); if ( false === $file ) { return new WP_Error( 'llms_certificate_error', __( 'Unable to open export file (HTML certificate) for writing.', 'lifterlms' ) ); } if ( false === fwrite( $file, $html ) ) { return new WP_Error( 'llms_certificate_error', __( 'Unable to write to export file (HTML certificate).', 'lifterlms' ) ); } fclose( $file ); return $filepath; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
4.3.1 | Introduce llms_certificate_error WP_Error code. |
3.37.3 | Added action llms_certificate_generate_export . |
3.18.0 | Introduced. |