📋

passenger_form_settings( $abprf_forms,true ); ?>

📋

passenger_form_settings( $client_forms ); ?>
0 ) { foreach ( $passenger_forms as $id => $form ) { $this->form_item( $form, $id ); } } ?>
* * * * *
form_item(); ?>
( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST[ $key ] ) ) : []; $post_textarea_array = fn( $key ) => ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) ? array_map( 'sanitize_textarea_field', wp_unslash( $_POST[ $key ] ) ) : []; $form_ids = $post_array( 'client_form_id' ); $form_title = $post_array( 'client_form_title' ); $types = $post_array( 'client_form_type' ); $option = $post_array( 'client_form_option' ); $d_value = $post_array( 'client_form_value' ); $required = $post_array( 'client_form_required' ); $date_value = $post_textarea_array( 'client_form_value_date' ); if ( ! empty( $form_ids ) ) { foreach ( $form_ids as $key => $form_id ) { $title = $form_title[ $key ] ?? ''; $type = $types[ $key ] ?? ''; if ( $form_id && $title && $type ) { $value = ( $type === 'date' ) ? ( $date_value[ $key ] ?? '' ) : ( $d_value[ $key ] ?? '' ); $form_infos[ $form_id ] = [ 'label' => $title, 'type' => $type, 'option' => $option[ $key ] ?? '', 'd_value' => $value, 'required' => $required[ $key ] ?? 'off', ]; } } } } return $form_infos; } public function save_global_client_form(): void { if ( ! check_ajax_referer( 'abprf_admin_ajax_nonce', 'nonce', false ) ) { wp_send_json_error( [ 'html' => '', 'msg' => __( 'Invalid security token.', 'abp-rentalforge' ) ], 403 ); } if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( [ 'html' => '', 'msg' => __( 'Insufficient permissions.', 'abp-rentalforge' ) ], 403 ); } $form_infos = $this->get_form_array(); update_option( 'abprf_forms', $form_infos ); wp_send_json_success( [ 'msg' => __( 'Client Form Configuration Saved Successfully..... !! ', 'abp-rentalforge' ) ] ); } public function import_global_form(): void { if ( ! check_ajax_referer( 'abprf_admin_ajax_nonce', 'nonce', false ) ) { wp_send_json_error( [ 'html' => '', 'msg' => __( 'Invalid security token.', 'abp-rentalforge' ) ], 403 ); } if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( [ 'html' => '', 'msg' => __( 'Insufficient permissions.', 'abp-rentalforge' ) ], 403 ); } $default_form = ABPRF_Static::static_form(); $forms = ABPRF_Function::get_option( 'abprf_forms', $default_form ) ?? []; $forms = is_array( $forms ) ? $forms : []; ob_start(); $this->passenger_form_settings( $forms ); $html_content = ob_get_clean(); wp_send_json_success( [ 'html' => $html_content, 'msg' => __( 'Global Client Form Imported Successfully ..... !! ', 'abp-rentalforge' ) ] ); } } new ABPRF_Form(); }