| @@ -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,14 +42,10 @@ | ||
| 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); |
| @@ -58,9 +56,9 @@ | ||
| 58 | 56 | } |
| 59 | 57 | } |
| 60 | 58 | |
| 61 | 59 | public function get_proxy_data( $url ) { |
| 62 | - $response = wp_safe_remote_get( $url ); | |
| 60 | + $response = wp_safe_remote_get( utf8_decode( $url ) ); | |
| 63 | 61 | |
| 64 | 62 | if ( is_wp_error( $response ) ) { |
| 65 | 63 | return ''; |
| 66 | 64 | } |
| @@ -81,8 +79,23 @@ | ||
| 81 | 79 | |
| 82 | 80 | return $settings; |
| 83 | 81 | } |
| 84 | 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 | + | |
| 85 | 98 | private function register_app() { |
| 86 | 99 | add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) { |
| 87 | 100 | $connect_module->register_app( 'cloud-library', Cloud_Library::get_class_name() ); |
| 88 | 101 | } ); |
| @@ -99,9 +112,9 @@ | ||
| 99 | 112 | |
| 100 | 113 | /** |
| 101 | 114 | * @param Render_Mode_Manager $manager |
| 102 | 115 | * |
| 103 | - * @throws \Exception If render mode registration fails. | |
| 116 | + * @throws \Exception | |
| 104 | 117 | */ |
| 105 | 118 | public function register_render_mode( Render_Mode_Manager $manager ) { |
| 106 | 119 | $manager->register_render_mode( Render_Mode_Preview::class ); |
| 107 | 120 | } |
| @@ -159,25 +172,12 @@ | ||
| 159 | 172 | |
| 160 | 173 | private function print_thumbnail_preview_callback() { |
| 161 | 174 | $doc = Plugin::$instance->documents->get_current(); |
| 162 | 175 | |
| 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 | - } | |
| 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 | |
| 169 | 178 | |
| 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 | |
| 179 | + wp_delete_post( $doc->get_main_id(), true ); | |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 | protected function is_screenshot_proxy_mode( array $query_params ) { |