| Server IP : 104.21.13.219 / Your IP : 162.159.115.10 Web Server : nginx/1.26.1 System : Linux HE9229 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 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/jl3_ph_com/wp-content/plugins/elementor-pro/modules/popup/ |
Upload File : |
<?php
namespace ElementorPro\Modules\Popup;
use Elementor\Controls_Manager;
use ElementorPro\Modules\Forms\Classes\Action_Base;
use ElementorPro\Modules\QueryControl\Module as QueryControlModule;
use ElementorPro\Modules\Forms\Module as FormsModule;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Form_Action extends Action_Base {
public function get_name() {
return 'popup';
}
public function get_label() {
return esc_html__( 'Popup', 'elementor-pro' );
}
public function register_settings_section( $widget ) {
$widget->start_controls_section(
'section_popup',
[
'label' => esc_html__( 'Popup', 'elementor-pro' ),
'condition' => [
'submit_actions' => $this->get_name(),
],
]
);
$widget->add_control(
'popup_action',
[
'label' => esc_html__( 'Action', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'options' => [
'' => esc_html__( 'Choose', 'elementor-pro' ),
'open' => esc_html__( 'Open Popup', 'elementor-pro' ),
'close' => esc_html__( 'Close Popup', 'elementor-pro' ),
],
]
);
$widget->add_control(
'popup_action_popup_id',
[
'label' => esc_html__( 'Popup', 'elementor-pro' ),
'type' => QueryControlModule::QUERY_CONTROL_ID,
'label_block' => true,
'autocomplete' => [
'object' => QueryControlModule::QUERY_OBJECT_LIBRARY_TEMPLATE,
'query' => [
'posts_per_page' => 20,
'meta_query' => [
[
'key' => Document::TYPE_META_KEY,
'value' => 'popup',
],
],
],
],
'condition' => [
'popup_action' => 'open',
],
]
);
$widget->add_control(
'popup_action_do_not_show_again',
[
'label' => esc_html__( 'Don\'t Show Again', 'elementor-pro' ),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'popup_action' => 'close',
],
]
);
$widget->end_controls_section();
}
public function on_export( $element ) {
unset(
$element['settings']['popup_action'],
$element['settings']['popup_action_popup_id'],
$element['settings']['popup_action_do_not_show_again']
);
return $element;
}
public function run( $record, $ajax_handler ) {
$popup_action = $record->get_form_settings( 'popup_action' );
if ( empty( $popup_action ) ) {
return;
}
$action_settings = [
'action' => $popup_action,
];
if ( 'open' === $popup_action ) {
$popup_id = $record->get_form_settings( 'popup_action_popup_id' );
if ( empty( $popup_id ) ) {
return;
}
$action_settings['id'] = $popup_id;
} else {
$action_settings['do_not_show_again'] = $record->get_form_settings( 'popup_action_do_not_show_again' );
}
$ajax_handler->add_response_data( 'popup', $action_settings );
}
public function maybe_print_popup( $settings, $widget ) {
if ( ! is_array( $settings['submit_actions'] ) || ! in_array( 'popup', $settings['submit_actions'] ) ) {
return;
}
$has_valid_settings = ( ! empty( $settings['popup_action'] ) && 'open' === $settings['popup_action'] && ! empty( $settings['popup_action_popup_id'] ) );
if ( ! $has_valid_settings ) {
return;
}
Module::add_popup_to_location( $settings['popup_action_popup_id'] );
}
public function __construct() {
/** @var FormsModule $forms_module */
$forms_module = FormsModule::instance();
// Register popup form action
$forms_module->actions_registrar->register( $this );
add_action( 'elementor-pro/forms/pre_render', [ $this, 'maybe_print_popup' ], 10, 2 );
}
}