PluginProbe
Elementor Website Builder – more than just a page builder / 3.31.4
Elementor Website Builder – more than just a page builder v3.31.4
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | modules/cloud-library/module.php +33 -36 4.1.0-dev33.31.4 View file →
@@ -27,40 +27,40 @@
27 27
28 28 public function __construct() {
29 29 parent::__construct();
30 30
31 - $this->register_app();
31 + $this->register_experiments();
32 32
33 - add_action( 'elementor/init', function () {
34 - $this->set_cloud_library_settings();
35 - }, 12 /** After the initiation of the connect cloud library */ );
33 + if ( Plugin::$instance->experiments->is_feature_active( $this->get_name() ) ) {
34 + $this->register_app();
36 35
37 - add_filter( 'elementor/editor/localize_settings', function ( $settings ) {
38 - return $this->localize_settings( $settings );
39 - }, 11 /** After Elementor Core */ );
36 + add_action( 'elementor/init', function () {
37 + $this->set_cloud_library_settings();
38 + }, 12 /** After the initiation of the connect cloud library */ );
40 39
41 - add_filter( 'elementor/render_mode/module', function( $module_name ) {
42 - $render_mode_manager = \Elementor\Plugin::$instance->frontend->render_mode_manager;
40 + add_filter( 'elementor/editor/localize_settings', function ( $settings ) {
41 + return $this->localize_settings( $settings );
42 + }, 11 /** After Elementor Core */ );
43 43
44 - if ( $render_mode_manager ) {
45 - $current_render_mode = $render_mode_manager->get_current();
44 + add_filter( 'elementor/render_mode/module', function( $module_name ) {
45 + $render_mode_manager = \Elementor\Plugin::$instance->frontend->render_mode_manager;
46 46
47 - if ( $current_render_mode instanceof \Elementor\Modules\CloudLibrary\Render_Mode_Preview ) {
47 + if ( $render_mode_manager && $render_mode_manager->get_current() instanceof \Elementor\Modules\CloudLibrary\Render_Mode_Preview ) {
48 48 return 'cloud-library';
49 49 }
50 - }
51 50
52 - return $module_name;
53 - }, 12);
51 + return $module_name;
52 + }, 12);
54 53
55 - if ( $this->is_screenshot_proxy_mode( $_GET ) ) { // phpcs:ignore -- Checking nonce inside the method.
56 - echo $this->get_proxy_data( htmlspecialchars( $_GET['href'] ) ); // phpcs:ignore -- Nonce was checked on the above method
57 - die;
54 + if ( $this->is_screenshot_proxy_mode( $_GET ) ) { // phpcs:ignore -- Checking nonce inside the method.
55 + echo $this->get_proxy_data( htmlspecialchars( $_GET['href'] ) ); // phpcs:ignore -- Nonce was checked on the above method
56 + die;
57 + }
58 58 }
59 59 }
60 60
61 61 public function get_proxy_data( $url ) {
62 - $response = wp_safe_remote_get( $url );
62 + $response = wp_safe_remote_get( utf8_decode( $url ) );
63 63
64 64 if ( is_wp_error( $response ) ) {
65 65 return '';
66 66 }
@@ -81,8 +81,18 @@
81 81
82 82 return $settings;
83 83 }
84 84
85 + private function register_experiments() {
86 + Plugin::$instance->experiments->add_feature( [
87 + 'name' => $this->get_name(),
88 + 'title' => esc_html__( 'Cloud Library', 'elementor' ),
89 + 'description' => esc_html__( 'Cloud Templates and Website Templates empowers you to save and manage design elements across all your projects. This feature is associated and connected to your Elementor Pro account and can be accessed from any website associated with your account.', 'elementor' ),
90 + 'release_status' => ExperimentsManager::RELEASE_STATUS_BETA,
91 + 'default' => ExperimentsManager::STATE_ACTIVE,
92 + ] );
93 + }
94 +
85 95 private function register_app() {
86 96 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
87 97 $connect_module->register_app( 'cloud-library', Cloud_Library::get_class_name() );
88 98 } );
@@ -99,9 +109,9 @@
99 109
100 110 /**
101 111 * @param Render_Mode_Manager $manager
102 112 *
103 - * @throws \Exception If render mode registration fails.
113 + * @throws \Exception
104 114 */
105 115 public function register_render_mode( Render_Mode_Manager $manager ) {
106 116 $manager->register_render_mode( Render_Mode_Preview::class );
107 117 }
@@ -159,25 +169,12 @@
159 169
160 170 private function print_thumbnail_preview_callback() {
161 171 $doc = Plugin::$instance->documents->get_current();
162 172
163 - if ( ! $doc ) {
164 - $render_mode = Plugin::$instance->frontend->render_mode_manager->get_current();
165 - if ( $render_mode instanceof Render_Mode_Preview ) {
166 - $doc = $render_mode->get_document();
167 - }
168 - }
173 + // PHPCS - should not be escaped.
174 + echo Plugin::$instance->frontend->get_builder_content_for_display( $doc->get_main_id(), true ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
169 175
170 - if ( ! $doc ) {
171 - echo '<div class="elementor-alert elementor-alert-danger">' . esc_html__( 'Document not found for preview.', 'elementor' ) . '</div>';
172 - return;
173 - }
174 -
175 - Plugin::$instance->documents->switch_to_document( $doc );
176 -
177 - $content = $doc->get_content( true );
178 -
179 - echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
176 + wp_delete_post( $doc->get_main_id(), true );
180 177 }
181 178
182 179
183 180 protected function is_screenshot_proxy_mode( array $query_params ) {