PluginProbe
Elementor Website Builder – more than just a page builder / 3.29.0-dev4
Elementor Website Builder – more than just a page builder v3.29.0-dev4
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 +31 -80 4.1.23.29.0-dev4 View file →
@@ -27,52 +27,33 @@
27 27
28 28 public function __construct() {
29 29 parent::__construct();
30 30
31 - $this->register_app();
31 + $this->register_experiment();
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);
54 -
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;
51 + return $module_name;
52 + }, 12);
58 53 }
59 54 }
60 55
61 - public function get_proxy_data( $url ) {
62 - $response = wp_safe_remote_get( $url );
63 -
64 - if ( is_wp_error( $response ) ) {
65 - return '';
66 - }
67 -
68 - $content_type = wp_remote_retrieve_headers( $response )->offsetGet( 'content-type' );
69 -
70 - header( 'content-type: ' . $content_type );
71 -
72 - return wp_remote_retrieve_body( $response );
73 - }
74 -
75 56 public function localize_settings( $settings ) {
76 57 if ( isset( $settings['i18n'] ) ) {
77 58 $settings['i18n']['folder'] = esc_html__( 'Folder', 'elementor' );
78 59 }
@@ -81,8 +62,18 @@
81 62
82 63 return $settings;
83 64 }
84 65
66 + private function register_experiment() {
67 + Plugin::$instance->experiments->add_feature( [
68 + 'name' => $this->get_name(),
69 + 'title' => esc_html__( 'Cloud Templates', 'elementor' ),
70 + 'description' => esc_html__( 'Cloud 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' ),
71 + 'release_status' => ExperimentsManager::RELEASE_STATUS_BETA,
72 + 'default' => ExperimentsManager::STATE_ACTIVE,
73 + ] );
74 + }
75 +
85 76 private function register_app() {
86 77 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
87 78 $connect_module->register_app( 'cloud-library', Cloud_Library::get_class_name() );
88 79 } );
@@ -99,9 +90,9 @@
99 90
100 91 /**
101 92 * @param Render_Mode_Manager $manager
102 93 *
103 - * @throws \Exception If render mode registration fails.
94 + * @throws \Exception
104 95 */
105 96 public function register_render_mode( Render_Mode_Manager $manager ) {
106 97 $manager->register_render_mode( Render_Mode_Preview::class );
107 98 }
@@ -128,11 +119,11 @@
128 119 'utm_campaign' => 'library-connect',
129 120 'utm_content' => 'cloud-library',
130 121 'source' => 'cloud-library',
131 122 ] ) ),
132 - 'library_connect_title_copy' => esc_html__( 'Connect to your Elementor account', 'elementor' ),
133 - 'library_connect_sub_title_copy' => esc_html__( 'Then you can find all your templates in one convenient library.', 'elementor' ),
134 - 'library_connect_button_copy' => esc_html__( 'Connect', 'elementor' ),
123 + 'library_connect_title' => esc_html__( 'Connect to your Elementor account', 'elementor' ),
124 + 'library_connect_sub_title' => esc_html__( 'Then you can find all your templates in one convenient library.', 'elementor' ),
125 + 'library_connect_button_text' => esc_html__( 'Connect', 'elementor' ),
135 126 ] );
136 127 }
137 128
138 129 private function get_document_types() {
@@ -159,50 +150,10 @@
159 150
160 151 private function print_thumbnail_preview_callback() {
161 152 $doc = Plugin::$instance->documents->get_current();
162 153
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 - }
154 + // PHPCS - should not be escaped.
155 + echo Plugin::$instance->frontend->get_builder_content_for_display( $doc->get_main_id(), true ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
169 156
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
180 - }
181 -
182 -
183 - protected function is_screenshot_proxy_mode( array $query_params ) {
184 - $is_proxy = isset( $query_params['screenshot_proxy'] );
185 -
186 - if ( $is_proxy ) {
187 - if ( ! wp_verify_nonce( $query_params['nonce'], 'screenshot-proxy' ) ) {
188 - // WP >= 6.2-alpha
189 - if ( class_exists( '\WpOrg\Requests\Exception\Http\Status403' ) ) {
190 - throw new \WpOrg\Requests\Exception\Http\Status403();
191 - } else {
192 - throw new \Requests_Exception_HTTP_403();
193 - }
194 - }
195 -
196 - if ( ! $query_params['href'] ) {
197 - // WP >= 6.2-alpha
198 - if ( class_exists( '\WpOrg\Requests\Exception\Http\Status400' ) ) {
199 - throw new \WpOrg\Requests\Exception\Http\Status400();
200 - } else {
201 - throw new \Requests_Exception_HTTP_400();
202 - }
203 - }
204 - }
205 -
206 - return $is_proxy;
157 + wp_delete_post( $doc->get_main_id(), true );
207 158 }
208 159 }