PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.7.3
Shortcodes and extra features for Phlox theme v2.7.3
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 6 years ago class-auxels-archive-menu-links.php 6 years ago class-auxels-envato-elements.php 6 years ago class-auxels-import-parser.php 8 years ago class-auxels-import.php 6 years ago class-auxels-search-post-type.php 6 years ago class-auxels-wc-attribute-nav-menu.php 5 years ago class-auxin-admin-dashboard.php 6 years ago class-auxin-demo-importer.php 5 years ago class-auxin-dependency-sorting.php 8 years ago class-auxin-import.php 6 years ago class-auxin-install.php 6 years ago class-auxin-master-nav-menu-admin.php 6 years ago class-auxin-page-template.php 6 years ago class-auxin-permalink.php 6 years ago class-auxin-plugin-requirements.php 6 years ago class-auxin-post-type-base.php 6 years ago class-auxin-siteorigin-widget.php 6 years ago class-auxin-svg-support-allowedattributes.php 7 years ago class-auxin-svg-support-allowedtags.php 7 years ago class-auxin-svg-support.php 7 years ago class-auxin-walker-nav-menu-back.php 5 years ago class-auxin-welcome-sections.php 6 years ago class-auxin-welcome.php 5 years ago class-auxin-whitelabel.php 7 years ago class-auxin-widget-indie.php 6 years ago class-auxin-widget-shortcode-map.php 6 years ago class-auxin-widget.php 6 years ago
class-auxin-welcome.php
1830 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' ), __( 'You are recommended to install Phlox exclusive plugins in order to enable all features.', 'auxin-elements' ) );
295 } else {
296 echo esc_html( $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( ',', $_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 '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.',
377 'waspthemes-yellow-pencil' => 'The most advanced visual CSS editor. Customize any page in real-time without coding.',
378 'auxin-the-news' => 'Publish news easily and beautifully with Phlox theme.',
379 'auxin-pro-tools' => 'Premium features for Phlox theme.',
380 'auxin-shop' => 'Make a shop in easiest way using phlox theme.',
381 'envato-market' => 'WP Theme Updater based on the Envato WordPress Toolkit Library and Pixelentity class from ThemeForest forums.'
382 );
383
384 /* If we arrive here, we have the filesystem */
385
386 ?>
387 <div class="aux-setup-content">
388 <div class="aux-section-content-box">
389 <?php if( ! isset( $_GET['view'] ) || $_GET['view'] !== 'abstract' ) : ?>
390 <h3 class="aux-content-title"><?php _e('Recommended Plugins', 'auxin-elements' ); ?></h3>
391 <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>
392 <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>
393 <?php endif; ?>
394
395 <div class="aux-plugins-step aux-has-required-plugins aux-fadein-animation">
396 <?php
397 if ( count( $plugins['all'] ) ) {
398
399 $plugin_categories = $this->get_plugins_categories( $plugins['all'] );
400 $plugin_categories_localized = $this->get_plugins_categories_localized();
401
402 // -----------------------------------------------------
403 ?>
404
405 <div class="aux-table">
406 <section class="auxin-list-table">
407
408 <?php if( ! isset( $_GET['view'] ) || $_GET['view'] !== 'abstract' ) : ?>
409 <div class="aux-isotope-filters aux-filters aux-underline aux-clearfix aux-togglable aux-clearfix aux-center">
410 <div class="aux-select-overlay"></div>
411 <ul>
412 <li data-filter="all"><a href="#" class="aux-selected"><span data-select="<?php _e('Recent', 'auxin-elements'); ?>"><?php _e('Recent', 'auxin-elements'); ?></span></a></li>
413 <?php
414 foreach ( $plugin_categories_localized as $filter_slug => $filter_label ) {
415 if( in_array( $filter_slug, $plugin_categories ) ){
416 echo '<li data-filter="'. esc_attr( $filter_slug . '-plugins' ) .'"><a href="#"><span data-select="'. $filter_label .'">'. $filter_label .'</span></a></li>';
417 }
418 }
419 ?>
420 </ul>
421 </div>
422 <?php endif; ?>
423
424 <header class="aux-table-heading aux-table-row aux-clearfix">
425 <div id="cb" class="manage-column aux-column-cell column-cb check-column">
426 <label class="screen-reader-text" for="cb-select-all"><?php esc_html_e( 'Select All', 'auxin-elements' ); ?></label>
427 <input id="cb-select-all" type="checkbox" style="display:none;">
428 </div>
429 <div class="manage-column aux-column-cell column-thumbnail"></div>
430 <div scope="col" id="name" class="manage-column aux-column-cell column-name"><?php esc_html_e( 'Name', 'auxin-elements' ); ?></div>
431 <div scope="col" id="description" class="manage-column aux-column-cell column-description"><?php esc_html_e( 'Description', 'auxin-elements' ); ?></div>
432 <div scope="col" id="status" class="manage-column aux-column-cell column-status"><?php esc_html_e( 'Status', 'auxin-elements' ); ?></div>
433 <div scope="col" id="version" class="manage-column aux-column-cell column-version"><?php esc_html_e( 'Version', 'auxin-elements' ); ?></div>
434 </header>
435
436 <div class="aux-wizard-plugins aux-table-body aux-isotope-plugins-list aux-clearfix">
437 <?php
438 foreach ( $plugins['all'] as $slug => $plugin ) {
439
440 // Collect plugin filters for current item
441 $filter_terms = '';
442 if( ! empty( $plugin['categories'] ) ){
443 if( is_array( $plugin['categories'] ) ){
444 foreach ( $plugin['categories'] as $category ) {
445 $filter_terms .= $category . '-plugins ';
446 }
447 }
448 }
449
450 if( $this->tgmpa_instance->is_plugin_installed( $slug ) ) {
451 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin['file_path'] );
452 } else {
453 $plugin_data = $this->get_plugin_data_by_slug( $slug );
454 }
455 ?>
456 <div class="aux-plugin aux-table-row aux-iso-item <?php echo esc_attr( $filter_terms ); ?>" data-slug="<?php echo esc_attr( $slug ); ?>">
457 <div scope="row" class="check-column aux-column-cell">
458 <input class="aux-check-column" name="plugin[]" value="<?php echo esc_attr( $slug ); ?>" type="checkbox">
459 <div class="spinner"></div>
460 </div>
461 <div class="thumbnail column-thumbnail aux-column-cell" data-colname="Thumbnail">
462 <?php
463 $thumbnail = "https://ps.w.org/{$plugin['slug']}/assets/icon-128x128.png";
464
465 if( isset( $plugin['thumbnail'] ) ){
466 if( 'custom' == $plugin['thumbnail'] ){
467 $thumbnail = AUXELS_ADMIN_URL . '/assets/images/welcome/' . $plugin['slug'] . '-plugin.png';
468 } elseif( 'default' === $plugin['thumbnail'] ){
469 $thumbnail = AUXELS_ADMIN_URL . '/assets/images/welcome/def-plugin.png';
470 } elseif( ! empty( $plugin['thumbnail'] ) ){
471 $thumbnail = $plugin['thumbnail'];
472 }
473 }
474 ?>
475 <img src="<?php echo esc_url( $thumbnail ); ?>" width="64" height="64" />
476 </div>
477 <div class="name column-name aux-column-cell" data-colname="Plugin"><?php echo esc_html( $plugin['name'] ); ?></div>
478 <div class="description column-description aux-column-cell" data-colname="Description">
479 <?php
480 $description = '';
481 if( isset( $plugin_data['Description'] ) ) {
482 $description = $plugin_data['Description'];
483 } else if ( isset( $embeds_plugins_desc[ $plugin['slug'] ] ) ){
484 $description = $embeds_plugins_desc[ $plugin['slug'] ];
485 }
486 if( $description ){
487 echo '<p>'. $description .'</p>';
488 }
489 if ( ! empty( $plugin['badge'] ) ) {
490 echo '<span class="aux-label aux-exclusive-label">' . esc_html( $plugin['badge'] ) . '</span>';
491 }
492 ?>
493 </div>
494 <div class="status column-status aux-column-cell" data-colname="Status">
495 <span>
496 <?php
497 if ( isset( $plugins['install'][ $slug ] ) ) {
498 echo esc_html__( 'Not Installed', 'auxin-elements' );
499 } elseif ( isset( $plugins['activate'][ $slug ] ) ) {
500 echo esc_html__( 'Not Activated', 'auxin-elements' );
501 }
502 ?>
503 </span>
504 </div>
505 <div class="version column-version aux-column-cell" data-colname="Version">
506 <?php if( isset( $plugin_data['Version'] ) ) { ?>
507 <span><?php echo esc_html( $plugin_data['Version'] ); ?></span>
508 <?php } ?>
509 </div>
510 </div>
511 <?php } ?>
512 </div>
513 </section>
514 </div>
515
516 <div class="clear"></div>
517
518 <div class="aux-sticky">
519 <div class="aux-setup-actions step">
520 <a href="#"
521 class="aux-button aux-primary install-plugins disabled"
522 data-callback="install_plugins"><?php esc_html_e( 'Install Plugins', 'auxin-elements' ); ?></a>
523 <?php wp_nonce_field( 'aux-setup' ); ?>
524 </div>
525 </div>
526
527 <?php
528 } else { ?>
529
530 <?php $this->display_alerts( esc_html__( 'Good news! All plugins are already installed and up to date. Please continue.', 'auxin-elements' ) , 'success' ); ?>
531
532 <?php
533 } ?>
534 </div>
535 </div>
536 </div>
537 <?php
538 }
539
540 /**
541 * Output the tgmpa plugins list
542 */
543 private function get_plugins( $custom_list = array() ) {
544
545 $plugins = array(
546 'all' => array(), // Meaning: all plugins which still have open actions.
547 'install' => array(),
548 'update' => array(),
549 'activate' => array(),
550 );
551
552 foreach ( $this->tgmpa_instance->plugins as $slug => $plugin ) {
553
554 if( ! empty( $custom_list ) && ! in_array( $slug, $custom_list ) ){
555 // This condition is for custom requests lists
556 continue;
557 } elseif( $this->tgmpa_instance->is_plugin_active( $slug ) && false === $this->tgmpa_instance->does_plugin_have_update( $slug ) ) {
558 // No need to display plugins if they are installed, up-to-date and active.
559 continue;
560 } else {
561 $plugins['all'][ $slug ] = $plugin;
562
563 if ( ! $this->tgmpa_instance->is_plugin_installed( $slug ) ) {
564 $plugins['install'][ $slug ] = $plugin;
565 } else {
566
567 if ( false !== $this->tgmpa_instance->does_plugin_have_update( $slug ) ) {
568 $plugins['update'][ $slug ] = $plugin;
569 }
570 if ( $this->tgmpa_instance->can_plugin_activate( $slug ) ) {
571 $plugins['activate'][ $slug ] = $plugin;
572 }
573
574 }
575 }
576 }
577
578 return $plugins;
579 }
580
581 /**
582 * Returns the plugin data from WP.org API
583 */
584 private function get_plugin_data_by_slug( $slug = '' ) {
585
586 if ( empty( $slug ) ) {
587 return false;
588 }
589
590 $key = sanitize_key( 'auxin_plugin_data_'.$slug );
591
592 if ( false === ( $plugins = auxin_get_transient( $key ) ) ) {
593 $args = array(
594 'slug' => $slug,
595 'fields' => array(
596 'short_description' => true
597 )
598 );
599 $response = wp_remote_post(
600 'http://api.wordpress.org/plugins/info/1.0/',
601 array(
602 'body' => array(
603 'action' => 'plugin_information',
604 'request' => serialize( (object) $args )
605 )
606 )
607 );
608 $data = unserialize( wp_remote_retrieve_body( $response ) );
609
610 $plugins = is_object( $data ) ? array( 'Description' => $data->short_description , 'Version' => $data->version ) : false;
611
612 // Set transient for next time... keep it for 24 hours
613 auxin_set_transient( $key, $plugins, 24 * HOUR_IN_SECONDS );
614
615 }
616
617 return $plugins;
618 }
619
620 /**
621 * Plugins AJAX Process
622 */
623 public function ajax_plugins() {
624 // Inputs validations
625 if ( ! check_ajax_referer( 'aux_setup_nonce', 'wpnonce' ) || ! isset( $_POST['slug'] ) || empty( $_POST['slug'] ) ) {
626 wp_send_json_error( array( 'message' => esc_html__( 'No Slug Found', 'auxin-elements' ) ) );
627 }
628 $request = array();
629 // send back some json we use to hit up TGM
630 $plugins = $this->get_plugins();
631 // what are we doing with this plugin?
632 foreach ( $plugins['activate'] as $slug => $plugin ) {
633 if ( $slug === 'related-posts-for-wp' ) {
634 update_option( 'rp4wp_do_install', false );
635 }
636 if ( $_POST['slug'] == $slug ) {
637 $request = array(
638 'url' => admin_url( $this->tgmpa_url ),
639 'plugin' => array( $slug ),
640 'tgmpa-page' => $this->tgmpa_menu_slug,
641 'plugin_status' => 'all',
642 '_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
643 'action' => 'tgmpa-bulk-activate',
644 'action2' => - 1,
645 'message' => esc_html__( 'Activating', 'auxin-elements' ),
646 );
647 break;
648 }
649 }
650 foreach ( $plugins['update'] as $slug => $plugin ) {
651 if ( $_POST['slug'] == $slug ) {
652 $request = array(
653 'url' => admin_url( $this->tgmpa_url ),
654 'plugin' => array( $slug ),
655 'tgmpa-page' => $this->tgmpa_menu_slug,
656 'plugin_status' => 'all',
657 '_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
658 'action' => 'tgmpa-bulk-update',
659 'action2' => - 1,
660 'message' => esc_html__( 'Updating', 'auxin-elements' ),
661 );
662 break;
663 }
664 }
665 foreach ( $plugins['install'] as $slug => $plugin ) {
666 if ( $_POST['slug'] == $slug ) {
667 $request = array(
668 'url' => admin_url( $this->tgmpa_url ),
669 'plugin' => array( $slug ),
670 'tgmpa-page' => $this->tgmpa_menu_slug,
671 'plugin_status' => 'all',
672 '_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
673 'action' => 'tgmpa-bulk-install',
674 'action2' => - 1,
675 'message' => esc_html__( 'Installing', 'auxin-elements' ),
676 );
677 break;
678 }
679 }
680
681 if ( ! empty( $request ) ) {
682 $request['hash'] = md5( serialize( $request ) ); // used for checking if duplicates happen, move to next plugin
683 wp_send_json_success( $request );
684 }
685
686 wp_send_json_success( array( 'message' => esc_html__( 'Activated', 'auxin-elements' ) ) );
687
688 }
689
690
691 /*-----------------------------------------------------------------------------------*/
692 /* Online Demo Importer
693 /*-----------------------------------------------------------------------------------*/
694
695 public function setup_templates(){
696 $template_list = $this->get_demo_list( 'templates' );
697
698 // Create subjects group by type
699 $subjects_group = array();
700
701 if( $template_list ){
702 foreach ( $template_list['templates'] as $key => $args ) {
703 // Convert subject JSON to Array
704 $categoryStack = json_decode( $args['subject'], true );
705 // Set group type
706 if( ! isset( $subjects_group[ $args['type'] ] ) ) {
707 $subjects_group[ $args['type'] ] = array();
708 }
709 // Pass items to group type
710 $subjects_group[ $args['type'] ] = array_unique( array_merge( $subjects_group[ $args['type'] ], $categoryStack ), SORT_REGULAR );
711 }
712 }
713
714 $activeIsoGroup = get_option( 'aux_isotope_group_templates_kit', 'page' );
715 ?>
716
717 <div class="aux-setup-template">
718
719 <div class="aux-fadein-animation">
720
721 <div class="aux-isotope-filters aux-filters aux-underline aux-clearfix aux-togglable aux-clearfix aux-center">
722 <div class="aux-isotope-group-wrapper">
723 <span>Pages</span>
724 <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 ); ?> />
725 <span>Sections</span>
726 </div>
727 <div class="aux-isotope-filters-wrapper">
728 <?php
729 foreach ( $subjects_group as $type => $subjects ) {
730 ?>
731 <ul class="aux-group-filter aux-grouping-<?php echo esc_attr( $type ); ?> <?php echo $activeIsoGroup !== $type ? 'aux-iso-hidden' : ''; ?>">
732 <li data-filter="all"><a href="#" class="aux-selected"><span data-select="<?php _e('Recent', 'auxin-elements'); ?>"><?php _e('Recent', 'auxin-elements'); ?></span></a></li>
733 <?php
734 foreach ( $subjects as $filter_label ) {
735 $filter_data = preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $filter_label ) );
736 echo '<li data-filter="'. strtolower( str_replace( ' ', '-', $filter_data ) . '-subject' ) .'"><a href="#"><span data-select="'. $filter_label .'">'. $filter_label .'</span></a></li>';
737 }
738 ?>
739 </ul>
740 <?php
741 }
742 ?>
743 </div>
744 <div class="aux-isotope-search-wrapper">
745 <input type="text" placeholder="<?php echo esc_html__( 'Search Templates', 'auxin-elements' ); ?>" class="aux-isotope-search">
746 </div>
747 </div>
748
749 <div class="aux-templates-list aux-grid-list aux-isotope-templates" data-search-filter="true" data-grouping="<?php echo esc_attr( $activeIsoGroup ); ?> ">
750 <?php
751 if( ! is_array( $template_list['templates'] ) ){
752 echo '<p class="aux-grid-item grid_12">'. __( 'An error occurred while downloading the list of templates. Please try again later.' ) .'</p>';
753 } else {
754 foreach ( $template_list['templates'] as $key => $args ) {
755
756 // Collect plugin filters for current item
757 $filter_categories = '';
758 if( ! empty( $args['subject'] ) ){
759 $categories = json_decode( $args['subject'], true );
760 foreach ( $categories as $num => $category ) {
761 $category_decode = preg_replace( '/[^A-Za-z0-9\-]/', '', wp_specialchars_decode( $category ) );
762 $filter_categories .= strtolower( str_replace( ' ', '-', $category_decode ) . '-subject ' );
763 }
764 }
765
766 $filter_tags = '';
767 if( ! empty( $args['tags'] ) ){
768 $categories = json_decode( $args['tags'], true );
769 foreach ( $categories as $num => $tags ) {
770 $filter_tags .= strtolower( str_replace( ' ', '-', $tags ) . '-tag ' );
771 }
772 }
773
774 // Check demo license
775 $is_demo_allowed = auxin_is_activated() || ! $args['is_pro'];
776
777 echo '<div data-template-type="'.$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 ).'">';
778 echo '<div class="aux-grid-item-inner">';
779 echo '<div class="aux-grid-template-media">';
780 echo '<img class="template_thumbnail aux-preload aux-blank" data-src='.$args['thumbnail'].' src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">';
781 if( ! $is_demo_allowed ) {
782 echo '<img class="premium_badge" alt="This is a premium demo" src="'. esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/pro-badge.png' ) .'">';
783 }
784 echo '</div>';
785 ?>
786 <div class="aux-grid-item-footer">
787 <h3 class="aux-item-title"><?php echo $args['title']; ?></h3>
788 <div class="aux-grid-item-buttons aux-clearfix">
789 <?php
790
791 $template_status = 'import';
792 $more_btn_class = 'hide';
793
794 if( $is_demo_allowed ) {
795 $color_class = " aux-open-modal aux-import-template aux-has-next-action aux-iconic-action aux-green2";
796 $btn_label = esc_html__( 'Download', 'auxin-elements' );
797 $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' ) );
798
799 if( ! empty( $args['plugins'] ) ) {
800 $plugins = $this->get_plugins( json_decode( $args['plugins'], true ) );
801 if( ! empty( $plugins['all'] ) ) {
802 $color_class = " aux-open-modal aux-import-template aux-iconic-action aux-green2";
803 $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' ) );
804 }
805 }
806
807 if( false !== auxin_get_transient( sanitize_key( "auxin_template_kit_{$args['type']}_data_for_origin_id_{$args['id']}" ) ) ) {
808 $template_status = 'copy';
809 $btn_label = esc_html__( 'Copy to clipboard', 'auxin-elements' );
810 $color_class = " aux-copy-template aux-iconic-action aux-orange";
811 $import_btn_url = '#';
812 $more_btn_class = '';
813 }
814
815 } else {
816 $color_class = " aux-blue aux-pro-demo aux-locked-demo aux-iconic-action";
817 $btn_label = esc_html__( 'Unlock', 'auxin-elements' );
818 $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'] );
819
820 if( defined('THEME_PRO' ) && THEME_PRO ){
821 $color_class .= " aux-ajax-open-modal";
822 $import_btn_url = add_query_arg( array( 'action' => 'auxin_display_actvation_form', 'nonce' => wp_create_nonce( 'aux-activation-form' ) ), admin_url( 'admin-ajax.php' ) );
823 }
824 }
825
826
827 ?>
828 <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' ) ) ) ?>"
829 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>
830 <a href="<?php echo esc_url( $import_btn_url ); ?>"
831 class="aux-wl-button aux-outline aux-round aux-large <?php echo esc_attr( $color_class ); ?>"
832 data-template-id="<?php echo esc_attr( $args['id'] ); ?>"
833 data-template-type="<?php echo esc_attr( $args['type'] ); ?>"
834 data-template-page-tmpl="<?php echo esc_attr( $args['page_tmpl'] ); ?>"
835 data-template-title="<?php echo esc_attr( $args['title'] ); ?>"
836 data-status-type="<?php echo esc_attr( $template_status ); ?>"
837 data-nonce="<?php echo wp_create_nonce( 'aux-template-manager' ); ?>"
838 ><span><?php echo $btn_label; ?></span></a>
839 <a href="#" class="aux-more-button <?php echo esc_attr( $more_btn_class ) ;?>">
840 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/more.svg' ); ?>" width="4" height="18" />
841 </a>
842 <ul class="aux-more-items">
843 <li>
844 <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' ) ) ); ?>"
845 class="aux-open-modal aux-has-next-action"
846 data-template-id="<?php echo esc_attr( $args['id'] ); ?>"
847 data-template-type="<?php echo esc_attr( $args['type'] ); ?>"
848 data-template-page-tmpl="<?php echo esc_attr( $args['page_tmpl'] ); ?>"
849 data-template-title="<?php echo esc_attr( $args['title'] ); ?>"
850 data-status-type="create_my_template"
851 data-nonce="<?php echo wp_create_nonce( 'aux-template-manager' ); ?>"
852 ><span><?php echo esc_html__( 'Save to my templates', 'auxin-elements' ); ?></span></a>
853 </li>
854 <li>
855 <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' ) ) ); ?>"
856 class="aux-open-modal aux-has-next-action"
857 data-template-id="<?php echo esc_attr( $args['id'] ); ?>"
858 data-template-type="<?php echo esc_attr( $args['type'] ); ?>"
859 data-template-page-tmpl="<?php echo esc_attr( $args['page_tmpl'] ); ?>"
860 data-status-type="create_new_page"
861 data-template-title="<?php echo esc_attr( $args['title'] ); ?>"
862 data-nonce="<?php echo wp_create_nonce( 'aux-template-manager' ); ?>"
863 ><span><?php echo esc_html__( 'Create new page', 'auxin-elements' ); ?></span></a>
864 </li>
865 </ul>
866 </div>
867 </div>
868 </div>
869 <?php
870 echo '</div>';
871 }
872 }
873 ?>
874 </div>
875
876 <div class="clear"></div>
877
878 </div>
879
880 </div>
881
882 <?php
883 }
884
885 /*-----------------------------------------------------------------------------------*/
886 /* Online Demo Importer
887 /*-----------------------------------------------------------------------------------*/
888
889 public function setup_importer() {
890 // Get the available demos list from Averta API
891 $demo_list = $this->get_demo_list();
892 // Get last imported demo data
893 $last_demo_imported = get_option( 'auxin_last_imported_demo' );
894
895 ?>
896 <div class="aux-setup-content">
897
898 <div class="aux-demo-importer-step aux-fadein-animation">
899
900 <div class="aux-demo-list aux-grid-list aux-isotope-list">
901 <?php
902 if( ! is_array( $demo_list ) ){
903 echo '<p class="aux-grid-item grid_12">'. __( 'An error occurred while downloading the list of demo sites. Please try again later.' ) .'</p>';
904 } else {
905 foreach ( $demo_list['items'] as $key => $args ) {
906 // Checking the last imported demo...
907 $is_active_demo = ! empty( $last_demo_imported ) && $last_demo_imported['id'] == $args['id'] ? 'aux-last-imported-demo' : '';
908
909 // Check demo license
910 $is_demo_allowed = auxin_is_activated() || !$args['is_pro'];
911
912 echo '<div data-demo-id="demo-'.$args['id'].'" class="aux-grid-item aux-iso-item grid_4 '.$is_active_demo.'">';
913 echo '<div class="aux-grid-item-inner">';
914 echo '<div class="aux-grid-item-media">';
915 echo '<img class="demo_thumbnail aux-preload aux-blank" data-src='.$args['thumbnail'].' src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">';
916 if( ! $is_demo_allowed ) {
917 echo '<img class="premium_badge" alt="This is a premium demo" src="'. esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/pro-badge.png' ) .'">';
918 }
919 echo '</div>';
920 ?>
921 <div class="aux-grid-item-footer">
922 <h3><?php echo $args['title']; ?></h3>
923 <div class="aux-grid-item-buttons aux-clearfix">
924 <?php
925 if( $is_demo_allowed ) {
926 $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";
927 $btn_label = $is_active_demo ? esc_html__( 'Uninstall', 'auxin-elements' ) : esc_html__( 'Import', 'auxin-elements' );
928 $import_type = $is_active_demo ? 'uninstall' : 'install';
929 $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' ) );
930 } else {
931 $color_class = " aux-blue aux-pro-demo aux-locked-demo aux-iconic-action";
932 $btn_label = esc_html__( 'Unlock', 'auxin-elements' );
933 $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=demo-unlock&utm_term='. $args['id'] );
934 if( defined('THEME_PRO' ) && THEME_PRO ){
935 $color_class .= " aux-ajax-open-modal";
936 $import_btn_url = add_query_arg( array( 'action' => 'auxin_display_actvation_form', 'nonce' => wp_create_nonce( 'aux-activation-form' ) ), admin_url( 'admin-ajax.php' ) );
937 }
938 }
939 ?>
940 <a target="_blank" href="<?php echo $import_btn_url; ?>"
941 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 $btn_label; ?></a>
942 <a target="_blank" href="<?php echo ! empty( $args['url'] ) ? esc_url( $args['url'] .'&utm_term='.$args['id'] ) : '#'; ?>"
943 class="aux-wl-button aux-outline aux-round aux-transparent aux-large aux-preview"><?php esc_html_e( 'Preview', 'auxin-elements' ); ?></a>
944 </div>
945 </div>
946 </div>
947 <?php
948 echo '</div>';
949 }
950 }
951 ?>
952 </div>
953
954 <div class="clear"></div>
955
956 </div>
957
958 </div>
959
960 <?php
961 }
962
963 /**
964 * Parse the demos list API
965 */
966 public function get_demo_list( $type = 'demos', $url = 'http://demo.phlox.pro/api/v2/info/', $sanitize_key = 'auxin_cache_demo_library_items' ) {
967
968 if( $type === 'templates' ){
969 $url = 'http://library.phlox.pro/info-api/';
970 $sanitize_key = 'auxin_cache_template_library_items';
971 }
972
973 $key = sanitize_key( $sanitize_key );
974
975 if ( ( false === $data = auxin_get_transient( $key ) ) || isset( $_GET['flush_transient'] ) ) {
976
977 $response = wp_remote_post( $url );
978
979 if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
980 $response = wp_remote_retrieve_body( $response );
981 } else {
982 $error_message = "Something went wrong while connecting ($url): " . $response->get_error_message();
983 echo '<div class="aux-admin-info-box aux-admin-info-warn aux-admin-welcome-info">' . $error_message . '</div>';
984 // if cUrl timeout error was thrown, increase the timeout to 15. Default is 5.
985 if( false !== strpos( $error_message, 'cURL error 28') ){
986 set_theme_mod('increasing_curl_timeout_is_required', 15);
987 }
988
989 if ( wp_doing_ajax() ){
990 die();
991 } else {
992 return;
993 }
994 }
995
996 // translate the JSON into Array
997 $data = json_decode( $response, true );
998
999 if( ! is_array( $data ) ){
1000 if ( wp_doing_ajax() ){
1001 die();
1002 } else {
1003 return;
1004 }
1005 }
1006
1007 // Add transient
1008 auxin_set_transient( $key, $data, 24 * HOUR_IN_SECONDS );
1009 }
1010
1011 return $data;
1012 }
1013
1014
1015 /*-----------------------------------------------------------------------------------*/
1016 /* Step setup_updates
1017 /*-----------------------------------------------------------------------------------*/
1018
1019 public function setup_updates(){
1020 $last_update = auxin_get_update_list();
1021
1022 $has_response = isset( $last_update->total_updates ) ? $last_update->total_updates : false;
1023 ?>
1024 <div class="aux-setup-content">
1025 <div class="aux-updates-step aux-section-content-box">
1026
1027 <?php
1028 if( ! $has_response ){
1029 ?>
1030 <h3 class="aux-content-title"><?php _e('You have already the latest version.', 'auxin-elements' ); ?></h3>
1031 <?php
1032 } else {
1033 ?>
1034 <h3 class="aux-content-title"><?php _e('New updates are available.', 'auxin-elements' ); ?></h3>
1035 <p><?php esc_html_e( 'The following items require update, click update button to update them to the latest version.', 'auxin-elements' ); ?></p>
1036 <?php
1037 }
1038 ?>
1039 <div class="aux-fadein-animation">
1040 <?php
1041 if( ! $has_response ){
1042 $this->display_alerts( sprintf(
1043 '%s %s %s',
1044 esc_html__( 'Last checked ', 'auxin-elements' ),
1045 $last_update->last_checked,
1046 esc_html__( 'ago', 'auxin-elements' )
1047 ) , 'success' );
1048 } else {
1049 echo '<div class="aux-update-items">';
1050
1051 if( isset( $last_update->themes ) && is_array( $last_update->themes ) ) {
1052 ?>
1053 <ul class="aux-update-list aux-update-themes">
1054 <?php
1055 foreach ( $last_update->themes as $stylesheet => $args ) {
1056 $theme = wp_get_theme( $stylesheet );
1057 ?>
1058 <li class="aux-item" data-key="<?php echo esc_attr( $stylesheet ); ?>" data-type="themes">
1059 <label class="aux-control">
1060 <?php echo esc_html( $theme->get( 'Name' ) ); ?>
1061 <div class="aux-indicator"></div>
1062 <input name="theme[]" value="<?php echo esc_attr( $stylesheet ); ?>" type="hidden">
1063 </label>
1064 <div class="aux-status column-status">
1065 <span class="update">
1066 <?php echo esc_html__( 'Ready to update', 'auxin-elements' ); ?>
1067 </span>
1068 </div>
1069 </li>
1070 <?php
1071 }
1072 ?>
1073 </ul>
1074 <?php
1075 }
1076
1077 if( isset( $last_update->plugins ) && is_array( $last_update->plugins ) ) {
1078 ?>
1079 <div class="aux-headers">
1080 <span>Plugin Name</span>
1081 <span>Status</span>
1082 </div>
1083 <ul class="aux-update-list aux-update-plugins">
1084 <?php
1085 foreach ( $last_update->plugins as $path => $args ) {
1086 $plugin = get_plugin_data( WP_PLUGIN_DIR . '/' . $path );
1087 ?>
1088 <li class="aux-item" data-key="<?php echo esc_attr( $path ); ?>" data-type="plugins">
1089 <label class="aux-control">
1090 <?php echo esc_html( $plugin['Name'] ); ?>
1091 <div class="aux-indicator"></div>
1092 <input name="plugin[]" value="<?php echo esc_attr( $path ); ?>" type="hidden">
1093 </label>
1094 <div class="aux-status column-status">
1095 <span class="update">
1096 <?php echo esc_html__( 'Ready to update', 'auxin-elements' ); ?>
1097 </span>
1098 </div>
1099 </li>
1100 <?php
1101 }
1102 ?>
1103 </ul>
1104 <?php
1105 }
1106
1107 echo '</div>';
1108 }
1109
1110 ?>
1111 </div>
1112 <div class="aux-sticky">
1113 <div class="aux-setup-actions step">
1114 <?php if( $has_response ){ ?>
1115 <a href="#"
1116 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>
1117 <?php } ?>
1118 <a href="<?php echo self_admin_url( 'admin.php?page=auxin-welcome&tab=updates&force-check=1' ); ?>"
1119 class="aux-button aux-outline"><?php esc_html_e( 'Check Again', 'auxin-elements' ); ?></a>
1120 </div>
1121 </div>
1122 <div class="clear"></div>
1123 </div>
1124 </div>
1125 <?php
1126 }
1127
1128 /*-----------------------------------------------------------------------------------*/
1129 /* Step manager in modal
1130 /*-----------------------------------------------------------------------------------*/
1131
1132 /**
1133 * This function will removing the last imported demo
1134 */
1135 public function ajax_uninstall(){
1136 // Check Security Token
1137 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'aux-demo-uninstall' ) ) {
1138 // This nonce is not valid.
1139 wp_send_json_error( esc_html__( 'Security Token Error!', 'auxin-elements' ) );
1140 }
1141
1142 // Checking the Active Demo ID with requested one
1143 $last_demo = get_option( 'auxin_last_imported_demo' );
1144 $request_id = isset( $_POST['id'] ) ? $_POST['id'] : false;
1145 if( ! $request_id || ! $last_demo || $last_demo['id'] != $request_id ) {
1146 wp_send_json_error( esc_html__( 'You can\'t remove this demo.', 'auxin-elements' ) );
1147 }
1148
1149 // call WPDB class instance
1150 global $wpdb;
1151
1152 // Remove Attachments
1153 $attachments = get_posts( array(
1154 'post_type' => 'attachment',
1155 'posts_per_page' => -1,
1156 'post_status' => 'inherit',
1157 'meta_key' => 'auxin_import_id'
1158 ) );
1159 if ( $attachments ) {
1160 foreach ( $attachments as $attachment ) {
1161 wp_delete_attachment( $attachment->ID, true );
1162 }
1163 }
1164
1165 // Remove Posts
1166 $posts = get_posts( array(
1167 'post_type' => 'any',
1168 'posts_per_page' => -1,
1169 'post_status' => 'any',
1170 'meta_key' => 'auxin_import_post'
1171 ) );
1172 if ( $posts ) {
1173 foreach ( $posts as $post ) {
1174 wp_delete_post( $post->ID, true );
1175 }
1176 }
1177
1178 // Remove Menus
1179 $menus = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}options WHERE option_name LIKE '%auxin_demo_importer_menu_origin_id_%'", OBJECT );
1180 foreach ($menus as $key => $menu) {
1181 if( is_numeric( $menu->option_value ) ) {
1182 wp_delete_nav_menu( $menu->option_value );
1183 }
1184 }
1185
1186 // Remove Options
1187 delete_option( THEME_ID.'_theme_options' );
1188 update_option( 'show_on_front', 'page' );
1189 update_option( 'page_on_front', '0' );
1190 remove_theme_mod('custom_css_string');
1191 remove_theme_mod('custom_css_array');
1192 remove_theme_mod('custom_logo');
1193 remove_theme_mod('font_subsets');
1194
1195 // Remove all active widgets
1196 update_option( 'sidebars_widgets', array( 'array_version' => 3 ) );
1197
1198 // Disable all demo plugins other than auxin plugins...
1199 $demo_plugins = isset( $_POST['plugins'] ) ? $_POST['plugins'] : array();
1200 if( ! empty( $demo_plugins ) ) {
1201 $active_plugins = get_option( 'active_plugins' );
1202 foreach ( $active_plugins as $key => $name ) {
1203 if( auxin_strposa( $name, $demo_plugins ) && strpos( $name, 'auxin' ) === false ){
1204 unset( $active_plugins[$key] );
1205 }
1206 }
1207 update_option( 'active_plugins', $active_plugins );
1208 }
1209
1210 // Remove Additional CSS data
1211 wp_update_custom_css_post( NULL );
1212
1213 // Stores css content in custom css file
1214 auxin_save_custom_css();
1215 // Stores JavaScript content in custom js file
1216 auxin_save_custom_js();
1217
1218 // And finally remove the last imported demo info
1219 delete_option( 'auxin_last_imported_demo' );
1220
1221 ob_start();
1222 ?>
1223 <div class="aux-setup-demo-content aux-content-col aux-step-import-completed">
1224 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/completed.svg' ); ?>" />
1225 <div><h2 class="aux-step-import-title"><?php esc_html_e( 'Done!', 'auxin-elements' ); ?></h2></div>
1226 <p class="aux-step-description"><?php esc_html_e( "Demo has been successfully uninstalled.", 'auxin-elements' ); ?></p>
1227 </div>
1228 <div class="aux-setup-demo-actions">
1229 <div class="aux-return-back">
1230 <a href="<?php echo home_url(); ?>" class="aux-button aux-round aux-green aux-medium" target="_blank">
1231 <?php _e( 'Preview', 'auxin-elements' ); ?>
1232 </a>
1233 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1234 <?php _e( 'Close', 'auxin-elements' ); ?>
1235 </a>
1236 </div>
1237 </div>
1238 <?php
1239
1240 // Return Success Notification
1241 wp_send_json_success( array(
1242 'button' => __( 'Import', 'auxin-elements' ),
1243 'url' => add_query_arg( array( 'action' => 'aux_ajax_lightbox', 'key' => $_POST['key'], 'type' => 'install' , 'nonce' => wp_create_nonce( 'aux-open-lightbox' ) ), admin_url( 'admin-ajax.php' ) ),
1244 'markup' => ob_get_clean(),
1245 ) );
1246 }
1247
1248 /**
1249 * Ajax modal box
1250 */
1251 public function ajax_lightbox() {
1252
1253 if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'aux-open-lightbox' ) ) {
1254 // This nonce is not valid.
1255 wp_die( esc_html__( 'Security Token Error!', 'auxin-elements' ) );
1256 }
1257
1258 $type = isset( $_GET['type'] ) ? $_GET['type'] : 'progress';
1259
1260 ob_start();
1261
1262 if( $type == 'progress' ) {
1263 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(), '' ) );
1264 wp_die( ob_get_clean() );
1265 }
1266
1267 if( $type == 'preview' ) {
1268 if( isset( $_GET['preview'] ) ){
1269 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>', $_GET['preview'], __( 'Close', 'auxin-elements' ) );
1270 wp_die( ob_get_clean() );
1271 }
1272 }
1273
1274 if( $type == 'plugins' ) {
1275 $data = $this->get_demo_list( 'templates' );
1276 $args = $data['templates'][ $_GET['key'] ];
1277 $args = array(
1278 'plugins' => $args['plugins'],
1279 'next_action' => 'template_manager'
1280 );
1281 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' ) );
1282 wp_die( ob_get_clean() );
1283 }
1284
1285 $data = $this->get_demo_list();
1286
1287 if( ! isset( $_GET['key'] ) || empty( $data['items'] ) || ! array_key_exists( $_GET['key'] , $data['items'] ) ) {
1288 wp_die( esc_html__( 'An Error Occurred!', 'auxin-elements' ) );
1289 }
1290
1291 $args = $data['items'][ $_GET['key'] ];
1292
1293 if( $type == 'install' ) :
1294 ?>
1295 <div id="demo-<?php echo esc_attr( $args['id'] ); ?>" class="aux-demo-lightbox">
1296 <div class="aux-modal-item clearfix aux-has-required-plugins">
1297 <div class="grid_5 no-gutter aux-media-col" style="background-image: url(<?php echo esc_url( $args['screen'] ); ?>);" >
1298 </div>
1299 <div class="grid_7 no-gutter aux-steps-col">
1300 <div class="aux-setup-demo-content aux-content-col aux-step-import-notice">
1301 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/import-notice.svg' ); ?>" />
1302 <div><h2 class="aux-step-import-title aux-iconic-title"><?php esc_html_e( 'Notice', 'auxin-elements' ); ?></h2></div>
1303 <p class="aux-step-description">
1304 <?php esc_html_e( "For better and faster result, it's recommended to install the demo on a clean WordPress website.", 'auxin-elements' ); ?>
1305 </p>
1306 </div>
1307 <div class="aux-setup-demo-actions">
1308 <div class="aux-return-back">
1309 <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' ); ?>">
1310 <?php _e( 'Continue', 'auxin-elements' ); ?>
1311 </a>
1312 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1313 <?php _e( 'Cancel', 'auxin-elements' ); ?>
1314 </a>
1315 </div>
1316 </div>
1317 </div>
1318 </div>
1319 </div>
1320 <?php
1321 else :
1322 ?>
1323 <div id="demo-<?php echo esc_attr( $args['id'] ); ?>" class="aux-demo-lightbox">
1324 <div class="aux-modal-item clearfix aux-has-required-plugins">
1325 <div class="grid_5 no-gutter aux-media-col" style="background-image: url(<?php echo esc_url( $args['screen'] ); ?>);" >
1326 </div>
1327 <div class="grid_7 no-gutter aux-steps-col">
1328 <div class="aux-setup-demo-content aux-content-col aux-step-import-notice">
1329 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/warning.png' ); ?>" />
1330 <div><h2 class="aux-step-import-title aux-iconic-title"><?php esc_html_e( 'Warning!', 'auxin-elements' ); ?></h2></div>
1331 <p class="aux-step-description">
1332 <?php esc_html_e( "This process will erase all images, posts and settings of this demo...", 'auxin-elements' ); ?>
1333 </p>
1334 </div>
1335 <div class="aux-setup-demo-actions">
1336 <div class="aux-return-back">
1337 <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 $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' ); ?>">
1338 <?php _e( 'Uninstall', 'auxin-elements' ); ?>
1339 </a>
1340 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1341 <?php _e( 'Cancel', 'auxin-elements' ); ?>
1342 </a>
1343 </div>
1344 <div class="aux-progress hide">
1345 <div class="aux-big">
1346 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;">
1347 <span class="aux-progress-label"><?php esc_html_e( 'Please wait, this may take several minutes ..', 'auxin-elements' ); ?></span>
1348 </div>
1349 </div>
1350 </div>
1351 </div>
1352 </div>
1353 </div>
1354 </div>
1355 <?php
1356 endif;
1357
1358 wp_die( ob_get_clean() );
1359 }
1360
1361
1362 public function step_manager() {
1363 $next_step = $_POST['next_step'];
1364 $nonce = $_POST['nonce'];
1365 $args = $_POST['args'];
1366
1367 $steps = array(
1368 '1' => array(
1369 'method' => 'first_step',
1370 'next' => '2'
1371 ),
1372 '2' => array(
1373 'method' => 'second_step',
1374 'next' => '6'
1375 ),
1376 '3' => array(
1377 'method' => 'third_step',
1378 'next' => '4'
1379 ),
1380 '4' => array(
1381 'method' => 'fourth_step',
1382 'next' => ''
1383 ),
1384 '5' => array(
1385 'method' => 'progress_step',
1386 'next' => ''
1387 ),
1388 '6' => array(
1389 'method' => 'remove_watermark_step',
1390 'next' => '7'
1391 ),
1392 '7' => array(
1393 'method' => 'envato_elements_step',
1394 'next' => '3'
1395 ),
1396 '8' => array(
1397 'method' => 'get_user_email_step',
1398 'next' => '9'
1399 ),
1400 '9' => array(
1401 'method' => 'verify_envato_elements_step',
1402 'next' => '10'
1403 ),
1404 '10' => array(
1405 'method' => 'envato_elements_success_step',
1406 'next' => '3'
1407 )
1408
1409 );
1410
1411 if ( ! wp_verify_nonce( $nonce, 'aux-step-manager' ) ) {
1412 // This nonce is not valid.
1413 wp_send_json_error( esc_html__( 'An error occurred!', 'auxin-elements' ) );
1414 } elseif( ! $next_step || $steps[$next_step]['method'] == '' ){
1415 wp_send_json_error( esc_html__( 'Method not exist!', 'auxin-elements' ) );
1416 }
1417
1418 wp_send_json_success(
1419 array(
1420 'markup' => call_user_func( array( $this, $steps[$next_step]['method'] ), $args, $steps[$next_step]['next'] )
1421 )
1422 );
1423 }
1424
1425 public function first_step( array $args, $next_step ) {
1426 ob_start();
1427 ?>
1428 <div class="aux-setup-demo-content aux-content-col">
1429 <h2><?php esc_html_e( 'Required Plugins for this demo.', 'auxin-elements' ); ?></h2>
1430 <p class="aux-step-description">
1431 <?php esc_html_e( "For better and faster install process it's recommended to install demo on a clean WordPress website.", 'auxin-elements' ); ?>
1432 </p>
1433 </div>
1434 <div class="aux-setup-demo-actions">
1435 <div class="aux-return-back">
1436 <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' ); ?>">
1437 <?php _e( 'Continue', 'auxin-elements' ); ?>
1438 </a>
1439 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1440 <?php _e( 'Cancel', 'auxin-elements' ); ?>
1441 </a>
1442 </div>
1443 </div>
1444 <?php
1445 return ob_get_clean();
1446 }
1447
1448 public function second_step( array $args, $next_step ) {
1449
1450 // Goto next step, if no required plugins found
1451 if( ! isset( $args['plugins'] ) ) {
1452 return call_user_func( array( $this, 'remove_watermark_step' ), $args, '7' );
1453 }
1454
1455 $plugins_list = json_decode( stripslashes( $args['plugins'] ), true );
1456
1457 $plugins = $this->get_plugins( $plugins_list );
1458 $has_plugin_required = ! empty( $plugins_list ) && ! empty( $plugins['all'] );
1459
1460 if( $has_plugin_required ) :
1461 $next_step = Auxels_Envato_Elements::get_instance()->is_envato_element_enabled() ? '4' : $next_step;
1462 ob_start();
1463 ?>
1464 <div class="aux-setup-demo-content aux-content-col aux-install-plugins">
1465 <h2><?php esc_html_e( 'Required Plugins for this demo.', 'auxin-elements' ); ?></h2>
1466 <p class="aux-step-description"><?php esc_html_e( 'The following plugins are required to be installed for this demo.', 'auxin-elements' ); ?></p>
1467 <ul class="aux-wizard-plugins">
1468 <?php
1469 foreach ( $plugins['all'] as $slug => $plugin ) { ?>
1470 <li class="aux-plugin" data-slug="<?php echo esc_attr( $slug ); ?>">
1471 <label class="aux-control aux-checkbox">
1472 <?php echo esc_html( $plugin['name'] ); ?>
1473 <input name="plugin[]" value="<?php echo esc_attr($slug); ?>" type="checkbox" checked>
1474 <div class="aux-indicator"></div>
1475 </label>
1476 <div class="status column-status">
1477 <?php
1478 $keys = $class = '';
1479 if ( isset( $plugins['install'][ $slug ] ) ) {
1480 $keys = esc_html__( 'Ready to install', 'auxin-elements' );
1481 $class = 'install';
1482 }
1483 if ( isset( $plugins['activate'][ $slug ] ) ) {
1484 $keys = esc_html__( 'Not activated', 'auxin-elements' );
1485 $class = 'activate';
1486 }
1487 if ( isset( $plugins['update'][ $slug ] ) ) {
1488 $keys = esc_html__( 'Ready to update', 'auxin-elements' );
1489 $class = 'update';
1490 }
1491 ?>
1492 <span class="<?php echo $class ?>">
1493 <?php echo $keys; ?>
1494 </span>
1495 <div class="spinner"></div>
1496 </div>
1497 </li>
1498 <?php
1499 }
1500 ?>
1501 </ul>
1502 </div>
1503 <div class="aux-setup-demo-actions">
1504 <div class="aux-return-back">
1505 <a href="#"
1506 class="aux-button aux-medium install-plugins aux-primary"
1507 data-callback="install_plugins"
1508 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1509 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1510 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1511 data-next-action="<?php echo isset( $args['next_action'] ) ? $args['next_action'] : false; ?>"
1512 ><?php esc_html_e( 'Install Plugins', 'auxin-elements' ); ?></a>
1513 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1514 <?php _e( 'Cancel', 'auxin-elements' ); ?>
1515 </a>
1516 </div>
1517 </div>
1518 <?php
1519 return ob_get_clean();
1520 else :
1521 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' ) ;
1522 return ;
1523 endif;
1524 }
1525
1526 public function third_step( array $args, $next_step ) {
1527 ob_start();
1528 ?>
1529 <div class="aux-setup-demo-content aux-content-col aux-install-demos">
1530 <h2><?php esc_html_e( 'Import Demo Content of Phlox Theme.' ); ?></h2>
1531
1532 <form id="aux-import-data-<?php echo esc_attr( $args['id'] ); ?>" class="aux-import-parts">
1533 <div class="complete aux-border is-checked">
1534 <label class="aux-control aux-radio">
1535 <?php esc_html_e( 'Complete pre-build Website', 'auxin-elements' ); ?>
1536 <input type="radio" name="import" value="complete" checked="checked" />
1537 <div class="aux-indicator"></div>
1538 </label>
1539 <label class="aux-control aux-checkbox">
1540 <?php esc_html_e( 'Import media (images, videos, etc.)', 'auxin-elements' ); ?>
1541 <input type="checkbox" name="import-media" checked="checked" />
1542 <div class="aux-indicator"></div>
1543 </label>
1544 </div>
1545 <div class="custom aux-border">
1546 <label class="aux-control aux-radio">
1547 <?php esc_html_e( 'Selected Data Only', 'auxin-elements' ); ?>
1548 <input type="radio" name="import" value="custom" />
1549 <div class="aux-indicator"></div>
1550 </label>
1551 <div class="one_half no-gutter">
1552 <label class="aux-control aux-checkbox">
1553 <?php esc_html_e( 'Posts/Pages', 'auxin-elements' ); ?>
1554 <input type="checkbox" name="posts" />
1555 <div class="aux-indicator"></div>
1556 </label>
1557 <label class="aux-control aux-checkbox">
1558 <?php esc_html_e( 'Media', 'auxin-elements' ); ?>
1559 <input type="checkbox" name="media" />
1560 <div class="aux-indicator"></div>
1561 </label>
1562 <label class="aux-control aux-checkbox">
1563 <?php esc_html_e( 'Widgets', 'auxin-elements' ); ?>
1564 <input type="checkbox" name="widgets" />
1565 <div class="aux-indicator"></div>
1566 </label>
1567 </div>
1568 <div class="one_half no-gutter right-half">
1569 <label class="aux-control aux-checkbox">
1570 <?php esc_html_e( 'Menus', 'auxin-elements' ); ?>
1571 <input type="checkbox" name="menus" />
1572 <div class="aux-indicator"></div>
1573 </label>
1574 <label class="aux-control aux-checkbox">
1575 <?php esc_html_e( 'Theme Options', 'auxin-elements' ); ?>
1576 <input type="checkbox" name="options" />
1577 <div class="aux-indicator"></div>
1578 </label>
1579 <label class="aux-control aux-checkbox">
1580 <?php esc_html_e( 'MasterSlider (If Available)', 'auxin-elements' ); ?>
1581 <input type="checkbox" name="masterslider" />
1582 <div class="aux-indicator"></div>
1583 </label>
1584 </div>
1585 </div>
1586 </form>
1587 </div>
1588 <div class="aux-setup-demo-content aux-content-col aux-install-demos-waiting hide">
1589 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/importing-cloud.svg' ); ?>" />
1590 <h2><?php esc_html_e( 'Importing Demo Content is in Progress...' ); ?></h2>
1591 <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>
1592 </div>
1593 <div class="aux-setup-demo-actions">
1594 <div class="aux-return-back">
1595 <a href="#"
1596 class="aux-button aux-install-demo aux-medium aux-primary button-next"
1597 data-nonce="<?php echo wp_create_nonce( 'aux-import-demo-' . $args['id'] ); ?>"
1598 data-import-id="<?php echo esc_attr( $args['id'] ); ?>"
1599 data-callback="install_demos"
1600 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1601 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1602 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1603 ><?php esc_html_e( 'Import Content', 'auxin-elements' ); ?></a>
1604 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1605 <?php _e( 'Cancel', 'auxin-elements' ); ?>
1606 </a>
1607 </div>
1608 <div class="aux-progress hide">
1609 <div class="aux-big">
1610 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;">
1611 <span class="aux-progress-label"><?php esc_html_e( 'Please wait, this may take several minutes ..', 'auxin-elements' ); ?></span>
1612 </div>
1613 </div>
1614 </div>
1615 </div>
1616 <?php
1617 return ob_get_clean();
1618 }
1619
1620 public function fourth_step( array $args, $next_step ) {
1621 ob_start();
1622 ?>
1623 <div class="aux-setup-demo-content aux-content-col aux-step-import-completed">
1624 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/completed.svg' ); ?>" />
1625 <div><h2 class="aux-step-import-title"><?php esc_html_e( 'Congratulations!' ); ?></h2></div>
1626 <p class="aux-step-description"><?php esc_html_e( "Demo has been successfully imported.", 'auxin-elements' ); ?></p>
1627 </div>
1628 <div class="aux-setup-demo-actions">
1629 <div class="aux-return-back">
1630 <a href="<?php echo self_admin_url('customize.php'); ?>" class="aux-button aux-primary aux-medium" target="_blank">
1631 <?php _e( 'Customize', 'auxin-elements' ); ?>
1632 </a>
1633 <a href="<?php echo home_url(); ?>" class="aux-button aux-round aux-green aux-medium" target="_blank">
1634 <?php _e( 'Preview', 'auxin-elements' ); ?>
1635 </a>
1636 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1637 <?php _e( 'Close', 'auxin-elements' ); ?>
1638 </a>
1639 </div>
1640 </div>
1641 <?php
1642 return ob_get_clean();
1643 }
1644
1645 public function progress_step( array $args, $next_step ) {
1646 ob_start();
1647 ?>
1648 <h3 class="aux-loading-title"><?php esc_html_e( 'Importing page content ...', 'auxin-elements' ); ?></h3>
1649 <div class="aux-progress">
1650 <div class="aux-big">
1651 <div class="aux-progress-bar aux-progress-info aux-progress-active" data-percent="100" style="transition: none; width: 100%;"></div>
1652 </div>
1653 </div>
1654 <?php
1655 return ob_get_clean();
1656 }
1657
1658 public function remove_watermark_step( array $args, $next_step ) {
1659 ob_start();
1660 ?>
1661 <div class="aux-setup-demo-content aux-content-col aux-step-remove-watermark">
1662 <div class="aux-watermark">
1663 <div class="locked">
1664 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/watermark-2.png' ); ?>" />
1665 <img class="lock-icon" src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/lock-icon.svg' ); ?>" />
1666 </div>
1667 <div class="unlocked">
1668 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/watermark.png' ); ?>" />
1669 <img class="check-icon" src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/check.svg' ); ?>" />
1670 </div>
1671 </div>
1672 <h2 class="aux-step-import-title"><?php esc_html_e( 'Remove Watermarks?', 'auxin-elements' ); ?></h2>
1673 <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>
1674 <?php
1675 $skip_watermark_step = '3';
1676 ?>
1677 </div>
1678 <div class="aux-setup-demo-actions">
1679 <div class="aux-return-back">
1680 <a href="#"
1681 class="aux-button aux-medium aux-primary aux-next-step"
1682 data-callback="envato_elements_step"
1683 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1684 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1685 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1686 data-next-action="<?php echo isset( $args['next_action'] ) ? $args['next_action'] : false; ?>"
1687 ><?php esc_html_e( 'Remove Watermarks', 'auxin-elements' ); ?></a>
1688 <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' ); ?>">
1689 <?php _e( 'Skip', 'auxin-elements' ); ?>
1690 </a>
1691 </div>
1692 </div>
1693 <?php
1694 return ob_get_clean();
1695 }
1696
1697 public function envato_elements_step( array $args, $next_step ) {
1698 ob_start();
1699 ?>
1700 <div class="aux-setup-demo-content aux-content-col aux-step-envato-elements">
1701 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/envato_elements.svg' ); ?>" />
1702 <h2 class="aux-step-import-title"><?php esc_html_e( 'Remove watermarks by authorizing your Envato Elements subscription', 'auxin-elements' ); ?></h2>
1703 <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>
1704 <a href="http://avt.li/elements" class="aux-button aux-primary aux-medium aux-explore-envato" target="_blank">
1705 <?php _e( 'Explore and Subscribe', 'auxin-elements' ); ?>
1706 </a>
1707 <?php
1708 $activate_step = '8';
1709 if ( ! empty( get_option( 'phlox_envato_elements_license_code', '' ) ) ) {
1710 $activate_step = '9';
1711 }
1712 ?>
1713 <p><?php esc_html_e( 'Already an Envato Elements member?', 'auxin-elements' ); ?> <a href="#" class="aux-next-step" data-next-step="<?php echo esc_attr( $activate_step ); ?>" 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>
1714 </div>
1715 <div class="aux-setup-demo-actions">
1716 <div class="aux-return-back">
1717 <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' ); ?>">
1718 <?php _e( 'Skip', 'auxin-elements' ); ?>
1719 </a>
1720 </div>
1721 </div>
1722 <?php
1723 return ob_get_clean();
1724 }
1725
1726 public function get_user_email_step( array $args, $next_step) {
1727 ob_start();
1728 ?>
1729 <div class="aux-setup-demo-content aux-content-col aux-step-envato-elements aux-step-verify-envato-elements">
1730 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/activation.svg' ); ?>" />
1731 <h2 class="aux-step-import-title"><?php esc_html_e( 'Verify Your Envato Elements Subscription', 'auxin-elements' ); ?></h2>
1732 <p class="aux-step-description"><?php esc_html_e( "Enter your email below and click continue button", 'auxin-elements' ); ?></p>
1733 <div class="token-wrapper">
1734 <input type="text" class="email-field" placeholder="<?php esc_attr_e( 'Enter your email', 'auxin-elements' ); ?>">
1735 <p class="result"></p>
1736 </div>
1737 </div>
1738 <div class="aux-setup-demo-actions">
1739 <div class="aux-return-back">
1740 <a href="#"
1741 class="aux-button aux-medium aux-primary aux-verify-elements-email"
1742 data-callback="get_license_code"
1743 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1744 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1745 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1746 ><?php esc_html_e( 'Continue', 'auxin-elements' ); ?></a>
1747 <a href="#" class="aux-button aux-outline aux-round aux-transparent aux-medium aux-pp-close">
1748 <?php _e( 'Cancel', 'auxin-elements' ); ?>
1749 </a>
1750 </div>
1751 </div>
1752 <?php
1753 return ob_get_clean();
1754 }
1755
1756 public function verify_envato_elements_step( array $args, $next_step) {
1757 ob_start();
1758 ?>
1759 <div class="aux-setup-demo-content aux-content-col aux-step-envato-elements aux-step-verify-envato-elements">
1760 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/activation.svg' ); ?>" />
1761 <h2 class="aux-step-import-title"><?php esc_html_e( 'Verify Your Envato Elements Subscription', 'auxin-elements' ); ?></h2>
1762 <p class="aux-step-description"><?php esc_html_e( "Enter your token below to verify your Subscription", 'auxin-elements' ); ?></p>
1763 <div class="token-wrapper">
1764 <input type="text" class="token-field" placeholder="<?php esc_attr_e( 'Enter token here', 'auxin-elements' ); ?>">
1765 <p class="result"></p>
1766 </div>
1767 <div class="aux-info-links">
1768 <?php
1769 $token_link = '#';
1770 $extension_id = get_option( 'phlox_envato_elements_license_code', '' );
1771 if ( ! empty( $extension_id ) ) {
1772 $extension_description = get_bloginfo( 'name' ) . ' (' . get_home_url() . ')';
1773 $token_link = 'https://api.extensions.envato.com/extensions/begin_activation?extension_id=' . $extension_id . '&extension_type=envato-wordpress&extension_description=' . $this->encode_url_parameter( $extension_description ) . '&utm_content=settings&irgwc=1&clickid=1bPRxZzJ-xyOR7DwUx0Mo3EUUkiwuR1BCVsiXk0&iradid=298927&utm_campaign=elements_af_1264782&iradtype=ONLINE_TRACKING_LINK&irmptype=mediapartner&utm_medium=affiliate&utm_source=impact_radius&mp=averta';
1774 }
1775 ?>
1776 <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>
1777 <a href="http://avt.li/elements" target="_blank" class="aux-subscription" ><?php esc_html_e( 'Don\'t have subscription?', 'auxin-elements' );?></a>
1778 </div>
1779 </div>
1780 <div class="aux-setup-demo-actions">
1781 <div class="aux-return-back">
1782 <a href="#"
1783 class="aux-button aux-medium aux-primary button-next aux-verify-elements-token"
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( 'Verify Token', 'auxin-elements' ); ?></a>
1788 <a href="#"
1789 class="aux-button aux-outline aux-round aux-transparent aux-medium aux-next-step aux-skip"
1790 data-next-step="3"
1791 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1792 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' );?>">
1793 <?php _e( 'Skip', 'auxin-elements' ); ?>
1794 </a>
1795 </div>
1796 </div>
1797 <?php
1798 return ob_get_clean();
1799 }
1800
1801 public function envato_elements_success_step( array $args, $next_step) {
1802 ob_start();
1803 ?>
1804 <div class="aux-setup-demo-content aux-content-col aux-step-envato-elements-success aux-step-import-notice">
1805 <img src="<?php echo esc_url( AUXELS_ADMIN_URL . '/assets/images/welcome/completed.svg' ); ?>" />
1806 <h2 class="aux-step-import-title"><?php esc_html_e( 'Succeed', 'auxin-elements' ); ?></h2>
1807 <p class="aux-step-description"><?php esc_html_e( "Congratulations! you have successfully authorized your Envato Elements subscription.", 'auxin-elements' ); ?></p>
1808 </div>
1809 <div class="aux-setup-demo-actions">
1810 <div class="aux-return-back">
1811 <a href="#"
1812 class="aux-button aux-medium aux-primary button-next aux-next-step"
1813 data-next-step="<?php echo esc_attr( $next_step ); ?>"
1814 data-args="<?php echo htmlspecialchars( wp_json_encode($args), ENT_QUOTES, 'UTF-8' ); ?>"
1815 data-step-nonce="<?php echo wp_create_nonce( 'aux-step-manager' ); ?>"
1816 ><?php esc_html_e( 'Continue', 'auxin-elements' ); ?></a>
1817 </div>
1818 </div>
1819 <?php
1820 return ob_get_clean();
1821 }
1822
1823 private function encode_url_parameter( $parameter ) {
1824 $parameter = html_entity_decode( $parameter, ENT_QUOTES | ENT_XML1, 'UTF-8' );
1825 $parameter = str_replace( '#', '', $parameter );
1826
1827 return urlencode( $parameter );
1828 }
1829 }
1830