PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / trunk
Shortcodes and extra features for Phlox theme vtrunk
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / includes / classes / class-auxin-welcome.php
auxin-elements / includes / classes Last commit date
class-auxels-admin-assets.php 5 months ago class-auxels-archive-menu-links.php 5 months ago class-auxels-envato-elements.php 5 months ago class-auxels-import-parser.php 3 years ago class-auxels-import.php 3 years ago class-auxels-search-post-type.php 5 months ago class-auxels-wc-attribute-nav-menu.php 5 months ago class-auxin-admin-dashboard.php 5 months ago class-auxin-demo-importer.php 15 hours ago class-auxin-dependency-sorting.php 3 years ago class-auxin-import.php 5 months ago class-auxin-install.php 5 months ago class-auxin-master-nav-menu-admin.php 5 months ago class-auxin-page-template.php 5 months ago class-auxin-permalink.php 5 months ago class-auxin-plugin-requirements.php 3 years ago class-auxin-post-type-base.php 5 months ago class-auxin-svg-support-allowedattributes.php 7 years ago class-auxin-svg-support-allowedtags.php 7 years ago class-auxin-svg-support.php 1 year ago class-auxin-walker-nav-menu-back.php 5 months ago class-auxin-welcome-sections.php 1 year ago class-auxin-welcome.php 1 month ago class-auxin-whitelabel.php 3 years ago class-auxin-widget-indie.php 5 months ago class-auxin-widget-shortcode-map.php 5 months ago class-auxin-widget.php 5 months ago
class-auxin-welcome.php
1979 lines
1 <?php
2
3 // no direct access allowed
4 if ( ! defined('ABSPATH') ) exit;
5
6 /**
7 * Auxin_Welcome class
8 */
9 class Auxin_Welcome extends Auxin_Welcome_Base {
10
11 /**
12 * Current step
13 *
14 * @var string
15 */
16 protected $step = '';
17
18 /** @var array Steps for the setup wizard */
19 protected $steps = array();
20
21 /**
22 * TGMPA instance storage
23 *
24 * @var object
25 */
26 protected $tgmpa_instance;
27
28 /**
29 * TGMPA Menu slug
30 *
31 * @var string
32 */
33 protected $tgmpa_menu_slug = 'tgmpa-install-plugins';
34
35 /**
36 * TGMPA Menu url
37 *
38 * @var string
39 */
40 protected $tgmpa_url = 'themes.php?page=tgmpa-install-plugins';
41
42 /**
43 * Plugin filters
44 *
45 * @var array
46 */
47 protected $plugin_filters = array();
48
49
50 /**
51 * Holds the current instance of the theme manager
52 *
53 */
54 protected static $instance = null;
55
56 /**
57 * Retrieves class instance
58 *
59 * @return Auxin_Welcome
60 */
61 public static function get_instance() {
62 if ( ! self::$instance ) {
63 self::$instance = new self;
64 }
65
66 return self::$instance;
67 }
68
69
70 /**
71 * Constructor
72 */
73 public function __construct() {
74 parent::__construct();
75
76 $this->init_globals();
77 $this->init_actions();
78 }
79
80 /**
81 * Setup the class globals.
82 *
83 */
84 public function init_globals() {
85 $this->page_slug = 'auxin-welcome';
86 $this->parent_slug = 'auxin-welcome';
87 }
88
89 /**
90 * Setup the hooks, actions and filters.
91 *
92 */
93 public function init_actions() {
94 // Call the parent method
95 parent::init_actions();
96
97 if ( current_user_can( 'manage_options' ) ) {
98
99 // Disable redirect for "related posts for WordPress" plugin
100 update_option('rp4wp_do_install', 0, false );
101 // Disable redirect for the "WooCommerce" plugin
102 delete_transient( '_wc_activation_redirect' );
103 // Disable redirect for Phlox Pro plugin
104 remove_action( 'init', 'auxpro_redirect_to_welcome_page_on_first_activation' );
105
106 if ( class_exists( 'TGM_Plugin_Activation' ) && isset( $GLOBALS['tgmpa'] ) ) {
107 add_action( 'init' , array( $this, 'get_tgmpa_instanse' ), 30 );
108 add_action( 'init' , array( $this, 'set_tgmpa_url' ), 40 );
109 }
110
111 if( ! class_exists( 'Auxin_Demo_Importer' ) ){
112 require_once( 'class-auxin-demo-importer.php' );
113 }
114
115 // Get instance of Auxin_Demo_Importer Class
116 Auxin_Demo_Importer::get_instance();
117
118 // add_action( 'admin_enqueue_scripts' , array( $this, 'enqueue_scripts' ) );
119 add_filter( 'tgmpa_load' , array( $this, 'tgmpa_load' ), 10, 1 );
120 add_action( 'wp_ajax_aux_setup_plugins' , array( $this, 'ajax_plugins' ) );
121
122 add_action( 'wp_ajax_aux_ajax_uninstall', array( $this, 'ajax_uninstall') );
123
124 add_action( 'wp_ajax_aux_ajax_lightbox' , array( $this, 'ajax_lightbox') );
125 add_action( 'wp_ajax_aux_step_manager' , array( $this, 'step_manager' ) );
126
127 if( isset( $_POST['action'] ) && $_POST['action'] === "aux_setup_plugins" && wp_doing_ajax() ) {
128 add_filter( 'wp_redirect', '__return_false', 999 );
129 }
130
131 Auxin_Welcome_Sections::get_instance()->page_slug = $this->page_slug;
132 Auxin_Welcome_Sections::get_instance()->welcome = $this;
133 }
134 }
135
136 /**
137 * Adds a constant class names to body on wizard page
138 */
139 public function add_body_class( $classes ){
140 $classes = parent::add_body_class( $classes );
141
142 if( $this->current_tab( 'importer', 'plugins' ) ){
143 $classes .= ' auxin-wizard-panel';
144
145 // Add PRO selector, for some probable custom styles
146 if( defined('THEME_PRO' ) && THEME_PRO ) {
147 $classes .= ' auxin-wizard-pro';
148 }
149 }
150
151 return $classes;
152 }
153
154 /**
155 * Enqueue admin scripts
156 *
157 */
158 public function enqueue_scripts() {}
159
160 /**
161 * Check for TGMPA load
162 *
163 */
164 public function tgmpa_load( $status ) {
165 return is_admin() || current_user_can( 'install_themes' );
166 }
167
168 /**
169 * Get configured TGMPA instance
170 *
171 */
172 public function get_tgmpa_instanse() {
173 $this->tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
174 }
175
176 /**
177 * Update $tgmpa_menu_slug and $tgmpa_parent_slug from TGMPA instance
178 *
179 */
180 public function set_tgmpa_url() {
181 $this->tgmpa_menu_slug = ( property_exists( $this->tgmpa_instance, 'menu' ) ) ? $this->tgmpa_instance->menu : $this->tgmpa_menu_slug;
182 $this->tgmpa_menu_slug = apply_filters( $this->theme_id . '_theme_setup_wizard_tgmpa_menu_slug', $this->tgmpa_menu_slug );
183
184 $tgmpa_parent_slug = ( property_exists( $this->tgmpa_instance, 'parent_slug' ) && $this->tgmpa_instance->parent_slug !== 'themes.php' ) ? 'admin.php' : 'themes.php';
185
186 $this->tgmpa_url = apply_filters( $this->theme_id . '_theme_setup_wizard_tgmpa_url', $tgmpa_parent_slug . '?page=' . $this->tgmpa_menu_slug );
187 }
188
189 /**
190 * Register the admin menu
191 *
192 * @return void
193 */
194 public function register_admin_menu() {
195
196 $menu_args = $this->get_admin_menu_args();
197
198 /* Register root setting menu
199 /*-----------------------------*/
200 add_menu_page(
201 $menu_args['title'], // [Title] The title to be displayed on the corresponding page for this menu
202 $menu_args['name'], // [Text] The text to be displayed for this actual menu item
203 $menu_args['compatibility'],
204 $this->page_slug, // [ID/slug] The unique ID - that is, the slug - for this menu item
205 array( $this, 'render'), // [Callback] The name of the function to call when rendering the menu for this page
206 '', // icon_url
207 3 // [Position] The position in the menu order this menu should appear 3 means after dashboard
208 );
209
210 /* Add a menu separator
211 /*-----------------------------*/
212 add_menu_page(
213 '',
214 '',
215 'read',
216 'wp-menu-separator',
217 '',
218 '',
219 4
220 );
221
222 $this->add_submenus();
223 }
224
225
226 /**
227 * Add submenu for admin menu
228 *
229 * @return void
230 */
231 protected function add_submenus(){
232
233 global $submenu;
234
235 $menu_args = $this->get_admin_menu_args();
236
237 $sections = $this->get_sections();
238 if( empty( $sections ) ){
239 return;
240 }
241
242 foreach ( $sections as $section_id => $section ) {
243 if( ! empty( $section['add_admin_menu'] ) && $section['add_admin_menu'] ){
244
245 if( ! empty( $section['url'] ) ){
246
247 $submenu[ $this->page_slug ][] = array(
248 $section['label'],
249 $menu_args['compatibility'],
250 esc_url( $section['url'] )
251 );
252
253 } else {
254 add_submenu_page(
255 $this->page_slug,
256 $section['label'],
257 $section['label'],
258 $menu_args['compatibility'],
259 $this->get_page_rel_tab( $section_id )
260 );
261 }
262
263 }
264 }
265
266 if( isset( $submenu[ $this->page_slug ]['0'] ) ){
267 $submenu[ $this->page_slug ]['0']['0'] = __( 'Dashboard', 'auxin-elements' );
268 }
269 unset( $submenu[ $this->page_slug ]['1'] );
270 }
271
272 /*-----------------------------------------------------------------------------------*/
273 /* Start Setup Wizard
274 /*-----------------------------------------------------------------------------------*/
275
276 /**
277 * Retrieves the welcome page relative path
278 *
279 * @return string Page relative path
280 */
281 public function get_page_rel_path(){
282 return 'admin.php?page=' . $this->page_slug;
283 }
284
285 /**
286 * Display Alert Message
287 */
288 public function display_alerts( $message_body = '', $class_name = '' ){
289 ?>
290 <div class="aux-alert <?php echo esc_attr( $class_name ); ?>">
291 <p>
292 <?php
293 if( empty($message_body ) ) {
294 echo sprintf("<strong>%s</strong> %s", esc_html__( 'Note:', 'auxin-elements' ), esc_html__( 'You are recommended to install Phlox exclusive plugins in order to enable all features.', 'auxin-elements' ) );
295 } else {
296 echo wp_kses_post( $message_body );
297 }
298 ?>
299 </p>
300 </div>
301 <?php
302 }
303
304
305 /**
306 * Collect the plugin filters
307 *
308 * @return array plugin filters
309 */
310 private function get_plugins_categories_localized(){
311 if( empty( $this->plugin_filters ) ){
312 $this->plugin_filters = apply_filters( 'auxin_admin_welcome_plugins_categories_localized', array() );
313 }
314
315 return $this->plugin_filters;
316 }
317
318
319 /**
320 * Collect all plugin categories from bundled plugins
321 *
322 * @return array plugin categories
323 */
324 private function get_plugins_categories( $all_plugins ){
325 $plugin_categories = array();
326
327 foreach ( $all_plugins as $slug => $plugin ) {
328 $filter_terms = '';
329 if( ! empty( $plugin['categories'] ) ){
330 if( is_array( $plugin['categories'] ) ){
331 $plugin_categories = array_merge( $plugin_categories, $plugin['categories'] );
332 }
333 }
334 }
335
336 return array_unique( $plugin_categories );
337 }
338
339
340 /*-----------------------------------------------------------------------------------*/
341 /* Third step (Plugin installation)
342 /*-----------------------------------------------------------------------------------*/
343 public function setup_plugins() {
344
345 tgmpa_load_bulk_installer();
346 // install plugins with TGM.
347 if ( ! class_exists( 'TGM_Plugin_Activation' ) || ! isset( $GLOBALS['tgmpa'] ) ) {
348 die( 'Failed to find TGM' );
349 }
350 $url = wp_nonce_url( add_query_arg( array( 'plugins' => 'go' ) ), 'aux-setup' );
351
352 $custom_list = isset( $_GET['items'] ) && ! empty( $_GET['items'] ) ? explode( ',', auxin_sanitize_input( $_GET['items'] ) ) : array();
353 $plugins = $this->get_plugins( $custom_list );
354
355 // copied from TGM
356
357 $method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
358 $fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem.
359
360 if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, $fields ) ) ) {
361 return true; // Stop the normal page form from displaying, credential request form will be shown.
362 }
363
364 // Now we have some credentials, setup WP_Filesystem.
365 if ( ! WP_Filesystem( $creds ) ) {
366 // Our credentials were no good, ask the user for them again.
367 request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, $fields );
368
369 return true;
370 }
371
372 $embeds_plugins_desc = array(
373 'js_composer' => 'Drag and drop page builder for WordPress. Take full control over your WordPress site, build any layout you can imagine – no programming knowledge required.',
374 'Ultimate_VC_Addons' => 'Includes Visual Composer premium addon elements like Icon, Info Box, Interactive Banner, Flip Box, Info List & Counter. Best of all - provides A Font Icon Manager allowing users to upload / delete custom icon fonts.',
375 'masterslider' => 'Master Slider is the most advanced responsive HTML5 WordPress slider plugin with touch swipe navigation that works smoothly on devices too.',
376 'depicter' => 'Make animated and interactive sliders and carousels which work smoothly across devices.',
377 'go_pricing' => 'The New Generation Pricing Tables. If you like traditional Pricing Tables, but you would like get much more out of it, then this rodded product is a useful tool for you.',
378 'waspthemes-yellow-pencil' => 'The most advanced visual CSS editor. Customize any page in real-time without coding.',
379 'auxin-the-news' => 'Publish news easily and beautifully with Phlox theme.',
380 'auxin-pro-tools' => 'Premium features for Phlox theme.',
381 'auxin-shop' => 'Make a shop in easiest way using phlox theme.',
382 'envato-market' => 'WP Theme Updater based on the Envato WordPress Toolkit Library and Pixelentity class from ThemeForest forums.'
383 );
384
385 /* If we arrive here, we have the filesystem */
386
387 ?>
388 <div class="aux-setup-content">
389 <div class="aux-section-content-box">
390 <?php if( ! isset( $_GET['view'] ) || $_GET['view'] !== 'abstract' ) : ?>
391 <h3 class="aux-content-title"><?php esc_html_e('Recommended Plugins', 'auxin-elements' ); ?></h3>
392 <p style="margin-bottom:0;"><?php echo wp_sprintf( esc_html__( 'The following is a list of best integrated plugins for %s theme, you can install them from here and add or remove them later on WordPress plugins page.', 'auxin-elements' ), THEME_NAME_I18N );?></p>
393 <p><?php esc_html_e( 'We recommend you to install only the plugins under "Essential" tab, and avoid installing all of plugins.', 'auxin-elements' ); ?></p>
394 <?php endif; ?>
395
396 <div class="aux-plugins-step aux-has-required-plugins aux-fadein-animation">
397 <?php
398 if ( count( $plugins['all'] ) ) {
399
400 $plugin_categories = $this->get_plugins_categories( $plugins['all'] );
401 $plugin_categories_localized = $this->get_plugins_categories_localized();
402
403 // -----------------------------------------------------
404 ?>
405
406 <div class="aux-table">
407 <section class="auxin-list-table">
408
409 <?php if( ! isset( $_GET['view'] ) || $_GET['view'] !== 'abstract' ) : ?>
410 <div class="aux-isotope-filters aux-filters aux-underline aux-clearfix aux-togglable aux-clearfix aux-center">
411 <div class="aux-select-overlay"></div>
412 <ul>
413 <li data-filter="all"><a href="#" class="aux-selected"><span data-select="<?php esc_attr_e('Recent', 'auxin-elements'); ?>"><?php esc_attr_e('Recent', 'auxin-elements'); ?></span></a></li>
414 <?php
415 foreach ( $plugin_categories_localized as $filter_slug => $filter_label ) {
416 if( in_array( $filter_slug, $plugin_categories ) ){
417 echo '<li data-filter="'. esc_attr( $filter_slug . '-plugins' ) .'"><a href="#"><span data-select="'. esc_attr( $filter_label ) .'">'. esc_html( $filter_label ) .'</span></a></li>';
418 }
419 }
420 ?>
421 </ul>
422 </div>
423 <?php endif; ?>
424
425 <header class="aux-table-heading aux-table-row aux-clearfix">
426 <div id="cb" class="manage-column aux-column-cell column-cb check-column">
427 <label class="screen-reader-text" for="cb-select-all"><?php esc_html_e( 'Select All', 'auxin-elements' ); ?></label>
428 <input id="cb-select-all" type="checkbox" style="display:none;">
429 </div>
430 <div class="manage-column aux-column-cell column-thumbnail"></div>
431 <div scope="col" id="name" class="manage-column aux-column-cell column-name"><?php esc_html_e( 'Name', 'auxin-elements' ); ?></div>
432 <div scope="col" id="description" class="manage-column aux-column-cell column-description"><?php esc_html_e( 'Description', 'auxin-elements' ); ?></div>
433 <div scope="col" id="status" class="manage-column aux-column-cell column-status"><?php esc_html_e( 'Status', 'auxin-elements' ); ?></div>
434 <div scope="col" id="version" class="manage-column aux-column-cell column-version"><?php esc_html_e( 'Version', 'auxin-elements' ); ?></div>
435 </header>
436
437 <div class="aux-wizard-plugins aux-table-body aux-isotope-plugins-list aux-clearfix">
438 <?php
439 foreach ( $plugins['all'] as $slug => $plugin ) {
440
441 // Collect plugin filters for current item
442 $filter_terms = '';
443 if( ! empty( $plugin['categories'] ) ){
444 if( is_array( $plugin['categories'] ) ){
445 foreach ( $plugin['categories'] as $category ) {
446 $filter_terms .= $category . '-plugins ';
447 }
448 }
449 }
450
451 if( $this->tgmpa_instance->is_plugin_installed( $slug ) ) {
452 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin['file_path'] );
453 } else {
454 $plugin_data = $this->get_plugin_data_by_slug( $slug );
455 }
456 ?>
457 <div class="aux-plugin aux-table-row aux-iso-item <?php echo esc_attr( $filter_terms ); ?>" data-slug="<?php echo esc_attr( $slug ); ?>">
458 <div scope="row" class="check-column aux-column-cell">
459 <input class="aux-check-column" name="plugin[]" value="<?php echo esc_attr( $slug ); ?>" type="checkbox">
460 <div class="spinner"></div>
461 </div>
462 <div class="thumbnail column-thumbnail aux-column-cell" data-colname="Thumbnail">
463 <?php
464 if ( isset( $plugin['wp-image-name'] ) ) {
465 $thumbnail = "https://ps.w.org/{$plugin['slug']}/assets/" . $plugin['wp-image-name'];
466 } else {
467 $thumbnail = "https://ps.w.org/{$plugin['slug']}/assets/icon-128x128.png";
468 }
469
470 if( isset( $plugin['thumbnail'] ) ){
471 if( 'custom' == $plugin['thumbnail'] ){
472 $thumbnail = AUXELS_ADMIN_URL . '/assets/images/welcome/' . $plugin['slug'] . '-plugin.png';
473 } elseif( 'default' === $plugin['thumbnail'] ){
474 $thumbnail = AUXELS_ADMIN_URL . '/assets/images/welcome/def-plugin.png';
475 } elseif( ! empty( $plugin['thumbnail'] ) ){
476 $thumbnail = $plugin['thumbnail'];
477 }
478 }
479 ?>
480 <img src="<?php echo esc_url( $thumbnail ); ?>" width="64" height="64" />
481 </div>
482 <div class="name column-name aux-column-cell" data-colname="Plugin"><?php echo esc_html( $plugin['name'] ); ?></div>
483 <div class="description column-description aux-column-cell" data-colname="Description">
484 <?php
485 $description = '';
486 if( isset( $plugin_data['Description'] ) ) {
487 $description = $plugin_data['Description'];
488 } else if ( isset( $embeds_plugins_desc[ $plugin['slug'] ] ) ){
489 $description = $embeds_plugins_desc[ $plugin['slug'] ];
490 }
491 if( $description ){
492 echo '<p>'. wp_kses_post( $description ) .'</p>';
493 }
494 if ( ! empty( $plugin['badge'] ) ) {
495 echo '<span class="aux-label aux-exclusive-label">' . esc_html( $plugin['badge'] ) . '</span>';
496 }
497 ?>
498 </div>
499 <div class="status column-status aux-column-cell" data-colname="Status">
500 <span>
501 <?php
502 if ( isset( $plugins['install'][ $slug ] ) ) {
503 echo esc_html__( 'Not Installed', 'auxin-elements' );
504 } elseif ( isset( $plugins['activate'][ $slug ] ) ) {
505 echo esc_html__( 'Not Activated', 'auxin-elements' );
506 }
507 ?>
508 </span>
509 </div>
510 <div class="version column-version aux-column-cell" data-colname="Version">
511 <?php if( isset( $plugin_data['Version'] ) ) { ?>
512 <span><?php echo esc_html( $plugin_data['Version'] ); ?></span>
513 <?php } ?>
514 </div>
515 </div>
516 <?php } ?>
517 </div>
518 </section>
519 </div>
520
521 <div class="clear"></div>
522
523 <div class="aux-sticky">
524 <div class="aux-setup-actions step">
525 <a href="#"
526 class="aux-button aux-primary install-plugins disabled"
527 data-callback="install_plugins"><?php esc_html_e( 'Install Plugins', 'auxin-elements' ); ?></a>
528 <?php wp_nonce_field( 'aux-setup' ); ?>
529 </div>
530 </div>
531
532 <?php
533 } else { ?>
534
535 <?php $this->display_alerts( esc_html__( 'Good news! All plugins are already installed and up to date. Please continue.', 'auxin-elements' ) , 'success' ); ?>
536
537 <?php
538 } ?>
539 </div>
540 </div>
541 </div>
542 <?php
543 }
544
545 /**
546 * Output the tgmpa plugins list
547 */
548 private function get_plugins( $custom_list = array() ) {
549
550 $plugins = array(
551 'all' => array(), // Meaning: all plugins which still have open actions.
552 'install' => array(),
553 'update' => array(),
554 'activate' => array(),
555 );
556
557 foreach ( $this->tgmpa_instance->plugins as $slug => $plugin ) {
558
559 if( ! empty( $custom_list ) && ! in_array( $slug, $custom_list ) ){
560 // This condition is for custom requests lists
561 continue;
562 } elseif( $this->tgmpa_instance->is_plugin_active( $slug ) && false === $this->tgmpa_instance->does_plugin_have_update( $slug ) ) {
563 // No need to display plugins if they are installed, up-to-date and active.
564 continue;
565 } else {
566 $plugins['all'][ $slug ] = $plugin;
567
568 if ( ! $this->tgmpa_instance->is_plugin_installed( $slug ) ) {
569 $plugins['install'][ $slug ] = $plugin;
570 } else {
571
572 if ( false !== $this->tgmpa_instance->does_plugin_have_update( $slug ) ) {
573 $plugins['update'][ $slug ] = $plugin;
574 }
575 if ( $this->tgmpa_instance->can_plugin_activate( $slug ) ) {
576 $plugins['activate'][ $slug ] = $plugin;
577 }
578
579 }
580 }
581 }
582
583 return $plugins;
584 }
585
586 /**
587 * Returns the plugin data from WP.org API
588 */
589 private function get_plugin_data_by_slug( $slug = '' ) {
590
591 if ( empty( $slug ) ) {
592 return false;
593 }
594
595 $key = sanitize_key( 'auxin_plugin_data_'.$slug );
596
597 if ( false === ( $plugins = auxin_get_transient( $key ) ) ) {
598 $args = array(
599 'slug' => $slug,
600 'fields' => array(
601 'short_description' => true
602 )
603 );
604 $response = wp_remote_post(
605 'http://api.wordpress.org/plugins/info/1.0/',
606 array(
607 'body' => array(
608 'action' => 'plugin_information',
609 'request' => serialize( (object) $args )
610 )
611 )
612 );
613 $data = unserialize( wp_remote_retrieve_body( $response ) );
614
615 $plugins = is_object( $data ) ? array( 'Description' => $data->short_description , 'Version' => $data->version ) : false;
616
617 // Set transient for next time... keep it for 24 hours
618 auxin_set_transient( $key, $plugins, 24 * HOUR_IN_SECONDS );
619
620 }
621
622 return $plugins;
623 }
624
625 /**
626 * Plugins AJAX Process
627 */
628 public function ajax_plugins() {
629 // Inputs validations
630 if ( ! check_ajax_referer( 'aux_setup_nonce', 'wpnonce' ) || ! isset( $_POST['slug'] ) || empty( $_POST['slug'] ) ) {
631 wp_send_json_error( array( 'message' => esc_html__( 'No Slug Found', 'auxin-elements' ) ) );
632 }
633
634 if ( ! current_user_can( 'manage_options' ) ) {
635 wp_send_json_error( array( 'message' => esc_html__( 'Permission Error', 'auxin-elements' ) ) );
636 }
637
638 $request = array();
639 // send back some json we use to hit up TGM
640 $plugins = $this->get_plugins();
641 // what are we doing with this plugin?
642 foreach ( $plugins['activate'] as $slug => $plugin ) {
643 if ( $slug === 'related-posts-for-wp' ) {
644 update_option( 'rp4wp_do_install', false );
645 }
646 if ( $_POST['slug'] == $slug ) {
647 $request = array(
648 'url' => admin_url( $this->tgmpa_url ),
649 'plugin' => array( $slug ),
650 'tgmpa-page' => $this->tgmpa_menu_slug,
651 'plugin_status' => 'all',
652 '_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
653 'action' => 'tgmpa-bulk-activate',
654 'action2' => - 1,
655 'message' => esc_html__( 'Activating', 'auxin-elements' ),
656 );
657 break;
658 }
659 }
660 foreach ( $plugins['update'] as $slug => $plugin ) {
661 if ( $_POST['slug'] == $slug ) {
662 $request = array(
663 'url' => admin_url( $this->tgmpa_url ),
664 'plugin' => array( $slug ),
665 'tgmpa-page' => $this->tgmpa_menu_slug,
666 'plugin_status' => 'all',
667 '_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
668 'action' => 'tgmpa-bulk-update',
669 'action2' => - 1,
670 'message' => esc_html__( 'Updating', 'auxin-elements' ),
671 );
672 break;
673 }
674 }
675 foreach ( $plugins['install'] as $slug => $plugin ) {
676 if ( $_POST['slug'] == $slug ) {
677 $request = array(
678 'url' => admin_url( $this->tgmpa_url ),
679 'plugin' => array( $slug ),
680 'tgmpa-page' => $this->tgmpa_menu_slug,
681 'plugin_status' => 'all',
682 '_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
683 'action' => 'tgmpa-bulk-install',
684 'action2' => - 1,
685 'message' => esc_html__( 'Installing', 'auxin-elements' ),
686 );
687 break;
688 }
689 }
690
691 if ( ! empty( $request ) ) {
692 $request['hash'] = md5( serialize( $request ) ); // used for checking if duplicates happen, move to next plugin
693 wp_send_json_success( $request );
694 }
695
696 wp_send_json_success( array( 'message' => esc_html__( 'Activated', 'auxin-elements' ) ) );
697
698 }
699
700
701 /*-----------------------------------------------------------------------------------*/
702 /* Online Demo Importer
703 /*-----------------------------------------------------------------------------------*/
704
705 public function setup_templates(){
706 $template_list = $this->get_demo_list( 'templates' );
707
708 // Create subjects group by type
709 $subjects_group = array();
710
711 if( $template_list ){
712 foreach ( $template_list['templates'] as $key => $args ) {
713 // Convert subject JSON to Array
714 $categoryStack = json_decode( $args['subject'], true );
715 // Set group type
716 if( ! isset( $subjects_group[ $args['type'] ] ) ) {
717 $subjects_group[ $args['type'] ] = array();
718 }
719 // Pass items to group type
720 $subjects_group[ $args['type'] ] = array_unique( array_merge( $subjects_group[ $args['type'] ], $categoryStack ), SORT_REGULAR );
721 }
722 }
723
724 $activeIsoGroup = get_option( 'aux_isotope_group_templates_kit', 'page' );
725 ?>
726
727 <div class="aux-setup-template">
728
729 <div class="aux-fadein-animation">
730
731 <div class="aux-isotope-filters aux-filters aux-underline aux-clearfix aux-togglable aux-clearfix aux-center">
732 <div class="aux-isotope-group-wrapper">
733 <span>Pages</span>
734 <input type="checkbox" class="aux-isotope-group aux_switch" data-nonce="<?php echo wp_create_nonce( 'aux-iso-group' ); ?>" value="1" <?php checked( 1, $activeIsoGroup === 'page' ? 0 : 1, true ); ?> />
735 <span>Sections</span>
736 </div>
737 <div class="aux-isotope-filters-wrapper">
738 <?php
739 foreach ( $subjects_group as $type => $subjects ) {
740 ?>
741 <ul class="aux-group-filter aux-grouping-<?php echo esc_attr( $type ); ?> <?php echo $activeIsoGroup !== $type ? 'aux-iso-hidden' : ''; ?>">
742 <li data-filter="all"><a href="#" class="aux-selected"><span data-select="<?php esc_attr_e('Recent', 'auxin-elements'); ?>"><?php esc_html_e('Recent', 'auxin-elements'); ?></span></a></li>
743 <?php
744 foreach ( $subjects as $filter_label ) {
745 $filter_data = preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $filter_label ) );
746 echo '<li data-filter="'. esc_attr( strtolower( str_replace( ' ', '-', $filter_data ) . '-subject' ) ) .'"><a href="#"><span data-select="'. esc_attr( $filter_label ) .'">'. esc_html( $filter_label ) .'</span></a></li>';
747 }
748 ?>
749 </ul>
750 <?php
751 }
752 ?>
753 </div>
754 <div class="aux-isotope-search-wrapper">
755 <input type="text" placeholder="<?php echo esc_html__( 'Search Templates', 'auxin-elements' ); ?>" class="aux-isotope-search">
756 </div>
757 </div>
758
759 <div class="aux-templates-list aux-grid-list aux-isotope-templates" data-search-filter="true" data-grouping="<?php echo esc_attr( $activeIsoGroup ); ?> ">
760 <?php
761 if( ! is_array( $template_list['templates'] ) ){
762 echo '<p class="aux-grid-item grid_12">'. esc_html__( 'An error occurred while downloading the list of templates. Please try again later.', 'auxin-elements' ) .'</p>';
763 } else {
764 foreach ( $template_list['templates'] as $key => $args ) {
765
766 // Collect plugin filters for current item
767 $filter_categories = '';
768 if( ! empty( $args['subject'] ) ){
769 $categories = json_decode( $args['subject'], true );
770 foreach ( $categories as $num => $category ) {
771 $category_decode = preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $category ) );
772 $filter_categories .= strtolower( str_replace( ' ', '-', $category_decode ) . '-subject ' );
773 }
774 }
775
776 $filter_tags = '';
777 if( ! empty( $args['tags'] ) ){
778 $categories = json_decode( $args['tags'], true );
779 foreach ( $categories as $num => $tags ) {
780 $filter_tags .= strtolower( str_replace( ' ', '-', $tags ) . '-tag ' );
781 }
782 }
783
784 // Check demo license
785 $is_demo_allowed = auxin_is_activated() || ! $args['is_pro'];
786
787 echo '<div data-template-type="'. esc_attr( $args['type'] ) .'" class="aux-grid-item aux-iso-item grid_3 aux-grouping-'.esc_attr( $args['type'] ).' '.esc_attr( $filter_categories ).' '.esc_attr( $filter_tags ).'">';
788 echo '<div class="aux-grid-item-inner">';
789 echo '<div class="aux-grid-template-media">';
790 echo '<img class="template_thumbnail aux-preload aux-blank" data-src='.esc_url( $args['thumbnail'] ).' src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">';
791 if( ! $is_demo_allowed ) {
792 echo '<img class="premium_badge" alt="This is a premium demo" src="'. esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/pro-badge.png' ) .'">';
793 }
794 echo '</div>';
795 ?>
796 <div class="aux-grid-item-footer">
797 <h3 class="aux-item-title"><?php echo esc_html( $args['title'] ); ?></h3>
798 <div class="aux-grid-item-buttons aux-clearfix">
799 <?php
800
801 $template_status = 'import';
802 $more_btn_class = 'hide';
803
804 if( $is_demo_allowed ) {
805 $color_class = " aux-open-modal aux-import-template aux-has-next-action aux-iconic-action aux-green2";
806 $btn_label = __( 'Download', 'auxin-elements' );
807 $import_btn_url = add_query_arg( array( 'action' => 'aux_ajax_lightbox', 'type' => 'progress' , 'nonce' => wp_create_nonce( 'aux-open-lightbox' ) ), admin_url( 'admin-ajax.php' ) );
808
809 if( ! empty( $args['plugins'] ) ) {
810 $plugins = $this->get_plugins( json_decode( $args['plugins'], true ) );
811 if( ! empty( $plugins['all'] ) ) {
812 $color_class = " aux-open-modal aux-import-template aux-iconic-action aux-green2";
813 $import_btn_url = add_query_arg( array( 'action' => 'aux_ajax_lightbox', 'key' => $key, 'type' => 'plugins' , 'nonce' => wp_create_nonce( 'aux-open-lightbox' ) ), admin_url( 'admin-ajax.php' ) );
814 }
815 }
816
817 if( false !== auxin_get_transient( sanitize_key( "auxin_template_kit_{$args['type']}_data_for_origin_id_{$args['id']}" ) ) ) {
818 $template_status = 'copy';
819 $btn_label = __( 'Copy to clipboard', 'auxin-elements' );
820 $color_class = " aux-copy-template aux-iconic-action aux-orange";
821 $import_btn_url = '#';
822 $more_btn_class = '';
823 }
824
825 } else {
826 $color_class = " aux-blue aux-pro-demo aux-locked-demo aux-iconic-action";
827 $btn_label = __( 'Unlock', 'auxin-elements' );
828 $import_btn_url = esc_url( 'http://phlox.pro/go-pro/?utm_source=phlox-welcome&utm_medium=phlox-free&utm_campaign=phlox-go-pro&utm_content=template-unlock&utm_term='. $args['id'] );
829
830 if( defined('THEME_PRO' ) && THEME_PRO ){
831 $color_class .= " aux-ajax-open-modal";
832 $import_btn_url = add_query_arg( array( 'action' => 'auxin_display_actvation_form', 'nonce' => wp_create_nonce( 'aux-activation-form' ) ), admin_url( 'admin-ajax.php' ) );
833 }
834 }
835
836
837 ?>
838 <a target="_blank" href="<?php echo esc_url( add_query_arg( array( 'action' => 'aux_ajax_lightbox', 'type' => 'preview', 'preview' => $args['preview'], 'nonce' => wp_create_nonce( 'aux-open-lightbox' ) ), admin_url( 'admin-ajax.php' ) ) ) ?>"
839 class="aux-wl-button aux-open-modal aux-outline aux-round aux-transparent aux-large aux-preview"><?php esc_html_e( 'Preview', 'auxin-elements' ); ?></a>
840 <a href="<?php echo esc_url( $import_btn_url ); ?>"
841 class="aux-wl-button aux-outline aux-round aux-large <?php echo esc_attr( $color_class ); ?>"
842 data-template-id="<?php echo esc_attr( $args['id'] ); ?>"
843 data-template-type="<?php echo esc_attr( $args['type'] ); ?>"
844 data-template-page-tmpl="<?php echo esc_attr( $args['page_tmpl'] ); ?>"
845 data-template-title="<?php echo esc_attr( $args['title'] ); ?>"
846 data-status-type="<?php echo esc_attr( $template_status ); ?>"
847 data-nonce="<?php echo wp_create_nonce( 'aux-template-manager' ); ?>"
848 ><span><?php echo esc_html( $btn_label ); ?></span></a>
849 <a href="#" class="aux-more-button <?php echo esc_attr( $more_btn_class ) ;?>">
850 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/more.svg' ); ?>" width="4" height="18" />
851 </a>
852 <ul class="aux-more-items">
853 <li>
854 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'aux_ajax_lightbox', 'type' => 'progress' , 'nonce' => wp_create_nonce( 'aux-open-lightbox' ) ), admin_url( 'admin-ajax.php' ) ) ); ?>"
855 class="aux-open-modal aux-has-next-action"
856 data-template-id="<?php echo esc_attr( $args['id'] ); ?>"
857 data-template-type="<?php echo esc_attr( $args['type'] ); ?>"
858 data-template-page-tmpl="<?php echo esc_attr( $args['page_tmpl'] ); ?>"
859 data-template-title="<?php echo esc_attr( $args['title'] ); ?>"
860 data-status-type="create_my_template"
861 data-nonce="<?php echo wp_create_nonce( 'aux-template-manager' ); ?>"
862 ><span><?php echo esc_html__( 'Save to my templates', 'auxin-elements' ); ?></span></a>
863 </li>
864 <li>
865 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'aux_ajax_lightbox', 'type' => 'progress' , 'nonce' => wp_create_nonce( 'aux-open-lightbox' ) ), admin_url( 'admin-ajax.php' ) ) ); ?>"
866 class="aux-open-modal aux-has-next-action"
867 data-template-id="<?php echo esc_attr( $args['id'] ); ?>"
868 data-template-type="<?php echo esc_attr( $args['type'] ); ?>"
869 data-template-page-tmpl="<?php echo esc_attr( $args['page_tmpl'] ); ?>"
870 data-status-type="create_new_page"
871 data-template-title="<?php echo esc_attr( $args['title'] ); ?>"
872 data-nonce="<?php echo wp_create_nonce( 'aux-template-manager' ); ?>"
873 ><span><?php echo esc_html__( 'Create new page', 'auxin-elements' ); ?></span></a>
874 </li>
875 </ul>
876 </div>
877 </div>
878 </div>
879 <?php
880 echo '</div>';
881 }
882 }
883 ?>
884 </div>
885
886 <div class="clear"></div>
887
888 </div>
889
890 </div>
891
892 <?php
893 }
894
895 /*-----------------------------------------------------------------------------------*/
896 /* Online Demo Importer
897 /*-----------------------------------------------------------------------------------*/
898
899 public function setup_importer() {
900 // Get the available demos list from Averta API
901 $demo_list = $this->get_demo_list();
902 // Get last imported demo data
903 $last_demo_imported = get_option( 'auxin_last_imported_demo' );
904 if ( empty($demo_list ) ) {
905 return;
906 }
907
908 ?>
909 <div class="aux-setup-content">
910
911 <div class="aux-demo-importer-step aux-fadein-animation">
912 <div class="aux-isotope-filters aux-filters aux-underline aux-clearfix aux-togglable aux-clearfix aux-center">
913 <?php
914 $categories_list = [];
915 foreach ( $demo_list['items'] as $key => $args ) {
916
917 if ( !empty( $args['category'] ) && $args['category'] != "[]" ) {
918 $categories = str_replace( '"', '', substr( $args['category'], 1, -1 ) );
919 } else {
920 $categories = '';
921 }
922
923 $categories_array = explode( ',', $categories );
924 foreach ( $categories_array as $index => $category ) {
925 $categories_list[ $category ] = isset( $categories_list[ $category ] ) ? ++$categories_list[ $category ] : 1;
926 }
927 }
928 ?>
929 <ul class="aux-group-filter">
930 <li data-filter="all"><a href="#" class="aux-selected"><span data-select="<?php esc_attr_e('All Templates', 'auxin-elements'); ?>"><?php esc_html_e('All Templates', 'auxin-elements'); ?><span>(<?php echo count( $demo_list['items']);?>)</span></span></a></li>
931 <?php
932
933 // move shop category to second position
934 $categories_list = auxin_array_insert_after( $categories_list, key( $categories_list ), [ "Shop" => $categories_list['Shop'] ] );
935 $categories_list = array_map( "unserialize", array_unique( array_map( "serialize", $categories_list ) ) );
936
937 foreach ( $categories_list as $category => $demos_count ) {
938 $filter = strtolower( preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $category ) ) );
939 if ( empty( $filter ) ) {
940 continue;
941 }
942 echo '<li data-filter="'. esc_attr( $filter ) .'-subject"><a href="#"><span data-select="'. esc_attr( $filter ) .'">'. esc_html( $category ) .'<span>(' . esc_html( $demos_count ) . ')</span></span></a></li>';
943 }
944 ?>
945 </ul>
946 <div class="aux-isotope-search-wrapper">
947 <input type="text" placeholder="<?php echo esc_html__( 'Search Templates', 'auxin-elements' ); ?>" class="aux-isotope-search">
948 </div>
949 </div>
950 <div class="aux-demo-list aux-grid-list aux-isotope-list" data-search-filter="true">
951 <?php
952 if( ! is_array( $demo_list ) ){
953 echo '<p class="aux-grid-item grid_12">'. esc_html__( 'An error occurred while downloading the list of demo sites. Please try again later.', 'auxin-elements' ) .'</p>';
954 } else {
955 foreach ( $demo_list['items'] as $key => $args ) {
956 // Checking the last imported demo...
957 $is_active_demo = ! empty( $last_demo_imported ) && $last_demo_imported['id'] == $args['id'] ? 'aux-last-imported-demo' : '';
958
959 // Check demo license
960 $is_demo_allowed = auxin_is_activated() || !$args['is_pro'];
961
962 if ( !empty( $args['category'] ) && $args['category'] != "[]" ) {
963 $categories = str_replace( '"', '', substr( $args['category'], 1, -1 ) );
964 } else {
965 $categories = '';
966 }
967 $categories_array = explode( ',', $categories );
968 foreach( $categories_array as $cat_key => $category ) {
969 $categories_array[ $cat_key ] = strtolower( preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $category ) ) );
970 }
971 $categories_class = implode( '-subject ', $categories_array );
972 $categories_class = !empty( $categories_class ) ? $categories_class . '-subject' : '';
973
974 if ( !empty( $args['tags'] ) && $args['tags'] != "[]" ) {
975 $tags = str_replace( '"', '', substr( $args['tags'], 1, -1 ) );
976 } else {
977 $tags = '';
978 }
979 $tags_array = explode( ',', $tags );
980 foreach( $tags_array as $tag_key => $tag ) {
981 $tags_array[ $tag_key ] = strtolower( preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $tag ) ) );
982 }
983 $tags_class = implode( '-tag ', $tags_array );
984 $tags_class = !empty( $tags_class ) ? $tags_class . '-tag' : '';
985
986
987 echo '<div data-demo-id="demo-'. esc_attr( $args['id'] ) .'" class="aux-grid-item aux-iso-item grid_4 '. esc_attr( $is_active_demo ) . ' ' . esc_attr( $categories_class ) . ' ' . esc_attr( $tags_class ) . '">';
988 echo '<div class="aux-grid-item-inner">';
989 echo '<div class="aux-grid-item-media">';
990 echo '<img class="demo_thumbnail aux-preload aux-blank" data-src='. esc_url( $args['thumbnail'] ) .' src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">';
991 if( ! $is_demo_allowed ) {
992 echo '<img class="premium_badge" alt="This is a premium demo" src="'. esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/pro-badge.png' ) .'">';
993 }
994 echo '</div>';
995 ?>
996 <div class="aux-grid-item-footer">
997 <h3><?php echo esc_html( $args['title'] ); ?></h3>
998 <div class="aux-grid-item-buttons aux-clearfix">
999 <?php
1000 if( $is_demo_allowed ) {
1001 $color_class = $is_active_demo ? " aux-open-modal aux-import-demo aux-iconic-action aux-uninstall aux-orange" : " aux-open-modal aux-import-demo aux-iconic-action aux-green2";
1002 $btn_label = $is_active_demo ? __( 'Uninstall', 'auxin-elements' ) : __( 'Import', 'auxin-elements' );
1003 $import_type = $is_active_demo ? 'uninstall' : 'install';
1004 $import_btn_url = add_query_arg( array( 'action' => 'aux_ajax_lightbox', 'key' => $key, 'type' => $import_type , 'nonce' => wp_create_nonce( 'aux-open-lightbox' ) ), admin_url( 'admin-ajax.php' ) );
1005 } else {
1006 $color_class = " aux-blue aux-pro-demo aux-locked-demo aux-iconic-action";
1007 $btn_label = __( 'Unlock', 'auxin-elements' );
1008 $import_btn_url = 'http://phlox.pro/go-pro/?utm_source=phlox-welcome&utm_medium=phlox-free&utm_campaign=phlox-go-pro&utm_content=demo-unlock&utm_term='. $args['id'];
1009 if( defined('THEME_PRO' ) && THEME_PRO ){
1010 $color_class .= " aux-ajax-open-modal";
1011 $import_btn_url = add_query_arg( array( 'action' => 'auxin_display_actvation_form', 'nonce' => wp_create_nonce( 'aux-activation-form' ) ), admin_url( 'admin-ajax.php' ) );
1012 }
1013 }
1014 ?>
1015 <a target="_blank" href="<?php echo esc_url( $import_btn_url ); ?>"
1016 class="aux-wl-button aux-outline aux-round aux-large <?php echo esc_attr( $color_class ); ?>" data-demo-key="<?php echo esc_html( $key );?>"><?php echo esc_html( $btn_label ); ?></a>
1017 <a target="_blank" href="<?php echo ! empty( $args['url'] ) ? esc_url( $args['url'] .'&utm_term='.$args['id'] ) : '#'; ?>"
1018 class="aux-wl-button aux-outline aux-round aux-transparent aux-large aux-preview"><?php esc_html_e( 'Preview', 'auxin-elements' ); ?></a>
1019 </div>
1020 </div>
1021 </div>
1022 <?php
1023 echo '</div>';
1024 }
1025 }
1026 ?>
1027 </div>
1028
1029 <div class="clear"></div>
1030
1031 </div>
1032
1033 </div>
1034
1035 <?php
1036 }
1037
1038 /**
1039 * Parse the demos list API
1040 */
1041 public function get_demo_list( $type = 'demos', $url = 'https://demo.phlox.pro/api/v2/info/', $sanitize_key = 'auxin_cache_demo_library_items' ) {
1042
1043 if( $type === 'templates' ){
1044 $url = 'https://library.phlox.pro/info-api/';
1045 $sanitize_key = 'auxin_cache_template_library_items';
1046 }
1047
1048 $key = sanitize_key( $sanitize_key );
1049
1050 if ( ( false === $data = auxin_get_transient( $key ) ) || isset( $_GET['flush_transient'] ) ) {
1051
1052 $response = wp_remote_post( $url );
1053
1054 if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
1055 $response = wp_remote_retrieve_body( $response );
1056 } else {
1057 $error_message = "Something went wrong while connecting ($url): " . $response->get_error_message();
1058 echo '<div class="aux-admin-info-box aux-admin-info-warn aux-admin-welcome-info">' . esc_html( $error_message ) . '</div>';
1059 // if cUrl timeout error was thrown, increase the timeout to 15. Default is 5.
1060 if( false !== strpos( $error_message, 'cURL error 28') ){
1061 set_theme_mod('increasing_curl_timeout_is_required', 15);
1062 }
1063
1064 if ( wp_doing_ajax() ){
1065 die();
1066 } else {
1067 return;
1068 }
1069 }
1070
1071 // translate the JSON into Array
1072 $data = json_decode( $response, true );
1073
1074 if( ! is_array( $data ) ){
1075 if ( wp_doing_ajax() ){
1076 die();
1077 } else {
1078 return;
1079 }
1080 }
1081
1082 // Add transient
1083 auxin_set_transient( $key, $data, 24 * HOUR_IN_SECONDS );
1084 }
1085
1086 return $data;
1087 }
1088
1089
1090 /*-----------------------------------------------------------------------------------*/
1091 /* Step setup_updates
1092 /*-----------------------------------------------------------------------------------*/
1093
1094 public function setup_updates(){
1095 $last_update = auxin_get_update_list();
1096
1097 $has_response = isset( $last_update->total_updates ) ? $last_update->total_updates : false;
1098 ?>
1099 <div class="aux-setup-content">
1100 <div class="aux-updates-step aux-section-content-box">
1101
1102 <?php
1103 if( ! $has_response ){
1104 ?>
1105 <h3 class="aux-content-title"><?php esc_html_e('You have already the latest version.', 'auxin-elements' ); ?></h3>
1106 <?php
1107 } else {
1108 ?>
1109 <h3 class="aux-content-title"><?php esc_html_e('New updates are available.', 'auxin-elements' ); ?></h3>
1110 <p><?php esc_html_e( 'The following items require update, click update button to update them to the latest version.', 'auxin-elements' ); ?></p>
1111 <?php
1112 }
1113 ?>
1114 <div class="aux-fadein-animation">
1115 <?php
1116 if( ! $has_response ){
1117 $this->display_alerts( sprintf(
1118 '%s %s %s',
1119 esc_html__( 'Last checked ', 'auxin-elements' ),
1120 $last_update->last_checked,
1121 esc_html__( 'ago', 'auxin-elements' )
1122 ) , 'success' );
1123 } else {
1124 echo '<div class="aux-update-items">';
1125
1126 if( isset( $last_update->themes ) && is_array( $last_update->themes ) ) {
1127 ?>
1128 <ul class="aux-update-list aux-update-themes">
1129 <?php
1130 foreach ( $last_update->themes as $stylesheet => $args ) {
1131 $theme = wp_get_theme( $stylesheet );
1132 ?>
1133 <li class="aux-item" data-key="<?php echo esc_attr( $stylesheet ); ?>" data-type="themes">
1134 <label class="aux-control">
1135 <?php echo esc_html( $theme->get( 'Name' ) ); ?>
1136 <div class="aux-indicator"></div>
1137 <input name="theme[]" value="<?php echo esc_attr( $stylesheet ); ?>" type="hidden">
1138 </label>
1139 <div class="aux-status column-status">
1140 <span class="update">
1141 <?php echo esc_html__( 'Ready to update', 'auxin-elements' ); ?>
1142 </span>
1143 </div>
1144 </li>
1145 <?php
1146 }
1147 ?>
1148 </ul>
1149 <?php
1150 }
1151
1152 if( isset( $last_update->plugins ) && is_array( $last_update->plugins ) ) {
1153 ?>
1154 <div class="aux-headers">
1155 <span>Plugin Name</span>
1156 <span>Status</span>
1157 </div>
1158 <ul class="aux-update-list aux-update-plugins">
1159 <?php
1160 foreach ( $last_update->plugins as $path => $args ) {
1161 $plugin = get_plugin_data( WP_PLUGIN_DIR . '/' . $path );
1162 ?>
1163 <li class="aux-item" data-key="<?php echo esc_attr( $path ); ?>" data-type="plugins">
1164 <label class="aux-control">
1165 <?php echo esc_html( $plugin['Name'] ); ?>
1166 <div class="aux-indicator"></div>
1167 <input name="plugin[]" value="<?php echo esc_attr( $path ); ?>" type="hidden">
1168 </label>
1169 <div class="aux-status column-status">
1170 <span class="update">
1171 <?php echo esc_html__( 'Ready to update', 'auxin-elements' ); ?>
1172 </span>
1173 </div>
1174 </li>
1175 <?php
1176 }
1177 ?>
1178 </ul>
1179 <?php
1180 }
1181
1182 echo '</div>';
1183 }
1184
1185 ?>
1186 </div>
1187 <div class="aux-sticky">
1188 <div class="aux-setup-actions step">
1189 <?php if( $has_response ){ ?>
1190 <a href="#"
1191 class="aux-button aux-primary aux-install-updates" data-nonce="<?php echo esc_attr( wp_create_nonce( 'auxin-start-upgrading' ) ); ?>"><?php esc_html_e( 'Update Now', 'auxin-elements' ); ?></a>
1192 <?php } ?>
1193 <a href="<?php echo esc_url( self_admin_url( 'admin.php?page=auxin-welcome&tab=updates&force-check=1' ) ); ?>"
1194 class="aux-button aux-outline"><?php esc_html_e( 'Check Again', 'auxin-elements' ); ?></a>
1195 </div>
1196 </div>
1197 <div class="clear"></div>
1198 </div>
1199 </div>
1200 <?php
1201 }
1202
1203 /*-----------------------------------------------------------------------------------*/
1204 /* Step manager in modal
1205 /*-----------------------------------------------------------------------------------*/
1206
1207 /**
1208 * This function will removing the last imported demo
1209 */
1210 public function ajax_uninstall( $request_id = false, $nonce = '', $next_step = '' ){
1211 // Check Security Token
1212 if ( empty( $nonce ) ) {
1213 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'aux-demo-uninstall' ) ) {
1214 // This nonce is not valid.
1215 wp_send_json_error( esc_html__( 'Security Token Error!', 'auxin-elements' ) );
1216 }
1217 } else {
1218 if ( ! wp_verify_nonce( $nonce, 'aux-step-manager' ) ) {
1219 // This nonce is not valid.
1220 wp_send_json_error( esc_html__( 'Security Token Error!', 'auxin-elements' ) );
1221 }
1222 }
1223
1224 if ( ! current_user_can( 'manage_options' ) ) {
1225 wp_send_json_error( esc_html__( 'Permission Error.', 'auxin-elements' ) );
1226 }
1227
1228 // Checking the Active Demo ID with requested one
1229 $last_demo = get_option( 'auxin_last_imported_demo' );
1230 $request_id = empty( $request_id ) && isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : $request_id;
1231 if( ! $request_id || ! $last_demo || $last_demo['id'] != $request_id ) {
1232 wp_send_json_error( esc_html__( 'You can\'t remove this demo.', 'auxin-elements' ) );
1233 }
1234
1235 // call WPDB class instance
1236 global $wpdb;
1237
1238 // Remove Attachments
1239 $attachments = get_posts( array(
1240 'post_type' => 'attachment',
1241 'posts_per_page' => -1,
1242 'post_status' => 'inherit',
1243 'meta_key' => 'auxin_import_id'
1244 ) );
1245 if ( $attachments ) {
1246 foreach ( $attachments as $attachment ) {
1247 wp_delete_attachment( $attachment->ID, true );
1248 }
1249 }
1250
1251 // Remove Posts
1252 $posts = $wpdb->get_results( $wpdb->prepare(
1253 "SELECT p.ID FROM {$wpdb->posts} p
1254 INNER JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id
1255 WHERE pm.meta_key = %s",
1256 'auxin_import_post'
1257 ), ARRAY_A );
1258
1259 if ( $posts ) {
1260 // bypass elementor confirm question for deleting imported kit
1261 $_GET['force_delete_kit'] = 1;
1262
1263 foreach ( $posts as $post ) {
1264 wp_delete_post( $post['ID'], true );
1265 }
1266
1267 $kit = Elementor\Plugin::$instance->kits_manager->get_active_kit();
1268
1269 if ( !$kit->get_id() ) {
1270 $created_default_kit = Elementor\Plugin::$instance->kits_manager->create_default();
1271 if ( $created_default_kit ) {
1272 update_option( Elementor\Core\Kits\Manager::OPTION_ACTIVE, $created_default_kit );
1273 }
1274 }
1275 }
1276
1277 //setting the status of imported depicter documents to draft
1278 $imported_documents_ids = get_option( 'auxin_imported_depicter_documents', []);
1279 if ( ! empty( $imported_documents_ids ) && class_exists( '\Depicter' ) ) {
1280 foreach ( $imported_documents_ids as $old_id => $imported_id ) {
1281 \Depicter::documentRepository()->update( $imported_id, [
1282 'status' => 'draft'
1283 ] );
1284 }
1285
1286 \Depicter::cache('base')->delete('_conditional_document_ids');
1287 }
1288
1289 // Remove Menus
1290 $menus = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_name LIKE '%auxin_demo_importer_menu_origin_id_%'", OBJECT );
1291 foreach ($menus as $key => $menu) {
1292 if( is_numeric( $menu->option_value ) ) {
1293 wp_delete_nav_menu( $menu->option_value );
1294 }
1295 }
1296
1297 // Remove Options
1298 delete_option( THEME_ID.'_theme_options' );
1299 update_option( 'show_on_front', 'page' );
1300 update_option( 'page_on_front', '0' );
1301 remove_theme_mod('custom_css_string');
1302 remove_theme_mod('custom_css_array');
1303 remove_theme_mod('custom_logo');
1304 remove_theme_mod('font_subsets');
1305
1306 // Remove all active widgets
1307 update_option( 'sidebars_widgets', array( 'array_version' => 3 ) );
1308
1309 // Disable all demo plugins other than auxin plugins...
1310 $data = $this->get_demo_list();
1311 $uninstall_demo = [];
1312 foreach( $data['items'] as $item ) {
1313 if ( $item['id'] == $request_id ) {
1314 $uninstall_demo = $item;
1315 break;
1316 }
1317 }
1318 $demo_plugins = isset( $uninstall_demo['plugins'] ) ? $uninstall_demo['plugins'] : '';
1319 if( ! empty( $demo_plugins ) ) {
1320 $demo_plugins = str_replace( '"', '', $demo_plugins );
1321 $demo_plugins = str_replace( '\\', '', $demo_plugins );
1322 $demo_plugins = explode( ',' , trim( $demo_plugins, '[]') );
1323
1324 $active_plugins = get_option( 'active_plugins' );
1325 foreach ( $active_plugins as $key => $name ) {
1326 if ( strpos( $name, 'auxin' ) !== false ) {
1327 continue;
1328 }
1329
1330 foreach( $demo_plugins as $plugin_key => $plugin ) {
1331 if( ( strpos( $name, $plugin ) === 0 || strpos( $name, $plugin ) ) && $plugin != 'elementor' && $plugin != 'woocommerce' ){
1332 unset( $active_plugins[$key] );
1333 }
1334 }
1335 }
1336 update_option( 'active_plugins', $active_plugins );
1337 }
1338
1339 // Remove Additional CSS data
1340 wp_update_custom_css_post('');
1341
1342 // Stores css content in custom css file
1343 auxin_save_custom_css();
1344 // Stores JavaScript content in custom js file
1345 auxin_save_custom_js();
1346
1347 // And finally remove the last imported demo info
1348 delete_option( 'auxin_last_imported_demo' );
1349
1350 if ( !empty( $nonce ) ) {
1351 return $this->step_manager( $next_step );
1352 }
1353
1354 ob_start();
1355 ?>
1356 <div class="aux-setup-demo-content aux-content-col aux-step-import-completed">
1357 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/completed.svg' ); ?>" />
1358 <div><h2 class="aux-step-import-title"><?php esc_html_e( 'Done!', 'auxin-elements' ); ?></h2></div>
1359 <p class="aux-step-description"><?php esc_html_e( "Demo has been successfully uninstalled.", 'auxin-elements' ); ?></p>
1360 </div>
1361 <div class="aux-setup-demo-actions">
1362 <div class="aux-return-back">
1363 <a href="<?php echo esc_url( home_url() ); ?>" class="aux-button aux-round aux-green aux-medium" target="_blank">
1364 <?php esc_html_e( 'Preview', 'auxin-elements' ); ?>
1365 </a>
1366 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1367 <?php esc_html_e( 'Close', 'auxin-elements' ); ?>
1368 </a>
1369 </div>
1370 </div>
1371 <?php
1372
1373 // Return Success Notification
1374 wp_send_json_success( array(
1375 'button' => __( 'Import', 'auxin-elements' ),
1376 'url' => add_query_arg( array( 'action' => 'aux_ajax_lightbox', 'key' => sanitize_text_field( $_POST['key'] ), 'type' => 'install' , 'nonce' => wp_create_nonce( 'aux-open-lightbox' ) ), admin_url( 'admin-ajax.php' ) ),
1377 'markup' => ob_get_clean(),
1378 ) );
1379 }
1380
1381 /**
1382 * Ajax modal box
1383 */
1384 public function ajax_lightbox() {
1385
1386 if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'aux-open-lightbox' ) ) {
1387 // This nonce is not valid.
1388 wp_die( esc_html__( 'Security Token Error!', 'auxin-elements' ) );
1389 }
1390
1391 $type = isset( $_GET['type'] ) ? sanitize_text_field( $_GET['type'] ) : 'progress';
1392
1393 ob_start();
1394
1395 if( $type == 'progress' ) {
1396 echo sprintf( '<div class="aux-template-lightbox"><div class="aux-modal-item aux-default-modal clearfix aux-steps-col">%s</div></div>', $this->progress_step( array(), '' ) );
1397 wp_die( ob_get_clean() );
1398 }
1399
1400 if( $type == 'preview' ) {
1401 if( isset( $_GET['preview'] ) ){
1402 echo sprintf( '<div class="aux-template-lightbox aux-preview-lightbox"><div class="clearfix"><img class="aux-preview-image" src="%s" /><div class="aux-template-actions"><a href="#" class="aux-button aux-medium aux-outline aux-transparent aux-pp-close">%s</a></div></div></div>', esc_url( $_GET['preview'] ), esc_html__( 'Close', 'auxin-elements' ) );
1403 wp_die( ob_get_clean() );
1404 }
1405 }
1406
1407 if( $type == 'plugins' ) {
1408 $data = $this->get_demo_list( 'templates' );
1409 $args = $data['templates'][ sanitize_text_field( $_GET['key'] ) ];
1410 $args = array(
1411 'plugins' => $args['plugins'],
1412 'next_action' => 'template_manager'
1413 );
1414 echo sprintf( '<div class="aux-template-lightbox"><div class="aux-modal-item aux-default-modal clearfix aux-has-required-plugins aux-steps-col">%s</div></div>', $this->second_step( $args, '5' ) );
1415 wp_die( ob_get_clean() );
1416 }
1417
1418 $data = $this->get_demo_list();
1419
1420 if( ! isset( $_GET['key'] ) || empty( $data['items'] ) || ! array_key_exists( $_GET['key'] , $data['items'] ) ) {
1421 wp_die( esc_html__( 'An Error Occurred!', 'auxin-elements' ) );
1422 }
1423
1424 $args = $data['items'][ sanitize_text_field( $_GET['key'] ) ];
1425
1426 if( $type == 'install' ) :
1427 ?>
1428 <div id="demo-<?php echo esc_attr( $args['id'] ); ?>" class="aux-demo-lightbox">
1429 <div class="aux-modal-item clearfix aux-has-required-plugins">
1430 <div class="grid_5 no-gutter aux-media-col" style="background-image: url(<?php echo esc_url( $args['screen'] ); ?>);" >
1431 </div>
1432 <div class="grid_7 no-gutter aux-steps-col">
1433 <div class="aux-setup-demo-content aux-content-col aux-step-import-notice">
1434 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/import-notice.svg' ); ?>" />
1435 <div><h2 class="aux-step-import-title aux-iconic-title"><?php esc_html_e( 'Notice', 'auxin-elements' ); ?></h2></div>
1436 <p class="aux-step-description">
1437 <?php esc_html_e( "For better and faster result, it's recommended to install the demo on a clean WordPress website.", 'auxin-elements' ); ?>
1438 </p>
1439 </div>
1440 <div class="aux-setup-demo-actions">
1441 <div class="aux-return-back">
1442 <a href="#" data-next-step="2" class="aux-button aux-next-step aux-primary aux-medium" data-args="<?php echo htmlspecialchars( wp_json_encode( $args ), ENT_QUOTES, 'UTF-8' ); ?>" data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>">
1443 <?php esc_html_e( 'Continue', 'auxin-elements' ); ?>
1444 </a>
1445 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1446 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1447 </a>
1448 </div>
1449 </div>
1450 </div>
1451 </div>
1452 </div>
1453 <?php
1454 else :
1455 ?>
1456 <div id="demo-<?php echo esc_attr( $args['id'] ); ?>" class="aux-demo-lightbox">
1457 <div class="aux-modal-item clearfix aux-has-required-plugins">
1458 <div class="grid_5 no-gutter aux-media-col" style="background-image: url(<?php echo esc_url( $args['screen'] ); ?>);" >
1459 </div>
1460 <div class="grid_7 no-gutter aux-steps-col">
1461 <div class="aux-setup-demo-content aux-content-col aux-step-import-notice">
1462 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/warning.png' ); ?>" />
1463 <div><h2 class="aux-step-import-title aux-iconic-title"><?php esc_html_e( 'Warning!', 'auxin-elements' ); ?></h2></div>
1464 <p class="aux-step-description">
1465 <?php esc_html_e( "This process will erase all images, posts and settings of this demo...", 'auxin-elements' ); ?>
1466 </p>
1467 </div>
1468 <div class="aux-setup-demo-actions">
1469 <div class="aux-return-back">
1470 <a href="#" class="aux-button aux-uninstall-demo aux-red aux-medium" data-demo-plugins="<?php echo htmlspecialchars( wp_json_encode( $args['plugins'] ), ENT_QUOTES, 'UTF-8' ); ?>" data-demo-id="<?php echo esc_attr( $args['id'] ); ?>" data-demo-nonce="<?php echo wp_create_nonce( 'aux-demo-uninstall' ); ?>" data-demo-confirm="<?php esc_html_e( 'Are you sure you want to uninstall this demo?', 'auxin-elements' ); ?>">
1471 <?php esc_html_e( 'Uninstall', 'auxin-elements' ); ?>
1472 </a>
1473 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1474 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1475 </a>
1476 </div>
1477 <div class="aux-progress hide">
1478 <div class="aux-big">
1479 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;">
1480 <span class="aux-progress-label"><?php esc_html_e( 'Please wait, this may take several minutes ..', 'auxin-elements' ); ?></span>
1481 </div>
1482 </div>
1483 </div>
1484 </div>
1485 </div>
1486 </div>
1487 </div>
1488 <?php
1489 endif;
1490
1491 wp_die( ob_get_clean() );
1492 }
1493
1494
1495 public function step_manager( $next_step = '' ) {
1496 $next_step = empty( $next_step ) ? sanitize_text_field( $_POST['next_step'] ) : $next_step;
1497 $nonce = sanitize_text_field( $_POST['nonce'] );
1498 $args = auxin_sanitize_input( $_POST['args'] );
1499
1500 if ( ! current_user_can( 'manage_options' ) ) {
1501 wp_send_json_error( esc_html__( 'Permission Error.', 'auxin-elements' ) );
1502 }
1503
1504 $steps = array(
1505 '1' => array(
1506 'method' => 'first_step',
1507 'next' => '2'
1508 ),
1509 '2' => array(
1510 'method' => 'second_step',
1511 'next' => '6'
1512 ),
1513 '3' => array(
1514 'method' => 'third_step',
1515 'next' => '4'
1516 ),
1517 '4' => array(
1518 'method' => 'fourth_step',
1519 'next' => ''
1520 ),
1521 '5' => array(
1522 'method' => 'progress_step',
1523 'next' => ''
1524 ),
1525 '6' => array(
1526 'method' => 'remove_watermark_step',
1527 'next' => '7'
1528 ),
1529 '7' => array(
1530 'method' => 'envato_elements_step',
1531 'next' => '3'
1532 ),
1533 '8' => array(
1534 'method' => 'verify_envato_elements_step',
1535 'next' => '9'
1536 ),
1537 '9' => array(
1538 'method' => 'envato_elements_success_step',
1539 'next' => '3'
1540 ),
1541 '10' => array(
1542 'method' => 'uninstall_demo_through_wizard',
1543 'next' => '2'
1544 )
1545
1546 );
1547
1548 if ( ! wp_verify_nonce( $nonce, 'aux-step-manager' ) ) {
1549 // This nonce is not valid.
1550 wp_send_json_error( esc_html__( 'An error occurred!', 'auxin-elements' ) );
1551 } elseif( ! $next_step || $steps[$next_step]['method'] == '' ){
1552 wp_send_json_error( esc_html__( 'Method not exist!', 'auxin-elements' ) );
1553 }
1554
1555 wp_send_json_success(
1556 array(
1557 'markup' => call_user_func( array( $this, $steps[$next_step]['method'] ), $args, $steps[$next_step]['next'] )
1558 )
1559 );
1560 }
1561
1562 public function first_step( array $args, $next_step ) {
1563 ob_start();
1564 ?>
1565 <div class="aux-setup-demo-content aux-content-col">
1566 <h2><?php esc_html_e( 'Required Plugins for this demo.', 'auxin-elements' ); ?></h2>
1567 <p class="aux-step-description">
1568 <?php esc_html_e( "For better and faster install process it's recommended to install demo on a clean WordPress website.", 'auxin-elements' ); ?>
1569 </p>
1570 </div>
1571 <div class="aux-setup-demo-actions">
1572 <div class="aux-return-back">
1573 <a href="#" data-next-step="<?php echo esc_attr( $next_step ); ?>" class="aux-button aux-next-step aux-primary aux-medium" data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>" data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>">
1574 <?php esc_html_e( 'Continue', 'auxin-elements' ); ?>
1575 </a>
1576 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1577 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1578 </a>
1579 </div>
1580 </div>
1581 <?php
1582 return ob_get_clean();
1583 }
1584
1585 public function second_step( array $args, $next_step ) {
1586 $last_demo_imported = get_option( 'auxin_last_imported_demo' );
1587 $is_active_demo = ! empty( $last_demo_imported ) && $last_demo_imported['id'];
1588 if ( $is_active_demo ) {
1589 return $this->uninstall_step( $last_demo_imported['id'], $args );
1590 }
1591
1592 // Goto next step, if no required plugins found
1593 if( ! isset( $args['plugins'] ) ) {
1594 return call_user_func( array( $this, 'remove_watermark_step' ), $args, '7' );
1595 }
1596
1597 $plugins_list = json_decode( stripslashes( $args['plugins'] ), true );
1598
1599 $plugins = $this->get_plugins( $plugins_list );
1600 $has_plugin_required = ! empty( $plugins_list ) && ! empty( $plugins['all'] );
1601
1602 if( $has_plugin_required ) :
1603 $next_step = Auxels_Envato_Elements::get_instance()->is_envato_element_enabled() ? '3' : $next_step;
1604 ob_start();
1605 ?>
1606 <div class="aux-setup-demo-content aux-content-col aux-install-plugins">
1607 <h2><?php esc_html_e( 'Required Plugins for this demo.', 'auxin-elements' ); ?></h2>
1608 <p class="aux-step-description"><?php esc_html_e( 'The following plugins are required to be installed for this demo.', 'auxin-elements' ); ?></p>
1609 <ul class="aux-wizard-plugins">
1610 <?php
1611 foreach ( $plugins['all'] as $slug => $plugin ) { ?>
1612 <li class="aux-plugin" data-slug="<?php echo esc_attr( $slug ); ?>">
1613 <label class="aux-control aux-checkbox">
1614 <?php echo esc_html( $plugin['name'] ); ?>
1615 <input name="plugin[]" value="<?php echo esc_attr($slug); ?>" type="checkbox" checked>
1616 <div class="aux-indicator"></div>
1617 </label>
1618 <div class="status column-status">
1619 <?php
1620 $keys = $class = '';
1621 if ( isset( $plugins['install'][ $slug ] ) ) {
1622 $keys = __( 'Ready to install', 'auxin-elements' );
1623 $class = 'install';
1624 }
1625 if ( isset( $plugins['activate'][ $slug ] ) ) {
1626 $keys = __( 'Not activated', 'auxin-elements' );
1627 $class = 'activate';
1628 }
1629 if ( isset( $plugins['update'][ $slug ] ) ) {
1630 $keys = __( 'Ready to update', 'auxin-elements' );
1631 $class = 'update';
1632 }
1633 ?>
1634 <span class="<?php echo esc_attr( $class ); ?>">
1635 <?php echo esc_html( $keys ); ?>
1636 </span>
1637 <div class="spinner"></div>
1638 </div>
1639 </li>
1640 <?php
1641 }
1642 ?>
1643 </ul>
1644 </div>
1645 <div class="aux-setup-demo-actions">
1646 <div class="aux-return-back">
1647 <a href="#"
1648 class="aux-button aux-medium install-plugins aux-primary"
1649 data-callback="install_plugins"
1650 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1651 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1652 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1653 data-next-action="<?php echo isset( $args['next_action'] ) ? esc_attr( $args['next_action'] ) : false; ?>"
1654 ><?php esc_html_e( 'Install Plugins', 'auxin-elements' ); ?></a>
1655 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1656 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1657 </a>
1658 </div>
1659 </div>
1660 <?php
1661 return ob_get_clean();
1662 else :
1663 return Auxels_Envato_Elements::get_instance()->is_envato_element_enabled() ? call_user_func( array( $this, 'third_step' ), $args, '4' ) : call_user_func( array( $this, 'remove_watermark_step' ), $args, '7' ) ;
1664 return ;
1665 endif;
1666 }
1667
1668 public function uninstall_step( $demo_id, array $args ) {
1669 $data = $this->get_demo_list();
1670 $items = $data['items'];
1671 foreach( $items as $item ) {
1672 if ( $item['id'] == $demo_id ) {
1673 $uninstall_args = $item;
1674 break;
1675 }
1676 }
1677
1678 $args['plugins'] = stripslashes( $args['plugins'] );
1679 $args['tags'] = stripslashes( $args['tags'] );
1680 $args['category'] = stripslashes( $args['category'] );
1681
1682 ob_start();
1683 ?>
1684 <div class="aux-setup-demo-content aux-content-col aux-step-import-notice aux-uninstall-demo-content">
1685 <img src="<?php echo esc_url( $uninstall_args['screen'] ); ?>" />
1686 <div class="aux-installed-template">Installed Template</div>
1687 <div><h2 class="aux-step-import-title aux-iconic-title"><?php esc_html_e( 'You already have installed template!', 'auxin-elements' ); ?></h2></div>
1688 <p class="aux-step-description">
1689 <?php esc_html_e( "For better and faster install proccess it's recommanded to install demo on a clean wordpress website.", 'auxin-elements' ); ?>
1690 </p>
1691 </div>
1692 <div class="aux-setup-demo-actions">
1693 <div class="aux-return-back">
1694 <a href="#"
1695 class="aux-button aux-next-step aux-red aux-medium"
1696 data-next-step="10"
1697 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1698 data-demo-plugins="<?php echo htmlspecialchars( wp_json_encode( $args['plugins'] ), ENT_QUOTES, 'UTF-8' ); ?>"
1699 data-demo-id="<?php echo esc_attr( $demo_id ); ?>"
1700 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>">
1701 <?php esc_html_e( 'Unistall Template', 'auxin-elements' ); ?>
1702 </a>
1703 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1704 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1705 </a>
1706 </div>
1707 <div class="aux-progress hide">
1708 <div class="aux-big">
1709 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;">
1710 <span class="aux-progress-label"><?php esc_html_e( 'Please wait, this may take several minutes ..', 'auxin-elements' ); ?></span>
1711 </div>
1712 </div>
1713 </div>
1714 </div>
1715 <?php
1716 return ob_get_clean();
1717 }
1718
1719 public function uninstall_demo_through_wizard() {
1720 return $this->ajax_uninstall( sanitize_text_field( $_POST['demo_id'] ), sanitize_text_field( $_POST['nonce'] ), '2' );
1721 }
1722
1723 public function third_step( array $args, $next_step ) {
1724 ob_start();
1725 ?>
1726 <div class="aux-setup-demo-content aux-content-col aux-install-demos">
1727 <h2><?php esc_html_e( 'Import Demo Content of Phlox Theme.', 'auxin-elements' ); ?></h2>
1728
1729 <form id="aux-import-data-<?php echo esc_attr( $args['id'] ); ?>" class="aux-import-parts">
1730 <div class="complete aux-border is-checked">
1731 <label class="aux-control aux-radio">
1732 <?php esc_html_e( 'Complete pre-build Website', 'auxin-elements' ); ?>
1733 <input type="radio" name="import" value="complete" checked="checked" />
1734 <div class="aux-indicator"></div>
1735 </label>
1736 <label class="aux-control aux-checkbox">
1737 <?php esc_html_e( 'Import media (images, videos, etc.)', 'auxin-elements' ); ?>
1738 <input type="checkbox" name="import-media" checked="checked" />
1739 <div class="aux-indicator"></div>
1740 </label>
1741 </div>
1742 <div class="custom aux-border">
1743 <label class="aux-control aux-radio">
1744 <?php esc_html_e( 'Selected Data Only', 'auxin-elements' ); ?>
1745 <input type="radio" name="import" value="custom" />
1746 <div class="aux-indicator"></div>
1747 </label>
1748 <div class="one_half no-gutter">
1749 <label class="aux-control aux-checkbox">
1750 <?php esc_html_e( 'Posts/Pages', 'auxin-elements' ); ?>
1751 <input type="checkbox" name="posts" />
1752 <div class="aux-indicator"></div>
1753 </label>
1754 <label class="aux-control aux-checkbox">
1755 <?php esc_html_e( 'Media', 'auxin-elements' ); ?>
1756 <input type="checkbox" name="media" />
1757 <div class="aux-indicator"></div>
1758 </label>
1759 <label class="aux-control aux-checkbox">
1760 <?php esc_html_e( 'Widgets', 'auxin-elements' ); ?>
1761 <input type="checkbox" name="widgets" />
1762 <div class="aux-indicator"></div>
1763 </label>
1764 </div>
1765 <div class="one_half no-gutter right-half">
1766 <label class="aux-control aux-checkbox">
1767 <?php esc_html_e( 'Menus', 'auxin-elements' ); ?>
1768 <input type="checkbox" name="menus" />
1769 <div class="aux-indicator"></div>
1770 </label>
1771 <label class="aux-control aux-checkbox">
1772 <?php esc_html_e( 'Theme Options', 'auxin-elements' ); ?>
1773 <input type="checkbox" name="options" />
1774 <div class="aux-indicator"></div>
1775 </label>
1776 <label class="aux-control aux-checkbox">
1777 <?php esc_html_e( 'MasterSlider (If Available)', 'auxin-elements' ); ?>
1778 <input type="checkbox" name="masterslider" />
1779 <div class="aux-indicator"></div>
1780 </label>
1781 </div>
1782 </div>
1783 </form>
1784 </div>
1785 <div class="aux-setup-demo-content aux-content-col aux-install-demos-waiting hide">
1786 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/importing-cloud.svg' ); ?>" />
1787 <h2><?php esc_html_e( 'Importing Demo Content is in Progress...', 'auxin-elements' ); ?></h2>
1788 <p class="aux-step-description"><?php esc_html_e( 'This process may take 5 to 10 minutes to complete, please do not close or refresh this page.', 'auxin-elements' ); ?></p>
1789 </div>
1790 <div class="aux-setup-demo-actions">
1791 <div class="aux-return-back">
1792 <a href="#"
1793 class="aux-button aux-install-demo aux-medium aux-primary button-next"
1794 data-nonce="<?php echo wp_create_nonce( 'aux-import-demo-' . $args['id'] ); ?>"
1795 data-import-id="<?php echo esc_attr( $args['id'] ); ?>"
1796 data-callback="install_demos"
1797 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1798 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1799 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1800 ><?php esc_html_e( 'Import Content', 'auxin-elements' ); ?></a>
1801 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1802 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1803 </a>
1804 </div>
1805 <div class="aux-progress hide">
1806 <div class="aux-big">
1807 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;">
1808 <span class="aux-progress-label"><?php esc_html_e( 'Please wait, this may take several minutes ..', 'auxin-elements' ); ?></span>
1809 </div>
1810 </div>
1811 </div>
1812 </div>
1813 <?php
1814 return ob_get_clean();
1815 }
1816
1817 public function fourth_step( array $args, $next_step ) {
1818 ob_start();
1819 ?>
1820 <div class="aux-setup-demo-content aux-content-col aux-step-import-completed">
1821 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/completed.svg' ); ?>" />
1822 <div><h2 class="aux-step-import-title"><?php esc_html_e( 'Congratulations!', 'auxin-elements' ); ?></h2></div>
1823 <p class="aux-step-description"><?php esc_html_e( "Demo has been successfully imported.", 'auxin-elements' ); ?></p>
1824 </div>
1825 <div class="aux-setup-demo-actions">
1826 <div class="aux-return-back">
1827 <a href="<?php echo esc_url( self_admin_url('customize.php') ); ?>" class="aux-button aux-primary aux-medium" target="_blank">
1828 <?php esc_html_e( 'Customize', 'auxin-elements' ); ?>
1829 </a>
1830 <a href="<?php echo esc_url( home_url() ); ?>" class="aux-button aux-round aux-green aux-medium" target="_blank">
1831 <?php esc_html_e( 'Preview', 'auxin-elements' ); ?>
1832 </a>
1833 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1834 <?php esc_html_e( 'Close', 'auxin-elements' ); ?>
1835 </a>
1836 </div>
1837 </div>
1838 <?php
1839 return ob_get_clean();
1840 }
1841
1842 public function progress_step( array $args, $next_step ) {
1843 ob_start();
1844 ?>
1845 <h3 class="aux-loading-title"><?php esc_html_e( 'Importing page content ...', 'auxin-elements' ); ?></h3>
1846 <div class="aux-progress">
1847 <div class="aux-big">
1848 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;"></div>
1849 </div>
1850 </div>
1851 <?php
1852 return ob_get_clean();
1853 }
1854
1855 public function remove_watermark_step( array $args, $next_step ) {
1856 ob_start();
1857 ?>
1858 <div class="aux-setup-demo-content aux-content-col aux-step-remove-watermark">
1859 <div class="aux-watermark">
1860 <div class="locked">
1861 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/watermark-2.png' ); ?>" />
1862 <img class="lock-icon" src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/lock-icon.svg' ); ?>" />
1863 </div>
1864 <div class="unlocked">
1865 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/watermark.png' ); ?>" />
1866 <img class="check-icon" src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/check.svg' ); ?>" />
1867 </div>
1868 </div>
1869 <h2 class="aux-step-import-title"><?php esc_html_e( 'Remove Watermarks?', 'auxin-elements' ); ?></h2>
1870 <p class="aux-step-description"><?php esc_html_e( "Some images in this demo are copyrighted and watermarked, you can remove watermarks by authorizing your Envato Elements subscription.", 'auxin-elements' ); ?></p>
1871 <?php
1872 $skip_watermark_step = '3';
1873 ?>
1874 </div>
1875 <div class="aux-setup-demo-actions">
1876 <div class="aux-return-back">
1877 <a href="#"
1878 class="aux-button aux-medium aux-primary aux-next-step"
1879 data-callback="envato_elements_step"
1880 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1881 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1882 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1883 data-next-action="<?php echo isset( $args['next_action'] ) ? esc_attr( $args['next_action'] ) : false; ?>"
1884 ><?php esc_html_e( 'Remove Watermarks', 'auxin-elements' ); ?></a>
1885 <a href="#" data-next-step="<?php echo esc_attr( $skip_watermark_step ); ?>" class="aux-button aux-next-step aux-outline aux-round aux-transparent aux-medium aux-skip" data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>" data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>">
1886 <?php esc_html_e( 'Skip', 'auxin-elements' ); ?>
1887 </a>
1888 </div>
1889 </div>
1890 <?php
1891 return ob_get_clean();
1892 }
1893
1894 public function envato_elements_step( array $args, $next_step ) {
1895 ob_start();
1896 ?>
1897 <div class="aux-setup-demo-content aux-content-col aux-step-envato-elements">
1898 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/envato_elements.svg' ); ?>" />
1899 <h2 class="aux-step-import-title"><?php esc_html_e( 'Remove watermarks by authorizing your Envato Elements subscription', 'auxin-elements' ); ?></h2>
1900 <p class="aux-step-description"><?php esc_html_e( "By subscribing to Envato Elements you will have access to unlimited premium stock images, icons, graphical assets, videos and more.", 'auxin-elements' ); ?></p>
1901 <a href="http://avt.li/elements" class="aux-button aux-primary aux-medium aux-explore-envato" target="_blank">
1902 <?php esc_html_e( 'Explore and Subscribe', 'auxin-elements' ); ?>
1903 </a>
1904 <p><?php esc_html_e( 'Already an Envato Elements member?', 'auxin-elements' ); ?> <a href="#" class="aux-next-step" data-next-step="8" data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>" data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"><?php esc_html_e( 'Activate here', 'auxin-elements' );?></a> </p>
1905 </div>
1906 <div class="aux-setup-demo-actions">
1907 <div class="aux-return-back">
1908 <a href="#" data-next-step="<?php echo esc_attr( $next_step ); ?>" class="aux-button aux-next-step aux-outline aux-round aux-transparent aux-medium" data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>" data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>">
1909 <?php esc_html_e( 'Skip', 'auxin-elements' ); ?>
1910 </a>
1911 </div>
1912 </div>
1913 <?php
1914 return ob_get_clean();
1915 }
1916
1917 public function verify_envato_elements_step( array $args, $next_step) {
1918 ob_start();
1919 ?>
1920 <div class="aux-setup-demo-content aux-content-col aux-step-envato-elements aux-step-verify-envato-elements">
1921 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/activation.svg' ); ?>" />
1922 <h2 class="aux-step-import-title"><?php esc_html_e( 'Verify Your Envato Elements Subscription', 'auxin-elements' ); ?></h2>
1923 <p class="aux-step-description"><?php esc_html_e( "Enter your token below to verify your Subscription", 'auxin-elements' ); ?></p>
1924 <div class="token-wrapper">
1925 <input type="text" class="token-field" placeholder="<?php esc_attr_e( 'Enter token here', 'auxin-elements' ); ?>">
1926 <p class="result"></p>
1927 </div>
1928 <div class="aux-info-links">
1929 <?php
1930 $token_link = Auxels_Envato_Elements::get_instance()->get_token_url();
1931 ?>
1932 <a href="<?php echo esc_url( $token_link ); ?>" target="_blank" class="aux-generate-token" ><?php esc_html_e( 'How to generate a token ?', 'auxin-elements' );?></a>
1933 <a href="http://avt.li/elements" target="_blank" class="aux-subscription" ><?php esc_html_e( 'Don\'t have subscription?', 'auxin-elements' );?></a>
1934 </div>
1935 </div>
1936 <div class="aux-setup-demo-actions">
1937 <div class="aux-return-back">
1938 <a href="#"
1939 class="aux-button aux-medium aux-primary button-next aux-verify-elements-token"
1940 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1941 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1942 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1943 ><?php esc_html_e( 'Verify Token', 'auxin-elements' ); ?></a>
1944 <a href="#"
1945 class="aux-button aux-outline aux-round aux-transparent aux-medium aux-next-step aux-skip"
1946 data-next-step="3"
1947 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1948 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' );?>">
1949 <?php esc_html_e( 'Skip', 'auxin-elements' ); ?>
1950 </a>
1951 </div>
1952 </div>
1953 <?php
1954 return ob_get_clean();
1955 }
1956
1957 public function envato_elements_success_step( array $args, $next_step) {
1958 ob_start();
1959 ?>
1960 <div class="aux-setup-demo-content aux-content-col aux-step-envato-elements-success aux-step-import-notice">
1961 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/completed.svg' ); ?>" />
1962 <h2 class="aux-step-import-title"><?php esc_html_e( 'Succeed', 'auxin-elements' ); ?></h2>
1963 <p class="aux-step-description"><?php esc_html_e( "Congratulations! you have successfully authorized your Envato Elements subscription.", 'auxin-elements' ); ?></p>
1964 </div>
1965 <div class="aux-setup-demo-actions">
1966 <div class="aux-return-back">
1967 <a href="#"
1968 class="aux-button aux-medium aux-primary button-next aux-next-step"
1969 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1970 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1971 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1972 ><?php esc_html_e( 'Continue', 'auxin-elements' ); ?></a>
1973 </div>
1974 </div>
1975 <?php
1976 return ob_get_clean();
1977 }
1978 }
1979