PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.17.14
Shortcodes and extra features for Phlox theme v2.17.14
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 1 year ago class-auxels-archive-menu-links.php 1 year ago class-auxels-envato-elements.php 1 year ago class-auxels-import-parser.php 3 years ago class-auxels-import.php 3 years ago class-auxels-search-post-type.php 6 months ago class-auxels-wc-attribute-nav-menu.php 1 year ago class-auxin-admin-dashboard.php 1 year ago class-auxin-demo-importer.php 6 months ago class-auxin-dependency-sorting.php 3 years ago class-auxin-import.php 1 year ago class-auxin-install.php 1 year ago class-auxin-master-nav-menu-admin.php 1 year ago class-auxin-page-template.php 1 year ago class-auxin-permalink.php 1 year ago class-auxin-plugin-requirements.php 3 years ago class-auxin-post-type-base.php 1 year 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 1 year ago class-auxin-welcome-sections.php 1 year ago class-auxin-welcome.php 6 months ago class-auxin-whitelabel.php 3 years ago class-auxin-widget-indie.php 1 year ago class-auxin-widget-shortcode-map.php 11 months ago class-auxin-widget.php 1 year ago
class-auxin-welcome.php
1966 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 $request = array();
634 // send back some json we use to hit up TGM
635 $plugins = $this->get_plugins();
636 // what are we doing with this plugin?
637 foreach ( $plugins['activate'] as $slug => $plugin ) {
638 if ( $slug === 'related-posts-for-wp' ) {
639 update_option( 'rp4wp_do_install', false );
640 }
641 if ( $_POST['slug'] == $slug ) {
642 $request = array(
643 'url' => admin_url( $this->tgmpa_url ),
644 'plugin' => array( $slug ),
645 'tgmpa-page' => $this->tgmpa_menu_slug,
646 'plugin_status' => 'all',
647 '_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
648 'action' => 'tgmpa-bulk-activate',
649 'action2' => - 1,
650 'message' => esc_html__( 'Activating', 'auxin-elements' ),
651 );
652 break;
653 }
654 }
655 foreach ( $plugins['update'] as $slug => $plugin ) {
656 if ( $_POST['slug'] == $slug ) {
657 $request = array(
658 'url' => admin_url( $this->tgmpa_url ),
659 'plugin' => array( $slug ),
660 'tgmpa-page' => $this->tgmpa_menu_slug,
661 'plugin_status' => 'all',
662 '_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
663 'action' => 'tgmpa-bulk-update',
664 'action2' => - 1,
665 'message' => esc_html__( 'Updating', 'auxin-elements' ),
666 );
667 break;
668 }
669 }
670 foreach ( $plugins['install'] as $slug => $plugin ) {
671 if ( $_POST['slug'] == $slug ) {
672 $request = array(
673 'url' => admin_url( $this->tgmpa_url ),
674 'plugin' => array( $slug ),
675 'tgmpa-page' => $this->tgmpa_menu_slug,
676 'plugin_status' => 'all',
677 '_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
678 'action' => 'tgmpa-bulk-install',
679 'action2' => - 1,
680 'message' => esc_html__( 'Installing', 'auxin-elements' ),
681 );
682 break;
683 }
684 }
685
686 if ( ! empty( $request ) ) {
687 $request['hash'] = md5( serialize( $request ) ); // used for checking if duplicates happen, move to next plugin
688 wp_send_json_success( $request );
689 }
690
691 wp_send_json_success( array( 'message' => esc_html__( 'Activated', 'auxin-elements' ) ) );
692
693 }
694
695
696 /*-----------------------------------------------------------------------------------*/
697 /* Online Demo Importer
698 /*-----------------------------------------------------------------------------------*/
699
700 public function setup_templates(){
701 $template_list = $this->get_demo_list( 'templates' );
702
703 // Create subjects group by type
704 $subjects_group = array();
705
706 if( $template_list ){
707 foreach ( $template_list['templates'] as $key => $args ) {
708 // Convert subject JSON to Array
709 $categoryStack = json_decode( $args['subject'], true );
710 // Set group type
711 if( ! isset( $subjects_group[ $args['type'] ] ) ) {
712 $subjects_group[ $args['type'] ] = array();
713 }
714 // Pass items to group type
715 $subjects_group[ $args['type'] ] = array_unique( array_merge( $subjects_group[ $args['type'] ], $categoryStack ), SORT_REGULAR );
716 }
717 }
718
719 $activeIsoGroup = get_option( 'aux_isotope_group_templates_kit', 'page' );
720 ?>
721
722 <div class="aux-setup-template">
723
724 <div class="aux-fadein-animation">
725
726 <div class="aux-isotope-filters aux-filters aux-underline aux-clearfix aux-togglable aux-clearfix aux-center">
727 <div class="aux-isotope-group-wrapper">
728 <span>Pages</span>
729 <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 ); ?> />
730 <span>Sections</span>
731 </div>
732 <div class="aux-isotope-filters-wrapper">
733 <?php
734 foreach ( $subjects_group as $type => $subjects ) {
735 ?>
736 <ul class="aux-group-filter aux-grouping-<?php echo esc_attr( $type ); ?> <?php echo $activeIsoGroup !== $type ? 'aux-iso-hidden' : ''; ?>">
737 <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>
738 <?php
739 foreach ( $subjects as $filter_label ) {
740 $filter_data = preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $filter_label ) );
741 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>';
742 }
743 ?>
744 </ul>
745 <?php
746 }
747 ?>
748 </div>
749 <div class="aux-isotope-search-wrapper">
750 <input type="text" placeholder="<?php echo esc_html__( 'Search Templates', 'auxin-elements' ); ?>" class="aux-isotope-search">
751 </div>
752 </div>
753
754 <div class="aux-templates-list aux-grid-list aux-isotope-templates" data-search-filter="true" data-grouping="<?php echo esc_attr( $activeIsoGroup ); ?> ">
755 <?php
756 if( ! is_array( $template_list['templates'] ) ){
757 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>';
758 } else {
759 foreach ( $template_list['templates'] as $key => $args ) {
760
761 // Collect plugin filters for current item
762 $filter_categories = '';
763 if( ! empty( $args['subject'] ) ){
764 $categories = json_decode( $args['subject'], true );
765 foreach ( $categories as $num => $category ) {
766 $category_decode = preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $category ) );
767 $filter_categories .= strtolower( str_replace( ' ', '-', $category_decode ) . '-subject ' );
768 }
769 }
770
771 $filter_tags = '';
772 if( ! empty( $args['tags'] ) ){
773 $categories = json_decode( $args['tags'], true );
774 foreach ( $categories as $num => $tags ) {
775 $filter_tags .= strtolower( str_replace( ' ', '-', $tags ) . '-tag ' );
776 }
777 }
778
779 // Check demo license
780 $is_demo_allowed = auxin_is_activated() || ! $args['is_pro'];
781
782 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 ).'">';
783 echo '<div class="aux-grid-item-inner">';
784 echo '<div class="aux-grid-template-media">';
785 echo '<img class="template_thumbnail aux-preload aux-blank" data-src='.esc_url( $args['thumbnail'] ).' src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">';
786 if( ! $is_demo_allowed ) {
787 echo '<img class="premium_badge" alt="This is a premium demo" src="'. esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/pro-badge.png' ) .'">';
788 }
789 echo '</div>';
790 ?>
791 <div class="aux-grid-item-footer">
792 <h3 class="aux-item-title"><?php echo esc_html( $args['title'] ); ?></h3>
793 <div class="aux-grid-item-buttons aux-clearfix">
794 <?php
795
796 $template_status = 'import';
797 $more_btn_class = 'hide';
798
799 if( $is_demo_allowed ) {
800 $color_class = " aux-open-modal aux-import-template aux-has-next-action aux-iconic-action aux-green2";
801 $btn_label = __( 'Download', 'auxin-elements' );
802 $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' ) );
803
804 if( ! empty( $args['plugins'] ) ) {
805 $plugins = $this->get_plugins( json_decode( $args['plugins'], true ) );
806 if( ! empty( $plugins['all'] ) ) {
807 $color_class = " aux-open-modal aux-import-template aux-iconic-action aux-green2";
808 $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' ) );
809 }
810 }
811
812 if( false !== auxin_get_transient( sanitize_key( "auxin_template_kit_{$args['type']}_data_for_origin_id_{$args['id']}" ) ) ) {
813 $template_status = 'copy';
814 $btn_label = __( 'Copy to clipboard', 'auxin-elements' );
815 $color_class = " aux-copy-template aux-iconic-action aux-orange";
816 $import_btn_url = '#';
817 $more_btn_class = '';
818 }
819
820 } else {
821 $color_class = " aux-blue aux-pro-demo aux-locked-demo aux-iconic-action";
822 $btn_label = __( 'Unlock', 'auxin-elements' );
823 $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'] );
824
825 if( defined('THEME_PRO' ) && THEME_PRO ){
826 $color_class .= " aux-ajax-open-modal";
827 $import_btn_url = add_query_arg( array( 'action' => 'auxin_display_actvation_form', 'nonce' => wp_create_nonce( 'aux-activation-form' ) ), admin_url( 'admin-ajax.php' ) );
828 }
829 }
830
831
832 ?>
833 <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' ) ) ) ?>"
834 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>
835 <a href="<?php echo esc_url( $import_btn_url ); ?>"
836 class="aux-wl-button aux-outline aux-round aux-large <?php echo esc_attr( $color_class ); ?>"
837 data-template-id="<?php echo esc_attr( $args['id'] ); ?>"
838 data-template-type="<?php echo esc_attr( $args['type'] ); ?>"
839 data-template-page-tmpl="<?php echo esc_attr( $args['page_tmpl'] ); ?>"
840 data-template-title="<?php echo esc_attr( $args['title'] ); ?>"
841 data-status-type="<?php echo esc_attr( $template_status ); ?>"
842 data-nonce="<?php echo wp_create_nonce( 'aux-template-manager' ); ?>"
843 ><span><?php echo esc_html( $btn_label ); ?></span></a>
844 <a href="#" class="aux-more-button <?php echo esc_attr( $more_btn_class ) ;?>">
845 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/more.svg' ); ?>" width="4" height="18" />
846 </a>
847 <ul class="aux-more-items">
848 <li>
849 <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' ) ) ); ?>"
850 class="aux-open-modal aux-has-next-action"
851 data-template-id="<?php echo esc_attr( $args['id'] ); ?>"
852 data-template-type="<?php echo esc_attr( $args['type'] ); ?>"
853 data-template-page-tmpl="<?php echo esc_attr( $args['page_tmpl'] ); ?>"
854 data-template-title="<?php echo esc_attr( $args['title'] ); ?>"
855 data-status-type="create_my_template"
856 data-nonce="<?php echo wp_create_nonce( 'aux-template-manager' ); ?>"
857 ><span><?php echo esc_html__( 'Save to my templates', 'auxin-elements' ); ?></span></a>
858 </li>
859 <li>
860 <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' ) ) ); ?>"
861 class="aux-open-modal aux-has-next-action"
862 data-template-id="<?php echo esc_attr( $args['id'] ); ?>"
863 data-template-type="<?php echo esc_attr( $args['type'] ); ?>"
864 data-template-page-tmpl="<?php echo esc_attr( $args['page_tmpl'] ); ?>"
865 data-status-type="create_new_page"
866 data-template-title="<?php echo esc_attr( $args['title'] ); ?>"
867 data-nonce="<?php echo wp_create_nonce( 'aux-template-manager' ); ?>"
868 ><span><?php echo esc_html__( 'Create new page', 'auxin-elements' ); ?></span></a>
869 </li>
870 </ul>
871 </div>
872 </div>
873 </div>
874 <?php
875 echo '</div>';
876 }
877 }
878 ?>
879 </div>
880
881 <div class="clear"></div>
882
883 </div>
884
885 </div>
886
887 <?php
888 }
889
890 /*-----------------------------------------------------------------------------------*/
891 /* Online Demo Importer
892 /*-----------------------------------------------------------------------------------*/
893
894 public function setup_importer() {
895 // Get the available demos list from Averta API
896 $demo_list = $this->get_demo_list();
897 // Get last imported demo data
898 $last_demo_imported = get_option( 'auxin_last_imported_demo' );
899 if ( empty($demo_list ) ) {
900 return;
901 }
902
903 ?>
904 <div class="aux-setup-content">
905
906 <div class="aux-demo-importer-step aux-fadein-animation">
907 <div class="aux-isotope-filters aux-filters aux-underline aux-clearfix aux-togglable aux-clearfix aux-center">
908 <?php
909 $categories_list = [];
910 foreach ( $demo_list['items'] as $key => $args ) {
911
912 if ( !empty( $args['category'] ) && $args['category'] != "[]" ) {
913 $categories = str_replace( '"', '', substr( $args['category'], 1, -1 ) );
914 } else {
915 $categories = '';
916 }
917
918 $categories_array = explode( ',', $categories );
919 foreach ( $categories_array as $index => $category ) {
920 $categories_list[ $category ] = isset( $categories_list[ $category ] ) ? ++$categories_list[ $category ] : 1;
921 }
922 }
923 ?>
924 <ul class="aux-group-filter">
925 <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>
926 <?php
927
928 // move shop category to second position
929 $categories_list = auxin_array_insert_after( $categories_list, key( $categories_list ), [ "Shop" => $categories_list['Shop'] ] );
930 $categories_list = array_map( "unserialize", array_unique( array_map( "serialize", $categories_list ) ) );
931
932 foreach ( $categories_list as $category => $demos_count ) {
933 $filter = strtolower( preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $category ) ) );
934 if ( empty( $filter ) ) {
935 continue;
936 }
937 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>';
938 }
939 ?>
940 </ul>
941 <div class="aux-isotope-search-wrapper">
942 <input type="text" placeholder="<?php echo esc_html__( 'Search Templates', 'auxin-elements' ); ?>" class="aux-isotope-search">
943 </div>
944 </div>
945 <div class="aux-demo-list aux-grid-list aux-isotope-list" data-search-filter="true">
946 <?php
947 if( ! is_array( $demo_list ) ){
948 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>';
949 } else {
950 foreach ( $demo_list['items'] as $key => $args ) {
951 // Checking the last imported demo...
952 $is_active_demo = ! empty( $last_demo_imported ) && $last_demo_imported['id'] == $args['id'] ? 'aux-last-imported-demo' : '';
953
954 // Check demo license
955 $is_demo_allowed = auxin_is_activated() || !$args['is_pro'];
956
957 if ( !empty( $args['category'] ) && $args['category'] != "[]" ) {
958 $categories = str_replace( '"', '', substr( $args['category'], 1, -1 ) );
959 } else {
960 $categories = '';
961 }
962 $categories_array = explode( ',', $categories );
963 foreach( $categories_array as $cat_key => $category ) {
964 $categories_array[ $cat_key ] = strtolower( preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $category ) ) );
965 }
966 $categories_class = implode( '-subject ', $categories_array );
967 $categories_class = !empty( $categories_class ) ? $categories_class . '-subject' : '';
968
969 if ( !empty( $args['tags'] ) && $args['tags'] != "[]" ) {
970 $tags = str_replace( '"', '', substr( $args['tags'], 1, -1 ) );
971 } else {
972 $tags = '';
973 }
974 $tags_array = explode( ',', $tags );
975 foreach( $tags_array as $tag_key => $tag ) {
976 $tags_array[ $tag_key ] = strtolower( preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $tag ) ) );
977 }
978 $tags_class = implode( '-tag ', $tags_array );
979 $tags_class = !empty( $tags_class ) ? $tags_class . '-tag' : '';
980
981
982 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 ) . '">';
983 echo '<div class="aux-grid-item-inner">';
984 echo '<div class="aux-grid-item-media">';
985 echo '<img class="demo_thumbnail aux-preload aux-blank" data-src='. esc_url( $args['thumbnail'] ) .' src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">';
986 if( ! $is_demo_allowed ) {
987 echo '<img class="premium_badge" alt="This is a premium demo" src="'. esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/pro-badge.png' ) .'">';
988 }
989 echo '</div>';
990 ?>
991 <div class="aux-grid-item-footer">
992 <h3><?php echo esc_html( $args['title'] ); ?></h3>
993 <div class="aux-grid-item-buttons aux-clearfix">
994 <?php
995 if( $is_demo_allowed ) {
996 $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";
997 $btn_label = $is_active_demo ? __( 'Uninstall', 'auxin-elements' ) : __( 'Import', 'auxin-elements' );
998 $import_type = $is_active_demo ? 'uninstall' : 'install';
999 $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' ) );
1000 } else {
1001 $color_class = " aux-blue aux-pro-demo aux-locked-demo aux-iconic-action";
1002 $btn_label = __( 'Unlock', 'auxin-elements' );
1003 $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'];
1004 if( defined('THEME_PRO' ) && THEME_PRO ){
1005 $color_class .= " aux-ajax-open-modal";
1006 $import_btn_url = add_query_arg( array( 'action' => 'auxin_display_actvation_form', 'nonce' => wp_create_nonce( 'aux-activation-form' ) ), admin_url( 'admin-ajax.php' ) );
1007 }
1008 }
1009 ?>
1010 <a target="_blank" href="<?php echo esc_url( $import_btn_url ); ?>"
1011 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>
1012 <a target="_blank" href="<?php echo ! empty( $args['url'] ) ? esc_url( $args['url'] .'&utm_term='.$args['id'] ) : '#'; ?>"
1013 class="aux-wl-button aux-outline aux-round aux-transparent aux-large aux-preview"><?php esc_html_e( 'Preview', 'auxin-elements' ); ?></a>
1014 </div>
1015 </div>
1016 </div>
1017 <?php
1018 echo '</div>';
1019 }
1020 }
1021 ?>
1022 </div>
1023
1024 <div class="clear"></div>
1025
1026 </div>
1027
1028 </div>
1029
1030 <?php
1031 }
1032
1033 /**
1034 * Parse the demos list API
1035 */
1036 public function get_demo_list( $type = 'demos', $url = 'https://demo.phlox.pro/api/v2/info/', $sanitize_key = 'auxin_cache_demo_library_items' ) {
1037
1038 if( $type === 'templates' ){
1039 $url = 'https://library.phlox.pro/info-api/';
1040 $sanitize_key = 'auxin_cache_template_library_items';
1041 }
1042
1043 $key = sanitize_key( $sanitize_key );
1044
1045 if ( ( false === $data = auxin_get_transient( $key ) ) || isset( $_GET['flush_transient'] ) ) {
1046
1047 $response = wp_remote_post( $url );
1048
1049 if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
1050 $response = wp_remote_retrieve_body( $response );
1051 } else {
1052 $error_message = "Something went wrong while connecting ($url): " . $response->get_error_message();
1053 echo '<div class="aux-admin-info-box aux-admin-info-warn aux-admin-welcome-info">' . esc_html( $error_message ) . '</div>';
1054 // if cUrl timeout error was thrown, increase the timeout to 15. Default is 5.
1055 if( false !== strpos( $error_message, 'cURL error 28') ){
1056 set_theme_mod('increasing_curl_timeout_is_required', 15);
1057 }
1058
1059 if ( wp_doing_ajax() ){
1060 die();
1061 } else {
1062 return;
1063 }
1064 }
1065
1066 // translate the JSON into Array
1067 $data = json_decode( $response, true );
1068
1069 if( ! is_array( $data ) ){
1070 if ( wp_doing_ajax() ){
1071 die();
1072 } else {
1073 return;
1074 }
1075 }
1076
1077 // Add transient
1078 auxin_set_transient( $key, $data, 24 * HOUR_IN_SECONDS );
1079 }
1080
1081 return $data;
1082 }
1083
1084
1085 /*-----------------------------------------------------------------------------------*/
1086 /* Step setup_updates
1087 /*-----------------------------------------------------------------------------------*/
1088
1089 public function setup_updates(){
1090 $last_update = auxin_get_update_list();
1091
1092 $has_response = isset( $last_update->total_updates ) ? $last_update->total_updates : false;
1093 ?>
1094 <div class="aux-setup-content">
1095 <div class="aux-updates-step aux-section-content-box">
1096
1097 <?php
1098 if( ! $has_response ){
1099 ?>
1100 <h3 class="aux-content-title"><?php esc_html_e('You have already the latest version.', 'auxin-elements' ); ?></h3>
1101 <?php
1102 } else {
1103 ?>
1104 <h3 class="aux-content-title"><?php esc_html_e('New updates are available.', 'auxin-elements' ); ?></h3>
1105 <p><?php esc_html_e( 'The following items require update, click update button to update them to the latest version.', 'auxin-elements' ); ?></p>
1106 <?php
1107 }
1108 ?>
1109 <div class="aux-fadein-animation">
1110 <?php
1111 if( ! $has_response ){
1112 $this->display_alerts( sprintf(
1113 '%s %s %s',
1114 esc_html__( 'Last checked ', 'auxin-elements' ),
1115 $last_update->last_checked,
1116 esc_html__( 'ago', 'auxin-elements' )
1117 ) , 'success' );
1118 } else {
1119 echo '<div class="aux-update-items">';
1120
1121 if( isset( $last_update->themes ) && is_array( $last_update->themes ) ) {
1122 ?>
1123 <ul class="aux-update-list aux-update-themes">
1124 <?php
1125 foreach ( $last_update->themes as $stylesheet => $args ) {
1126 $theme = wp_get_theme( $stylesheet );
1127 ?>
1128 <li class="aux-item" data-key="<?php echo esc_attr( $stylesheet ); ?>" data-type="themes">
1129 <label class="aux-control">
1130 <?php echo esc_html( $theme->get( 'Name' ) ); ?>
1131 <div class="aux-indicator"></div>
1132 <input name="theme[]" value="<?php echo esc_attr( $stylesheet ); ?>" type="hidden">
1133 </label>
1134 <div class="aux-status column-status">
1135 <span class="update">
1136 <?php echo esc_html__( 'Ready to update', 'auxin-elements' ); ?>
1137 </span>
1138 </div>
1139 </li>
1140 <?php
1141 }
1142 ?>
1143 </ul>
1144 <?php
1145 }
1146
1147 if( isset( $last_update->plugins ) && is_array( $last_update->plugins ) ) {
1148 ?>
1149 <div class="aux-headers">
1150 <span>Plugin Name</span>
1151 <span>Status</span>
1152 </div>
1153 <ul class="aux-update-list aux-update-plugins">
1154 <?php
1155 foreach ( $last_update->plugins as $path => $args ) {
1156 $plugin = get_plugin_data( WP_PLUGIN_DIR . '/' . $path );
1157 ?>
1158 <li class="aux-item" data-key="<?php echo esc_attr( $path ); ?>" data-type="plugins">
1159 <label class="aux-control">
1160 <?php echo esc_html( $plugin['Name'] ); ?>
1161 <div class="aux-indicator"></div>
1162 <input name="plugin[]" value="<?php echo esc_attr( $path ); ?>" type="hidden">
1163 </label>
1164 <div class="aux-status column-status">
1165 <span class="update">
1166 <?php echo esc_html__( 'Ready to update', 'auxin-elements' ); ?>
1167 </span>
1168 </div>
1169 </li>
1170 <?php
1171 }
1172 ?>
1173 </ul>
1174 <?php
1175 }
1176
1177 echo '</div>';
1178 }
1179
1180 ?>
1181 </div>
1182 <div class="aux-sticky">
1183 <div class="aux-setup-actions step">
1184 <?php if( $has_response ){ ?>
1185 <a href="#"
1186 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>
1187 <?php } ?>
1188 <a href="<?php echo esc_url( self_admin_url( 'admin.php?page=auxin-welcome&tab=updates&force-check=1' ) ); ?>"
1189 class="aux-button aux-outline"><?php esc_html_e( 'Check Again', 'auxin-elements' ); ?></a>
1190 </div>
1191 </div>
1192 <div class="clear"></div>
1193 </div>
1194 </div>
1195 <?php
1196 }
1197
1198 /*-----------------------------------------------------------------------------------*/
1199 /* Step manager in modal
1200 /*-----------------------------------------------------------------------------------*/
1201
1202 /**
1203 * This function will removing the last imported demo
1204 */
1205 public function ajax_uninstall( $request_id = false, $nonce = '', $next_step = '' ){
1206 // Check Security Token
1207 if ( empty( $nonce ) ) {
1208 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'aux-demo-uninstall' ) ) {
1209 // This nonce is not valid.
1210 wp_send_json_error( esc_html__( 'Security Token Error!', 'auxin-elements' ) );
1211 }
1212 } else {
1213 if ( ! wp_verify_nonce( $nonce, 'aux-step-manager' ) ) {
1214 // This nonce is not valid.
1215 wp_send_json_error( esc_html__( 'Security Token Error!', 'auxin-elements' ) );
1216 }
1217 }
1218
1219 // Checking the Active Demo ID with requested one
1220 $last_demo = get_option( 'auxin_last_imported_demo' );
1221 $request_id = empty( $request_id ) && isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : $request_id;
1222 if( ! $request_id || ! $last_demo || $last_demo['id'] != $request_id ) {
1223 wp_send_json_error( esc_html__( 'You can\'t remove this demo.', 'auxin-elements' ) );
1224 }
1225
1226 // call WPDB class instance
1227 global $wpdb;
1228
1229 // Remove Attachments
1230 $attachments = get_posts( array(
1231 'post_type' => 'attachment',
1232 'posts_per_page' => -1,
1233 'post_status' => 'inherit',
1234 'meta_key' => 'auxin_import_id'
1235 ) );
1236 if ( $attachments ) {
1237 foreach ( $attachments as $attachment ) {
1238 wp_delete_attachment( $attachment->ID, true );
1239 }
1240 }
1241
1242 // Remove Posts
1243 $posts = $wpdb->get_results( $wpdb->prepare(
1244 "SELECT p.ID FROM {$wpdb->posts} p
1245 INNER JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id
1246 WHERE pm.meta_key = %s",
1247 'auxin_import_post'
1248 ), ARRAY_A );
1249
1250 if ( $posts ) {
1251 // bypass elementor confirm question for deleting imported kit
1252 $_GET['force_delete_kit'] = 1;
1253
1254 foreach ( $posts as $post ) {
1255 wp_delete_post( $post['ID'], true );
1256 }
1257
1258 $kit = Elementor\Plugin::$instance->kits_manager->get_active_kit();
1259
1260 if ( !$kit->get_id() ) {
1261 $created_default_kit = Elementor\Plugin::$instance->kits_manager->create_default();
1262 if ( $created_default_kit ) {
1263 update_option( Elementor\Core\Kits\Manager::OPTION_ACTIVE, $created_default_kit );
1264 }
1265 }
1266 }
1267
1268 //setting the status of imported depicter documents to draft
1269 $imported_documents_ids = get_option( 'auxin_imported_depicter_documents', []);
1270 if ( ! empty( $imported_documents_ids ) && class_exists( '\Depicter' ) ) {
1271 foreach ( $imported_documents_ids as $old_id => $imported_id ) {
1272 \Depicter::documentRepository()->update( $imported_id, [
1273 'status' => 'draft'
1274 ] );
1275 }
1276
1277 \Depicter::cache('base')->delete('_conditional_document_ids');
1278 }
1279
1280 // Remove Menus
1281 $menus = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_name LIKE '%auxin_demo_importer_menu_origin_id_%'", OBJECT );
1282 foreach ($menus as $key => $menu) {
1283 if( is_numeric( $menu->option_value ) ) {
1284 wp_delete_nav_menu( $menu->option_value );
1285 }
1286 }
1287
1288 // Remove Options
1289 delete_option( THEME_ID.'_theme_options' );
1290 update_option( 'show_on_front', 'page' );
1291 update_option( 'page_on_front', '0' );
1292 remove_theme_mod('custom_css_string');
1293 remove_theme_mod('custom_css_array');
1294 remove_theme_mod('custom_logo');
1295 remove_theme_mod('font_subsets');
1296
1297 // Remove all active widgets
1298 update_option( 'sidebars_widgets', array( 'array_version' => 3 ) );
1299
1300 // Disable all demo plugins other than auxin plugins...
1301 $data = $this->get_demo_list();
1302 $uninstall_demo = [];
1303 foreach( $data['items'] as $item ) {
1304 if ( $item['id'] == $request_id ) {
1305 $uninstall_demo = $item;
1306 break;
1307 }
1308 }
1309 $demo_plugins = isset( $uninstall_demo['plugins'] ) ? $uninstall_demo['plugins'] : '';
1310 if( ! empty( $demo_plugins ) ) {
1311 $demo_plugins = str_replace( '"', '', $demo_plugins );
1312 $demo_plugins = str_replace( '\\', '', $demo_plugins );
1313 $demo_plugins = explode( ',' , trim( $demo_plugins, '[]') );
1314
1315 $active_plugins = get_option( 'active_plugins' );
1316 foreach ( $active_plugins as $key => $name ) {
1317 if ( strpos( $name, 'auxin' ) !== false ) {
1318 continue;
1319 }
1320
1321 foreach( $demo_plugins as $plugin_key => $plugin ) {
1322 if( ( strpos( $name, $plugin ) === 0 || strpos( $name, $plugin ) ) && $plugin != 'elementor' && $plugin != 'woocommerce' ){
1323 unset( $active_plugins[$key] );
1324 }
1325 }
1326 }
1327 update_option( 'active_plugins', $active_plugins );
1328 }
1329
1330 // Remove Additional CSS data
1331 wp_update_custom_css_post('');
1332
1333 // Stores css content in custom css file
1334 auxin_save_custom_css();
1335 // Stores JavaScript content in custom js file
1336 auxin_save_custom_js();
1337
1338 // And finally remove the last imported demo info
1339 delete_option( 'auxin_last_imported_demo' );
1340
1341 if ( !empty( $nonce ) ) {
1342 return $this->step_manager( $next_step );
1343 }
1344
1345 ob_start();
1346 ?>
1347 <div class="aux-setup-demo-content aux-content-col aux-step-import-completed">
1348 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/completed.svg' ); ?>" />
1349 <div><h2 class="aux-step-import-title"><?php esc_html_e( 'Done!', 'auxin-elements' ); ?></h2></div>
1350 <p class="aux-step-description"><?php esc_html_e( "Demo has been successfully uninstalled.", 'auxin-elements' ); ?></p>
1351 </div>
1352 <div class="aux-setup-demo-actions">
1353 <div class="aux-return-back">
1354 <a href="<?php echo esc_url( home_url() ); ?>" class="aux-button aux-round aux-green aux-medium" target="_blank">
1355 <?php esc_html_e( 'Preview', 'auxin-elements' ); ?>
1356 </a>
1357 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1358 <?php esc_html_e( 'Close', 'auxin-elements' ); ?>
1359 </a>
1360 </div>
1361 </div>
1362 <?php
1363
1364 // Return Success Notification
1365 wp_send_json_success( array(
1366 'button' => __( 'Import', 'auxin-elements' ),
1367 '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' ) ),
1368 'markup' => ob_get_clean(),
1369 ) );
1370 }
1371
1372 /**
1373 * Ajax modal box
1374 */
1375 public function ajax_lightbox() {
1376
1377 if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'aux-open-lightbox' ) ) {
1378 // This nonce is not valid.
1379 wp_die( esc_html__( 'Security Token Error!', 'auxin-elements' ) );
1380 }
1381
1382 $type = isset( $_GET['type'] ) ? sanitize_text_field( $_GET['type'] ) : 'progress';
1383
1384 ob_start();
1385
1386 if( $type == 'progress' ) {
1387 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(), '' ) );
1388 wp_die( ob_get_clean() );
1389 }
1390
1391 if( $type == 'preview' ) {
1392 if( isset( $_GET['preview'] ) ){
1393 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' ) );
1394 wp_die( ob_get_clean() );
1395 }
1396 }
1397
1398 if( $type == 'plugins' ) {
1399 $data = $this->get_demo_list( 'templates' );
1400 $args = $data['templates'][ sanitize_text_field( $_GET['key'] ) ];
1401 $args = array(
1402 'plugins' => $args['plugins'],
1403 'next_action' => 'template_manager'
1404 );
1405 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' ) );
1406 wp_die( ob_get_clean() );
1407 }
1408
1409 $data = $this->get_demo_list();
1410
1411 if( ! isset( $_GET['key'] ) || empty( $data['items'] ) || ! array_key_exists( $_GET['key'] , $data['items'] ) ) {
1412 wp_die( esc_html__( 'An Error Occurred!', 'auxin-elements' ) );
1413 }
1414
1415 $args = $data['items'][ sanitize_text_field( $_GET['key'] ) ];
1416
1417 if( $type == 'install' ) :
1418 ?>
1419 <div id="demo-<?php echo esc_attr( $args['id'] ); ?>" class="aux-demo-lightbox">
1420 <div class="aux-modal-item clearfix aux-has-required-plugins">
1421 <div class="grid_5 no-gutter aux-media-col" style="background-image: url(<?php echo esc_url( $args['screen'] ); ?>);" >
1422 </div>
1423 <div class="grid_7 no-gutter aux-steps-col">
1424 <div class="aux-setup-demo-content aux-content-col aux-step-import-notice">
1425 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/import-notice.svg' ); ?>" />
1426 <div><h2 class="aux-step-import-title aux-iconic-title"><?php esc_html_e( 'Notice', 'auxin-elements' ); ?></h2></div>
1427 <p class="aux-step-description">
1428 <?php esc_html_e( "For better and faster result, it's recommended to install the demo on a clean WordPress website.", 'auxin-elements' ); ?>
1429 </p>
1430 </div>
1431 <div class="aux-setup-demo-actions">
1432 <div class="aux-return-back">
1433 <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' ); ?>">
1434 <?php esc_html_e( 'Continue', 'auxin-elements' ); ?>
1435 </a>
1436 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1437 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1438 </a>
1439 </div>
1440 </div>
1441 </div>
1442 </div>
1443 </div>
1444 <?php
1445 else :
1446 ?>
1447 <div id="demo-<?php echo esc_attr( $args['id'] ); ?>" class="aux-demo-lightbox">
1448 <div class="aux-modal-item clearfix aux-has-required-plugins">
1449 <div class="grid_5 no-gutter aux-media-col" style="background-image: url(<?php echo esc_url( $args['screen'] ); ?>);" >
1450 </div>
1451 <div class="grid_7 no-gutter aux-steps-col">
1452 <div class="aux-setup-demo-content aux-content-col aux-step-import-notice">
1453 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/warning.png' ); ?>" />
1454 <div><h2 class="aux-step-import-title aux-iconic-title"><?php esc_html_e( 'Warning!', 'auxin-elements' ); ?></h2></div>
1455 <p class="aux-step-description">
1456 <?php esc_html_e( "This process will erase all images, posts and settings of this demo...", 'auxin-elements' ); ?>
1457 </p>
1458 </div>
1459 <div class="aux-setup-demo-actions">
1460 <div class="aux-return-back">
1461 <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' ); ?>">
1462 <?php esc_html_e( 'Uninstall', 'auxin-elements' ); ?>
1463 </a>
1464 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1465 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1466 </a>
1467 </div>
1468 <div class="aux-progress hide">
1469 <div class="aux-big">
1470 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;">
1471 <span class="aux-progress-label"><?php esc_html_e( 'Please wait, this may take several minutes ..', 'auxin-elements' ); ?></span>
1472 </div>
1473 </div>
1474 </div>
1475 </div>
1476 </div>
1477 </div>
1478 </div>
1479 <?php
1480 endif;
1481
1482 wp_die( ob_get_clean() );
1483 }
1484
1485
1486 public function step_manager( $next_step = '' ) {
1487 $next_step = empty( $next_step ) ? sanitize_text_field( $_POST['next_step'] ) : $next_step;
1488 $nonce = sanitize_text_field( $_POST['nonce'] );
1489 $args = auxin_sanitize_input( $_POST['args'] );
1490
1491 $steps = array(
1492 '1' => array(
1493 'method' => 'first_step',
1494 'next' => '2'
1495 ),
1496 '2' => array(
1497 'method' => 'second_step',
1498 'next' => '6'
1499 ),
1500 '3' => array(
1501 'method' => 'third_step',
1502 'next' => '4'
1503 ),
1504 '4' => array(
1505 'method' => 'fourth_step',
1506 'next' => ''
1507 ),
1508 '5' => array(
1509 'method' => 'progress_step',
1510 'next' => ''
1511 ),
1512 '6' => array(
1513 'method' => 'remove_watermark_step',
1514 'next' => '7'
1515 ),
1516 '7' => array(
1517 'method' => 'envato_elements_step',
1518 'next' => '3'
1519 ),
1520 '8' => array(
1521 'method' => 'verify_envato_elements_step',
1522 'next' => '9'
1523 ),
1524 '9' => array(
1525 'method' => 'envato_elements_success_step',
1526 'next' => '3'
1527 ),
1528 '10' => array(
1529 'method' => 'uninstall_demo_through_wizard',
1530 'next' => '2'
1531 )
1532
1533 );
1534
1535 if ( ! wp_verify_nonce( $nonce, 'aux-step-manager' ) ) {
1536 // This nonce is not valid.
1537 wp_send_json_error( esc_html__( 'An error occurred!', 'auxin-elements' ) );
1538 } elseif( ! $next_step || $steps[$next_step]['method'] == '' ){
1539 wp_send_json_error( esc_html__( 'Method not exist!', 'auxin-elements' ) );
1540 }
1541
1542 wp_send_json_success(
1543 array(
1544 'markup' => call_user_func( array( $this, $steps[$next_step]['method'] ), $args, $steps[$next_step]['next'] )
1545 )
1546 );
1547 }
1548
1549 public function first_step( array $args, $next_step ) {
1550 ob_start();
1551 ?>
1552 <div class="aux-setup-demo-content aux-content-col">
1553 <h2><?php esc_html_e( 'Required Plugins for this demo.', 'auxin-elements' ); ?></h2>
1554 <p class="aux-step-description">
1555 <?php esc_html_e( "For better and faster install process it's recommended to install demo on a clean WordPress website.", 'auxin-elements' ); ?>
1556 </p>
1557 </div>
1558 <div class="aux-setup-demo-actions">
1559 <div class="aux-return-back">
1560 <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' ); ?>">
1561 <?php esc_html_e( 'Continue', 'auxin-elements' ); ?>
1562 </a>
1563 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1564 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1565 </a>
1566 </div>
1567 </div>
1568 <?php
1569 return ob_get_clean();
1570 }
1571
1572 public function second_step( array $args, $next_step ) {
1573 $last_demo_imported = get_option( 'auxin_last_imported_demo' );
1574 $is_active_demo = ! empty( $last_demo_imported ) && $last_demo_imported['id'];
1575 if ( $is_active_demo ) {
1576 return $this->uninstall_step( $last_demo_imported['id'], $args );
1577 }
1578
1579 // Goto next step, if no required plugins found
1580 if( ! isset( $args['plugins'] ) ) {
1581 return call_user_func( array( $this, 'remove_watermark_step' ), $args, '7' );
1582 }
1583
1584 $plugins_list = json_decode( stripslashes( $args['plugins'] ), true );
1585
1586 $plugins = $this->get_plugins( $plugins_list );
1587 $has_plugin_required = ! empty( $plugins_list ) && ! empty( $plugins['all'] );
1588
1589 if( $has_plugin_required ) :
1590 $next_step = Auxels_Envato_Elements::get_instance()->is_envato_element_enabled() ? '3' : $next_step;
1591 ob_start();
1592 ?>
1593 <div class="aux-setup-demo-content aux-content-col aux-install-plugins">
1594 <h2><?php esc_html_e( 'Required Plugins for this demo.', 'auxin-elements' ); ?></h2>
1595 <p class="aux-step-description"><?php esc_html_e( 'The following plugins are required to be installed for this demo.', 'auxin-elements' ); ?></p>
1596 <ul class="aux-wizard-plugins">
1597 <?php
1598 foreach ( $plugins['all'] as $slug => $plugin ) { ?>
1599 <li class="aux-plugin" data-slug="<?php echo esc_attr( $slug ); ?>">
1600 <label class="aux-control aux-checkbox">
1601 <?php echo esc_html( $plugin['name'] ); ?>
1602 <input name="plugin[]" value="<?php echo esc_attr($slug); ?>" type="checkbox" checked>
1603 <div class="aux-indicator"></div>
1604 </label>
1605 <div class="status column-status">
1606 <?php
1607 $keys = $class = '';
1608 if ( isset( $plugins['install'][ $slug ] ) ) {
1609 $keys = __( 'Ready to install', 'auxin-elements' );
1610 $class = 'install';
1611 }
1612 if ( isset( $plugins['activate'][ $slug ] ) ) {
1613 $keys = __( 'Not activated', 'auxin-elements' );
1614 $class = 'activate';
1615 }
1616 if ( isset( $plugins['update'][ $slug ] ) ) {
1617 $keys = __( 'Ready to update', 'auxin-elements' );
1618 $class = 'update';
1619 }
1620 ?>
1621 <span class="<?php echo esc_attr( $class ); ?>">
1622 <?php echo esc_html( $keys ); ?>
1623 </span>
1624 <div class="spinner"></div>
1625 </div>
1626 </li>
1627 <?php
1628 }
1629 ?>
1630 </ul>
1631 </div>
1632 <div class="aux-setup-demo-actions">
1633 <div class="aux-return-back">
1634 <a href="#"
1635 class="aux-button aux-medium install-plugins aux-primary"
1636 data-callback="install_plugins"
1637 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1638 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1639 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1640 data-next-action="<?php echo isset( $args['next_action'] ) ? esc_attr( $args['next_action'] ) : false; ?>"
1641 ><?php esc_html_e( 'Install Plugins', 'auxin-elements' ); ?></a>
1642 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1643 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1644 </a>
1645 </div>
1646 </div>
1647 <?php
1648 return ob_get_clean();
1649 else :
1650 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' ) ;
1651 return ;
1652 endif;
1653 }
1654
1655 public function uninstall_step( $demo_id, array $args ) {
1656 $data = $this->get_demo_list();
1657 $items = $data['items'];
1658 foreach( $items as $item ) {
1659 if ( $item['id'] == $demo_id ) {
1660 $uninstall_args = $item;
1661 break;
1662 }
1663 }
1664
1665 $args['plugins'] = stripslashes( $args['plugins'] );
1666 $args['tags'] = stripslashes( $args['tags'] );
1667 $args['category'] = stripslashes( $args['category'] );
1668
1669 ob_start();
1670 ?>
1671 <div class="aux-setup-demo-content aux-content-col aux-step-import-notice aux-uninstall-demo-content">
1672 <img src="<?php echo esc_url( $uninstall_args['screen'] ); ?>" />
1673 <div class="aux-installed-template">Installed Template</div>
1674 <div><h2 class="aux-step-import-title aux-iconic-title"><?php esc_html_e( 'You already have installed template!', 'auxin-elements' ); ?></h2></div>
1675 <p class="aux-step-description">
1676 <?php esc_html_e( "For better and faster install proccess it's recommanded to install demo on a clean wordpress website.", 'auxin-elements' ); ?>
1677 </p>
1678 </div>
1679 <div class="aux-setup-demo-actions">
1680 <div class="aux-return-back">
1681 <a href="#"
1682 class="aux-button aux-next-step aux-red aux-medium"
1683 data-next-step="10"
1684 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1685 data-demo-plugins="<?php echo htmlspecialchars( wp_json_encode( $args['plugins'] ), ENT_QUOTES, 'UTF-8' ); ?>"
1686 data-demo-id="<?php echo esc_attr( $demo_id ); ?>"
1687 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>">
1688 <?php esc_html_e( 'Unistall Template', 'auxin-elements' ); ?>
1689 </a>
1690 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1691 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1692 </a>
1693 </div>
1694 <div class="aux-progress hide">
1695 <div class="aux-big">
1696 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;">
1697 <span class="aux-progress-label"><?php esc_html_e( 'Please wait, this may take several minutes ..', 'auxin-elements' ); ?></span>
1698 </div>
1699 </div>
1700 </div>
1701 </div>
1702 <?php
1703 return ob_get_clean();
1704 }
1705
1706 public function uninstall_demo_through_wizard() {
1707 return $this->ajax_uninstall( sanitize_text_field( $_POST['demo_id'] ), sanitize_text_field( $_POST['nonce'] ), '2' );
1708 }
1709
1710 public function third_step( array $args, $next_step ) {
1711 ob_start();
1712 ?>
1713 <div class="aux-setup-demo-content aux-content-col aux-install-demos">
1714 <h2><?php esc_html_e( 'Import Demo Content of Phlox Theme.', 'auxin-elements' ); ?></h2>
1715
1716 <form id="aux-import-data-<?php echo esc_attr( $args['id'] ); ?>" class="aux-import-parts">
1717 <div class="complete aux-border is-checked">
1718 <label class="aux-control aux-radio">
1719 <?php esc_html_e( 'Complete pre-build Website', 'auxin-elements' ); ?>
1720 <input type="radio" name="import" value="complete" checked="checked" />
1721 <div class="aux-indicator"></div>
1722 </label>
1723 <label class="aux-control aux-checkbox">
1724 <?php esc_html_e( 'Import media (images, videos, etc.)', 'auxin-elements' ); ?>
1725 <input type="checkbox" name="import-media" checked="checked" />
1726 <div class="aux-indicator"></div>
1727 </label>
1728 </div>
1729 <div class="custom aux-border">
1730 <label class="aux-control aux-radio">
1731 <?php esc_html_e( 'Selected Data Only', 'auxin-elements' ); ?>
1732 <input type="radio" name="import" value="custom" />
1733 <div class="aux-indicator"></div>
1734 </label>
1735 <div class="one_half no-gutter">
1736 <label class="aux-control aux-checkbox">
1737 <?php esc_html_e( 'Posts/Pages', 'auxin-elements' ); ?>
1738 <input type="checkbox" name="posts" />
1739 <div class="aux-indicator"></div>
1740 </label>
1741 <label class="aux-control aux-checkbox">
1742 <?php esc_html_e( 'Media', 'auxin-elements' ); ?>
1743 <input type="checkbox" name="media" />
1744 <div class="aux-indicator"></div>
1745 </label>
1746 <label class="aux-control aux-checkbox">
1747 <?php esc_html_e( 'Widgets', 'auxin-elements' ); ?>
1748 <input type="checkbox" name="widgets" />
1749 <div class="aux-indicator"></div>
1750 </label>
1751 </div>
1752 <div class="one_half no-gutter right-half">
1753 <label class="aux-control aux-checkbox">
1754 <?php esc_html_e( 'Menus', 'auxin-elements' ); ?>
1755 <input type="checkbox" name="menus" />
1756 <div class="aux-indicator"></div>
1757 </label>
1758 <label class="aux-control aux-checkbox">
1759 <?php esc_html_e( 'Theme Options', 'auxin-elements' ); ?>
1760 <input type="checkbox" name="options" />
1761 <div class="aux-indicator"></div>
1762 </label>
1763 <label class="aux-control aux-checkbox">
1764 <?php esc_html_e( 'MasterSlider (If Available)', 'auxin-elements' ); ?>
1765 <input type="checkbox" name="masterslider" />
1766 <div class="aux-indicator"></div>
1767 </label>
1768 </div>
1769 </div>
1770 </form>
1771 </div>
1772 <div class="aux-setup-demo-content aux-content-col aux-install-demos-waiting hide">
1773 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/importing-cloud.svg' ); ?>" />
1774 <h2><?php esc_html_e( 'Importing Demo Content is in Progress...', 'auxin-elements' ); ?></h2>
1775 <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>
1776 </div>
1777 <div class="aux-setup-demo-actions">
1778 <div class="aux-return-back">
1779 <a href="#"
1780 class="aux-button aux-install-demo aux-medium aux-primary button-next"
1781 data-nonce="<?php echo wp_create_nonce( 'aux-import-demo-' . $args['id'] ); ?>"
1782 data-import-id="<?php echo esc_attr( $args['id'] ); ?>"
1783 data-callback="install_demos"
1784 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1785 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1786 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1787 ><?php esc_html_e( 'Import Content', 'auxin-elements' ); ?></a>
1788 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1789 <?php esc_html_e( 'Cancel', 'auxin-elements' ); ?>
1790 </a>
1791 </div>
1792 <div class="aux-progress hide">
1793 <div class="aux-big">
1794 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;">
1795 <span class="aux-progress-label"><?php esc_html_e( 'Please wait, this may take several minutes ..', 'auxin-elements' ); ?></span>
1796 </div>
1797 </div>
1798 </div>
1799 </div>
1800 <?php
1801 return ob_get_clean();
1802 }
1803
1804 public function fourth_step( array $args, $next_step ) {
1805 ob_start();
1806 ?>
1807 <div class="aux-setup-demo-content aux-content-col aux-step-import-completed">
1808 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/completed.svg' ); ?>" />
1809 <div><h2 class="aux-step-import-title"><?php esc_html_e( 'Congratulations!', 'auxin-elements' ); ?></h2></div>
1810 <p class="aux-step-description"><?php esc_html_e( "Demo has been successfully imported.", 'auxin-elements' ); ?></p>
1811 </div>
1812 <div class="aux-setup-demo-actions">
1813 <div class="aux-return-back">
1814 <a href="<?php echo esc_url( self_admin_url('customize.php') ); ?>" class="aux-button aux-primary aux-medium" target="_blank">
1815 <?php esc_html_e( 'Customize', 'auxin-elements' ); ?>
1816 </a>
1817 <a href="<?php echo esc_url( home_url() ); ?>" class="aux-button aux-round aux-green aux-medium" target="_blank">
1818 <?php esc_html_e( 'Preview', 'auxin-elements' ); ?>
1819 </a>
1820 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1821 <?php esc_html_e( 'Close', 'auxin-elements' ); ?>
1822 </a>
1823 </div>
1824 </div>
1825 <?php
1826 return ob_get_clean();
1827 }
1828
1829 public function progress_step( array $args, $next_step ) {
1830 ob_start();
1831 ?>
1832 <h3 class="aux-loading-title"><?php esc_html_e( 'Importing page content ...', 'auxin-elements' ); ?></h3>
1833 <div class="aux-progress">
1834 <div class="aux-big">
1835 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;"></div>
1836 </div>
1837 </div>
1838 <?php
1839 return ob_get_clean();
1840 }
1841
1842 public function remove_watermark_step( array $args, $next_step ) {
1843 ob_start();
1844 ?>
1845 <div class="aux-setup-demo-content aux-content-col aux-step-remove-watermark">
1846 <div class="aux-watermark">
1847 <div class="locked">
1848 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/watermark-2.png' ); ?>" />
1849 <img class="lock-icon" src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/lock-icon.svg' ); ?>" />
1850 </div>
1851 <div class="unlocked">
1852 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/watermark.png' ); ?>" />
1853 <img class="check-icon" src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/check.svg' ); ?>" />
1854 </div>
1855 </div>
1856 <h2 class="aux-step-import-title"><?php esc_html_e( 'Remove Watermarks?', 'auxin-elements' ); ?></h2>
1857 <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>
1858 <?php
1859 $skip_watermark_step = '3';
1860 ?>
1861 </div>
1862 <div class="aux-setup-demo-actions">
1863 <div class="aux-return-back">
1864 <a href="#"
1865 class="aux-button aux-medium aux-primary aux-next-step"
1866 data-callback="envato_elements_step"
1867 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1868 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1869 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1870 data-next-action="<?php echo isset( $args['next_action'] ) ? esc_attr( $args['next_action'] ) : false; ?>"
1871 ><?php esc_html_e( 'Remove Watermarks', 'auxin-elements' ); ?></a>
1872 <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' ); ?>">
1873 <?php esc_html_e( 'Skip', 'auxin-elements' ); ?>
1874 </a>
1875 </div>
1876 </div>
1877 <?php
1878 return ob_get_clean();
1879 }
1880
1881 public function envato_elements_step( array $args, $next_step ) {
1882 ob_start();
1883 ?>
1884 <div class="aux-setup-demo-content aux-content-col aux-step-envato-elements">
1885 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/envato_elements.svg' ); ?>" />
1886 <h2 class="aux-step-import-title"><?php esc_html_e( 'Remove watermarks by authorizing your Envato Elements subscription', 'auxin-elements' ); ?></h2>
1887 <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>
1888 <a href="http://avt.li/elements" class="aux-button aux-primary aux-medium aux-explore-envato" target="_blank">
1889 <?php esc_html_e( 'Explore and Subscribe', 'auxin-elements' ); ?>
1890 </a>
1891 <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>
1892 </div>
1893 <div class="aux-setup-demo-actions">
1894 <div class="aux-return-back">
1895 <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' ); ?>">
1896 <?php esc_html_e( 'Skip', 'auxin-elements' ); ?>
1897 </a>
1898 </div>
1899 </div>
1900 <?php
1901 return ob_get_clean();
1902 }
1903
1904 public function verify_envato_elements_step( array $args, $next_step) {
1905 ob_start();
1906 ?>
1907 <div class="aux-setup-demo-content aux-content-col aux-step-envato-elements aux-step-verify-envato-elements">
1908 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/activation.svg' ); ?>" />
1909 <h2 class="aux-step-import-title"><?php esc_html_e( 'Verify Your Envato Elements Subscription', 'auxin-elements' ); ?></h2>
1910 <p class="aux-step-description"><?php esc_html_e( "Enter your token below to verify your Subscription", 'auxin-elements' ); ?></p>
1911 <div class="token-wrapper">
1912 <input type="text" class="token-field" placeholder="<?php esc_attr_e( 'Enter token here', 'auxin-elements' ); ?>">
1913 <p class="result"></p>
1914 </div>
1915 <div class="aux-info-links">
1916 <?php
1917 $token_link = Auxels_Envato_Elements::get_instance()->get_token_url();
1918 ?>
1919 <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>
1920 <a href="http://avt.li/elements" target="_blank" class="aux-subscription" ><?php esc_html_e( 'Don\'t have subscription?', 'auxin-elements' );?></a>
1921 </div>
1922 </div>
1923 <div class="aux-setup-demo-actions">
1924 <div class="aux-return-back">
1925 <a href="#"
1926 class="aux-button aux-medium aux-primary button-next aux-verify-elements-token"
1927 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1928 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1929 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1930 ><?php esc_html_e( 'Verify Token', 'auxin-elements' ); ?></a>
1931 <a href="#"
1932 class="aux-button aux-outline aux-round aux-transparent aux-medium aux-next-step aux-skip"
1933 data-next-step="3"
1934 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1935 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' );?>">
1936 <?php esc_html_e( 'Skip', 'auxin-elements' ); ?>
1937 </a>
1938 </div>
1939 </div>
1940 <?php
1941 return ob_get_clean();
1942 }
1943
1944 public function envato_elements_success_step( array $args, $next_step) {
1945 ob_start();
1946 ?>
1947 <div class="aux-setup-demo-content aux-content-col aux-step-envato-elements-success aux-step-import-notice">
1948 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/completed.svg' ); ?>" />
1949 <h2 class="aux-step-import-title"><?php esc_html_e( 'Succeed', 'auxin-elements' ); ?></h2>
1950 <p class="aux-step-description"><?php esc_html_e( "Congratulations! you have successfully authorized your Envato Elements subscription.", 'auxin-elements' ); ?></p>
1951 </div>
1952 <div class="aux-setup-demo-actions">
1953 <div class="aux-return-back">
1954 <a href="#"
1955 class="aux-button aux-medium aux-primary button-next aux-next-step"
1956 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1957 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1958 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1959 ><?php esc_html_e( 'Continue', 'auxin-elements' ); ?></a>
1960 </div>
1961 </div>
1962 <?php
1963 return ob_get_clean();
1964 }
1965 }
1966