PluginProbe ʕ •ᴥ•ʔ
Ultimate Addons for Elementor / 1.6.17
Ultimate Addons for Elementor v1.6.17
2.8.8 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 v1.1.3 v1.1.4 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.29 1.6.3 1.6.30 1.6.31 1.6.32 1.6.33 1.6.34 1.6.35 1.6.36 1.6.37 1.6.38 1.6.39 1.6.4 1.6.40 1.6.41 1.6.42 1.6.43 1.6.44 1.6.45 1.6.46 1.6.47 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.2 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2
header-footer-elementor / inc / class-hfe-settings-page.php
header-footer-elementor / inc Last commit date
compatibility 5 years ago js 3 years ago lib 4 years ago widgets-css 4 years ago widgets-manager 2 years ago class-header-footer-elementor.php 2 years ago class-hfe-elementor-canvas-compat.php 6 years ago class-hfe-settings-page.php 4 years ago class-hfe-update.php 6 years ago hfe-functions.php 6 years ago
class-hfe-settings-page.php
814 lines
1 <?php
2 /**
3 * HFE Settings Page.
4 *
5 * Add plugin setting page.
6 *
7 * @since 1.6.0
8 * @package hfe
9 */
10
11 namespace HFE\Themes;
12
13 /**
14 * Class Settings Page.
15 *
16 * @since 1.6.0
17 */
18 class HFE_Settings_Page {
19
20 /**
21 * Constructor.
22 *
23 * @since 1.6.0
24 */
25 public function __construct() {
26 add_action( 'admin_head', [ $this, 'hfe_global_css' ] );
27 add_action( 'admin_menu', [ $this, 'hfe_register_settings_page' ] );
28 add_action( 'admin_init', [ $this, 'hfe_admin_init' ] );
29 add_filter( 'views_edit-elementor-hf', [ $this, 'hfe_settings' ], 10, 1 );
30 add_filter( 'admin_footer_text', [ $this, 'admin_footer_text' ] );
31 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_scripts' ] );
32 add_filter( 'plugin_action_links_' . HFE_PATH, [ $this, 'settings_link' ] );
33 }
34
35 /**
36 * Settings tab array
37 *
38 * @var settings tabs
39 */
40 public static $hfe_settings_tabs;
41
42 /**
43 * Adds CSS to Hide the extra submenu added for the settings tab.
44 *
45 * @since 1.6.0
46 * @return void
47 */
48 public function hfe_global_css() {
49 wp_enqueue_style( 'hfe-admin-style', HFE_URL . 'admin/assets/css/ehf-admin.css', [], HFE_VER );
50 }
51
52 /**
53 * Load admin styles on header footer elementor edit screen.
54 */
55 public function enqueue_admin_scripts() {
56 wp_enqueue_script( 'hfe-admin-script', HFE_URL . 'admin/assets/js/ehf-admin.js', [ 'jquery', 'updates' ], HFE_VER, true );
57
58 $is_dismissed = get_user_meta( get_current_user_id(), 'hfe-popup' );
59
60 $strings = [
61 'addon_activate' => esc_html__( 'Activate', 'header-footer-elementor' ),
62 'addon_activated' => esc_html__( 'Activated', 'header-footer-elementor' ),
63 'addon_active' => esc_html__( 'Active', 'header-footer-elementor' ),
64 'addon_deactivate' => esc_html__( 'Deactivate', 'header-footer-elementor' ),
65 'addon_inactive' => esc_html__( 'Inactive', 'header-footer-elementor' ),
66 'addon_install' => esc_html__( 'Install', 'header-footer-elementor' ),
67 'theme_installed' => esc_html__( 'Theme Installed', 'header-footer-elementor' ),
68 'plugin_installed' => esc_html__( 'Plugin Installed', 'header-footer-elementor' ),
69 'addon_download' => esc_html__( 'Download', 'header-footer-elementor' ),
70 'addon_exists' => esc_html__( 'Already Exists.', 'header-footer-elementor' ),
71 'visit_site' => esc_html__( 'Visit Website', 'header-footer-elementor' ),
72 'plugin_error' => esc_html__( 'Could not install. Please download from WordPress.org and install manually.', 'header-footer-elementor' ),
73 'subscribe_success' => esc_html__( 'Your details are submitted successfully.', 'header-footer-elementor' ),
74 'subscribe_error' => esc_html__( 'Encountered an error while performing your request.', 'header-footer-elementor' ),
75 'ajax_url' => admin_url( 'admin-ajax.php' ),
76 'nonce' => wp_create_nonce( 'hfe-admin-nonce' ),
77 'popup_dismiss' => false,
78 'data_source' => 'HFE',
79 ];
80
81 $strings = apply_filters( 'hfe_admin_strings', $strings );
82
83 wp_localize_script(
84 'hfe-admin-script',
85 'hfe_admin_data',
86 $strings
87 );
88
89 }
90
91 /**
92 * Adds a tab in plugin submenu page.
93 *
94 * @since 1.6.0
95 * @param string $views to add tab to current post type view.
96 *
97 * @return mixed
98 */
99 public function hfe_settings( $views ) {
100
101 $this->hfe_tabs();
102 $this->hfe_modal();
103 return $views;
104
105 }
106
107 /**
108 * Function for registering the settings api.
109 *
110 * @since 1.6.0
111 * @return void
112 */
113 public function hfe_admin_init() {
114 register_setting( 'hfe-plugin-options', 'hfe_compatibility_option' );
115 add_settings_section( 'hfe-options', __( 'Add Theme Support', 'header-footer-elementor' ), [ $this, 'hfe_compatibility_callback' ], 'Settings' );
116 add_settings_field( 'hfe-way', 'Methods to Add Theme Support', [ $this, 'hfe_compatibility_option_callback' ], 'Settings', 'hfe-options' );
117
118 register_setting( 'hfe-plugin-guide', 'hfe_guide_email' );
119 register_setting( 'hfe-plugin-guide', 'hfe_guide_fname' );
120
121 }
122
123 /**
124 * Call back function for the ssettings api function add_settings_section
125 *
126 * This function can be used to add description of the settings sections
127 *
128 * @since 1.6.0
129 * @return void
130 */
131 public function hfe_compatibility_callback() {
132 _e( 'The Elementor Header & Footer Builder plugin need compatibility with your current theme to work smoothly.</br></br>Following are two methods that enable theme support for the plugin.</br></br>Method 1 is selected by default and that works fine almost will all themes. In case, you face any issue with the header or footer template, try choosing Method 2.', 'header-footer-elementor' );
133 }
134
135 /**
136 * Call back function for the ssettings api function add_settings_field
137 *
138 * This function will contain the markup for the input feilds that we can add.
139 *
140 * @since 1.6.0
141 * @return void
142 */
143 public function hfe_compatibility_option_callback() {
144 $hfe_radio_button = get_option( 'hfe_compatibility_option', '1' );
145 wp_enqueue_style( 'hfe-admin-style', HFE_URL . 'admin/assets/css/ehf-admin.css', [], HFE_VER );
146 ?>
147
148 <label>
149 <input type="radio" name="hfe_compatibility_option" value= 1 <?php checked( $hfe_radio_button, 1 ); ?> > <div class="hfe_radio_options"><?php esc_html_e( ' Method 1 (Recommended)', 'header-footer-elementor' ); ?></div>
150 <p class="description"><?php esc_html_e( 'This method replaces your theme\'s header (header.php) & footer (footer.php) template with plugin\'s custom templates.', 'header-footer-elementor' ); ?></p><br>
151 </label>
152 <label>
153 <input type="radio" name="hfe_compatibility_option" value= 2 <?php checked( $hfe_radio_button, 2 ); ?> > <div class="hfe_radio_options"><?php esc_html_e( 'Method 2', 'header-footer-elementor' ); ?></div>
154 <p class="description">
155 <?php
156 echo sprintf(
157 esc_html( "This method hides your theme's header & footer template with CSS and displays custom templates from the plugin.", 'header-footer-elementor' ),
158 '<br>'
159 );
160 ?>
161 </p><br>
162 </label>
163 <p class="description">
164 <?php
165 echo sprintf(
166 _e( 'Sometimes above methods might not work well with your theme, in this case, contact your theme author and request them to add support for the <a href="https://github.com/Nikschavan/header-footer-elementor/wiki/Adding-Header-Footer-Elementor-support-for-your-theme">plugin.</>', 'header-footer-elementor' ),
167 '<br>'
168 );
169 ?>
170 </p>
171
172 <?php
173 }
174
175 /**
176 * Show a settings page incase of unsupported theme.
177 *
178 * @since 1.6.0
179 *
180 * @return void
181 */
182 public function hfe_register_settings_page() {
183 add_submenu_page(
184 'themes.php',
185 __( 'Settings', 'header-footer-elementor' ),
186 __( 'Settings', 'header-footer-elementor' ),
187 'manage_options',
188 'hfe-settings',
189 [ $this, 'hfe_settings_page' ]
190 );
191
192 add_submenu_page(
193 'themes.php',
194 __( 'About Us', 'header-footer-elementor' ),
195 __( 'About Us', 'header-footer-elementor' ),
196 'manage_options',
197 'hfe-about',
198 [ $this, 'hfe_settings_page' ]
199 );
200 }
201
202 /**
203 * Settings page.
204 *
205 * Call back function for add submenu page function.
206 *
207 * @since 1.6.0
208 */
209 public function hfe_settings_page() {
210 echo '<h1 class="hfe-heading-inline">';
211 esc_attr_e( 'Elementor Header & Footer Builder ', 'header-footer-elementor' );
212 echo '</h1>';
213 $this->hfe_tabs();
214 ?>
215 <?php
216 $hfe_radio_button = get_option( 'hfe_compatibility_option', '1' );
217 ?>
218 <?php
219 switch ( $_GET['page'] ) {
220 case 'hfe-settings':
221 $this->get_themes_support();
222 break;
223
224 case 'hfe-about':
225 $this->get_about_html();
226 break;
227
228 case 'default':
229 break;
230 }
231 }
232
233 /**
234 * Settings page - load modal content.
235 *
236 * Call back function for add submenu page function.
237 *
238 * @since 1.6.2
239 */
240 public function hfe_modal() {
241 $is_dismissed = [];
242 $is_dismissed = get_user_meta( get_current_user_id(), 'hfe-popup' );
243
244 $is_subscribed = get_user_meta( get_current_user_ID(), 'hfe-subscribed' );
245 $subscribe_valid = ( is_array( $is_subscribed ) && isset( $is_subscribed[0] ) && 'yes' === $is_subscribed[0] ) ? 'yes' : false;
246
247 if ( ( ! empty( $is_dismissed ) && 'dismissed' === $is_dismissed[0] ) || 'yes' === $subscribe_valid ) {
248 return false;
249 } else {
250 $this->get_guide_modal();
251 }
252 }
253
254 /**
255 * Function for adding tabs
256 *
257 * @since 1.6.0
258 * @return void
259 */
260 public function hfe_tabs() {
261 ?>
262 <div class="nav-tab-wrapper">
263 <?php
264 if ( ! isset( self::$hfe_settings_tabs ) ) {
265 self::$hfe_settings_tabs['hfe_templates'] = [
266 'name' => __( 'All Templates', 'header-footer-elementor' ),
267 'url' => admin_url( 'edit.php?post_type=elementor-hf' ),
268 ];
269 }
270
271 self::$hfe_settings_tabs['hfe_about'] = [
272 'name' => __( 'About Us', 'header-footer-elementor' ),
273 'url' => admin_url( 'themes.php?page=hfe-about' ),
274 ];
275
276 $tabs = apply_filters( 'hfe_settings_tabs', self::$hfe_settings_tabs );
277
278 foreach ( $tabs as $tab_id => $tab ) {
279
280 $tab_slug = str_replace( '_', '-', $tab_id );
281
282 $active_tab = ( ( isset( $_GET['page'] ) && $tab_slug == $_GET['page'] ) || ( ! isset( $_GET['page'] ) && 'hfe_templates' == $tab_id ) ) ? $tab_id : '';
283
284 $active = ( $active_tab == $tab_id ) ? ' nav-tab-active' : '';
285
286 echo '<a href="' . esc_url( $tab['url'] ) . '" class="nav-tab' . esc_attr( $active ) . '">';
287 echo esc_html( $tab['name'] );
288 echo '</a>';
289 }
290
291 ?>
292 </div>
293 <?php
294 }
295
296 /**
297 * Admin footer text.
298 *
299 * Modifies the "Thank you" text displayed in the admin footer.
300 *
301 * Fired by `admin_footer_text` filter.
302 *
303 * @since 1.6.0
304 * @access public
305 *
306 * @param string $footer_text The content that will be printed.
307 *
308 * @return string The content that will be printed.
309 */
310 public function admin_footer_text( $footer_text ) {
311 $current_screen = get_current_screen();
312
313 $is_elementor_screen = ( $current_screen && ( 'elementor-hf' === $current_screen->post_type || 'appearance_page_hfe-guide' === $current_screen->id || 'appearance_page_hfe-about' === $current_screen->id || 'appearance_page_hfe-settings' === $current_screen->id ) );
314
315 if ( $is_elementor_screen ) {
316 $footer_text = sprintf(
317 /* translators: 1: Elementor, 2: Link to plugin review */
318 __( 'Help us spread the word about the plugin by leaving %2$s %1$s %3$s ratings on %2$s WordPress.org %3$s. Thank you from the Brainstorm Force team!', 'header-footer-elementor' ),
319 '&#9733;&#9733;&#9733;&#9733;&#9733;',
320 '<a href="https://wordpress.org/support/plugin/header-footer-elementor/reviews/#new-post" target="_blank">',
321 '</a>'
322 );
323 }
324
325 return $footer_text;
326 }
327
328 /**
329 * Function for theme support tab
330 *
331 * @since 1.6.0
332 * @return void
333 */
334 public function get_themes_support() {
335 ?>
336 <form action="options.php" method="post">
337 <?php settings_fields( 'hfe-plugin-options' ); ?>
338 <?php do_settings_sections( 'Settings' ); ?>
339 <?php submit_button(); ?>
340 </form>
341 <?php
342 }
343
344 /**
345 * Function for Step-By-Step guide
346 *
347 * @since 1.6.0
348 * @return void
349 */
350 public function get_guide_html() {
351
352 $is_subscribed = get_user_meta( get_current_user_ID(), 'hfe-subscribed' );
353 $subscribe_valid = ( is_array( $is_subscribed ) && isset( $is_subscribed[0] ) && 'yes' === $is_subscribed[0] ) ? 'yes' : false;
354 $subscribe_flag = ( 'yes' === $subscribe_valid ) ? ' hfe-user-subscribed' : ' hfe-user-unsubscribed';
355 ?>
356
357 <div class="hfe-admin-about-section hfe-admin-columns hfe-admin-guide-section<?php echo $subscribe_flag; ?>">
358
359 <div class="hfe-admin-column-50">
360 <div class="hfe-admin-about-section-column">
361 <h2><?php esc_html_e( 'Create Impressive Header and Footer Designs', 'header-footer-elementor' ); ?></h2>
362 <p><?php esc_html_e( 'Elementor Header & Footer Builder plugin lets you build impactful navigation for your website very easily. Before we begin, we would like to know more about you. This will help us to serve you better.', 'header-footer-elementor' ); ?></p>
363 </div>
364 </div>
365 <?php if ( 'yes' !== $subscribe_valid ) { ?>
366 <div class="hfe-admin-column-50 hfe-admin-column-last">
367 <div class="hfe-guide-content hfe-subscription-step-1-active">
368 <div class="hfe-guide-content-header hfe-admin-columns">
369 </div>
370 <form action="options.php" method="post">
371 <?php $this->get_form_html(); ?>
372 </form>
373 </div>
374 <div class="hfe-privacy-policy-container">
375 <?php /* translators: %1$s and %3$s are opening anchor tags, and %2$s and %4$s is closing anchor tags. */ ?>
376 <p class="hfe-subscription-policy"><?php printf( __( 'By submitting, you agree to our %1$sTerms%2$s and %3$sPrivacy Policy%4$s.', 'header-footer-elementor' ), '<a href="https://store.brainstormforce.com/terms-and-conditions/" target="_blank">', '</a>', '<a href="https://store.brainstormforce.com/privacy-policy/" target="_blank">', '</a>' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
377 </div>
378 </div>
379 <?php } ?>
380 </div>
381 <?php
382 }
383
384 /**
385 * Function for form HTML
386 *
387 * @since 1.6.0
388 * @return void
389 */
390 public function get_form_html() {
391 ?>
392 <?php $this->get_form_row_1(); ?>
393 <?php $this->get_form_row_2(); ?>
394 <a href="#" class="button-subscription-skip"><?php esc_html_e( 'Skip', 'header-footer-elementor' ); ?></a>
395 <?php
396 }
397
398 /**
399 * Function for form Row 1 HTML
400 *
401 * @since 1.6.0
402 * @return void
403 */
404 public function get_form_row_1() {
405 ?>
406
407 <div class="hfe-subscription-step-1">
408 <div class="hfe-subscription-row">
409 <div class="hfe-input-container">
410 <select class="hfe-subscribe-field subscription-input-wp-user-type" name="wp_user_type">
411 <option value=""></option>
412 <option value="1"><?php esc_html_e( 'Beginner', 'header-footer-elementor' ); ?></option>
413 <option value="2"><?php esc_html_e( 'Intermediate', 'header-footer-elementor' ); ?></option>
414 <option value="3"><?php esc_html_e( 'Expert', 'header-footer-elementor' ); ?></option>
415 </select>
416 <small class="subscription-desc"><?php esc_html_e( 'Field is required', 'header-footer-elementor' ); ?></small>
417 <label class="subscription-label"><?php esc_html_e( 'I\'m a WordPress:', 'header-footer-elementor' ); ?></label>
418 </div>
419 <div class="hfe-input-container">
420 <select class="hfe-subscribe-field subscription-input-build-website-for" name="build_website_for">
421 <option value=""></option>
422 <option value="1"><?php esc_html_e( 'Myself/My company', 'header-footer-elementor' ); ?></option>
423 <option value="2"><?php esc_html_e( 'My client', 'header-footer-elementor' ); ?></option>
424 </select>
425 <small class="subscription-desc"><?php esc_html_e( 'Field is required', 'header-footer-elementor' ); ?></small>
426 <label class="subscription-label"><?php esc_html_e( 'I\'m building website for:', 'header-footer-elementor' ); ?></label>
427 </div>
428 </div>
429
430 <p class="submit">
431 <input type="submit" name="submit-1" id="submit-1" class="button submit-1 button-primary" value="Next">
432 </p>
433 </div>
434 <?php
435 }
436
437 /**
438 * Function for form Row 2 HTML
439 *
440 * @since 1.6.0
441 * @return void
442 */
443 public function get_form_row_2() {
444 ?>
445 <div class="hfe-subscription-step-2">
446 <div class="hfe-subscription-row">
447 <div class="hfe-input-container">
448 <input id="hfe_subscribe_name" class="hfe-subscribe-field hfe-subscribe-name" type="text" name="hfe_subscribe_name" value="<?php echo get_option( 'hfe_guide_fname' ); ?>">
449 <small class="subscription-desc"><?php esc_html_e( 'First name is required', 'header-footer-elementor' ); ?></small>
450 <label class="subscription-label"><?php esc_html_e( 'Your First Name', 'header-footer-elementor' ); ?></label>
451 </div>
452 <div class="hfe-input-container">
453 <input id="hfe_subscribe_email" class="hfe-subscribe-field hfe-subscribe-email" type="text" name="hfe_subscribe_email" value="<?php echo get_option( 'hfe_guide_email' ); ?>">
454 <small class="subscription-desc"><?php esc_html_e( 'Email address is required', 'header-footer-elementor' ); ?></small>
455 <label class="subscription-label"><?php esc_html_e( 'Your Work Email', 'header-footer-elementor' ); ?></label>
456 </div>
457 <div class="hfe-input-container">
458 <input type="checkbox" name="hfe_subscribe_accept" id="hfe_subscribe_accept" class="hfe_subscribe_accept" value="check">
459 <label for="hfe_subscribe_accept" class="hfe-subscribe-accept-label"><?php esc_html_e( 'I agree to receive your newsletters and accept the data privacy statement.', 'header-footer-elementor' ); ?></label>
460 </div>
461 </div>
462 <p class="submit">
463 <button type="submit" id="submit-2" class="button submit-2 button-primary">
464 <span class="hfe-submit-button-text"><?php echo __( 'Submit', 'header-footer-elementor' ); ?></span>
465 </button>
466 </p>
467 </div>
468 <?php
469 }
470
471
472 /**
473 * Function for Step-By-Step guide modal popup
474 *
475 * @since 1.6.0
476 * @return void
477 */
478 public function get_guide_modal() {
479 $new_page_url = admin_url( 'post-new.php?post_type=elementor-hf' );
480 ?>
481 <div class="hfe-guide-modal-popup" data-new-page="<?php echo esc_attr( $new_page_url ); ?>">
482 <div class="hfe-guide-modal-popup-wrapper">
483 <div class="hfe-guide-modal-content">
484 <div class="heading">
485 <img src="<?php echo HFE_URL . 'assets/images/header-footer-elementor-icon.svg'; ?>" class="hfe-logo">
486 <h3><?php esc_html_e( 'Elementor Header & Footer Builder', 'header-footer-elementor' ); ?></h3>
487 </div>
488 <?php $this->get_guide_html(); ?>
489 </div>
490 </div>
491 <div class="hfe-guide-modal-overlay"></div>
492 </div>
493 <?php
494 }
495
496 /**
497 * Function for About us HTML
498 *
499 * @since 1.6.0
500 * @return void
501 */
502 public function get_about_html() {
503 $this->output_about_info();
504 $this->output_about_addons();
505 }
506
507 /**
508 * Display the General Info section of About tab.
509 *
510 * @since 1.6.0
511 */
512 protected function output_about_info() {
513 ?>
514
515 <div class="hfe-admin-about-section hfe-admin-columns hfe-admin-about-us">
516
517 <div class="hfe-admin-column-60">
518 <h3><?php esc_html_e( 'Welcome to Elementor Header & Footer Builder!', 'header-footer-elementor' ); ?></h3>
519
520 <p><?php esc_html_e( 'With this awesome plugin, experience the easiest way to create a customized header and footer for your website with Elementor. That too 100% FREE!', 'header-footer-elementor' ); ?></p>
521
522 <p><?php esc_html_e( 'Design beautiful layouts with simple drag & drop and display them at desired location with powerful target controls. The plugin comes with inbuilt Elementor widgets that offer essential features to build header and footer. It\'s a lightweight plugin that works seamlessly with all themes and backed up by 24/7 support.', 'header-footer-elementor' ); ?></p>
523
524 <p><?php esc_html_e( 'Trusted by more than 1+ Million users, Elementor Header & Footer Builder is a modern way to build advanced navigation for your website.', 'header-footer-elementor' ); ?></p>
525
526 <p><?php esc_html_e( 'This plugin is brought to you by the same team behind the popular WordPress theme Astra and a series of Ultimate Addons plugins.', 'header-footer-elementor' ); ?></p>
527
528 </div>
529
530 <div class="hfe-admin-column-40 hfe-admin-column-last">
531 <figure>
532 <img src="<?php echo HFE_URL; ?>assets/images/settings/our-team.jpeg" alt="<?php esc_attr_e( 'Team photo', 'header-footer-elementor' ); ?>">
533 <figcaption>
534 <?php esc_html_e( 'Brainstorm Force Team', 'header-footer-elementor' ); ?><br>
535 </figcaption>
536 </figure>
537 </div>
538
539 </div>
540 <?php
541 }
542
543 /**
544 * Display the Addons section of About tab.
545 *
546 * @since 1.6.0
547 */
548 protected function output_about_addons() {
549
550 if ( ! current_user_can( 'manage_options' ) ) {
551 return;
552 }
553
554 $all_plugins = get_plugins();
555 $all_themes = wp_get_themes();
556 $bsf_plugins = $this->get_bsf_plugins();
557 $can_install_plugins = $this->hfe_can_install( 'plugin' );
558 $can_install_themes = $this->hfe_can_install( 'theme' );
559
560 ?>
561 <div class="hfe-admin-addons">
562 <div class="addons-container">
563 <?php
564 foreach ( $bsf_plugins as $plugin => $details ) :
565
566 $plugin_data = $this->get_plugin_data( $plugin, $details, $all_plugins, $all_themes );
567
568 ?>
569 <div class="addon-container">
570 <div class="addon-item">
571 <div class="details hfe-clear">
572 <img src="<?php echo esc_url( $plugin_data['details']['icon'] ); ?>">
573 <div class="addon-details">
574 <h5 class="addon-name">
575 <?php
576 printf(
577 /* translators: %s - addon status label. */
578 esc_html__( '%1$s %3$s %2$s', 'header-footer-elementor' ),
579 '<a href="' . esc_attr( $details['siteurl'] ) . '" target="_blank" class="website-link">',
580 '</a>',
581 esc_html( $plugin_data['details']['name'] )
582 );
583 ?>
584 </h5>
585
586 <p class="addon-desc"><?php echo wp_kses_post( $plugin_data['details']['desc'] ); ?></p>
587 </div>
588 </div>
589 <div class="actions hfe-clear">
590 <div class="status">
591 <strong>
592 <?php
593 printf(
594 /* translators: %s - addon status label. */
595 esc_html__( 'Status: %s', 'header-footer-elementor' ),
596 '<span class="status-label ' . esc_attr( $plugin_data['status_class'] ) . '">' . wp_kses_post( $plugin_data['status_text'] ) . '</span>'
597 );
598 ?>
599 </strong>
600 </div>
601 <div class="action-button">
602 <?php if ( 'Visit Website' === $plugin_data['action_text'] ) { ?>
603 <a href="<?php echo esc_url( $plugin_data['plugin_src'] ); ?>" target="_blank" rel="noopener noreferrer" class="pro-plugin button button-primary"><?php echo wp_kses_post( $plugin_data['action_text'] ); ?></a>
604 <?php } elseif ( 'theme' === $details['type'] && $can_install_themes ) { ?>
605 <button class="<?php echo esc_attr( $plugin_data['action_class'] ); ?>" data-plugin="<?php echo esc_attr( $plugin_data['plugin_src'] ); ?>" data-type="theme" data-slug="<?php echo esc_attr( $details['slug'] ); ?>" data-site="<?php echo esc_url( $details['url'] ); ?>">
606 <span><?php echo wp_kses_post( $plugin_data['action_text'] ); ?></span>
607 </button>
608 <?php } elseif ( 'plugin' === $details['type'] && $can_install_plugins ) { ?>
609 <button class="<?php echo esc_attr( $plugin_data['action_class'] ); ?>" data-plugin="<?php echo esc_attr( $plugin_data['plugin_src'] ); ?>" data-type="plugin" data-slug="<?php echo esc_attr( $details['slug'] ); ?>" data-site="<?php echo esc_url( $details['url'] ); ?>" data-file="<?php echo esc_attr( $plugin ); ?>">
610 <span><?php echo wp_kses_post( $plugin_data['action_text'] ); ?></span>
611 </button>
612 <?php } else { ?>
613 <a href="<?php echo esc_url( $details['wporg'] ); ?>" target="_blank" rel="noopener noreferrer">
614 <?php esc_html_e( 'WordPress.org', 'header-footer-elementor' ); ?>
615 <span aria-hidden="true" class="dashicons dashicons-external"></span>
616 </a>
617 <?php } ?>
618 </div>
619 </div>
620 </div>
621 </div>
622 <?php endforeach; ?>
623 </div>
624 </div>
625 <?php
626 }
627
628 /**
629 * Get plugin data to display in the Addons section of About tab.
630 *
631 * @since 1.6.0
632 *
633 * @param string $addon Plugin/Theme slug.
634 * @param array $details Plugin details.
635 * @param array $all_plugins List of all plugins.
636 * @param array $all_themes List of all themes.
637 *
638 * @return array
639 */
640 protected function get_plugin_data( $addon, $details, $all_plugins, $all_themes ) {
641
642 $have_pro = ( ! empty( $details['pro'] ) );
643 $show_pro = false;
644
645 $theme = wp_get_theme();
646
647 $plugin_data = [];
648
649 $is_plugin = ( 'plugin' === $details['type'] ) ? true : false;
650 $is_theme = ( 'theme' === $details['type'] ) ? true : false;
651
652 if ( ( $is_plugin && array_key_exists( $addon, $all_plugins ) ) || ( $is_theme && array_key_exists( $addon, $all_themes ) ) ) {
653
654 if ( ( $is_plugin && is_plugin_active( $addon ) ) || ( $is_theme && ( 'Astra' === $theme->name || 'Astra' === $theme->parent_theme ) ) ) {
655
656 // Status text/status.
657 $plugin_data['status_class'] = 'status-active';
658 $plugin_data['status_text'] = esc_html__( 'Active', 'header-footer-elementor' );
659 // Button text/status.
660 $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-secondary disabled';
661 $plugin_data['action_text'] = esc_html__( 'Activated', 'header-footer-elementor' );
662 $plugin_data['plugin_src'] = esc_attr( $addon );
663 } else {
664 // Status text/status.
665 $plugin_data['status_class'] = 'status-inactive';
666 $plugin_data['status_text'] = esc_html__( 'Inactive', 'header-footer-elementor' );
667 // Button text/status.
668 $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-secondary';
669 $plugin_data['action_text'] = esc_html__( 'Activate', 'header-footer-elementor' );
670 $plugin_data['plugin_src'] = esc_attr( $addon );
671 }
672 } else {
673 // install if already doesn't exists.
674 // Status text/status.
675 $plugin_data['status_class'] = 'status-download';
676 if ( isset( $details['act'] ) && 'go-to-url' === $details['act'] ) {
677 $plugin_data['status_class'] = 'status-go-to-url';
678 }
679 $plugin_data['status_text'] = esc_html__( 'Not Installed', 'header-footer-elementor' );
680 // Button text/status.
681 $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-primary';
682 $plugin_data['action_text'] = esc_html__( 'Install', 'header-footer-elementor' );
683 $plugin_data['plugin_src'] = esc_url( $details['url'] );
684
685 if ( $have_pro ) {
686 $plugin_data['status_class'] = '';
687 $plugin_data['action_text'] = esc_html__( 'Visit Website', 'header-footer-elementor' );
688 }
689 }
690
691 $plugin_data['details'] = $details;
692
693 return $plugin_data;
694 }
695
696 /**
697 * List of plugins that we propose to install.
698 *
699 * @since 1.6.0
700 *
701 * @return array
702 */
703 protected function get_bsf_plugins() {
704
705 $images_url = HFE_URL . 'assets/images/settings/';
706
707 return [
708
709 'astra' => [
710 'icon' => $images_url . 'plugin-astra.png',
711 'type' => 'theme',
712 'name' => esc_html__( 'Astra Theme', 'header-footer-elementor' ),
713 'desc' => esc_html__( 'Powering over 1+ Million websites, Astra is loved for the fast performance and ease of use it offers. It is suitable for all kinds of websites like blogs, portfolios, business, and WooCommerce stores.', 'header-footer-elementor' ),
714 'wporg' => 'https://wordpress.org/themes/astra/',
715 'url' => 'https://downloads.wordpress.org/theme/astra.zip',
716 'siteurl' => 'https://wpastra.com/',
717 'pro' => false,
718 'slug' => 'astra',
719 ],
720
721 'astra-sites/astra-sites.php' => [
722 'icon' => $images_url . 'plugin-st.png',
723 'type' => 'plugin',
724 'name' => esc_html__( 'Starter Templates', 'header-footer-elementor' ),
725 'desc' => esc_html__( 'A popular templates plugin that provides an extensive library of professional and fully customizable 600+ ready website and templates. More than 1+ Million websites have built with this plugin.', 'header-footer-elementor' ),
726 'wporg' => 'https://wordpress.org/plugins/astra-sites/',
727 'url' => 'https://downloads.wordpress.org/plugin/astra-sites.zip',
728 'siteurl' => 'https://startertemplates.com/',
729 'pro' => false,
730 'slug' => 'astra-sites',
731 ],
732
733 'ultimate-elementor/ultimate-elementor.php' => [
734 'icon' => $images_url . 'plugin-uae.png',
735 'type' => 'plugin',
736 'name' => esc_html__( 'Ultimate Addons for Elementor', 'header-footer-elementor' ),
737 'desc' => esc_html__( 'It’s a collection of 40+ unique, creative, and optimized Elementor widgets with 100+ readymade templates. Trusted by more than 600+ K web professionals. It’s a #1 toolkit for Elementor Page Builder.', 'header-footer-elementor' ),
738 'wporg' => '',
739 'url' => 'https://ultimateelementor.com/',
740 'siteurl' => 'https://ultimateelementor.com/',
741 'pro' => true,
742 'slug' => 'ultimate-elementor',
743 ],
744 ];
745 }
746
747 /**
748 * Determine if the plugin/addon installations are allowed.
749 *
750 * @since 1.6.0
751 * @param string $type defines addon type.
752 * @return bool
753 */
754 public function hfe_can_install( $type ) {
755
756 if ( ! in_array( $type, [ 'plugin', 'theme' ], true ) ) {
757 return false;
758 }
759
760 // Determine whether file modifications are allowed.
761 if ( ! wp_is_file_mod_allowed( 'hfe_can_install' ) ) {
762 return false;
763 }
764
765 if ( 'theme' === $type ) {
766 if ( ! current_user_can( 'install_themes' ) ) {
767 return false;
768 }
769
770 return true;
771
772 } elseif ( 'plugin' === $type ) {
773 if ( ! current_user_can( 'install_plugins' ) ) {
774 return false;
775 }
776
777 return true;
778 }
779
780 return false;
781 }
782
783 /**
784 * Add settings link to the Plugins page.
785 *
786 * @since 1.6.0
787 *
788 * @param array $links Plugin row links.
789 *
790 * @return array $links
791 */
792 public function settings_link( $links ) {
793
794 $custom['settings'] = sprintf(
795 '<a href="%s" aria-label="%s">%s</a>',
796 esc_url(
797 add_query_arg(
798 [
799 'post_type' => 'elementor-hf',
800 ],
801 admin_url( 'edit.php' )
802 )
803 ),
804 esc_attr__( 'Go to HFE Settings page', 'header-footer-elementor' ),
805 esc_html__( 'Settings', 'header-footer-elementor' )
806 );
807
808 return array_merge( $custom, (array) $links );
809 }
810
811 }
812
813 new HFE_Settings_Page();
814