LLMS_AJAX_Handler::instructors_mb_store( array $request )
Store data for the instructors metabox
Parameters Parameters
- $request
-
(array) (Required) $_REQUEST object.
Return Return
(array)
Source Source
File: includes/class.llms.ajax.handler.php
public static function instructors_mb_store( $request ) { // validate required params. if ( ! isset( $request['store_action'] ) || ! isset( $request['post_id'] ) ) { return array( 'data' => array(), 'message' => __( 'Missing required parameters', 'lifterlms' ), 'success' => false, ); } $post = llms_get_post( $request['post_id'] ); switch ( $request['store_action'] ) { case 'load': $instructors = $post->get_instructors(); break; case 'save': $instructors = array(); foreach ( $request['rows'] as $instructor ) { foreach ( $instructor as $key => $val ) { $new_key = str_replace( array( 'llms', '_' ), '', $key ); $new_key = preg_replace( '/[0-9]+/', '', $new_key ); $instructor[ $new_key ] = $val; unset( $instructor[ $key ] ); } $instructors[] = $instructor; } $post->set_instructors( $instructors ); break; } $data = array(); foreach ( $instructors as $instructor ) { $new_instructor = array(); foreach ( $instructor as $key => $val ) { if ( 'id' === $key ) { $val = llms_make_select2_student_array( array( $instructor['id'] ) ); } $new_instructor[ '_llms_' . $key ] = $val; } $data[] = $new_instructor; } wp_send_json( array( 'data' => $data, 'message' => 'success', 'success' => true, ) ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.30.3 | Fixed typos. |
3.13.0 | Introduced. |