PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-dev2
Elementor Website Builder – more than just a page builder v3.28.0-dev2
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 +19 -102 4.1.33.28.0-dev2 View file →
@@ -2,10 +2,8 @@
2 2 namespace Elementor\Modules\CloudLibrary;
3 3
4 4 use Elementor\Core\Base\Module as BaseModule;
5 5 use Elementor\Core\Common\Modules\Connect\Module as ConnectModule;
6 -use Elementor\Core\Documents_Manager;
7 -use Elementor\Core\Frontend\Render_Mode_Manager;
8 6 use Elementor\Modules\CloudLibrary\Connect\Cloud_Library;
9 7 use Elementor\Core\Common\Modules\Connect\Apps\Library;
10 8 use Elementor\Core\Experiments\Manager as ExperimentsManager;
11 9 use Elementor\Plugin;
@@ -15,13 +13,8 @@
15 13 }
16 14
17 15 class Module extends BaseModule {
18 16
19 - /**
20 - * @var callable
21 - */
22 - protected $print_preview_callback;
23 -
24 17 public function get_name(): string {
25 18 return 'cloud-library';
26 19 }
27 20
@@ -27,41 +20,28 @@
27 20
28 21 public function __construct() {
29 22 parent::__construct();
30 23
31 - $this->register_app();
24 + $this->register_experiment();
32 25
33 - add_action( 'elementor/init', function () {
34 - $this->set_cloud_library_settings();
35 - }, 12 /** After the initiation of the connect cloud library */ );
26 + if ( Plugin::$instance->experiments->is_feature_active( $this->get_name() ) ) {
27 + $this->register_app();
36 28
37 - add_filter( 'elementor/editor/localize_settings', function ( $settings ) {
38 - return $this->localize_settings( $settings );
39 - }, 11 /** After Elementor Core */ );
40 -
41 - add_filter( 'elementor/render_mode/module', function( $module_name ) {
42 - $render_mode_manager = \Elementor\Plugin::$instance->frontend->render_mode_manager;
43 -
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 - }
50 - }
51 -
52 - return $module_name;
53 - }, 12);
29 + add_action( 'elementor/init', function () {
30 + $this->set_cloud_library_settings();
31 + }, 12 /** After the initiation of the connect cloud library */ );
32 + }
54 33 }
55 34
56 - public function localize_settings( $settings ) {
57 - if ( isset( $settings['i18n'] ) ) {
58 - $settings['i18n']['folder'] = esc_html__( 'Folder', 'elementor' );
59 - }
60 -
61 - $settings['library']['doc_types'] = $this->get_document_types();
62 -
63 - return $settings;
35 + private function register_experiment() {
36 + Plugin::$instance->experiments->add_feature( [
37 + 'name' => $this->get_name(),
38 + 'title' => esc_html__( 'Cloud Library', 'elementor' ),
39 + 'description' => esc_html__( 'Enable Cloud Library.', 'elementor' ),
40 + 'release_status' => ExperimentsManager::RELEASE_STATUS_DEV,
41 + 'default' => ExperimentsManager::STATE_INACTIVE,
42 + 'hidden' => true,
43 + ] );
64 44 }
65 45
66 46 private function register_app() {
67 47 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
@@ -66,28 +46,10 @@
66 46 private function register_app() {
67 47 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
68 48 $connect_module->register_app( 'cloud-library', Cloud_Library::get_class_name() );
69 49 } );
70 -
71 - add_action( 'elementor/frontend/render_mode/register', [ $this, 'register_render_mode' ] );
72 -
73 - add_action( 'elementor/documents/register', function ( Documents_Manager $documents_manager ) {
74 - $documents_manager->register_document_type(
75 - Documents\Cloud_Template_Preview::TYPE,
76 - Documents\Cloud_Template_Preview::get_class_full_name()
77 - );
78 - });
79 50 }
80 51
81 - /**
82 - * @param Render_Mode_Manager $manager
83 - *
84 - * @throws \Exception If render mode registration fails.
85 - */
86 - public function register_render_mode( Render_Mode_Manager $manager ) {
87 - $manager->register_render_mode( Render_Mode_Preview::class );
88 - }
89 -
90 52 private function set_cloud_library_settings() {
91 53 if ( ! Plugin::$instance->common ) {
92 54 return;
93 55 }
@@ -107,56 +69,11 @@
107 69 'utm_source' => 'template-library',
108 70 'utm_medium' => 'wp-dash',
109 71 'utm_campaign' => 'library-connect',
110 72 'utm_content' => 'cloud-library',
111 - 'source' => 'cloud-library',
112 73 ] ) ),
113 - 'library_connect_title_copy' => esc_html__( 'Connect to your Elementor account', 'elementor' ),
114 - 'library_connect_sub_title_copy' => esc_html__( 'Then you can find all your templates in one convenient library.', 'elementor' ),
115 - 'library_connect_button_copy' => esc_html__( 'Connect', 'elementor' ),
74 + 'library_connect_title' => esc_html__( 'Connect', 'elementor' ),
75 + 'library_connect_sub_title' => esc_html__( 'Sub Title', 'elementor' ),
76 + 'library_connect_button_text' => esc_html__( 'Connect', 'elementor' ),
116 77 ] );
117 - }
118 -
119 - private function get_document_types() {
120 - $document_types = Plugin::$instance->documents->get_document_types( [
121 - 'show_in_library' => true,
122 - ] );
123 -
124 - $data = [];
125 -
126 - foreach ( $document_types as $name => $document_type ) {
127 - $data[ $name ] = $document_type::get_title();
128 - }
129 -
130 - return $data;
131 - }
132 -
133 - public function print_content() {
134 - if ( ! $this->print_preview_callback ) {
135 - $this->print_preview_callback = [ $this, 'print_thumbnail_preview_callback' ];
136 - }
137 -
138 - call_user_func( $this->print_preview_callback );
139 - }
140 -
141 - private function print_thumbnail_preview_callback() {
142 - $doc = Plugin::$instance->documents->get_current();
143 -
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();
148 - }
149 - }
150 -
151 - if ( ! $doc ) {
152 - echo '<div class="elementor-alert elementor-alert-danger">' . esc_html__( 'Document not found for preview.', 'elementor' ) . '</div>';
153 - return;
154 - }
155 -
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
161 78 }
162 79 }