diff --git a/includes/admin/core/class-admin-builder.php b/includes/admin/core/class-admin-builder.php index 5283fa49..7bc41c71 100644 --- a/includes/admin/core/class-admin-builder.php +++ b/includes/admin/core/class-admin-builder.php @@ -703,7 +703,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { } /** - * + * AJAX handler for dynamic content inside the modal window. */ public function dynamic_modal_content() { UM()->admin()->check_ajax_nonce(); @@ -712,350 +712,357 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) ); } + // phpcs:disable WordPress.Security.NonceVerification -- already verified here + if ( empty( $_POST['act_id'] ) ) { + wp_send_json_error( __( 'Wrong dynamic-content attribute.', 'ultimate-member' ) ); + } + $metabox = UM()->metabox(); + $act_id = sanitize_key( $_POST['act_id'] ); - /** - * @var $act_id - * @var $arg1 - * @var $arg2 - * @var $arg3 - */ - extract( $_POST ); - - if ( isset( $arg1 ) ) { - $arg1 = sanitize_text_field( $arg1 ); + $arg1 = null; + if ( isset( $_POST['arg1'] ) ) { + $arg1 = sanitize_text_field( $_POST['arg1'] ); } - if ( isset( $arg2 ) ) { - $arg2 = sanitize_text_field( $arg2 ); + $arg2 = null; + if ( isset( $_POST['arg2'] ) ) { + $arg2 = sanitize_text_field( $_POST['arg2'] ); } - if ( isset( $arg3 ) ) { - $arg3 = sanitize_text_field( $arg3 ); + $arg3 = null; + if ( isset( $_POST['arg3'] ) ) { + $arg3 = sanitize_text_field( $_POST['arg3'] ); } - switch ( sanitize_key( $act_id ) ) { + $form_mode = null; + if ( isset( $_POST['form_mode'] ) ) { + $form_mode = sanitize_key( $_POST['form_mode'] ); + } + $in_row = null; + if ( isset( $_POST['in_row'] ) ) { + $in_row = absint( $_POST['in_row'] ); + } + + $in_sub_row = null; + if ( isset( $_POST['in_sub_row'] ) ) { + $in_sub_row = absint( $_POST['in_sub_row'] ); + } + + $in_column = null; + if ( isset( $_POST['in_column'] ) ) { + $in_column = absint( $_POST['in_column'] ); + } + + $in_group = null; + if ( isset( $_POST['in_group'] ) ) { + $in_group = absint( $_POST['in_group'] ); + } + // phpcs:enable WordPress.Security.NonceVerification -- already verified here + + switch ( $act_id ) { default: - ob_start(); - /** - * UM hook + * Fires for integration on AJAX popup admin builder modal content. * - * @type action - * @title um_admin_ajax_modal_content__hook - * @description Integration hook on ajax popup admin builder modal content - * @input_vars - * [{"var":"$act_id","type":"string","desc":"Ajax Action"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_admin_ajax_modal_content__hook', 'function_name', 10, 1 ); - * @example - * Pass HTML to the custom UM modal with data-dynamic-content="user_info". + * function my_custom_um_admin_ajax_modal_content__hook( $act_id ) { + * if ( 'user_info' === $act_id ) { + * // Your HTML is here + * } * } - * ?> + * add_action( 'um_admin_ajax_modal_content__hook', 'my_custom_um_admin_ajax_modal_content__hook' ); */ - do_action( 'um_admin_ajax_modal_content__hook', sanitize_key( $act_id ) ); + do_action( 'um_admin_ajax_modal_content__hook', $act_id ); /** - * UM hook + * Fires for integration on AJAX popup admin builder modal content. * - * @type action - * @title um_admin_ajax_modal_content__hook_{$act_id} - * @description Integration hook on ajax popup admin builder modal content - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_admin_ajax_modal_content__hook_{$act_id}', 'function_name', 10 ); - * @example - * Pass HTML to the custom UM modal with data-dynamic-content="user_info". + * function my_custom_um_admin_ajax_modal_content__hook_user_info() { + * // Your HTML is here for `user_info` modal * } - * ?> + * add_action( 'um_admin_ajax_modal_content__hook_user_info', 'my_custom_um_admin_ajax_modal_content__hook_user_info' ); */ - do_action( "um_admin_ajax_modal_content__hook_" . sanitize_key( $act_id ) ); - + do_action( 'um_admin_ajax_modal_content__hook_' . $act_id ); $output = ob_get_clean(); break; - case 'um_admin_fonticon_selector': - - ob_start(); ?> - + ob_start(); + ?>
- - - + + query()->get_attr( 'custom_fields', $arg2 ); $form_fields = array_values( array_filter( array_keys( $form_fields ) ) ); - //$form_fields = array_keys( $form_fields ); ?> - - +' . esc_html__( 'This field is not setup correctly for this form.', 'ultimate-member' ) . '
'; + break; + } $metabox->set_field_type = $arg1; - $metabox->in_edit = true; - $metabox->edit_array = $form_fields[ $arg3 ]; + $metabox->in_edit = true; + $metabox->edit_array = $form_fields[ $arg3 ]; - if ( !isset( $metabox->edit_array['metakey'] ) ){ + if ( ! array_key_exists( 'metakey', $metabox->edit_array ) ) { $metabox->edit_array['metakey'] = $metabox->edit_array['id']; } - if ( !isset( $metabox->edit_array['position'] ) ){ + if ( ! array_key_exists( 'position', $metabox->edit_array ) ) { $metabox->edit_array['position'] = $metabox->edit_array['id']; } - extract( $args ); - - if ( ! isset( $col1 ) ) { - - echo ''. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '
'; - - } else { + ob_start(); + if ( ! array_key_exists( 'col1', $field_type_data ) ) { ?> - - edit_array['in_group'] ) ) { ?> - - - - - - - - - - + + + + + + + + + + - - - - - -'. __( 'This field type is not setup correcty.', 'ultimate-member' ) . '
'; - + if ( ! array_key_exists( 'col1', $field_type_data ) ) { + ?> + + - - - - - - - - - + ?> + + + + + + modal_header(); ?>