PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.9
Elementor Website Builder – more than just a page builder v3.35.9
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 +63 -0 4.2.13.35.9 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();
@@ -50,10 +52,29 @@
50 52 }
51 53
52 54 return $module_name;
53 55 }, 12);
56 +
57 + if ( $this->is_screenshot_proxy_mode( $_GET ) ) { // phpcs:ignore -- Checking nonce inside the method.
58 + echo $this->get_proxy_data( htmlspecialchars( $_GET['href'] ) ); // phpcs:ignore -- Nonce was checked on the above method
59 + die;
60 + }
54 61 }
55 62
63 + public function get_proxy_data( $url ) {
64 + $response = wp_safe_remote_get( $url );
65 +
66 + if ( is_wp_error( $response ) ) {
67 + return '';
68 + }
69 +
70 + $content_type = wp_remote_retrieve_headers( $response )->offsetGet( 'content-type' );
71 +
72 + header( 'content-type: ' . $content_type );
73 +
74 + return wp_remote_retrieve_body( $response );
75 + }
76 +
56 77 public function localize_settings( $settings ) {
57 78 if ( isset( $settings['i18n'] ) ) {
58 79 $settings['i18n']['folder'] = esc_html__( 'Folder', 'elementor' );
59 80 }
@@ -62,8 +83,23 @@
62 83
63 84 return $settings;
64 85 }
65 86
87 + private function register_experiments() {
88 + Plugin::$instance->experiments->add_feature( [
89 + 'name' => $this->get_name(),
90 + 'title' => esc_html__( 'Cloud Library', 'elementor' ),
91 + 'release_status' => ExperimentsManager::RELEASE_STATUS_STABLE,
92 + 'default' => ExperimentsManager::STATE_ACTIVE,
93 + 'hidden' => true,
94 + 'mutable' => false,
95 + 'new_site' => [
96 + 'always_active' => true,
97 + 'minimum_installation_version' => '3.32.0',
98 + ],
99 + ] );
100 + }
101 +
66 102 private function register_app() {
67 103 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
68 104 $connect_module->register_app( 'cloud-library', Cloud_Library::get_class_name() );
69 105 } );
@@ -157,6 +193,33 @@
157 193
158 194 $content = $doc->get_content( true );
159 195
160 196 echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
197 + }
198 +
199 +
200 + protected function is_screenshot_proxy_mode( array $query_params ) {
201 + $is_proxy = isset( $query_params['screenshot_proxy'] );
202 +
203 + if ( $is_proxy ) {
204 + if ( ! wp_verify_nonce( $query_params['nonce'], 'screenshot-proxy' ) ) {
205 + // WP >= 6.2-alpha
206 + if ( class_exists( '\WpOrg\Requests\Exception\Http\Status403' ) ) {
207 + throw new \WpOrg\Requests\Exception\Http\Status403();
208 + } else {
209 + throw new \Requests_Exception_HTTP_403();
210 + }
211 + }
212 +
213 + if ( ! $query_params['href'] ) {
214 + // WP >= 6.2-alpha
215 + if ( class_exists( '\WpOrg\Requests\Exception\Http\Status400' ) ) {
216 + throw new \WpOrg\Requests\Exception\Http\Status400();
217 + } else {
218 + throw new \Requests_Exception_HTTP_400();
219 + }
220 + }
221 + }
222 +
223 + return $is_proxy;
161 224 }
162 225 }