Astra Starter Sites - Version 1.0.6

Version Description

Download this release

Release Info

Developer Nikschavan
Plugin Icon Astra Starter Sites
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

admin/class-astra-sites-page.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Astra Sites Page
4
+ *
5
+ * @since 1.0.6
6
+ * @package Astra Sites
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ if ( ! class_exists( 'Astra_Sites_Page' ) ) {
14
+
15
+ /**
16
+ * Astra Admin Settings
17
+ */
18
+ class Astra_Sites_Page {
19
+
20
+ /**
21
+ * View all actions
22
+ *
23
+ * @since 1.0.6
24
+ * @var array $view_actions
25
+ */
26
+ static public $view_actions = array();
27
+
28
+ /**
29
+ * Menu page title
30
+ *
31
+ * @since 1.0.6
32
+ * @var array $menu_page_title
33
+ */
34
+ static public $menu_page_title = 'Astra Sites';
35
+
36
+ /**
37
+ * Plugin slug
38
+ *
39
+ * @since 1.0.6
40
+ * @var array $plugin_slug
41
+ */
42
+ static public $plugin_slug = 'astra-sites';
43
+
44
+ /**
45
+ * Default Menu position
46
+ *
47
+ * @since 1.0.6
48
+ * @var array $default_menu_position
49
+ */
50
+ static public $default_menu_position = 'themes.php';
51
+
52
+ /**
53
+ * Parent Page Slug
54
+ *
55
+ * @since 1.0.6
56
+ * @var array $parent_page_slug
57
+ */
58
+ static public $parent_page_slug = 'general';
59
+
60
+ /**
61
+ * Current Slug
62
+ *
63
+ * @since 1.0.6
64
+ * @var array $current_slug
65
+ */
66
+ static public $current_slug = 'general';
67
+
68
+ /**
69
+ * Constructor
70
+ */
71
+ function __construct() {
72
+
73
+ if ( ! is_admin() ) {
74
+ return;
75
+ }
76
+
77
+ add_action( 'after_setup_theme', __CLASS__ . '::init_admin_settings', 99 );
78
+ }
79
+
80
+ /**
81
+ * Admin settings init
82
+ */
83
+ static public function init_admin_settings() {
84
+
85
+ self::$menu_page_title = apply_filters( 'astra_sites_menu_page_title', __( 'Astra Sites' , 'astra-sites' ) );
86
+
87
+ if ( isset( $_REQUEST['page'] ) && strpos( $_REQUEST['page'], self::$plugin_slug ) !== false ) {
88
+
89
+ // Let extensions hook into saving.
90
+ do_action( 'astra_sites_page' );
91
+
92
+ self::save_settings();
93
+ }
94
+
95
+ add_action( 'admin_menu', __CLASS__ . '::add_admin_menu', 100 );
96
+
97
+ add_action( 'astra_sites_menu_general_action', __CLASS__ . '::general_page' );
98
+ }
99
+
100
+ /**
101
+ * Save All admin settings here
102
+ */
103
+ static public function save_settings() {
104
+
105
+ // Only admins can save settings.
106
+ if ( ! current_user_can( 'manage_options' ) ) {
107
+ return;
108
+ }
109
+
110
+ // Let extensions hook into saving.
111
+ do_action( 'astra_sites_page' );
112
+ }
113
+
114
+ /**
115
+ * Init Nav Menu
116
+ *
117
+ * @param mixed $action Action name.
118
+ * @since 1.0.6
119
+ */
120
+ static public function init_nav_menu( $action = '' ) {
121
+
122
+ if ( '' !== $action ) {
123
+ self::render_tab_menu( $action );
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Render tab menu
129
+ *
130
+ * @param mixed $action Action name.
131
+ * @since 1.0.6
132
+ */
133
+ static public function render_tab_menu( $action = '' ) {
134
+ ?>
135
+ <div id="astra-sites-menu-page">
136
+ <?php self::render( $action ); ?>
137
+ </div>
138
+ <?php
139
+ }
140
+
141
+ /**
142
+ * Prints HTML content for tabs
143
+ *
144
+ * @param mixed $action Action name.
145
+ * @since 1.0.6
146
+ */
147
+ static public function render( $action ) {
148
+
149
+ ?>
150
+ <div class="nav-tab-wrapper">
151
+ <h1 class='astra-sites-title'> <?php echo esc_html( self::$menu_page_title ); ?> </h1>
152
+ </div><!-- .nav-tab-wrapper -->
153
+
154
+ <?php
155
+ // Settings update message.
156
+ if ( isset( $_REQUEST['message'] ) && ( 'saved' == $_REQUEST['message'] || 'saved_ext' == $_REQUEST['message'] ) ) {
157
+ ?>
158
+ <span id="message" class="notice notice-success is-dismissive"><p> <?php esc_html_e( 'Settings saved successfully.', 'astra-sites' ); ?> </p></span>
159
+ <?php
160
+ }
161
+
162
+ }
163
+
164
+ /**
165
+ * Get and return page URL
166
+ *
167
+ * @param string $menu_slug Menu name.
168
+ * @since 1.0.6
169
+ * @return string page url
170
+ */
171
+ static public function get_page_url( $menu_slug ) {
172
+
173
+ $parent_page = self::$default_menu_position;
174
+
175
+ if ( strpos( $parent_page, '?' ) !== false ) {
176
+ $query_var = '&page=' . self::$plugin_slug;
177
+ } else {
178
+ $query_var = '?page=' . self::$plugin_slug;
179
+ }
180
+
181
+ $parent_page_url = admin_url( $parent_page . $query_var );
182
+
183
+ $url = $parent_page_url . '&action=' . $menu_slug;
184
+
185
+ return esc_url( $url );
186
+ }
187
+
188
+ /**
189
+ * Add main menu
190
+ *
191
+ * @since 1.0.6
192
+ */
193
+ static public function add_admin_menu() {
194
+
195
+ $parent_page = self::$default_menu_position;
196
+ $page_title = self::$menu_page_title;
197
+ $capability = 'manage_options';
198
+ $page_menu_slug = self::$plugin_slug;
199
+ $page_menu_func = __CLASS__ . '::menu_callback';
200
+
201
+ add_theme_page( $page_title, $page_title, $capability, $page_menu_slug, $page_menu_func );
202
+ }
203
+
204
+ /**
205
+ * Menu callback
206
+ *
207
+ * @since 1.0.6
208
+ */
209
+ static public function menu_callback() {
210
+
211
+ $current_slug = isset( $_GET['action'] ) ? esc_attr( $_GET['action'] ) : self::$current_slug;
212
+
213
+ $active_tab = str_replace( '_', '-', $current_slug );
214
+ $current_slug = str_replace( '-', '_', $current_slug );
215
+
216
+ ?>
217
+ <div class="astra-sites-menu-page-wrapper">
218
+ <?php self::init_nav_menu( $active_tab ); ?>
219
+ <?php do_action( 'astra_sites_menu_' . esc_attr( $current_slug ) . '_action' ); ?>
220
+ </div>
221
+ <?php
222
+ }
223
+
224
+ /**
225
+ * Include general page
226
+ *
227
+ * @since 1.0.6
228
+ */
229
+ static public function general_page() {
230
+ require_once ASTRA_SITES_DIR . 'admin/view-astra-sites.php';
231
+ }
232
+ }
233
+
234
+ new Astra_Sites_Page;
235
+
236
+ }// End if().
assets/css/admin.css CHANGED
@@ -175,3 +175,19 @@
175
  .astra-sites-preview.expanded .wp-full-overlay-footer {
176
  left: initial;
177
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  .astra-sites-preview.expanded .wp-full-overlay-footer {
176
  left: initial;
177
  }
178
+
179
+ /**
180
+ * Menu Page
181
+ */
182
+ .astra-sites-title {
183
+ float: left;
184
+ font-size: 23px;
185
+ font-weight: 400;
186
+ margin: 0 0 6px 0px;
187
+ padding: 0;
188
+ line-height: 29px;
189
+ }
190
+
191
+ #astra-sites-menu-page {
192
+ margin-top: 10px;
193
+ }
assets/js/admin.js CHANGED
@@ -355,7 +355,7 @@ function renderDemoPreview(anchor) {
355
  // delete any earlier fullscreen preview before we render new one.
356
  jQuery('.theme-install-overlay').remove();
357
 
358
- jQuery('#ast-menu-page').append(template(templateData[0]));
359
  jQuery('.theme-install-overlay').css('display', 'block');
360
  checkNextPrevButtons();
361
 
355
  // delete any earlier fullscreen preview before we render new one.
356
  jQuery('.theme-install-overlay').remove();
357
 
358
+ jQuery('#astra-sites-menu-page').append(template(templateData[0]));
359
  jQuery('.theme-install-overlay').css('display', 'block');
360
  checkNextPrevButtons();
361
 
astra-sites.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Astra Free Sites
4
  * Plugin URI: http://www.wpastra.com/pro/
5
  * Description: Import free sites build with Astra theme.
6
- * Version: 1.0.5
7
  * Author: Brainstorm Force
8
  * Author URI: http://www.brainstormforce.com
9
  * Text Domain: astra-sites
@@ -15,7 +15,7 @@
15
  * Set constants.
16
  */
17
  if ( ! defined( 'ASTRA_SITES_VER' ) ) {
18
- define( 'ASTRA_SITES_VER', '1.0.5' );
19
  }
20
 
21
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
@@ -48,4 +48,3 @@ if ( ! function_exists( 'astra_sites_setup' ) ) :
48
  add_action( 'plugins_loaded', 'astra_sites_setup' );
49
 
50
  endif;
51
-
3
  * Plugin Name: Astra Free Sites
4
  * Plugin URI: http://www.wpastra.com/pro/
5
  * Description: Import free sites build with Astra theme.
6
+ * Version: 1.0.6
7
  * Author: Brainstorm Force
8
  * Author URI: http://www.brainstormforce.com
9
  * Text Domain: astra-sites
15
  * Set constants.
16
  */
17
  if ( ! defined( 'ASTRA_SITES_VER' ) ) {
18
+ define( 'ASTRA_SITES_VER', '1.0.6' );
19
  }
20
 
21
  if ( ! defined( 'ASTRA_SITES_FILE' ) ) {
48
  add_action( 'plugins_loaded', 'astra_sites_setup' );
49
 
50
  endif;
 
classes/class-astra-sites.php CHANGED
@@ -59,7 +59,6 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
59
 
60
  $this->includes();
61
 
62
- add_action( 'wp_enqueue_scripts', array( $this, 'admin_enqueue' ) );
63
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) );
64
  add_action( 'wp_ajax_astra-import-demo', array( $this, 'demo_ajax_import' ) );
65
  add_action( 'wp_ajax_astra-list-sites', array( $this, 'list_demos' ) );
@@ -113,7 +112,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
113
  */
114
  function action_links( $links ) {
115
  $action_links = array(
116
- 'settings' => '<a href="' . admin_url( 'themes.php?page=astra&action=astra-sites' ) . '" aria-label="' . esc_attr__( 'See Library', 'astra-sites' ) . '">' . esc_html__( 'See Library', 'astra-sites' ) . '</a>',
117
  );
118
 
119
  return array_merge( $action_links, $links );
@@ -184,9 +183,18 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
184
  /**
185
  * Enqueue admin scripts.
186
  *
 
 
187
  * @since 1.0.0
 
 
 
188
  */
189
- public function admin_enqueue() {
 
 
 
 
190
 
191
  wp_register_script(
192
  'astra-sites-admin', ASTRA_SITES_URI . 'assets/js/admin.js', array(
@@ -232,7 +240,7 @@ if ( ! class_exists( 'Astra_Sites' ) ) :
232
  */
233
  private function includes() {
234
 
235
- require_once ASTRA_SITES_DIR . 'admin/class-astra-sites-admin.php';
236
  require_once ASTRA_SITES_DIR . 'classes/compatibility/class-astra-sites-compatibility-so-widgets.php';
237
 
238
  // Load the Importers.
59
 
60
  $this->includes();
61
 
 
62
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) );
63
  add_action( 'wp_ajax_astra-import-demo', array( $this, 'demo_ajax_import' ) );
64
  add_action( 'wp_ajax_astra-list-sites', array( $this, 'list_demos' ) );
112
  */
113
  function action_links( $links ) {
114
  $action_links = array(
115
+ 'settings' => '<a href="' . admin_url( 'themes.php?page=astra-sites' ) . '" aria-label="' . esc_attr__( 'See Library', 'astra-sites' ) . '">' . esc_html__( 'See Library', 'astra-sites' ) . '</a>',
116
  );
117
 
118
  return array_merge( $action_links, $links );
183
  /**
184
  * Enqueue admin scripts.
185
  *
186
+ * @since 1.0.5 Added 'getUpgradeText' and 'getUpgradeURL' localize variables.
187
+ *
188
  * @since 1.0.0
189
+ *
190
+ * @param string $hook Current hook name.
191
+ * @return void
192
  */
193
+ public function admin_enqueue( $hook ) {
194
+
195
+ if ( 'appearance_page_astra-sites' !== $hook ) {
196
+ return;
197
+ }
198
 
199
  wp_register_script(
200
  'astra-sites-admin', ASTRA_SITES_URI . 'assets/js/admin.js', array(
240
  */
241
  private function includes() {
242
 
243
+ require_once ASTRA_SITES_DIR . 'admin/class-astra-sites-page.php';
244
  require_once ASTRA_SITES_DIR . 'classes/compatibility/class-astra-sites-compatibility-so-widgets.php';
245
 
246
  // Load the Importers.
importers/class-astra-site-options-import.php CHANGED
@@ -87,31 +87,34 @@ class Astra_Site_Options_Import {
87
 
88
  foreach ( $options as $option_name => $option_value ) {
89
 
90
- // Is option exist in defined array site_options()?
91
- if ( in_array( $option_name, self::site_options() ) ) {
92
-
93
- switch ( $option_name ) {
94
-
95
- // page on front.
96
- // page on front.
97
- case 'page_for_posts':
98
- case 'page_on_front':
99
- $this->update_page_id_by_option_value( $option_name, $option_value );
100
- break;
101
-
102
- // nav menu locations.
103
- case 'nav_menu_locations':
104
- $this->set_nav_menu_locations( $option_value );
105
- break;
106
-
107
- // insert logo.
108
- case 'custom_logo':
109
- $this->insert_logo( $option_value );
110
- break;
111
-
112
- default:
113
- update_option( $option_name, $option_value );
114
- break;
 
 
 
115
  }
116
  }
117
  }
87
 
88
  foreach ( $options as $option_name => $option_value ) {
89
 
90
+ if ( null !== $option_value ) {
91
+
92
+ // Is option exist in defined array site_options()?
93
+ if ( in_array( $option_name, self::site_options() ) ) {
94
+
95
+ switch ( $option_name ) {
96
+
97
+ // page on front.
98
+ // page on front.
99
+ case 'page_for_posts':
100
+ case 'page_on_front':
101
+ $this->update_page_id_by_option_value( $option_name, $option_value );
102
+ break;
103
+
104
+ // nav menu locations.
105
+ case 'nav_menu_locations':
106
+ $this->set_nav_menu_locations( $option_value );
107
+ break;
108
+
109
+ // insert logo.
110
+ case 'custom_logo':
111
+ $this->insert_logo( $option_value );
112
+ break;
113
+
114
+ default:
115
+ update_option( $option_name, $option_value );
116
+ break;
117
+ }
118
  }
119
  }
120
  }
languages/astra-sites.pot CHANGED
@@ -1,10 +1,10 @@
1
  # Copyright (C) 2017 Brainstorm Force
2
- # This file is distributed under the same license as the Astra Sites package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Astra Sites 1.0.5\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
7
- "POT-Creation-Date: 2017-08-29 12:27:58+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -24,7 +24,7 @@ msgstr ""
24
  "X-Textdomain-Support: yes\n"
25
  "X-Generator: grunt-wp-i18n1.0.0\n"
26
 
27
- #. Plugin Name of the plugin/theme
28
  msgid "Astra Sites"
29
  msgstr ""
30
 
@@ -352,12 +352,16 @@ msgstr ""
352
  msgid "Could not update comment #%d with mapped data"
353
  msgstr ""
354
 
 
 
 
 
355
  #. Plugin URI of the plugin/theme
356
  msgid "http://www.wpastra.com/pro/"
357
  msgstr ""
358
 
359
  #. Description of the plugin/theme
360
- msgid "Import sites build with Astra theme."
361
  msgstr ""
362
 
363
  #. Author of the plugin/theme
1
  # Copyright (C) 2017 Brainstorm Force
2
+ # This file is distributed under the same license as the Astra Free Sites package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Astra Free Sites 1.0.6\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/astra-sites\n"
7
+ "POT-Creation-Date: 2017-08-30 12:56:28+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
24
  "X-Textdomain-Support: yes\n"
25
  "X-Generator: grunt-wp-i18n1.0.0\n"
26
 
27
+ #: admin/class-astra-sites-admin.php:63
28
  msgid "Astra Sites"
29
  msgstr ""
30
 
352
  msgid "Could not update comment #%d with mapped data"
353
  msgstr ""
354
 
355
+ #. Plugin Name of the plugin/theme
356
+ msgid "Astra Free Sites"
357
+ msgstr ""
358
+
359
  #. Plugin URI of the plugin/theme
360
  msgid "http://www.wpastra.com/pro/"
361
  msgstr ""
362
 
363
  #. Description of the plugin/theme
364
+ msgid "Import free sites build with Astra theme."
365
  msgstr ""
366
 
367
  #. Author of the plugin/theme
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpastra.com/pro/
4
  Tags: demo, theme demos, one click import
5
  Requires at least: 4.4
6
  Tested up to: 4.8.1
7
- Stable tag: 1.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -46,6 +46,10 @@ https://sites.wpastra.com/law-free/
46
 
47
  == Changelog ==
48
 
 
 
 
 
49
  v1.0.5 - 29-Aug-2017
50
  * New: Added filter `astra_sites_api_args` for adding extra arguments in api call.
51
  * Enhancement: Plugin name updated from `Astra Sites` with `Astra Free Sites`.
4
  Tags: demo, theme demos, one click import
5
  Requires at least: 4.4
6
  Tested up to: 4.8.1
7
+ Stable tag: 1.0.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
46
 
47
  == Changelog ==
48
 
49
+ v1.0.6 - 30-Aug-2017
50
+ * New: Added custom menu for Astra Sites.
51
+ * Fix: Validate site options before storing in database.
52
+
53
  v1.0.5 - 29-Aug-2017
54
  * New: Added filter `astra_sites_api_args` for adding extra arguments in api call.
55
  * Enhancement: Plugin name updated from `Astra Sites` with `Astra Free Sites`.