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