LLMS_Admin_Builder::heartbeat_received( array $res, array $data )
Handle AJAX Heartbeat received calls All builder data is sent through the heartbeat
Description Description
Parameters Parameters
- $res
-
(array) (Required) response data
- $data
-
(array) (Required) data from the heartbeat api builder data will be in the "llms_builder" array
Return Return
(array)
Source Source
File: includes/admin/class.llms.admin.builder.php
public static function heartbeat_received( $res, $data ) { // exit if there's no builder data in the heartbeat data if ( empty( $data['llms_builder'] ) ) { return $res; } // Isolate builder data & ensure slashes aren't removed. $data = $data['llms_builder']; // Escape slashes. // $data = json_decode( str_replace( '\\', '\\\\', $data ), true ); $data = json_decode( $data, true ); // setup our return $ret = array( 'status' => 'success', 'message' => esc_html__( 'Success', 'lifterlms' ), ); // need a numeric ID for a course post type! if ( empty( $data['id'] ) || ! is_numeric( $data['id'] ) || 'course' !== get_post_type( $data['id'] ) ) { $ret['status'] = 'error'; $ret['message'] = esc_html__( 'Error: Invalid or missing course ID.', 'lifterlms' ); } elseif ( ! current_user_can( 'edit_course', $data['id'] ) ) { $ret['status'] = 'error'; $ret['message'] = esc_html__( 'Error: You do not have permission to edit this course.', 'lifterlms' ); } else { if ( ! empty( $data['detach'] ) && is_array( $data['detach'] ) ) { $ret['detach'] = self::process_detachments( $data ); } if ( current_user_can( 'delete_course', $data['id'] ) ) { if ( ! empty( $data['trash'] ) && is_array( $data['trash'] ) ) { $ret['trash'] = self::process_trash( $data ); } } if ( ! empty( $data['updates'] ) && is_array( $data['updates'] ) ) { $ret['updates']['sections'] = self::process_updates( $data ); } } // Unescape slashes after saved. // This ensures that updates are recognized as successful during Sync comparisons. // $ret = json_decode( str_replace( '\\\\', '\\', json_encode( $ret ) ), true ); // Return our data. $res['llms_builder'] = $ret; return $res; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.16.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: