- wpcs for load_field_order();

This commit is contained in:
Mykyta Synelnikov
2023-06-22 23:44:14 +03:00
parent 3c11dfb47a
commit 6a67582e42
+10 -11
View File
@@ -35,18 +35,19 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
*/
public function update_order() {
UM()->admin()->check_ajax_nonce();
// phpcs:disable WordPress.Security.NonceVerification -- already verified here
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( __( 'Please login as administrator', 'ultimate-member' ) );
}
/**
* @var $form_id
*/
extract( $_POST );
if ( empty( $_POST['form_id'] ) ) {
wp_send_json_error( __( 'Invalid form ID.', 'ultimate-member' ) );
}
if ( isset( $form_id ) ) {
$form_id = absint( $form_id );
$form_id = absint( $_POST['form_id'] );
if ( empty( $form_id ) ) {
wp_send_json_error( __( 'Invalid form ID.', 'ultimate-member' ) );
}
$fields = UM()->query()->get_attr( 'custom_fields', $form_id );
@@ -71,12 +72,11 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
// adding rows
if ( 0 === strpos( $key, '_um_row_' ) ) {
$update_args = null;
$row_id = str_replace( '_um_row_', '', $key );
if ( strstr( $_POST[ '_um_rowcols_' . $row_id . '_cols' ], ':' ) ) {
if ( false !== strpos( $_POST[ '_um_rowcols_' . $row_id . '_cols' ], ':' ) ) {
$cols = sanitize_text_field( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] );
} else {
$cols = absint( $_POST[ '_um_rowcols_' . $row_id . '_cols' ] );
@@ -105,7 +105,6 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
}
$fields[ $key ] = $row_args;
}
// change field position
@@ -160,16 +159,16 @@ if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
update_option( 'um_form_rowdata_' . $form_id, $this->row_data );
UM()->query()->update_attr( 'custom_fields', $form_id, $fields );
// phpcs:enable WordPress.Security.NonceVerification -- already verified here
}
/**
* Load form to maintain form order.
*/
public function load_field_order() {
$screen = get_current_screen();
if ( ! isset( $screen->id ) || 'um_form' !== $screen->id ) {
if ( ! isset( $screen, $screen->id ) || 'um_form' !== $screen->id ) {
return;
} ?>