PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.3
Elementor Website Builder – more than just a page builder v3.32.3
4.3.1 4.3.0 4.3.0-beta3 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 All 454 releases
← All changes | modules/pro-install/pro-install-menu-item.php +170 -6 4.3.0 → 3.32.3 View file →
@@ -9,13 +9,15 @@
9 9 }
10 10
11 11 class Pro_Install_Menu_Item implements Admin_Menu_Item_With_Page {
12 12
13 - private Connect_Page_Renderer $renderer;
13 + private Connect $connect;
14 14
15 - public function __construct( Connect $connect, array $script_config ) {
16 - $page_url = admin_url( 'admin.php?page=elementor-connect-account' );
17 - $this->renderer = new Connect_Page_Renderer( $connect, $page_url, $script_config );
15 + private string $page_url;
16 +
17 + public function __construct( Connect $connect ) {
18 + $this->connect = $connect;
19 + $this->page_url = admin_url( 'admin.php?page=elementor-connect-account' );
18 20 }
19 21
20 22 public function get_label(): string {
21 23 return esc_html__( 'Connect Account', 'elementor' );
@@ -33,11 +35,173 @@
33 35 return Settings::PAGE_ID;
34 36 }
35 37
36 38 public function is_visible(): bool {
37 - return true;
39 + return false;
38 40 }
39 41
40 42 public function render() {
41 - $this->renderer->render();
43 + $this->enqueue_scripts();
44 + ?>
45 + <div class="wrap elementor-admin-page-license">
46 + <h2 class="wp-heading-inline"><?php echo esc_html( $this->get_page_title() ); ?></h2>
47 + <?php
48 + if ( ! $this->connect->is_connected() ) {
49 + $this->render_connect_box();
50 + } else {
51 + $this->render_license_box();
52 + }
53 + ?>
54 + </div>
55 + <?php
56 + }
57 +
58 + private function render_connect_box() {
59 + $connect_url = $this->connect->get_admin_url( 'authorize', [
60 + 'utm_source' => 'license-page-connect-free',
61 + 'utm_medium' => 'wp-dash',
62 + 'utm_campaign' => 'connect-and-activate-license',
63 + 'redirect_to' => $this->page_url,
64 + ] );
65 +
66 + ?>
67 + <div class="elementor-license-box">
68 + <h3><?php echo esc_html__( 'Connect your Elementor Account', 'elementor' ); ?></h3>
69 +
70 + <p>
71 + <?php echo esc_html__( 'Gain access to dozens of professionally designed templates, and connect your site to your My Elementor Dashboard.', 'elementor' ); ?>
72 + </p>
73 +
74 + <div class="elementor-box-action">
75 + <a id="elementor-connect-license" class="button button-primary" href="<?php echo esc_url( $connect_url ); ?>">
76 + <?php echo esc_html__( 'Connect to Elementor', 'elementor' ); ?>
77 + </a>
78 + </div>
79 + </div>
80 + <?php
81 + }
82 +
83 + private function render_license_box() {
84 + $disconnect_url = $this->connect->get_admin_url( 'disconnect', [
85 + 'redirect_to' => $this->page_url,
86 + ] );
87 + $download_link = $this->connect->get_download_link();
88 +
89 + ?>
90 + <div class="elementor-license-box">
91 + <h3>
92 + <?php echo esc_html__( 'Status', 'elementor' ); ?>:
93 + <span style="color: #008000; font-style: italic;"><?php echo esc_html__( 'Connected', 'elementor' ); ?></span>
94 + <small>
95 + <a class="button" href="https://go.elementor.com/my-account/" target="_blank">
96 + <?php echo esc_html__( 'My Account', 'elementor' ); ?>
97 + </a>
98 + </small>
99 + </h3>
100 +
101 + <p class="e-row-stretch e-row-divider-bottom">
102 + <span>
103 + <?php
104 + $connected_user = $this->get_connected_account();
105 +
106 + if ( $connected_user ) :
107 + printf(
108 + /* translators: %s: Connected user. */
109 + esc_html__( 'You\'re connected as %s.', 'elementor' ),
110 + '<strong>' . esc_html( $connected_user ) . '</strong>'
111 + );
112 + endif;
113 + ?>
114 + </span>
115 + </p>
116 +
117 + <p class="e-row-stretch">
118 + <span><?php echo esc_html__( 'Want to disconnect for any reason?', 'elementor' ); ?></span>
119 + <a class="button" href="<?php echo esc_url( $disconnect_url ); ?>">
120 + <?php echo esc_html__( 'Disconnect', 'elementor' ); ?>
121 + </a>
122 + </p>
123 + </div>
124 + <?php
125 + if ( empty( $download_link ) ) {
126 + $this->render_promotion_box();
127 + } else {
128 + $this->render_install_or_activate_box();
129 + }
130 + }
131 +
132 + private function get_connected_account() {
133 + $user = $this->connect->get( 'user' );
134 +
135 + $email = '';
136 + if ( $user ) {
137 + $email = $user->email;
138 + }
139 +
140 + return $email;
141 + }
142 +
143 + private function render_promotion_box() {
144 + ?>
145 + <div class="elementor-license-box elementor-pro-connect-promotion">
146 + <div>
147 + <h2><?php echo esc_html__( 'Upgrade to Pro to unlock powerful design tools and advanced features.', 'elementor' ); ?></h2>
148 + <p><?php echo esc_html__( 'Build custom headers, footers, forms, popups, and WooCommerce stores.', 'elementor' ); ?></p>
149 + <div class="elementor-box-action">
150 + <a class="button button-upgrade" href="https://go.elementor.com/go-pro-connect-account-screen" target="_blank">
151 + <i class="eicon-upgrade-crown" aria-hidden="true"></i>
152 + <?php echo esc_html__( 'Upgrade Now', 'elementor' ); ?>
153 + </a>
154 + </div>
155 + </div>
156 + <img src="https://assets.elementor.com/free-to-pro-upsell/v1/images/connect-pro-upgrade.jpg" alt="<?php echo esc_attr__( 'Pro Upgrade', 'elementor' ); ?>" />
157 + </div>
158 + <?php
159 + }
160 +
161 + private function render_install_or_activate_box() {
162 + $ctr_data = $this->get_cta_data();
163 + $ctr_url = wp_nonce_url( admin_url( 'admin-post.php?action=elementor_do_pro_install' ), 'elementor_do_pro_install' );
164 + $ctr_id = $this->is_pro_installed() ? 'elementor-connect-activate-pro' : 'elementor-connect-install-pro';
165 +
166 + ?>
167 + <div class="elementor-license-box">
168 + <h3><?php echo esc_html__( 'You\'ve got Elementor Pro', 'elementor' ); ?></h3>
169 +
170 + <p><?php echo esc_html( $ctr_data['description'] ); ?></p>
171 + <p class="elementor-box-action">
172 + <a id="<?php echo esc_attr( $ctr_id ); ?>" class="button button-primary" href="<?php echo esc_url( $ctr_url ); ?>">
173 + <?php echo esc_html( $ctr_data['button_text'] ); ?>
174 + </a>
175 + </p>
176 + </div>
177 + <?php
178 + }
179 +
180 + private function get_cta_data(): array {
181 + return [
182 + 'description' => esc_html__( 'Enjoy full access to powerful design tools, advanced widgets, and everything you need to create next-level websites.', 'elementor' ),
183 + 'button_text' => $this->is_pro_installed() ? esc_html__( 'Activate Elementor Pro', 'elementor' ) : esc_html__( 'Install & Activate', 'elementor' ),
184 + ];
185 + }
186 +
187 + private function is_pro_installed(): bool {
188 + $file_path = $this->get_elementor_pro_file_path();
189 + $installed_plugins = get_plugins();
190 +
191 + return isset( $installed_plugins[ $file_path ] );
192 + }
193 +
194 + private function get_elementor_pro_file_path(): string {
195 + return 'elementor-pro/elementor-pro.php';
196 + }
197 +
198 + private function enqueue_scripts() {
199 + wp_enqueue_script(
200 + 'elementor-pro-install-events',
201 + ELEMENTOR_URL . 'modules/pro-install/assets/js/pro-install-events.js',
202 + [ 'elementor-common' ],
203 + ELEMENTOR_VERSION,
204 + true
205 + );
42 206 }
43 207 }