ThemeGrill Demo Importer - Version 1.4.3

Version Description

  • 23-04-2018 =
  • Support - Cenote theme.
Download this release

Release Info

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

Code changes from version 1.4.2 to 1.4.3

Files changed (2) hide show
  1. readme.txt +3 -1
  2. themegrill-demo-importer.php +235 -211
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: ThemeGrill, shivapoudel
3
Tags: themegrill, themes, demo, importer, download
4
Requires at least: 4.7
5
Tested up to: 4.9
6
- Stable tag: 1.4.2
7
License: GPLv3 or later
8
License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
@@ -66,6 +66,8 @@ Bugs can be reported either in our support forum or preferably on the [GitHub re
66
Yes you can! Join in on our [GitHub repository](https://github.com/themegrill/themegrill-demo-importer/) :)
67
68
== Changelog ==
69
70
= 1.4.2 - 25-12-2017 =
71
* Fix - Disable WooCommerce setup wizard for demo import.
3
Tags: themegrill, themes, demo, importer, download
4
Requires at least: 4.7
5
Tested up to: 4.9
6
+ Stable tag: 1.4.3
7
License: GPLv3 or later
8
License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
66
Yes you can! Join in on our [GitHub repository](https://github.com/themegrill/themegrill-demo-importer/) :)
67
68
== Changelog ==
69
+ = 1.4.3 - 23-04-2018 =
70
+ * Support - Cenote theme.
71
72
= 1.4.2 - 25-12-2017 =
73
* Fix - Disable WooCommerce setup wizard for demo import.
themegrill-demo-importer.php CHANGED
@@ -3,7 +3,7 @@
3
* Plugin Name: ThemeGrill Demo Importer
4
* Plugin URI: https://themegrill.com/demo-importer/
5
* Description: Import your demo content, widgets and theme settings with one click for ThemeGrill official themes.
6
- * Version: 1.4.2
7
* Author: ThemeGrill
8
* Author URI: https://themegrill.com
9
* License: GPLv3 or later
@@ -17,254 +17,278 @@ if ( ! defined( 'ABSPATH' ) ) {
17
18
if ( ! class_exists( 'ThemeGrill_Demo_Importer' ) ) :
19
20
- /**
21
- * ThemeGrill_Demo_Importer main class.
22
- */
23
- final class ThemeGrill_Demo_Importer {
24
-
25
- /**
26
- * Plugin version.
27
- * @var string
28
- */
29
- public $version = '1.4.1';
30
-
31
/**
32
- * Instance of this class.
33
- * @var object
34
*/
35
- protected static $instance = null;
36
37
- /**
38
- * Return an instance of this class.
39
- * @return object A single instance of this class.
40
- */
41
- public static function get_instance() {
42
- // If the single instance hasn't been set, set it now.
43
- if ( is_null( self::$instance ) ) {
44
- self::$instance = new self();
45
}
46
- return self::$instance;
47
- }
48
49
- /**
50
- * Cloning is forbidden.
51
- * @since 1.4
52
- */
53
- public function __clone() {
54
- _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'themegrill-demo-importer' ), '1.4' );
55
- }
56
57
- /**
58
- * Unserializing instances of this class is forbidden.
59
- * @since 1.4
60
- */
61
- public function __wakeup() {
62
- _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'themegrill-demo-importer' ), '1.4' );
63
- }
64
65
- /**
66
- * Initialize the plugin.
67
- */
68
- private function __construct() {
69
- $this->define_constants();
70
- $this->init_hooks();
71
72
- do_action( 'themegrill_demo_importer_loaded' );
73
- }
74
75
- /**
76
- * Define TGDM Constants.
77
- */
78
- private function define_constants() {
79
- $upload_dir = wp_upload_dir( null, false );
80
-
81
- $this->define( 'TGDM_PLUGIN_FILE', __FILE__ );
82
- $this->define( 'TGDM_ABSPATH', dirname( TGDM_PLUGIN_FILE ) . '/' );
83
- $this->define( 'TGDM_PLUGIN_BASENAME', plugin_basename( TGDM_PLUGIN_FILE ) );
84
- $this->define( 'TGDM_VERSION', $this->version );
85
- $this->define( 'TGDM_DEMO_DIR', $upload_dir['basedir'] . '/tg-demo-pack/' );
86
- $this->define( 'TGDM_DEMO_URL', $upload_dir['baseurl'] . '/tg-demo-pack/' );
87
- }
88
89
- /**
90
- * Define constant if not already set.
91
- *
92
- * @param string $name
93
- * @param string|bool $value
94
- */
95
- private function define( $name, $value ) {
96
- if ( ! defined( $name ) ) {
97
- define( $name, $value );
98
}
99
- }
100
101
- /**
102
- * Hook into actions and filters.
103
- */
104
- private function init_hooks() {
105
- // Load plugin text domain.
106
- add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
107
-
108
- // Register activation hook.
109
- register_activation_hook( TGDM_PLUGIN_FILE, array( $this, 'install' ) );
110
-
111
- // Check with ThemeGrill theme is installed.
112
- if ( in_array( get_option( 'template' ), $this->get_core_supported_themes() ) ) {
113
- $this->includes();
114
-
115
- add_action( 'after_setup_theme', array( $this, 'include_template_functions' ), 11 );
116
- add_filter( 'plugin_action_links_' . TGDM_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
117
- add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
118
- } else {
119
- add_action( 'admin_notices', array( $this, 'theme_support_missing_notice' ) );
120
}
121
- }
122
123
- /**
124
- * Get core supported themes.
125
- * @return array
126
- */
127
- private function get_core_supported_themes() {
128
- $core_themes = array( 'spacious', 'colormag', 'flash', 'estore', 'ample', 'accelerate', 'colornews', 'foodhunt', 'fitclub', 'radiate', 'freedom', 'himalayas', 'esteem', 'envince', 'suffice', 'explore', 'masonic' );
129
130
- // Check for core themes pro version :)
131
- $pro_themes = array_diff( $core_themes, array( 'explore', 'masonic' ) );
132
- if ( ! empty( $pro_themes ) ) {
133
- $pro_themes = preg_replace( '/#x2F;', '-pro', $pro_themes );
134
- }
135
136
- return array_merge( $core_themes, $pro_themes );
137
- }
138
139
- /**
140
- * Includes.
141
- */
142
- private function includes() {
143
- include_once( TGDM_ABSPATH . 'includes/class-demo-importer.php' );
144
- include_once( TGDM_ABSPATH . 'includes/functions-demo-importer.php' );
145
-
146
- // Include valid demo packages config.
147
- if ( false === strpos( get_option( 'template' ), '-pro' ) ) {
148
- $files = glob( TGDM_DEMO_DIR . '**/tg-demo-config.php' );
149
- if ( $files ) {
150
- foreach ( $files as $file ) {
151
- if ( $file && is_readable( $file ) ) {
152
- include_once( $file );
153
}
154
}
155
}
156
}
157
- }
158
-
159
- /**
160
- * Template Functions - This makes them pluggable by plugins and themes.
161
- */
162
- public function include_template_functions() {
163
- include_once( TGDM_ABSPATH . 'includes/functions-demo-template.php' );
164
- }
165
166
- /**
167
- * Install TG Demo Importer.
168
- */
169
- public function install() {
170
- if ( ! is_blog_installed() ) {
171
- return;
172
}
173
174
- // Install files and folders for uploading files and prevent hotlinking.
175
- $files = array(
176
- array(
177
- 'base' => TGDM_DEMO_DIR,
178
- 'file' => 'index.html',
179
- 'content' => '',
180
- ),
181
- );
182
-
183
- foreach ( $files as $file ) {
184
- if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
185
- if ( $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ) ) {
186
- fwrite( $file_handle, $file['content'] );
187
- fclose( $file_handle );
188
- }
189
}
190
- }
191
192
- // Redirect to demo importer page.
193
- set_transient( '_tg_demo_importer_activation_redirect', 1, 30 );
194
- }
195
-
196
- /**
197
- * Load Localisation files.
198
- *
199
- * Note: the first-loaded translation file overrides any following ones if the same translation is present.
200
- *
201
- * Locales found in:
202
- * - WP_LANG_DIR/themegrill-demo-importer/themegrill-demo-importer-LOCALE.mo
203
- * - WP_LANG_DIR/plugins/themegrill-demo-importer-LOCALE.mo
204
- */
205
- public function load_plugin_textdomain() {
206
- $locale = apply_filters( 'plugin_locale', get_locale(), 'themegrill-demo-importer' );
207
208
- load_textdomain( 'themegrill-demo-importer', WP_LANG_DIR . '/themegrill-demo-importer/themegrill-demo-importer-' . $locale . '.mo' );
209
- load_plugin_textdomain( 'themegrill-demo-importer', false, plugin_basename( dirname( TGDM_PLUGIN_FILE ) ) . '/languages' );
210
- }
211
212
- /**
213
- * Get the plugin url.
214
- * @return string
215
- */
216
- public function plugin_url() {
217
- return untrailingslashit( plugins_url( '/', TGDM_PLUGIN_FILE ) );
218
- }
219
220
- /**
221
- * Get the plugin path.
222
- * @return string
223
- */
224
- public function plugin_path() {
225
- return untrailingslashit( plugin_dir_path( TGDM_PLUGIN_FILE ) );
226
- }
227
228
- /**
229
- * Display action links in the Plugins list table.
230
- * @param array $actions
231
- * @return array
232
- */
233
- public function plugin_action_links( $actions ) {
234
- $new_actions = array(
235
- 'importer' => '<a href="' . admin_url( 'themes.php?page=demo-importer' ) . '" aria-label="' . esc_attr( __( 'View Demo Importer', 'themegrill-demo-importer' ) ) . '">' . __( 'Demo Importer', 'themegrill-demo-importer' ) . '</a>',
236
- );
237
238
- return array_merge( $new_actions, $actions );
239
- }
240
241
- /**
242
- * Display row meta in the Plugins list table.
243
- * @param array $plugin_meta
244
- * @param string $plugin_file
245
- * @return array
246
- */
247
- public function plugin_row_meta( $plugin_meta, $plugin_file ) {
248
- if ( TGDM_PLUGIN_BASENAME == $plugin_file ) {
249
- $new_plugin_meta = array(
250
- 'docs' => '<a href="' . esc_url( apply_filters( 'themegrill_demo_importer_docs_url', 'https://themegrill.com/docs/themegrill-demo-importer/' ) ) . '" title="' . esc_attr( __( 'View Demo Importer Documentation', 'themegrill-demo-importer' ) ) . '">' . __( 'Docs', 'themegrill-demo-importer' ) . '</a>',
251
- 'support' => '<a href="' . esc_url( apply_filters( 'themegrill_demo_importer_support_url', 'https://themegrill.com/support-forum/' ) ) . '" title="' . esc_attr( __( 'Visit Free Customer Support Forum', 'themegrill-demo-importer' ) ) . '">' . __( 'Free Support', 'themegrill-demo-importer' ) . '</a>',
252
);
253
254
- return array_merge( $plugin_meta, $new_plugin_meta );
255
}
256
257
- return (array) $plugin_meta;
258
- }
259
260
- /**
261
- * Theme support fallback notice.
262
- * @return string
263
- */
264
- public function theme_support_missing_notice() {
265
- echo '<div class="error notice is-dismissible"><p><strong>' . __( 'ThemeGrill Demo Importer', 'themegrill-demo-importer' ) . '</strong> &#8211; ' . sprintf( __( 'This plugin requires %s by ThemeGrill to work.', 'themegrill-demo-importer' ), '<a href="https://themegrill.com/themes/" target="_blank">' . __( 'Official Theme', 'themegrill-demo-importer' ) . '</a>' ) . '</p></div>';
266
}
267
- }
268
269
endif;
270
3
* Plugin Name: ThemeGrill Demo Importer
4
* Plugin URI: https://themegrill.com/demo-importer/
5
* Description: Import your demo content, widgets and theme settings with one click for ThemeGrill official themes.
6
+ * Version: 1.4.3
7
* Author: ThemeGrill
8
* Author URI: https://themegrill.com
9
* License: GPLv3 or later
17
18
if ( ! class_exists( 'ThemeGrill_Demo_Importer' ) ) :
19
20
/**
21
+ * ThemeGrill_Demo_Importer main class.
22
*/
23
+ final class ThemeGrill_Demo_Importer {
24
+
25
+ /**
26
+ * Plugin version.
27
+ * @var string
28
+ */
29
+ public $version = '1.4.3';
30
+
31
+ /**
32
+ * Instance of this class.
33
+ * @var object
34
+ */
35
+ protected static $instance = null;
36
+
37
+ /**
38
+ * Return an instance of this class.
39
+ * @return object A single instance of this class.
40
+ */
41
+ public static function get_instance() {
42
+ // If the single instance hasn't been set, set it now.
43
+ if ( is_null( self::$instance ) ) {
44
+ self::$instance = new self();
45
+ }
46
47
+ return self::$instance;
48
}
49
50
+ /**
51
+ * Cloning is forbidden.
52
+ * @since 1.4
53
+ */
54
+ public function __clone() {
55
+ _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'themegrill-demo-importer' ), '1.4' );
56
+ }
57
58
+ /**
59
+ * Unserializing instances of this class is forbidden.
60
+ * @since 1.4
61
+ */
62
+ public function __wakeup() {
63
+ _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'themegrill-demo-importer' ), '1.4' );
64
+ }
65
66
+ /**
67
+ * Initialize the plugin.
68
+ */
69
+ private function __construct() {
70
+ $this->define_constants();
71
+ $this->init_hooks();
72
73
+ do_action( 'themegrill_demo_importer_loaded' );
74
+ }
75
76
+ /**
77
+ * Define TGDM Constants.
78
+ */
79
+ private function define_constants() {
80
+ $upload_dir = wp_upload_dir( null, false );
81
+
82
+ $this->define( 'TGDM_PLUGIN_FILE', __FILE__ );
83
+ $this->define( 'TGDM_ABSPATH', dirname( TGDM_PLUGIN_FILE ) . '/' );
84
+ $this->define( 'TGDM_PLUGIN_BASENAME', plugin_basename( TGDM_PLUGIN_FILE ) );
85
+ $this->define( 'TGDM_VERSION', $this->version );
86
+ $this->define( 'TGDM_DEMO_DIR', $upload_dir['basedir'] . '/tg-demo-pack/' );
87
+ $this->define( 'TGDM_DEMO_URL', $upload_dir['baseurl'] . '/tg-demo-pack/' );
88
+ }
89
90
+ /**
91
+ * Define constant if not already set.
92
+ *
93
+ * @param string $name
94
+ * @param string|bool $value
95
+ */
96
+ private function define( $name, $value ) {
97
+ if ( ! defined( $name ) ) {
98
+ define( $name, $value );
99
+ }
100
}
101
102
+ /**
103
+ * Hook into actions and filters.
104
+ */
105
+ private function init_hooks() {
106
+ // Load plugin text domain.
107
+ add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
108
+
109
+ // Register activation hook.
110
+ register_activation_hook( TGDM_PLUGIN_FILE, array( $this, 'install' ) );
111
+
112
+ // Check with ThemeGrill theme is installed.
113
+ if ( in_array( get_option( 'template' ), $this->get_core_supported_themes() ) ) {
114
+ $this->includes();
115
+
116
+ add_action( 'after_setup_theme', array( $this, 'include_template_functions' ), 11 );
117
+ add_filter( 'plugin_action_links_' . TGDM_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
118
+ add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
119
+ } else {
120
+ add_action( 'admin_notices', array( $this, 'theme_support_missing_notice' ) );
121
+ }
122
}
123
124
+ /**
125
+ * Get core supported themes.
126
+ * @return array
127
+ */
128
+ private function get_core_supported_themes() {
129
+ $core_themes = array(
130
+ 'spacious',
131
+ 'colormag',
132
+ 'flash',
133
+ 'estore',
134
+ 'ample',
135
+ 'accelerate',
136
+ 'colornews',
137
+ 'foodhunt',
138
+ 'fitclub',
139
+ 'radiate',
140
+ 'freedom',
141
+ 'himalayas',
142
+ 'esteem',
143
+ 'envince',
144
+ 'suffice',
145
+ 'explore',
146
+ 'masonic',
147
+ 'cenote',
148
+ );
149
150
+ // Check for core themes pro version :)
151
+ $pro_themes = array_diff( $core_themes, array( 'explore', 'masonic' ) );
152
+ if ( ! empty( $pro_themes ) ) {
153
+ $pro_themes = preg_replace( '/#x2F;', '-pro', $pro_themes );
154
+ }
155
156
+ return array_merge( $core_themes, $pro_themes );
157
+ }
158
159
+ /**
160
+ * Includes.
161
+ */
162
+ private function includes() {
163
+ include_once( TGDM_ABSPATH . 'includes/class-demo-importer.php' );
164
+ include_once( TGDM_ABSPATH . 'includes/functions-demo-importer.php' );
165
+
166
+ // Include valid demo packages config.
167
+ if ( false === strpos( get_option( 'template' ), '-pro' ) ) {
168
+ $files = glob( TGDM_DEMO_DIR . '**/tg-demo-config.php' );
169
+ if ( $files ) {
170
+ foreach ( $files as $file ) {
171
+ if ( $file && is_readable( $file ) ) {
172
+ include_once( $file );
173
+ }
174
}
175
}
176
}
177
}
178
179
+ /**
180
+ * Template Functions - This makes them pluggable by plugins and themes.
181
+ */
182
+ public function include_template_functions() {
183
+ include_once( TGDM_ABSPATH . 'includes/functions-demo-template.php' );
184
}
185
186
+ /**
187
+ * Install TG Demo Importer.
188
+ */
189
+ public function install() {
190
+ if ( ! is_blog_installed() ) {
191
+ return;
192
}
193
194
+ // Install files and folders for uploading files and prevent hotlinking.
195
+ $files = array(
196
+ array(
197
+ 'base' => TGDM_DEMO_DIR,
198
+ 'file' => 'index.html',
199
+ 'content' => '',
200
+ ),
201
+ );
202
203
+ foreach ( $files as $file ) {
204
+ if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
205
+ if ( $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ) ) {
206
+ fwrite( $file_handle, $file['content'] );
207
+ fclose( $file_handle );
208
+ }
209
+ }
210
+ }
211
212
+ // Redirect to demo importer page.
213
+ set_transient( '_tg_demo_importer_activation_redirect', 1, 30 );
214
+ }
215
216
+ /**
217
+ * Load Localisation files.
218
+ *
219
+ * Note: the first-loaded translation file overrides any following ones if the same translation is present.
220
+ *
221
+ * Locales found in:
222
+ * - WP_LANG_DIR/themegrill-demo-importer/themegrill-demo-importer-LOCALE.mo
223
+ * - WP_LANG_DIR/plugins/themegrill-demo-importer-LOCALE.mo
224
+ */
225
+ public function load_plugin_textdomain() {
226
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'themegrill-demo-importer' );
227
+
228
+ load_textdomain( 'themegrill-demo-importer', WP_LANG_DIR . '/themegrill-demo-importer/themegrill-demo-importer-' . $locale . '.mo' );
229
+ load_plugin_textdomain( 'themegrill-demo-importer', false, plugin_basename( dirname( TGDM_PLUGIN_FILE ) ) . '/languages' );
230
+ }
231
232
+ /**
233
+ * Get the plugin url.
234
+ * @return string
235
+ */
236
+ public function plugin_url() {
237
+ return untrailingslashit( plugins_url( '/', TGDM_PLUGIN_FILE ) );
238
+ }
239
240
+ /**
241
+ * Get the plugin path.
242
+ * @return string
243
+ */
244
+ public function plugin_path() {
245
+ return untrailingslashit( plugin_dir_path( TGDM_PLUGIN_FILE ) );
246
+ }
247
248
+ /**
249
+ * Display action links in the Plugins list table.
250
+ *
251
+ * @param array $actions
252
+ *
253
+ * @return array
254
+ */
255
+ public function plugin_action_links( $actions ) {
256
+ $new_actions = array(
257
+ 'importer' => '<a href="' . admin_url( 'themes.php?page=demo-importer' ) . '" aria-label="' . esc_attr( __( 'View Demo Importer', 'themegrill-demo-importer' ) ) . '">' . __( 'Demo Importer', 'themegrill-demo-importer' ) . '</a>',
258
);
259
260
+ return array_merge( $new_actions, $actions );
261
}
262
263
+ /**
264
+ * Display row meta in the Plugins list table.
265
+ *
266
+ * @param array $plugin_meta
267
+ * @param string $plugin_file
268
+ *
269
+ * @return array
270
+ */
271
+ public function plugin_row_meta( $plugin_meta, $plugin_file ) {
272
+ if ( TGDM_PLUGIN_BASENAME == $plugin_file ) {
273
+ $new_plugin_meta = array(
274
+ 'docs' => '<a href="' . esc_url( apply_filters( 'themegrill_demo_importer_docs_url', 'https://themegrill.com/docs/themegrill-demo-importer/' ) ) . '" title="' . esc_attr( __( 'View Demo Importer Documentation', 'themegrill-demo-importer' ) ) . '">' . __( 'Docs', 'themegrill-demo-importer' ) . '</a>',
275
+ 'support' => '<a href="' . esc_url( apply_filters( 'themegrill_demo_importer_support_url', 'https://themegrill.com/support-forum/' ) ) . '" title="' . esc_attr( __( 'Visit Free Customer Support Forum', 'themegrill-demo-importer' ) ) . '">' . __( 'Free Support', 'themegrill-demo-importer' ) . '</a>',
276
+ );
277
+
278
+ return array_merge( $plugin_meta, $new_plugin_meta );
279
+ }
280
281
+ return (array) $plugin_meta;
282
+ }
283
+
284
+ /**
285
+ * Theme support fallback notice.
286
+ * @return string
287
+ */
288
+ public function theme_support_missing_notice() {
289
+ echo '<div class="error notice is-dismissible"><p><strong>' . __( 'ThemeGrill Demo Importer', 'themegrill-demo-importer' ) . '</strong> &#8211; ' . sprintf( __( 'This plugin requires %s by ThemeGrill to work.', 'themegrill-demo-importer' ), '<a href="https://themegrill.com/themes/" target="_blank">' . __( 'Official Theme', 'themegrill-demo-importer' ) . '</a>' ) . '</p></div>';
290
+ }
291
}
292
293
endif;
294