LLMS_Admin_Builder::update_custom_schemas( string $type, LLMS_Post_Model $post, array $post_data )

Handle updating custom schema data


Parameters Parameters

$type

(string) (Required) Model type (lesson, quiz, etc...).

$post

(LLMS_Post_Model) (Required) LLMS_Post_Model object for the model being updated.

$post_data

(array) (Required) Assoc array of raw data to update the model with.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/admin/class.llms.admin.builder.php

934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
        }
    }
 
    return $ret;
 
}
 
/**
 * Handle updating custom schema data
 *
 * @since 3.17.0
 * @since 3.30.0 Fixed typo preventing fields specifying a custom callback from working.
 * @since 3.30.0 Array fields will run field values through `sanitize_text_field()` instead of requiring a custom sanitization callback.
 *
 * @param string          $type Model type (lesson, quiz, etc...).
 * @param LLMS_Post_Model $post LLMS_Post_Model object for the model being updated.
 * @param array           $post_data Assoc array of raw data to update the model with.
 * @return void
 */
public static function update_custom_schemas( $type, $post, $post_data ) {
 
    $schemas = self::get_custom_schemas();
    if ( empty( $schemas[ $type ] ) ) {
        return;
    }
 
    $groups = $schemas[ $type ];
 
    foreach ( $groups as $name => $group ) {
 
        // Allow 3rd parties to manage their own custom save methods.
        if ( apply_filters( 'llms_builder_update_custom_fields_group_' . $name, false, $post, $post_data, $groups ) ) {
            continue;
        }
 
        foreach ( $group['fields'] as $fields ) {
 
            foreach ( $fields as $field ) {
 
                $keys = array( $field['attribute'] );
                if ( isset( $field['switch_attribute'] ) ) {
                    $keys[] = $field['switch_attribute'];
                }
 
                foreach ( $keys as $attr ) {
 
                    if ( isset( $post_data[ $attr ] ) ) {


Top ↑

Changelog Changelog

Changelog
Version Description
3.30.0 Array fields will run field values through sanitize_text_field() instead of requiring a custom sanitization callback.
3.17.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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