C:\xampp\htdocs\landing\wp-content\plugins\wpforms-lite\src\Integrations\Elementor\Elementor.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php

namespace WPForms\Integrations\Elementor;

use 
Elementor\Plugin as ElementorPlugin;
use 
WPForms\Integrations\IntegrationInterface;

/**
 * Improve Elementor Compatibility.
 *
 * @since 1.6.0
 */
class Elementor implements IntegrationInterface {

    
/**
     * Indicates if current integration is allowed to load.
     *
     * @since 1.6.0
     *
     * @return bool
     */
    
public function allow_load() {

        return 
did_action'elementor/loaded' );
    }

    
/**
     * Load an integration.
     *
     * @since 1.6.0
     */
    
public function load() {

        
$this->hooks();
    }

    
/**
     * Integration hooks.
     *
     * @since 1.6.0
     */
    
protected function hooks() {

        
// Skip if Elementor is not available.
        
if ( ! class_exists'\Elementor\Plugin' ) ) {
            return;
        }

        
add_action'elementor/preview/init', [ $this'init' ] );
        
add_action'elementor/frontend/after_enqueue_scripts', [ $this'preview_assets' ] );
        
add_action'elementor/frontend/after_enqueue_scripts', [ $this'frontend_assets' ] );
        
add_action'elementor/editor/after_enqueue_styles', [ $this'editor_assets' ] );
        
add_action'elementor/widgets/widgets_registered', [ $this'register_widget' ] );

        
add_action'wp_ajax_wpforms_admin_get_form_selector_options', [ $this'ajax_get_form_selector_options' ] );
    }

    
/**
     * Init the main logic.
     *
     * @since 1.6.0
     */
    
public function init() {

        
/**
         * Allow developers to determine whether the compatibility layer should be applied.
         * We do this check here because we want this filter to be available for theme developers too.
         *
         * @since 1.6.0
         *
         * @param bool $use_compat
         */
        
$use_compat apply_filters'wpforms_apply_elementor_preview_compat'true );

        if ( 
true !== $use_compat ) {
            return;
        }

        
// Load WPForms assets globally on Elementor Preview panel only.
        
add_filter'wpforms_global_assets''__return_true' );

        
// Hide CAPTCHA badge on Elementor Preview panel.
        
add_filter'wpforms_frontend_recaptcha_disable''__return_true' );
    }

    
/**
     * Load assets in the preview panel.
     *
     * @since 1.6.2
     */
    
public function preview_assets() {

        if ( ! 
ElementorPlugin::$instance->preview->is_preview_mode() ) {
            return;
        }

        
$min wpforms_get_min_suffix();

        
wp_enqueue_style(
            
'wpforms-integrations',
            
WPFORMS_PLUGIN_URL "assets/css/admin-integrations{$min}.css",
            
null,
            
WPFORMS_VERSION
        
);

        
wp_enqueue_script(
            
'wpforms-elementor',
            
WPFORMS_PLUGIN_URL "assets/js/integrations/elementor/editor{$min}.js",
            [ 
'elementor-frontend''jquery''wp-util' ],
            
WPFORMS_VERSION,
            
true
        
);

        
wp_localize_script(
            
'wpforms-elementor',
            
'wpformsElementorVars',
            [
                
'ajax_url'      => admin_url'admin-ajax.php' ),
                
'nonce'         => wp_create_nonce'wpforms-elementor-integration' ),
                
'edit_form_url' => admin_url'admin.php?page=wpforms-builder&view=fields&form_id=' ),
                
'add_form_url'  => admin_url'admin.php?page=wpforms-builder&view=setup' ),
                
'css_url'       => WPFORMS_PLUGIN_URL "assets/css/admin-integrations{$min}.css",
                
'debug'         => wpforms_debug(),
            ]
        );
    }

    
/**
     * Load an integration assets on the frontend.
     *
     * @since 1.6.2
     */
    
public function frontend_assets() {

        if ( 
ElementorPlugin::$instance->preview->is_preview_mode() ) {
            return;
        }

        
$min wpforms_get_min_suffix();

        
wp_enqueue_script(
            
'wpforms-elementor',
            
WPFORMS_PLUGIN_URL "assets/js/integrations/elementor/frontend{$min}.js",
            [ 
'elementor-frontend''jquery''wp-util' ],
            
WPFORMS_VERSION,
            
true
        
);

        
wp_localize_script(
            
'wpforms-elementor',
            
'wpformsElementorVars',
            [
                
'captcha_provider' => wpforms_setting'captcha-provider''recaptcha' ),
                
'recaptcha_type'   => wpforms_setting'recaptcha-type''v2' ),
            ]
        );
    }

    
/**
     * Load an integration css in the elementor document.
     *
     * @since 1.6.2
     */
    
public function editor_assets() {

        if ( empty( 
$_GET['action'] ) || $_GET['action'] !== 'elementor' ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
            
return;
        }

        
$min wpforms_get_min_suffix();

        
wp_enqueue_style(
            
'wpforms-integrations',
            
WPFORMS_PLUGIN_URL "assets/css/admin-integrations{$min}.css",
            
null,
            
WPFORMS_VERSION
        
);
    }

    
/**
     * Register WPForms Widget.
     *
     * @since 1.6.2
     */
    
public function register_widget() {

        
ElementorPlugin::instance()->widgets_manager->register_widget_type( new Widget() );
    }

    
/**
     * Get form selector options.
     *
     * @since 1.6.2
     */
    
public function ajax_get_form_selector_options() {

        
check_ajax_referer'wpforms-elementor-integration''nonce' );

        
wp_send_json_success( ( new Widget() )->get_form_selector_options() );
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586