ThemeGrill Demo Importer - Version 1.2.0

Version Description

  • Tweak - Load scripts perfecly on demo importer appearance page.
  • Tweak - Set transient for redirecting to demo importer page after install or update.
  • Tweak - Introduced filter hook themegrill_demo_importer_installer to control demo view.
Download this release

Release Info

Developer ThemeGrill
Plugin Icon 128x128 ThemeGrill Demo Importer
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.0 to 1.2.0

includes/class-demo-importer.php CHANGED
@@ -34,7 +34,7 @@ class TG_Demo_Importer {
34
  * Demo installer.
35
  * @var bool
36
  */
37
- public $demo_install = true;
38
 
39
  /**
40
  * Constructor.
@@ -47,6 +47,7 @@ class TG_Demo_Importer {
47
  if ( apply_filters( 'themegrill_show_demo_importer_page', true ) ) {
48
  add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
49
  add_action( 'admin_head', array( $this, 'add_menu_classes' ) );
 
50
  }
51
 
52
  // AJAX Events to import demo and dismiss notice.
@@ -66,8 +67,9 @@ class TG_Demo_Importer {
66
  * Demo importer setup.
67
  */
68
  public function setup() {
69
- $this->demo_config = apply_filters( 'themegrill_demo_importer_config', array() );
70
- $this->demo_packages = apply_filters( 'themegrill_demo_importer_packages', array() );
 
71
  }
72
 
73
  /**
@@ -134,8 +136,7 @@ class TG_Demo_Importer {
134
  * Add menu item.
135
  */
136
  public function add_admin_menu() {
137
- $page = add_theme_page( __( 'Demo Importer', 'themegrill-demo-importer' ), __( 'Demo Importer', 'themegrill-demo-importer' ), 'switch_themes', 'demo-importer', array( $this, 'demo_importer' ) );
138
- add_action( 'admin_print_styles-' . $page, array( $this, 'enqueue_styles' ) );
139
  }
140
 
141
  /**
@@ -145,7 +146,7 @@ class TG_Demo_Importer {
145
  global $submenu;
146
 
147
  if ( isset( $submenu['themes.php'] ) ) {
148
- $submenu_class = $this->demo_install ? 'demo-installer hide-if-no-js' : 'demo-importer';
149
 
150
  // Add menu classes if user has access.
151
  if ( apply_filters( 'themegrill_demo_importer_include_class_in_menu', true ) ) {
@@ -160,58 +161,64 @@ class TG_Demo_Importer {
160
  }
161
 
162
  /**
163
- * Enqueue styles.
164
  */
165
- public function enqueue_styles() {
 
 
166
  $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
167
- $assets_path = tg_get_demo_importer_assets_path();
168
 
169
- // Enqueue Styles
170
- wp_enqueue_style( 'tg-demo-importer', $assets_path . 'css/demo-importer.css', array() );
171
 
172
- // Register Scripts
173
  wp_register_script( 'jquery-tiptip', $assets_path . 'js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), '1.3', true );
174
  wp_register_script( 'tg-demo-updates', $assets_path . 'js/admin/demo-updates' . $suffix . '.js', array( 'jquery', 'updates' ), '1.1.0', true );
175
- wp_localize_script( 'tg-demo-updates', '_demoUpdatesSettings', array(
176
- 'l10n' => array(
177
- 'importing' => __( 'Importing...', 'themegrill-demo-importer' ),
178
- 'demoImportingLabel' => _x( 'Importing %s...', 'demo', 'themegrill-demo-importer' ), // no ellipsis
179
- 'importingMsg' => __( 'Importing... please wait.', 'themegrill-demo-importer' ),
180
- 'importedMsg' => __( 'Import completed successfully.', 'themegrill-demo-importer' ),
181
- 'importFailedShort' => __( 'Import Failed!', 'themegrill-demo-importer' ),
182
- 'importFailed' => __( 'Import failed: %s', 'themegrill-demo-importer' ),
183
- 'demoImportedLabel' => _x( '%s imported!', 'demo', 'themegrill-demo-importer' ),
184
- 'demoImportFailedLabel' => _x( '%s import failed', 'demo', 'themegrill-demo-importer' ),
185
- 'livePreview' => __( 'Live Preview', 'themegrill-demo-importer' ),
186
- 'livePreviewLabel' => _x( 'Live Preview %s', 'demo', 'themegrill-demo-importer' ),
187
- 'imported' => __( 'Imported!', 'themegrill-demo-importer' ),
188
- 'statusTextLink' => '<a href="https://docs.themegrill.com/knowledgebase/demo-import-process-failed/" target="_blank">' . __( 'Try this solution!', 'themegrill-demo-importer' ) . '</a>',
189
- )
190
- ) );
191
-
192
- // Enqueue Scripts
193
- wp_enqueue_script( 'tg-demo-importer', $assets_path . 'js/admin/demo-importer' . $suffix . '.js', array( 'jquery', 'jquery-tiptip', 'wp-backbone', 'wp-a11y', 'tg-demo-updates' ), '1.1.0', true );
194
- wp_localize_script( 'tg-demo-importer', 'demoImporterLocalizeScript', array(
195
- 'demos' => $this->is_preview() ? $this->prepare_previews_for_js( $this->demo_packages ) : $this->prepare_demos_for_js( $this->demo_config ),
196
- 'settings' => array(
197
- 'isPreview' => $this->is_preview(),
198
- 'isInstall' => $this->demo_install,
199
- 'canInstall' => current_user_can( 'upload_files' ),
200
- 'installURI' => current_user_can( 'upload_files' ) ? self_admin_url( 'themes.php?page=demo-importer&browse=preview' ) : null,
201
- 'confirmDelete' => __( "Are you sure you want to delete this demo?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete.", 'themegrill-demo-importer' ),
202
- 'confirmImport' => __( 'Importing demo content will replicate the live demo and overwrites your current customizer, widgets and other settings. It might take few minutes to complete the demo import. Are you sure you want to import this demo?', 'themegrill-demo-importer' ),
203
- 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
204
- 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ),
205
- ),
206
- 'l10n' => array(
207
- 'addNew' => __( 'Add New Demo', 'themegrill-demo-importer' ),
208
- 'search' => __( 'Search Demos', 'themegrill-demo-importer' ),
209
- 'searchPlaceholder' => __( 'Search demos...', 'themegrill-demo-importer' ), // placeholder (no ellipsis)
210
- 'demosFound' => __( 'Number of Demos found: %d', 'themegrill-demo-importer' ),
211
- 'noDemosFound' => __( 'No demos found. Try a different search.', 'themegrill-demo-importer' ),
212
- ),
213
- 'installedDemos' => array_keys( $this->demo_config ),
214
- ) );
 
 
 
 
215
  }
216
 
217
  /**
@@ -219,7 +226,7 @@ class TG_Demo_Importer {
219
  * @return bool
220
  */
221
  public function is_preview() {
222
- if ( $this->demo_install && isset( $_GET['browse'] ) ) {
223
  return 'preview' === $_GET['browse'] ? true : false;
224
  }
225
 
@@ -232,8 +239,8 @@ class TG_Demo_Importer {
232
  private function prepare_previews_for_js( $demos = null ) {
233
  $prepared_demos = array();
234
  $current_template = get_option( 'template' );
235
- $demo_assets_path = tg_get_demo_importer_assets_path();
236
  $demo_imported_id = get_option( 'themegrill_demo_imported_id' );
 
237
 
238
  /**
239
  * Filters demo data before it is prepared for JavaScript.
@@ -320,6 +327,7 @@ class TG_Demo_Importer {
320
  foreach ( $demos as $demo_id => $demo_data ) {
321
  $demo_notices = array();
322
  $encoded_slug = urlencode( $demo_id );
 
323
  $plugins_list = isset( $demo_data['plugins_list'] ) ? $demo_data['plugins_list'] : array();
324
 
325
  // Plugins status.
@@ -339,7 +347,7 @@ class TG_Demo_Importer {
339
  'id' => $demo_id,
340
  'name' => $demo_data['name'],
341
  'theme' => $demo_data['theme'],
342
- 'package' => $demo_data['demo_pack'],
343
  'screenshot' => $this->import_file_url( $demo_id, 'screenshot.jpg' ),
344
  'description' => isset( $demo_data['description'] ) ? $demo_data['description'] : '',
345
  'author' => isset( $demo_data['author'] ) ? $demo_data['author'] : __( 'ThemeGrill', 'themegrill-demo-importer' ),
@@ -378,7 +386,7 @@ class TG_Demo_Importer {
378
  if ( isset( $_GET['action'] ) && 'upload-demo' === $_GET['action'] ) {
379
  $this->upload_demo_pack();
380
  } else {
381
- $suffix = $this->demo_install ? 'installer' : 'importer';
382
  include_once( dirname( __FILE__ ) . "/includes/admin/views/html-admin-page-{$suffix}.php" );
383
  }
384
  }
34
  * Demo installer.
35
  * @var bool
36
  */
37
+ public $demo_installer = true;
38
 
39
  /**
40
  * Constructor.
47
  if ( apply_filters( 'themegrill_show_demo_importer_page', true ) ) {
48
  add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
49
  add_action( 'admin_head', array( $this, 'add_menu_classes' ) );
50
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
51
  }
52
 
53
  // AJAX Events to import demo and dismiss notice.
67
  * Demo importer setup.
68
  */
69
  public function setup() {
70
+ $this->demo_config = apply_filters( 'themegrill_demo_importer_config', array() );
71
+ $this->demo_packages = apply_filters( 'themegrill_demo_importer_packages', array() );
72
+ $this->demo_installer = apply_filters( 'themegrill_demo_importer_installer', true );
73
  }
74
 
75
  /**
136
  * Add menu item.
137
  */
138
  public function add_admin_menu() {
139
+ add_theme_page( __( 'Demo Importer', 'themegrill-demo-importer' ), __( 'Demo Importer', 'themegrill-demo-importer' ), 'switch_themes', 'demo-importer', array( $this, 'demo_importer' ) );
 
140
  }
141
 
142
  /**
146
  global $submenu;
147
 
148
  if ( isset( $submenu['themes.php'] ) ) {
149
+ $submenu_class = $this->demo_installer ? 'demo-installer hide-if-no-js' : 'demo-importer';
150
 
151
  // Add menu classes if user has access.
152
  if ( apply_filters( 'themegrill_demo_importer_include_class_in_menu', true ) ) {
161
  }
162
 
163
  /**
164
+ * Enqueue scripts.
165
  */
166
+ public function enqueue_scripts() {
167
+ $screen = get_current_screen();
168
+ $screen_id = $screen ? $screen->id : '';
169
  $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
170
+ $assets_path = ThemeGrill_Demo_Importer::plugin_url() . '/assets/';
171
 
172
+ // Register Styles.
173
+ wp_register_style( 'tg-demo-importer', $assets_path . 'css/demo-importer.css', array() );
174
 
175
+ // Register Scripts.
176
  wp_register_script( 'jquery-tiptip', $assets_path . 'js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), '1.3', true );
177
  wp_register_script( 'tg-demo-updates', $assets_path . 'js/admin/demo-updates' . $suffix . '.js', array( 'jquery', 'updates' ), '1.1.0', true );
178
+ wp_register_script( 'tg-demo-importer', $assets_path . 'js/admin/demo-importer' . $suffix . '.js', array( 'jquery', 'jquery-tiptip', 'wp-backbone', 'wp-a11y', 'tg-demo-updates' ), '1.1.0', true );
179
+
180
+ // Demo Importer appearance page.
181
+ if ( 'appearance_page_demo-importer' === $screen_id ) {
182
+ wp_enqueue_style( 'tg-demo-importer' );
183
+ wp_enqueue_script( 'tg-demo-importer' );
184
+ wp_localize_script( 'tg-demo-updates', '_demoUpdatesSettings', array(
185
+ 'l10n' => array(
186
+ 'importing' => __( 'Importing...', 'themegrill-demo-importer' ),
187
+ 'demoImportingLabel' => _x( 'Importing %s...', 'demo', 'themegrill-demo-importer' ), // no ellipsis
188
+ 'importingMsg' => __( 'Importing... please wait.', 'themegrill-demo-importer' ),
189
+ 'importedMsg' => __( 'Import completed successfully.', 'themegrill-demo-importer' ),
190
+ 'importFailedShort' => __( 'Import Failed!', 'themegrill-demo-importer' ),
191
+ 'importFailed' => __( 'Import failed: %s', 'themegrill-demo-importer' ),
192
+ 'demoImportedLabel' => _x( '%s imported!', 'demo', 'themegrill-demo-importer' ),
193
+ 'demoImportFailedLabel' => _x( '%s import failed', 'demo', 'themegrill-demo-importer' ),
194
+ 'livePreview' => __( 'Live Preview', 'themegrill-demo-importer' ),
195
+ 'livePreviewLabel' => _x( 'Live Preview %s', 'demo', 'themegrill-demo-importer' ),
196
+ 'imported' => __( 'Imported!', 'themegrill-demo-importer' ),
197
+ 'statusTextLink' => '<a href="https://docs.themegrill.com/knowledgebase/demo-import-process-failed/" target="_blank">' . __( 'Try this solution!', 'themegrill-demo-importer' ) . '</a>',
198
+ )
199
+ ) );
200
+ wp_localize_script( 'tg-demo-importer', 'demoImporterLocalizeScript', array(
201
+ 'demos' => $this->is_preview() ? $this->prepare_previews_for_js( $this->demo_packages ) : $this->prepare_demos_for_js( $this->demo_config ),
202
+ 'settings' => array(
203
+ 'isPreview' => $this->is_preview(),
204
+ 'isInstall' => $this->demo_installer,
205
+ 'canInstall' => current_user_can( 'upload_files' ),
206
+ 'installURI' => current_user_can( 'upload_files' ) ? self_admin_url( 'themes.php?page=demo-importer&browse=preview' ) : null,
207
+ 'confirmDelete' => __( "Are you sure you want to delete this demo?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete.", 'themegrill-demo-importer' ),
208
+ 'confirmImport' => __( 'Importing demo content will replicate the live demo and overwrites your current customizer, widgets and other settings. It might take few minutes to complete the demo import. Are you sure you want to import this demo?', 'themegrill-demo-importer' ),
209
+ 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
210
+ 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ),
211
+ ),
212
+ 'l10n' => array(
213
+ 'addNew' => __( 'Add New Demo', 'themegrill-demo-importer' ),
214
+ 'search' => __( 'Search Demos', 'themegrill-demo-importer' ),
215
+ 'searchPlaceholder' => __( 'Search demos...', 'themegrill-demo-importer' ), // placeholder (no ellipsis)
216
+ 'demosFound' => __( 'Number of Demos found: %d', 'themegrill-demo-importer' ),
217
+ 'noDemosFound' => __( 'No demos found. Try a different search.', 'themegrill-demo-importer' ),
218
+ ),
219
+ 'installedDemos' => array_keys( $this->demo_config ),
220
+ ) );
221
+ }
222
  }
223
 
224
  /**
226
  * @return bool
227
  */
228
  public function is_preview() {
229
+ if ( $this->demo_installer && isset( $_GET['browse'] ) ) {
230
  return 'preview' === $_GET['browse'] ? true : false;
231
  }
232
 
239
  private function prepare_previews_for_js( $demos = null ) {
240
  $prepared_demos = array();
241
  $current_template = get_option( 'template' );
 
242
  $demo_imported_id = get_option( 'themegrill_demo_imported_id' );
243
+ $demo_assets_path = ThemeGrill_Demo_Importer::plugin_url() . '/assets/';
244
 
245
  /**
246
  * Filters demo data before it is prepared for JavaScript.
327
  foreach ( $demos as $demo_id => $demo_data ) {
328
  $demo_notices = array();
329
  $encoded_slug = urlencode( $demo_id );
330
+ $demo_package = isset( $demo_data['demo_pack'] ) ? $demo_data['demo_pack'] : false;
331
  $plugins_list = isset( $demo_data['plugins_list'] ) ? $demo_data['plugins_list'] : array();
332
 
333
  // Plugins status.
347
  'id' => $demo_id,
348
  'name' => $demo_data['name'],
349
  'theme' => $demo_data['theme'],
350
+ 'package' => $demo_package,
351
  'screenshot' => $this->import_file_url( $demo_id, 'screenshot.jpg' ),
352
  'description' => isset( $demo_data['description'] ) ? $demo_data['description'] : '',
353
  'author' => isset( $demo_data['author'] ) ? $demo_data['author'] : __( 'ThemeGrill', 'themegrill-demo-importer' ),
386
  if ( isset( $_GET['action'] ) && 'upload-demo' === $_GET['action'] ) {
387
  $this->upload_demo_pack();
388
  } else {
389
+ $suffix = $this->demo_installer ? 'installer' : 'importer';
390
  include_once( dirname( __FILE__ ) . "/includes/admin/views/html-admin-page-{$suffix}.php" );
391
  }
392
  }
includes/includes/functions-demo-importer.php CHANGED
@@ -38,18 +38,6 @@ if ( ! function_exists( 'tg_get_demo_file_path' ) ) {
38
  }
39
  }
40
 
41
- if ( ! function_exists( 'tg_get_demo_importer_assets_path' ) ) {
42
-
43
- /**
44
- * Get a demo importer assets path.
45
- *
46
- * @return string the demo data assets path.
47
- */
48
- function tg_get_demo_importer_assets_path() {
49
- return apply_filters( 'themegrill_demo_importer_assets_path', get_template_directory_uri() . '/inc/demo-importer/assets/' );
50
- }
51
- }
52
-
53
  /**
54
  * Get an attachment ID from the filename.
55
  *
@@ -122,7 +110,7 @@ function tg_ajax_delete_demo_pack() {
122
  }
123
 
124
  // Check filesystem credentials. `tg_delete_demo_pack()` will bail otherwise.
125
- $url = wp_nonce_url( 'tthemes.php?page=demo-importer&browse=uploads&action=delete&demo_pack=' . urlencode( $demo_pack ), 'delete-demo_' . $demo_pack );
126
  ob_start();
127
  $credentials = request_filesystem_credentials( $url );
128
  ob_end_clean();
38
  }
39
  }
40
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  /**
42
  * Get an attachment ID from the filename.
43
  *
110
  }
111
 
112
  // Check filesystem credentials. `tg_delete_demo_pack()` will bail otherwise.
113
+ $url = wp_nonce_url( 'themes.php?page=demo-importer&browse=uploads&action=delete&demo_pack=' . urlencode( $demo_pack ), 'delete-demo_' . $demo_pack );
114
  ob_start();
115
  $credentials = request_filesystem_credentials( $url );
116
  ob_end_clean();
languages/themegrill-demo-importer.pot CHANGED
@@ -1,46 +1,46 @@
1
- # Copyright (C) 2016 ThemeGrill
2
  # This file is distributed under the GPLv3 or later.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: ThemeGrill Demo Importer 1.1.0\n"
6
  "Report-Msgid-Bugs-To: themegrill@gmail.com\n"
7
- "POT-Creation-Date: 2016-12-30 16:49:14+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
14
  "X-Generator: grunt-wp-i18n 0.5.4\n"
15
 
16
- #: includes/class-demo-importer.php:137
17
  #: includes/includes/admin/views/html-admin-page-importer.php:14
18
  #: includes/includes/admin/views/html-admin-page-installer.php:23
19
- #: themegrill-demo-importer.php:171
20
  msgid "Demo Importer"
21
  msgstr ""
22
 
23
- #: includes/class-demo-importer.php:177
24
  msgid "Importing..."
25
  msgstr ""
26
 
27
- #: includes/class-demo-importer.php:179
28
  msgid "Importing... please wait."
29
  msgstr ""
30
 
31
- #: includes/class-demo-importer.php:180
32
  msgid "Import completed successfully."
33
  msgstr ""
34
 
35
- #: includes/class-demo-importer.php:181
36
  msgid "Import Failed!"
37
  msgstr ""
38
 
39
- #: includes/class-demo-importer.php:182
40
  msgid "Import failed: %s"
41
  msgstr ""
42
 
43
- #: includes/class-demo-importer.php:185
44
  #: includes/includes/admin/views/html-admin-page-importer.php:58
45
  #: includes/includes/admin/views/html-admin-page-importer.php:110
46
  #: includes/includes/admin/views/html-admin-page-importer.php:222
@@ -52,45 +52,45 @@ msgstr ""
52
  msgid "Live Preview"
53
  msgstr ""
54
 
55
- #: includes/class-demo-importer.php:187
56
  msgid "Imported!"
57
  msgstr ""
58
 
59
- #: includes/class-demo-importer.php:188
60
  msgid "Try this solution!"
61
  msgstr ""
62
 
63
- #: includes/class-demo-importer.php:201
64
  msgid ""
65
  "Are you sure you want to delete this demo?\n"
66
  "\n"
67
  "Click 'Cancel' to go back, 'OK' to confirm the delete."
68
  msgstr ""
69
 
70
- #: includes/class-demo-importer.php:202
71
  msgid ""
72
  "Importing demo content will replicate the live demo and overwrites your "
73
  "current customizer, widgets and other settings. It might take few minutes "
74
  "to complete the demo import. Are you sure you want to import this demo?"
75
  msgstr ""
76
 
77
- #: includes/class-demo-importer.php:207
78
  msgid "Add New Demo"
79
  msgstr ""
80
 
81
- #: includes/class-demo-importer.php:208
82
  msgid "Search Demos"
83
  msgstr ""
84
 
85
- #: includes/class-demo-importer.php:209
86
  msgid "Search demos..."
87
  msgstr ""
88
 
89
- #: includes/class-demo-importer.php:210
90
  msgid "Number of Demos found: %d"
91
  msgstr ""
92
 
93
- #: includes/class-demo-importer.php:211
94
  #: includes/includes/admin/views/html-admin-page-importer.php:81
95
  #: includes/includes/admin/views/html-admin-page-installer.php:94
96
  msgid "No demos found. Try a different search."
@@ -100,32 +100,32 @@ msgstr ""
100
  msgid "ThemeGrill"
101
  msgstr ""
102
 
103
- #: includes/class-demo-importer.php:393
104
  msgid "Sorry, you are not allowed to install demo on this site."
105
  msgstr ""
106
 
107
- #: includes/class-demo-importer.php:400
108
  msgid "Installing Demo from uploaded file: %s"
109
  msgstr ""
110
 
111
- #: includes/class-demo-importer.php:444
112
- #: includes/includes/functions-demo-importer.php:109
113
  msgid "No demo specified."
114
  msgstr ""
115
 
116
- #: includes/class-demo-importer.php:460
117
  msgid "Sorry, you are not allowed to import."
118
  msgstr ""
119
 
120
- #: includes/class-demo-importer.php:525
121
  msgid "The XML file dummy content is missing."
122
  msgstr ""
123
 
124
- #: includes/class-demo-importer.php:588
125
  msgid "The DAT file customizer data is missing."
126
  msgstr ""
127
 
128
- #: includes/class-demo-importer.php:612
129
  msgid "The WIE file widget content is missing."
130
  msgstr ""
131
 
@@ -452,31 +452,31 @@ msgstr ""
452
  msgid "No Title"
453
  msgstr ""
454
 
455
- #: includes/includes/functions-demo-importer.php:120
456
  msgid "Sorry, you are not allowed to delete demo on this site."
457
  msgstr ""
458
 
459
- #: includes/includes/functions-demo-importer.php:133
460
  msgid "Unable to connect to the filesystem. Please confirm your credentials."
461
  msgstr ""
462
 
463
- #: includes/includes/functions-demo-importer.php:149
464
  msgid "Demo could not be deleted."
465
  msgstr ""
466
 
467
- #: includes/includes/functions-demo-importer.php:211
468
  msgid "Could not access filesystem."
469
  msgstr ""
470
 
471
- #: includes/includes/functions-demo-importer.php:215
472
  msgid "Filesystem error."
473
  msgstr ""
474
 
475
- #: includes/includes/functions-demo-importer.php:221
476
  msgid "Unable to locate ThemeGrill demo pack directory."
477
  msgstr ""
478
 
479
- #: includes/includes/functions-demo-importer.php:229
480
  msgid "Could not fully remove the demo %s."
481
  msgstr ""
482
 
@@ -680,23 +680,23 @@ msgstr ""
680
  msgid "This does not appear to be a WXR file, missing/invalid WXR version number"
681
  msgstr ""
682
 
683
- #: themegrill-demo-importer.php:171
684
  msgid "View Demo Importer"
685
  msgstr ""
686
 
687
- #: themegrill-demo-importer.php:186
688
  msgid "View Demo Importer Documentation"
689
  msgstr ""
690
 
691
- #: themegrill-demo-importer.php:186
692
  msgid "Docs"
693
  msgstr ""
694
 
695
- #: themegrill-demo-importer.php:187
696
  msgid "Visit Free Customer Support Forum"
697
  msgstr ""
698
 
699
- #: themegrill-demo-importer.php:187
700
  msgid "Free Support"
701
  msgstr ""
702
 
@@ -704,11 +704,11 @@ msgstr ""
704
  msgid "ThemeGrill Demo Importer"
705
  msgstr ""
706
 
707
- #: themegrill-demo-importer.php:202
708
  msgid "This plugin requires %s by ThemeGrill to work."
709
  msgstr ""
710
 
711
- #: themegrill-demo-importer.php:202
712
  msgid "Official Theme"
713
  msgstr ""
714
 
@@ -726,27 +726,27 @@ msgstr ""
726
  msgid "http://themegrill.com"
727
  msgstr ""
728
 
729
- #: includes/class-demo-importer.php:153
730
  msgctxt "Admin menu name"
731
  msgid "Demo Importer"
732
  msgstr ""
733
 
734
- #: includes/class-demo-importer.php:178
735
  msgctxt "demo"
736
  msgid "Importing %s..."
737
  msgstr ""
738
 
739
- #: includes/class-demo-importer.php:183
740
  msgctxt "demo"
741
  msgid "%s imported!"
742
  msgstr ""
743
 
744
- #: includes/class-demo-importer.php:184
745
  msgctxt "demo"
746
  msgid "%s import failed"
747
  msgstr ""
748
 
749
- #: includes/class-demo-importer.php:186
750
  msgctxt "demo"
751
  msgid "Live Preview %s"
752
  msgstr ""
1
+ # Copyright (C) 2017 ThemeGrill
2
  # This file is distributed under the GPLv3 or later.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: ThemeGrill Demo Importer 1.2.0\n"
6
  "Report-Msgid-Bugs-To: themegrill@gmail.com\n"
7
+ "POT-Creation-Date: 2017-01-23 04:13:43+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
14
  "X-Generator: grunt-wp-i18n 0.5.4\n"
15
 
16
+ #: includes/class-demo-importer.php:139
17
  #: includes/includes/admin/views/html-admin-page-importer.php:14
18
  #: includes/includes/admin/views/html-admin-page-installer.php:23
19
+ #: themegrill-demo-importer.php:170
20
  msgid "Demo Importer"
21
  msgstr ""
22
 
23
+ #: includes/class-demo-importer.php:186
24
  msgid "Importing..."
25
  msgstr ""
26
 
27
+ #: includes/class-demo-importer.php:188
28
  msgid "Importing... please wait."
29
  msgstr ""
30
 
31
+ #: includes/class-demo-importer.php:189
32
  msgid "Import completed successfully."
33
  msgstr ""
34
 
35
+ #: includes/class-demo-importer.php:190
36
  msgid "Import Failed!"
37
  msgstr ""
38
 
39
+ #: includes/class-demo-importer.php:191
40
  msgid "Import failed: %s"
41
  msgstr ""
42
 
43
+ #: includes/class-demo-importer.php:194
44
  #: includes/includes/admin/views/html-admin-page-importer.php:58
45
  #: includes/includes/admin/views/html-admin-page-importer.php:110
46
  #: includes/includes/admin/views/html-admin-page-importer.php:222
52
  msgid "Live Preview"
53
  msgstr ""
54
 
55
+ #: includes/class-demo-importer.php:196
56
  msgid "Imported!"
57
  msgstr ""
58
 
59
+ #: includes/class-demo-importer.php:197
60
  msgid "Try this solution!"
61
  msgstr ""
62
 
63
+ #: includes/class-demo-importer.php:207
64
  msgid ""
65
  "Are you sure you want to delete this demo?\n"
66
  "\n"
67
  "Click 'Cancel' to go back, 'OK' to confirm the delete."
68
  msgstr ""
69
 
70
+ #: includes/class-demo-importer.php:208
71
  msgid ""
72
  "Importing demo content will replicate the live demo and overwrites your "
73
  "current customizer, widgets and other settings. It might take few minutes "
74
  "to complete the demo import. Are you sure you want to import this demo?"
75
  msgstr ""
76
 
77
+ #: includes/class-demo-importer.php:213
78
  msgid "Add New Demo"
79
  msgstr ""
80
 
81
+ #: includes/class-demo-importer.php:214
82
  msgid "Search Demos"
83
  msgstr ""
84
 
85
+ #: includes/class-demo-importer.php:215
86
  msgid "Search demos..."
87
  msgstr ""
88
 
89
+ #: includes/class-demo-importer.php:216
90
  msgid "Number of Demos found: %d"
91
  msgstr ""
92
 
93
+ #: includes/class-demo-importer.php:217
94
  #: includes/includes/admin/views/html-admin-page-importer.php:81
95
  #: includes/includes/admin/views/html-admin-page-installer.php:94
96
  msgid "No demos found. Try a different search."
100
  msgid "ThemeGrill"
101
  msgstr ""
102
 
103
+ #: includes/class-demo-importer.php:401
104
  msgid "Sorry, you are not allowed to install demo on this site."
105
  msgstr ""
106
 
107
+ #: includes/class-demo-importer.php:408
108
  msgid "Installing Demo from uploaded file: %s"
109
  msgstr ""
110
 
111
+ #: includes/class-demo-importer.php:452
112
+ #: includes/includes/functions-demo-importer.php:97
113
  msgid "No demo specified."
114
  msgstr ""
115
 
116
+ #: includes/class-demo-importer.php:468
117
  msgid "Sorry, you are not allowed to import."
118
  msgstr ""
119
 
120
+ #: includes/class-demo-importer.php:533
121
  msgid "The XML file dummy content is missing."
122
  msgstr ""
123
 
124
+ #: includes/class-demo-importer.php:596
125
  msgid "The DAT file customizer data is missing."
126
  msgstr ""
127
 
128
+ #: includes/class-demo-importer.php:620
129
  msgid "The WIE file widget content is missing."
130
  msgstr ""
131
 
452
  msgid "No Title"
453
  msgstr ""
454
 
455
+ #: includes/includes/functions-demo-importer.php:108
456
  msgid "Sorry, you are not allowed to delete demo on this site."
457
  msgstr ""
458
 
459
+ #: includes/includes/functions-demo-importer.php:121
460
  msgid "Unable to connect to the filesystem. Please confirm your credentials."
461
  msgstr ""
462
 
463
+ #: includes/includes/functions-demo-importer.php:137
464
  msgid "Demo could not be deleted."
465
  msgstr ""
466
 
467
+ #: includes/includes/functions-demo-importer.php:199
468
  msgid "Could not access filesystem."
469
  msgstr ""
470
 
471
+ #: includes/includes/functions-demo-importer.php:203
472
  msgid "Filesystem error."
473
  msgstr ""
474
 
475
+ #: includes/includes/functions-demo-importer.php:209
476
  msgid "Unable to locate ThemeGrill demo pack directory."
477
  msgstr ""
478
 
479
+ #: includes/includes/functions-demo-importer.php:217
480
  msgid "Could not fully remove the demo %s."
481
  msgstr ""
482
 
680
  msgid "This does not appear to be a WXR file, missing/invalid WXR version number"
681
  msgstr ""
682
 
683
+ #: themegrill-demo-importer.php:170
684
  msgid "View Demo Importer"
685
  msgstr ""
686
 
687
+ #: themegrill-demo-importer.php:185
688
  msgid "View Demo Importer Documentation"
689
  msgstr ""
690
 
691
+ #: themegrill-demo-importer.php:185
692
  msgid "Docs"
693
  msgstr ""
694
 
695
+ #: themegrill-demo-importer.php:186
696
  msgid "Visit Free Customer Support Forum"
697
  msgstr ""
698
 
699
+ #: themegrill-demo-importer.php:186
700
  msgid "Free Support"
701
  msgstr ""
702
 
704
  msgid "ThemeGrill Demo Importer"
705
  msgstr ""
706
 
707
+ #: themegrill-demo-importer.php:201
708
  msgid "This plugin requires %s by ThemeGrill to work."
709
  msgstr ""
710
 
711
+ #: themegrill-demo-importer.php:201
712
  msgid "Official Theme"
713
  msgstr ""
714
 
726
  msgid "http://themegrill.com"
727
  msgstr ""
728
 
729
+ #: includes/class-demo-importer.php:154
730
  msgctxt "Admin menu name"
731
  msgid "Demo Importer"
732
  msgstr ""
733
 
734
+ #: includes/class-demo-importer.php:187
735
  msgctxt "demo"
736
  msgid "Importing %s..."
737
  msgstr ""
738
 
739
+ #: includes/class-demo-importer.php:192
740
  msgctxt "demo"
741
  msgid "%s imported!"
742
  msgstr ""
743
 
744
+ #: includes/class-demo-importer.php:193
745
  msgctxt "demo"
746
  msgid "%s import failed"
747
  msgstr ""
748
 
749
+ #: includes/class-demo-importer.php:195
750
  msgctxt "demo"
751
  msgid "Live Preview %s"
752
  msgstr ""
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: ThemeGrill, shivapoudel
3
  Tags: themegrill, themes, demo, importer, download
4
  Requires at least: 4.0
5
  Tested up to: 4.7
6
- Stable tag: 1.1.0
7
  License: GPLv3 or later
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -39,6 +39,11 @@ Yes you can! Join in on our [GitHub repository](https://github.com/themegrill/th
39
 
40
  == Changelog ==
41
 
 
 
 
 
 
42
  = 1.1.0 =
43
  * Feature - Backbone views interface for demos and previews
44
  * Feature - Added download button for the preview not installed
3
  Tags: themegrill, themes, demo, importer, download
4
  Requires at least: 4.0
5
  Tested up to: 4.7
6
+ Stable tag: 1.2.0
7
  License: GPLv3 or later
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
 
39
 
40
  == Changelog ==
41
 
42
+ = 1.2.0 =
43
+ * Tweak - Load scripts perfecly on demo importer appearance page.
44
+ * Tweak - Set transient for redirecting to demo importer page after install or update.
45
+ * Tweak - Introduced filter hook `themegrill_demo_importer_installer` to control demo view.
46
+
47
  = 1.1.0 =
48
  * Feature - Backbone views interface for demos and previews
49
  * Feature - Added download button for the preview not installed
themegrill-demo-importer.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: ThemeGrill Demo Importer
4
  * Plugin URI: http://themegrill.com/demo-importer/
5
  * Description: Description: Import your demo content, widgets and theme settings with one click for ThemeGrill official themes.
6
- * Version: 1.1.0
7
  * Author: ThemeGrill
8
  * Author URI: http://themegrill.com
9
  * License: GPLv3 or later
@@ -44,10 +44,8 @@ final class ThemeGrill_Demo_Importer {
44
  // Check with ThemeGrill theme is installed.
45
  if ( in_array( get_option( 'template' ), $this->get_core_supported_themes() ) ) {
46
  $this->includes();
47
- $this->demo_includes();
48
 
49
  // Hooks.
50
- add_filter( 'themegrill_demo_importer_assets_path', array( $this, 'plugin_assets_path' ) );
51
  add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
52
  add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
53
  } else {
@@ -94,6 +92,9 @@ final class ThemeGrill_Demo_Importer {
94
  }
95
  }
96
  }
 
 
 
97
  }
98
 
99
  /**
@@ -117,7 +118,15 @@ final class ThemeGrill_Demo_Importer {
117
  * @return array
118
  */
119
  private function get_core_supported_themes() {
120
- return array( 'spacious', 'colormag', 'flash' );
 
 
 
 
 
 
 
 
121
  }
122
 
123
  /**
@@ -126,20 +135,18 @@ final class ThemeGrill_Demo_Importer {
126
  private function includes() {
127
  include_once( dirname( __FILE__ ) . '/includes/class-demo-importer.php' );
128
  include_once( dirname( __FILE__ ) . '/includes/functions-demo-update.php' );
129
- }
130
-
131
- /**
132
- * Includes demo config.
133
- */
134
- private function demo_includes() {
135
- $upload_dir = wp_upload_dir();
136
 
137
- // Check the folder contains at least 1 valid demo config.
138
- $files = glob( $upload_dir['basedir'] . '/tg-demo-pack/**/tg-demo-config.php' );
139
- if ( $files ) {
140
- foreach ( $files as $file ) {
141
- if ( $file && is_readable( $file ) ) {
142
- include_once( $file );
 
 
 
 
 
143
  }
144
  }
145
  }
@@ -149,18 +156,10 @@ final class ThemeGrill_Demo_Importer {
149
  * Get the plugin url.
150
  * @return string
151
  */
152
- public function plugin_url() {
153
  return untrailingslashit( plugins_url( '/', __FILE__ ) );
154
  }
155
 
156
- /**
157
- * Get the plugin assets path.
158
- * @return string
159
- */
160
- public function plugin_assets_path() {
161
- return trailingslashit( $this->plugin_url() . '/assets/' );
162
- }
163
-
164
  /**
165
  * Display action links in the Plugins list table.
166
  * @param array $actions
3
  * Plugin Name: ThemeGrill Demo Importer
4
  * Plugin URI: http://themegrill.com/demo-importer/
5
  * Description: Description: Import your demo content, widgets and theme settings with one click for ThemeGrill official themes.
6
+ * Version: 1.2.0
7
  * Author: ThemeGrill
8
  * Author URI: http://themegrill.com
9
  * License: GPLv3 or later
44
  // Check with ThemeGrill theme is installed.
45
  if ( in_array( get_option( 'template' ), $this->get_core_supported_themes() ) ) {
46
  $this->includes();
 
47
 
48
  // Hooks.
 
49
  add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
50
  add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
51
  } else {
92
  }
93
  }
94
  }
95
+
96
+ // Redirect to demo importer page.
97
+ set_transient( '_tg_demo_importer_activation_redirect', 1, 30 );
98
  }
99
 
100
  /**
118
  * @return array
119
  */
120
  private function get_core_supported_themes() {
121
+ $pro_themes = array();
122
+ $core_themes = array( 'spacious', 'colormag', 'flash', 'estore' );
123
+
124
+ // Check for core themes pro version :)
125
+ foreach ( $core_themes as $core_theme ) {
126
+ $pro_themes[] = $core_theme . '-pro';
127
+ }
128
+
129
+ return array_merge( $core_themes, $pro_themes );
130
  }
131
 
132
  /**
135
  private function includes() {
136
  include_once( dirname( __FILE__ ) . '/includes/class-demo-importer.php' );
137
  include_once( dirname( __FILE__ ) . '/includes/functions-demo-update.php' );
 
 
 
 
 
 
 
138
 
139
+ // Includes demo packages config.
140
+ if ( false === strpos( get_option( 'template' ), '-pro' ) ) {
141
+ $upload_dir = wp_upload_dir();
142
+
143
+ // Check the folder contains at least 1 valid demo config.
144
+ $files = glob( $upload_dir['basedir'] . '/tg-demo-pack/**/tg-demo-config.php' );
145
+ if ( $files ) {
146
+ foreach ( $files as $file ) {
147
+ if ( $file && is_readable( $file ) ) {
148
+ include_once( $file );
149
+ }
150
  }
151
  }
152
  }
156
  * Get the plugin url.
157
  * @return string
158
  */
159
+ public static function plugin_url() {
160
  return untrailingslashit( plugins_url( '/', __FILE__ ) );
161
  }
162
 
 
 
 
 
 
 
 
 
163
  /**
164
  * Display action links in the Plugins list table.
165
  * @param array $actions