| Server IP : 43.130.17.34 / Your IP : 216.73.217.6 Web Server : nginx/1.28.0 System : Linux VM-4-12-opencloudos 6.6.92-34.1.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 25 21:32:13 CST 2025 x86_64 User : www ( 1000) PHP Version : 8.0.26 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 MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/yespkg.com/wp-content/plugins/wpforms/src/Admin/Builder/Ajax/ |
Upload File : |
<?php
namespace WPForms\Admin\Builder\Ajax;
/**
* Form Builder Panel Loader AJAX actions.
*
* @since 1.8.6
*/
class PanelLoader {
/**
* 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_text_field( wp_unslash( $_REQUEST['action'] ) ) : '';
// Load only in the case of AJAX calls form the Form Builder.
return wpforms_is_admin_ajax() && strpos( $action, 'wpforms_builder_' ) === 0;
}
/**
* Initialize class.
*
* @since 1.8.6
*/
public function init() {
if ( ! $this->allow_load() ) {
return;
}
$this->hooks();
}
/**
* Hooks.
*
* @since 1.8.6
*/
private function hooks() {
add_action( 'wp_ajax_wpforms_builder_load_panel', [ $this, 'load_panel_content' ] );
}
/**
* Save tags.
*
* @since 1.8.6
*/
public function load_panel_content() {
$data = $this->get_prepared_data( 'load_panel' );
$panel_class = '\WPForms_Builder_Panel_' . ucfirst( $data['panel'] ?? '' );
if ( ! class_exists( $panel_class ) ) {
// Load panel base class.
require_once WPFORMS_PLUGIN_DIR . 'includes/admin/builder/panels/class-base.php';
$file = WPFORMS_PLUGIN_DIR . "includes/admin/builder/panels/class-{$data['panel']}.php";
$file_pro = WPFORMS_PLUGIN_DIR . "pro/includes/admin/builder/panels/class-{$data['panel']}.php";
if ( wpforms()->is_pro() && file_exists( $file_pro ) ) {
require_once $file_pro;
} elseif ( file_exists( $file ) ) {
require_once $file;
}
}
$panel_obj = $panel_class::instance();
if ( ! method_exists( $panel_obj, 'panel_content' ) ) {
wp_send_json_error( esc_html__( 'Invalid panel.', 'wpforms-lite' ) );
}
ob_start();
$panel_obj->panel_output( [], $data['panel'] );
$panel_content = ob_get_clean();
wp_send_json_success( $panel_content );
}
/**
* Get prepared data before perform ajax action.
*
* @since 1.8.6
*
* @param string $action Action: `save` OR `delete`.
*
* @return array
* @noinspection PhpSameParameterValueInspection
*/
private function get_prepared_data( string $action ): array {
// Run a security check.
if ( ! check_ajax_referer( 'wpforms-builder', 'nonce', false ) ) {
wp_send_json_error( esc_html__( 'Most likely, your session expired. Please reload the page.', 'wpforms-lite' ) );
}
// Check for permissions.
if ( ! wpforms_current_user_can( 'edit_forms' ) ) {
wp_send_json_error( esc_html__( 'You are not allowed to perform this action.', 'wpforms-lite' ) );
}
$data = [];
if ( $action === 'load_panel' ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$data['panel'] = ! empty( $_POST['panel'] ) ? sanitize_key( $_POST['panel'] ) : '';
}
return $data;
}
}