: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace WPForms\Admin\Forms\Ajax;
use WPForms\Admin\Forms\Table\Facades;
* Columns AJAX actions on Forms Overview list page.
* Determine if the class is allowed to load.
private function allow_load(): bool {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$action = isset( $_REQUEST['action'] ) ? sanitize_key( wp_unslash( $_REQUEST['action'] ) ) : '';
// Load only in the case of AJAX calls on Forms Overview page.
return wpforms_is_admin_ajax() && strpos( $action, 'wpforms_admin_forms_overview_' ) === 0;
if ( ! $this->allow_load() ) {
private function hooks() {
add_action( 'wp_ajax_wpforms_admin_forms_overview_save_columns_order', [ $this, 'save_order' ] );
public function save_order() {
$data = $this->get_prepared_data();
// Prepare the new columns' order.
foreach ( $data['columns'] as $column ) {
$columns[] = str_replace( '-foot', '', $column );
$result = Facades\Columns::sanitize_and_save_columns( $columns );
if ( $result === false ) {
wp_send_json_error( esc_html__( 'Cannot save columns order.', 'wpforms-lite' ) );
* Get prepared data before perform ajax action.
private function get_prepared_data(): array {
if ( ! check_ajax_referer( 'wpforms-admin', 'nonce', false ) ) {
wp_send_json_error( esc_html__( 'Most likely, your session expired. Please reload the page.', 'wpforms-lite' ) );
'columns' => ! empty( $_POST['columns'] ) ? map_deep( (array) wp_unslash( $_POST['columns'] ), 'sanitize_key' ) : [],