| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.3/wp-content/plugins/wpforms-lite/src/Admin/Forms/Ajax/ |
Upload File : |
<?php
namespace WPForms\Admin\Forms\Ajax;
use WPForms\Admin\Forms\Table\Facades;
/**
* Columns AJAX actions on Forms Overview list page.
*
* @since 1.8.6
*/
class Columns {
/**
* Determine if the class is allowed to load.
*
* @since 1.8.6
*
* @return bool
*/
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;
}
/**
* Initialize class.
*
* @since 1.8.6
*/
public function init(): void {
if ( ! $this->allow_load() ) {
return;
}
$this->hooks();
}
/**
* Hooks.
*
* @since 1.8.6
*/
private function hooks(): void {
add_action( 'wp_ajax_wpforms_admin_forms_overview_save_columns_order', [ $this, 'save_order' ] );
}
/**
* Save columns' order.
*
* @since 1.8.6
*/
public function save_order(): void {
check_ajax_referer( 'wpforms-admin', 'nonce' );
if ( ! wpforms_current_user_can( 'view_forms' ) ) {
wp_send_json_error( esc_html__( 'You do not have permission to perform this action.', 'wpforms-lite' ) );
}
$data = $this->get_prepared_data();
// Prepare the new columns' order.
$columns = [];
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' ) );
}
wp_send_json_success();
}
/**
* Get prepared data before perform ajax action.
*
* @since 1.8.6
*
* @return array
*/
private function get_prepared_data(): array {
// Run a security check.
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' ) );
}
return [
'columns' => ! empty( $_POST['columns'] ) ? map_deep( (array) wp_unslash( $_POST['columns'] ), 'sanitize_key' ) : [],
];
}
}