Advanced Import : One Click Import for WordPress or Theme Demo Data - Version 1.0.8

Version Description

  • 2020-02-19 =
  • Fixed : Secure reset function
Download this release

Release Info

Developer addonspress
Plugin Icon 128x128 Advanced Import : One Click Import for WordPress or Theme Demo Data
Version 1.0.8
Comparing to
See all releases

Code changes from version 1.0.7 to 1.0.8

admin/class-advanced-import-admin.php CHANGED
@@ -76,6 +76,14 @@ class Advanced_Import_Admin {
76
  */
77
  protected $demo_lists = array();
78
 
 
 
 
 
 
 
 
 
79
 
80
  /**
81
  * Array of delayed post for late process
@@ -145,8 +153,6 @@ class Advanced_Import_Admin {
145
  * Initialize the class and set its properties.
146
  *
147
  * @since 1.0.0
148
- * @param string $plugin_name The name of this plugin.
149
- * @param string $version The version of this plugin.
150
  * @return object $instance Advanced_Import_Admin Instance
151
  */
152
  public static function instance() {
@@ -169,6 +175,64 @@ class Advanced_Import_Admin {
169
  return $instance;
170
  }
171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  /**
173
  * Register the stylesheets for the admin area.
174
  *
@@ -670,8 +734,6 @@ class Advanced_Import_Admin {
670
  continue;
671
  }
672
 
673
- $plugins = isset( $demo_list['plugins'] ) && is_array( $demo_list['plugins'] )?' data-plugins="'.esc_attr(json_encode($demo_list['plugins'])).'"':'';
674
-
675
  $template_url = $demo_list['template_url'];
676
  if( is_array( $template_url )){
677
  $data_template = 'data-template_url="'.esc_attr(json_encode($template_url)).'"';
@@ -687,19 +749,25 @@ class Advanced_Import_Admin {
687
  }
688
  }
689
  ?>
690
- <div aria-label="<?php echo esc_attr( $demo_list['title'])?>" class="<?php echo isset( $demo_list['categories'] )?esc_attr(implode(" ",$demo_list['categories'])):'';?> ai-item <?php echo isset( $demo_list['type'] )?esc_attr($demo_list['type']):'';?>" <?php echo $data_template.' '.$data_template_type;?>>
 
 
 
 
 
 
691
  <?php
692
  wp_nonce_field( 'advanced-import' );
693
  ?>
694
  <div class="ai-item-preview">
695
  <div class="ai-item-screenshot">
696
  <img src="<?php echo esc_url( $demo_list['screenshot_url'])?>">
697
-
698
  </div>
699
  <h4 class="ai-author-info"><?php esc_html_e( 'Author: ', 'advanced-import' ) ?><?php echo esc_html( isset($demo_list['author'])?$demo_list['author']:wp_get_theme()->get( 'Author' ))?></h4>
700
  <div class="ai-details"><?php esc_html_e( 'Details', 'advanced-import' ) ?></div>
701
- <?php
702
- if( isset( $demo_list['is_premium'] ) && $demo_list['is_premium'] ){
703
  ?>
704
  <span class="ai-premium-label"><?php esc_html_e( 'Premium', 'advanced-import' ) ?></span>
705
  <?php
@@ -713,9 +781,9 @@ class Advanced_Import_Admin {
713
  <a class="button ai-item-demo-link" href="<?php echo esc_url( $demo_list['demo_url'])?>" target="_blank">
714
  <span class="dashicons dashicons-visibility"></span><?php esc_html_e( 'Preview', 'advanced-import' );?>
715
  </a>
716
- <a class="button ai-demo-import ai-item-import is-button is-default is-primary is-large button-primary" href="#" aria-label="<?php esc_attr_e( 'Import', 'advanced-import' )?>" <?php echo $plugins;?>>
717
- <span class="dashicons dashicons-download"></span><?php esc_html_e( 'Import', 'advanced-import' );?>
718
- </a>
719
  </div>
720
  <?php
721
  $keywords = isset( $demo_list['keywords'] )? $demo_list['keywords']:array();
@@ -789,6 +857,7 @@ class Advanced_Import_Admin {
789
  $total_demo = 0;
790
  if( $pagenow != 'tools.php' ){
791
  $this->demo_lists = apply_filters( 'advanced_import_demo_lists',array() );
 
792
  $demo_lists = $this->demo_lists;
793
 
794
  $total_demo = count( $demo_lists );
@@ -2245,6 +2314,11 @@ class Advanced_Import_Admin {
2245
  )
2246
  );
2247
 
 
 
 
 
 
2248
  $screen->add_help_tab(
2249
  array(
2250
  'id' => 'ai_help_tab_reset',
@@ -2252,7 +2326,7 @@ class Advanced_Import_Admin {
2252
  'content' =>
2253
  '<h2>'.__( '<strong>WordPress Reset</strong>', 'advanced-import' ).'</h2>'.
2254
  '<p>'.__( 'If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ).'</p>'.
2255
- '<p class="submit"><a href="'.esc_url( add_query_arg( 'ai_reset_wordpress', true, $current_url ) ).'" class="button button-primary ai-wp-reset">'. __( 'Run the Reset Wizard', 'advanced-import' ).'</a></p>' )
2256
  );
2257
 
2258
  $screen->set_help_sidebar(
76
  */
77
  protected $demo_lists = array();
78
 
79
+ /**
80
+ * Demo lists
81
+ *
82
+ * @since 1.0.0
83
+ * @access public
84
+ * @var array $demo_lists Array of demo lists.
85
+ */
86
+ protected $is_pro_active = false;
87
 
88
  /**
89
  * Array of delayed post for late process
153
  * Initialize the class and set its properties.
154
  *
155
  * @since 1.0.0
 
 
156
  * @return object $instance Advanced_Import_Admin Instance
157
  */
158
  public static function instance() {
175
  return $instance;
176
  }
177
 
178
+ /**
179
+ * Check if template is available to import
180
+ *
181
+ * @since 1.0.8
182
+ * @param array $item current array of demo list
183
+ * @return boolean
184
+ */
185
+ public function is_template_available( $item ){
186
+ $is_available = false;
187
+ if( !isset($item['is_pro'] ) ){
188
+ $is_available = true;
189
+ }
190
+ elseif( isset($item['is_pro'] ) && !$this->is_pro_active ){
191
+ $is_available = false;
192
+ }
193
+ elseif( isset($item['is_pro'] ) && $this->is_pro_active ){
194
+ $is_available = true;
195
+ }
196
+ return (boolean) apply_filters( 'advanced_import_is_template_available', $is_available );
197
+ }
198
+
199
+ /**
200
+ * Return Template Button
201
+ *
202
+ * @since 1.0.8
203
+ * @param array $item current array of demo list
204
+ * @return string
205
+ */
206
+ public function template_button( $item ){
207
+ /*Start buffering*/
208
+ ob_start();
209
+
210
+ if( $this->is_template_available($item)){
211
+ $plugins = isset( $item['plugins'] ) && is_array( $item['plugins'] )?' data-plugins="'.esc_attr(json_encode($item['plugins'])).'"':'';
212
+ ?>
213
+ <a class="button ai-demo-import ai-item-import is-button is-default is-primary is-large button-primary" href="#" aria-label="<?php esc_attr_e( 'Import', 'advanced-import' )?>" <?php echo $plugins;?>>
214
+ <span class="dashicons dashicons-download"></span><?php esc_html_e( 'Import', 'advanced-import' );?>
215
+ </a>
216
+ <?php
217
+ }
218
+ else{
219
+ ?>
220
+ <a class="button is-button is-default is-primary is-large button-primary"
221
+ href="<?php echo esc_url( isset($item['pro_url'])?$item['pro_url']:'#' );?>"
222
+ target="_blank"
223
+ aria-label="<?php esc_attr_e( 'View Pro', 'advanced-import' )?>">
224
+ <span class="dashicons dashicons-awards"></span><?php esc_html_e( 'View Pro', 'advanced-import' );?>
225
+ </a>
226
+ <?php
227
+ }
228
+ /*removes the buffer (without printing it), and returns its content.*/
229
+ $render_button = ob_get_clean();
230
+
231
+ $render_button = apply_filters( 'advanced_import_template_import_button', $render_button );
232
+ return $render_button;
233
+
234
+ }
235
+
236
  /**
237
  * Register the stylesheets for the admin area.
238
  *
734
  continue;
735
  }
736
 
 
 
737
  $template_url = $demo_list['template_url'];
738
  if( is_array( $template_url )){
739
  $data_template = 'data-template_url="'.esc_attr(json_encode($template_url)).'"';
749
  }
750
  }
751
  ?>
752
+ <div aria-label="<?php echo esc_attr( $demo_list['title'])?>"
753
+ class="<?php
754
+ echo isset( $demo_list['categories'] )?esc_attr(implode(" ",$demo_list['categories'])):'';?>
755
+ ai-item <?php echo isset( $demo_list['type'] )?esc_attr($demo_list['type']):'';?>"
756
+ <?php echo $data_template.' '.$data_template_type;?>
757
+ <?php echo $this->is_template_available($demo_list)?'':'ai-pro-item'?>
758
+ >
759
  <?php
760
  wp_nonce_field( 'advanced-import' );
761
  ?>
762
  <div class="ai-item-preview">
763
  <div class="ai-item-screenshot">
764
  <img src="<?php echo esc_url( $demo_list['screenshot_url'])?>">
765
+
766
  </div>
767
  <h4 class="ai-author-info"><?php esc_html_e( 'Author: ', 'advanced-import' ) ?><?php echo esc_html( isset($demo_list['author'])?$demo_list['author']:wp_get_theme()->get( 'Author' ))?></h4>
768
  <div class="ai-details"><?php esc_html_e( 'Details', 'advanced-import' ) ?></div>
769
+ <?php
770
+ if( isset( $demo_list['is_pro'] ) && $demo_list['is_pro'] ){
771
  ?>
772
  <span class="ai-premium-label"><?php esc_html_e( 'Premium', 'advanced-import' ) ?></span>
773
  <?php
781
  <a class="button ai-item-demo-link" href="<?php echo esc_url( $demo_list['demo_url'])?>" target="_blank">
782
  <span class="dashicons dashicons-visibility"></span><?php esc_html_e( 'Preview', 'advanced-import' );?>
783
  </a>
784
+ <?php
785
+ echo $this->template_button( $demo_list );
786
+ ?>
787
  </div>
788
  <?php
789
  $keywords = isset( $demo_list['keywords'] )? $demo_list['keywords']:array();
857
  $total_demo = 0;
858
  if( $pagenow != 'tools.php' ){
859
  $this->demo_lists = apply_filters( 'advanced_import_demo_lists',array() );
860
+ $this->is_pro_active = apply_filters( 'advanced_import_is_pro_active', $this->is_pro_active);
861
  $demo_lists = $this->demo_lists;
862
 
863
  $total_demo = count( $demo_lists );
2314
  )
2315
  );
2316
 
2317
+ $reset_url = wp_nonce_url(
2318
+ add_query_arg( 'ai_reset_wordpress', 'true', $current_url ),
2319
+ 'ai_reset_wordpress',
2320
+ 'ai_reset_wordpress_nonce'
2321
+ );
2322
  $screen->add_help_tab(
2323
  array(
2324
  'id' => 'ai_help_tab_reset',
2326
  'content' =>
2327
  '<h2>'.__( '<strong>WordPress Reset</strong>', 'advanced-import' ).'</h2>'.
2328
  '<p>'.__( 'If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ).'</p>'.
2329
+ '<p class="submit"><a href="'.esc_url( $reset_url ).'" class="button button-primary ai-wp-reset">'. __( 'Run the Reset Wizard', 'advanced-import' ).'</a></p>' )
2330
  );
2331
 
2332
  $screen->set_help_sidebar(
admin/class-reset.php CHANGED
@@ -75,7 +75,13 @@ class Advanced_Import_Reset_WordPress {
75
  public function reset_wizard_actions() {
76
  global $wpdb, $current_user;
77
 
78
- if ( ! empty( $_GET['ai_reset_wordpress'] ) ) {
 
 
 
 
 
 
79
  require_once ABSPATH . '/wp-admin/includes/upgrade.php';
80
 
81
  $template = get_option( 'template' );
@@ -154,6 +160,11 @@ class Advanced_Import_Reset_WordPress {
154
  return;
155
  }
156
  $current_url = advanced_import_current_url();
 
 
 
 
 
157
 
158
  $demo_notice_dismiss = get_option( 'advanced_import_reset_notice' );
159
 
@@ -162,7 +173,7 @@ class Advanced_Import_Reset_WordPress {
162
  ?>
163
  <div id="message" class="updated ai-import-message">
164
  <p><?php _e( '<strong>WordPress Reset</strong> &#8211; If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ); ?></p>
165
- <p class="submit"><a href="<?php echo esc_url( add_query_arg( 'ai_reset_wordpress', 'true', $current_url ) ); ?>" class="button button-primary ai-wp-reset"><?php esc_html_e( 'Run the Reset Wizard', 'advanced-import' ); ?></a> <a class="button-secondary skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'advanced-import-hide-notice', 'reset_notice', $current_url ), 'advanced_import_hide_notice_nonce', '_advanced_import_notice_nonce' ) ); ?>"><?php esc_attr_e( 'Hide this notice', 'advanced-import' ); ?></a></p>
166
  </div>
167
  <?php
168
  } elseif ( isset( $_GET['reset'] ) && 'true' === $_GET['reset'] ) {
75
  public function reset_wizard_actions() {
76
  global $wpdb, $current_user;
77
 
78
+ if ( ! empty( $_GET['ai_reset_wordpress'] ) && !empty($_GET['ai_reset_wordpress_nonce'] )) {
79
+ if ( ! wp_verify_nonce( wp_unslash( $_GET['ai_reset_wordpress_nonce'] ), 'ai_reset_wordpress' ) ) { // WPCS: input var ok, sanitization ok.
80
+ wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'advanced-import' ) );
81
+ }
82
+ if ( ! current_user_can( 'manage_options' ) ) {
83
+ wp_die( esc_html__( 'No permission to reset WordPress', 'advanced-import' ) );
84
+ }
85
  require_once ABSPATH . '/wp-admin/includes/upgrade.php';
86
 
87
  $template = get_option( 'template' );
160
  return;
161
  }
162
  $current_url = advanced_import_current_url();
163
+ $reset_url = wp_nonce_url(
164
+ add_query_arg( 'ai_reset_wordpress', 'true', $current_url ),
165
+ 'ai_reset_wordpress',
166
+ 'ai_reset_wordpress_nonce'
167
+ );
168
 
169
  $demo_notice_dismiss = get_option( 'advanced_import_reset_notice' );
170
 
173
  ?>
174
  <div id="message" class="updated ai-import-message">
175
  <p><?php _e( '<strong>WordPress Reset</strong> &#8211; If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ); ?></p>
176
+ <p class="submit"><a href="<?php echo esc_url( $reset_url ); ?>" class="button button-primary ai-wp-reset"><?php esc_html_e( 'Run the Reset Wizard', 'advanced-import' ); ?></a> <a class="button-secondary skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'advanced-import-hide-notice', 'reset_notice', $current_url ), 'advanced_import_hide_notice_nonce', '_advanced_import_notice_nonce' ) ); ?>"><?php esc_attr_e( 'Hide this notice', 'advanced-import' ); ?></a></p>
177
  </div>
178
  <?php
179
  } elseif ( isset( $_GET['reset'] ) && 'true' === $_GET['reset'] ) {
advanced-import.php CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'WPINC' ) ) {
14
  * Plugin Name: Advanced Import
15
  * Plugin URI: https://addonspress.com/item/advanced-import
16
  * Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area.
17
- * Version: 1.0.7
18
  * Author: AddonsPress
19
  * Author URI: https://addonspress.com/
20
  * License: GPL-2.0+
@@ -24,7 +24,7 @@ if ( ! defined( 'WPINC' ) ) {
24
  */
25
 
26
  /*Define Constants for this plugin*/
27
- define( 'ADVANCED_IMPORT_VERSION', '1.0.7' );
28
  define( 'ADVANCED_IMPORT_PLUGIN_NAME', 'advanced-import' );
29
  define( 'ADVANCED_IMPORT_PATH', plugin_dir_path( __FILE__ ) );
30
  define( 'ADVANCED_IMPORT_URL', plugin_dir_url( __FILE__ ) );
14
  * Plugin Name: Advanced Import
15
  * Plugin URI: https://addonspress.com/item/advanced-import
16
  * Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area.
17
+ * Version: 1.0.8
18
  * Author: AddonsPress
19
  * Author URI: https://addonspress.com/
20
  * License: GPL-2.0+
24
  */
25
 
26
  /*Define Constants for this plugin*/
27
+ define( 'ADVANCED_IMPORT_VERSION', '1.0.8' );
28
  define( 'ADVANCED_IMPORT_PLUGIN_NAME', 'advanced-import' );
29
  define( 'ADVANCED_IMPORT_PATH', plugin_dir_path( __FILE__ ) );
30
  define( 'ADVANCED_IMPORT_URL', plugin_dir_url( __FILE__ ) );
example.php CHANGED
@@ -3,7 +3,7 @@ function prefix_demo_import_lists(){
3
  $demo_lists = array(
4
  'demo1' =>array(
5
  'title' => __( 'Title', 'text-domain' ),/*Title*/
6
- 'is_premium' => true,/*Premium*/
7
  'type' => 'gutentor',/*Optional eg gutentor, elementor or other page builders*/
8
  'author' => __( 'Gutentor', 'gutentor' ),/*Author Name*/
9
  'keywords' => array( 'about-block', 'about 3' ),/*Search keyword*/
@@ -185,7 +185,8 @@ function prefix_demo_import_lists(){
185
  ),
186
  'demo9' =>array(
187
  'title' =>esc_html__('Demo 3', 'text-domain'),
188
- 'is_premium' => true,/*Premium*/
 
189
  'type' => 'gutentor',/*Optional eg gutentor, elementor or other page builders*/
190
  'categories' => array('education'),
191
  'template_url' => get_template_directory().'/index.php',
3
  $demo_lists = array(
4
  'demo1' =>array(
5
  'title' => __( 'Title', 'text-domain' ),/*Title*/
6
+ 'is_pro' => true,/*Premium*/
7
  'type' => 'gutentor',/*Optional eg gutentor, elementor or other page builders*/
8
  'author' => __( 'Gutentor', 'gutentor' ),/*Author Name*/
9
  'keywords' => array( 'about-block', 'about 3' ),/*Search keyword*/
185
  ),
186
  'demo9' =>array(
187
  'title' =>esc_html__('Demo 3', 'text-domain'),
188
+ 'is_pro' => true,/*Premium*/
189
+ 'pro_url' => 'https://www.cosmoswp.com/pricing/',/*Premium Url*/
190
  'type' => 'gutentor',/*Optional eg gutentor, elementor or other page builders*/
191
  'categories' => array('education'),
192
  'template_url' => get_template_directory().'/index.php',
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: import, advanced import, demo import, theme import, widget import, customi
6
  Requires at least: 4.5
7
  Tested up to: 5.3.2
8
  Requires PHP: 5.6.20
9
- Stable tag: 1.0.7
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -70,6 +70,9 @@ Please make sure it is exported using [Advanced Export](https://wordpress.org/pl
70
 
71
  == Changelog ==
72
 
 
 
 
73
  = 1.0.7 - 2020-01-05 =
74
  * Fixed : Script loading when SCRIPT_DEBUG on
75
 
@@ -96,4 +99,4 @@ Please make sure it is exported using [Advanced Export](https://wordpress.org/pl
96
  * Fixed : Minor Changes
97
 
98
  = 1.0.0 =
99
- * Initial release.
6
  Requires at least: 4.5
7
  Tested up to: 5.3.2
8
  Requires PHP: 5.6.20
9
+ Stable tag: 1.0.8
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
70
 
71
  == Changelog ==
72
 
73
+ = 1.0.8 - 2020-02-19 =
74
+ * Fixed : Secure reset function
75
+
76
  = 1.0.7 - 2020-01-05 =
77
  * Fixed : Script loading when SCRIPT_DEBUG on
78
 
99
  * Fixed : Minor Changes
100
 
101
  = 1.0.0 =
102
+ * Initial release.