LLMS_Controller_Awards::on_save( int $post_id )
Callback function when a post is saved or updated.
Description Description
This method automatically merges the certificates post_content
and additionally triggers the creation actions to be fired if the certificate is newly created.
Parameters Parameters
- $post_id
-
(int) (Required) WP_Post ID of the certificate.
Return Return
(boolean) Returns true
if the certificate can't be loaded, otherwise returns true
.
Source Source
File: includes/controllers/class-llms-controller-awards.php
public static function on_save( $post_id ) { $obj = self::get_object( $post_id ); if ( ! $obj || 'publish' !== $obj->get( 'status' ) ) { return false; } $post_type = get_post_type( $post_id ); remove_action( "save_post_{$post_type}", array( __CLASS__, 'on_save' ), 20 ); $is_awarded = $obj->is_awarded(); if ( 'llms_my_certificate' === $post_type ) { if ( ! $is_awarded ) { $obj->update_sequential_id(); } /** * Whenever an awarded certificate is updated, we want to re-merge the content * in the event that any shortcodes or merge codes were added. */ $content = $obj->get( 'content', true ); $obj->set( 'content', $obj->merge_content( $content, true ) ); } /** * If the award is being published for the first time, trigger the creation actions. */ if ( ! $obj->is_awarded() ) { LLMS_Engagement_Handler::create_actions( self::strip_prefix( $post_type ), $obj->get_user_id(), $post_id, $obj->get( 'related' ), $obj->get( 'engagement' ) ); } add_action( "save_post_{$post_type}", array( __CLASS__, 'on_save' ), 20 ); return true; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.4.0 | Added replacement of references to reusable blocks with their actual blocks. |
6.0.0 | Introduced. |