PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.2
Elementor Website Builder – more than just a page builder v3.32.2
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 +66 -20 4.2.03.32.2 View file →
@@ -27,8 +27,10 @@
27 27
28 28 public function __construct() {
29 29 parent::__construct();
30 30
31 + $this->register_experiments();
32 +
31 33 $this->register_app();
32 34
33 35 add_action( 'elementor/init', function () {
34 36 $this->set_cloud_library_settings();
@@ -40,20 +42,35 @@
40 42
41 43 add_filter( 'elementor/render_mode/module', function( $module_name ) {
42 44 $render_mode_manager = \Elementor\Plugin::$instance->frontend->render_mode_manager;
43 45
44 - if ( $render_mode_manager ) {
45 - $current_render_mode = $render_mode_manager->get_current();
46 -
47 - if ( $current_render_mode instanceof \Elementor\Modules\CloudLibrary\Render_Mode_Preview ) {
48 - return 'cloud-library';
49 - }
46 + if ( $render_mode_manager && $render_mode_manager->get_current() instanceof \Elementor\Modules\CloudLibrary\Render_Mode_Preview ) {
47 + return 'cloud-library';
50 48 }
51 49
52 50 return $module_name;
53 51 }, 12);
52 +
53 + if ( $this->is_screenshot_proxy_mode( $_GET ) ) { // phpcs:ignore -- Checking nonce inside the method.
54 + echo $this->get_proxy_data( htmlspecialchars( $_GET['href'] ) ); // phpcs:ignore -- Nonce was checked on the above method
55 + die;
56 + }
54 57 }
55 58
59 + public function get_proxy_data( $url ) {
60 + $response = wp_safe_remote_get( utf8_decode( $url ) );
61 +
62 + if ( is_wp_error( $response ) ) {
63 + return '';
64 + }
65 +
66 + $content_type = wp_remote_retrieve_headers( $response )->offsetGet( 'content-type' );
67 +
68 + header( 'content-type: ' . $content_type );
69 +
70 + return wp_remote_retrieve_body( $response );
71 + }
72 +
56 73 public function localize_settings( $settings ) {
57 74 if ( isset( $settings['i18n'] ) ) {
58 75 $settings['i18n']['folder'] = esc_html__( 'Folder', 'elementor' );
59 76 }
@@ -62,8 +79,23 @@
62 79
63 80 return $settings;
64 81 }
65 82
83 + private function register_experiments() {
84 + Plugin::$instance->experiments->add_feature( [
85 + 'name' => $this->get_name(),
86 + 'title' => esc_html__( 'Cloud Library', 'elementor' ),
87 + 'release_status' => ExperimentsManager::RELEASE_STATUS_STABLE,
88 + 'default' => ExperimentsManager::STATE_ACTIVE,
89 + 'hidden' => true,
90 + 'mutable' => false,
91 + 'new_site' => [
92 + 'always_active' => true,
93 + 'minimum_installation_version' => '3.32.0',
94 + ],
95 + ] );
96 + }
97 +
66 98 private function register_app() {
67 99 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
68 100 $connect_module->register_app( 'cloud-library', Cloud_Library::get_class_name() );
69 101 } );
@@ -80,9 +112,9 @@
80 112
81 113 /**
82 114 * @param Render_Mode_Manager $manager
83 115 *
84 - * @throws \Exception If render mode registration fails.
116 + * @throws \Exception
85 117 */
86 118 public function register_render_mode( Render_Mode_Manager $manager ) {
87 119 $manager->register_render_mode( Render_Mode_Preview::class );
88 120 }
@@ -140,23 +172,37 @@
140 172
141 173 private function print_thumbnail_preview_callback() {
142 174 $doc = Plugin::$instance->documents->get_current();
143 175
144 - if ( ! $doc ) {
145 - $render_mode = Plugin::$instance->frontend->render_mode_manager->get_current();
146 - if ( $render_mode instanceof Render_Mode_Preview ) {
147 - $doc = $render_mode->get_document();
176 + // PHPCS - should not be escaped.
177 + echo Plugin::$instance->frontend->get_builder_content_for_display( $doc->get_main_id(), true ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
178 +
179 + wp_delete_post( $doc->get_main_id(), true );
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 + }
148 194 }
149 - }
150 195
151 - if ( ! $doc ) {
152 - echo '<div class="elementor-alert elementor-alert-danger">' . esc_html__( 'Document not found for preview.', 'elementor' ) . '</div>';
153 - return;
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 + }
154 204 }
155 205
156 - Plugin::$instance->documents->switch_to_document( $doc );
157 -
158 - $content = $doc->get_content( true );
159 -
160 - echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
206 + return $is_proxy;
161 207 }
162 208 }