__( 'Invalid security token.', 'alert-box-block' ) ], 403 ); } if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( [ 'message' => __( 'You do not have permission to perform this action.', 'alert-box-block' ) ], 403 ); } // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- decoded JSON, each element sanitized below. $raw = isset( $_POST['data'] ) ? wp_unslash( $_POST['data'] ) : ''; $data = is_string( $raw ) ? json_decode( $raw, true ) : null; if ( is_array( $data ) ) { $data = array_values( array_map( 'sanitize_text_field', $data ) ); update_option( self::OPTION, $data ); wp_send_json_success( $data ); } wp_send_json_success( self::get() ); } } }