Genesis Simple Sidebars - Version 2.1.0

Version Description

  • Rewrite based on new plugin boilerplate.
  • Make ID field readonly, rather than disabled.
  • Add header widget area support.
  • Allow for empty ID (auto-generate ID from name).
  • Allow for only alphanumeric characters in ID.
  • Use WordPress native term meta functions.
Download this release

Release Info

Developer nathanrice
Plugin Icon 128x128 Genesis Simple Sidebars
Version 2.1.0
Comparing to
See all releases

Code changes from version 2.0.4 to 2.1.0

Gruntfile.js CHANGED
@@ -20,17 +20,21 @@ module.exports = function(grunt) {
20
 
21
 
22
  // I18n
23
-
24
  // Add text domain as last argument of i18n functions
25
  addtextdomain: {
26
  php: {
27
  options: {
28
  updateDomains: true
29
  },
30
- src: [
31
- '*.php',
32
- 'lib/**/*.php'
33
- ]
 
 
 
 
34
  }
35
  },
36
 
@@ -43,15 +47,15 @@ module.exports = function(grunt) {
43
  '_e:1,2d',
44
  '_x:1,2c,3d',
45
  '_ex:1,2c,3d',
46
- '_n:1,2,4d',
47
  '_nx:1,2,4c,5d',
48
  '_n_noop:1,2,3d',
49
  '_nx_noop:1,2,3c,4d',
50
- 'esc_attr__:1,2d',
51
  'esc_html__:1,2d',
52
- 'esc_attr_e:1,2d',
53
  'esc_html_e:1,2d',
54
- 'esc_attr_x:1,2c,3d',
55
  'esc_html_x:1,2c,3d'
56
  ]
57
  },
@@ -75,7 +79,7 @@ module.exports = function(grunt) {
75
  pot.headers['last-translator'] = 'StudioPress <translations@studiopress.com>';
76
  pot.headers['language-team'] = 'English <translations@studiopress.com>';
77
  pot.headers['plural-forms'] = 'nplurals=2; plural=n != 1;';
78
- pot.headers['x-generator'] = 'grunt-wp-i18n';
79
  pot.headers['x-poedit-basepath'] = '.';
80
  pot.headers['x-poedit-language'] = 'English';
81
  pot.headers['x-poedit-country'] = 'UNITED STATES';
20
 
21
 
22
  // I18n
23
+
24
  // Add text domain as last argument of i18n functions
25
  addtextdomain: {
26
  php: {
27
  options: {
28
  updateDomains: true
29
  },
30
+ target: {
31
+ files: {
32
+ src: [
33
+ '*.php',
34
+ 'lib/**/*.php'
35
+ ]
36
+ }
37
+ }
38
  }
39
  },
40
 
47
  '_e:1,2d',
48
  '_x:1,2c,3d',
49
  '_ex:1,2c,3d',
50
+ '_n:1,2,4d',
51
  '_nx:1,2,4c,5d',
52
  '_n_noop:1,2,3d',
53
  '_nx_noop:1,2,3c,4d',
54
+ 'esc_attr__:1,2d',
55
  'esc_html__:1,2d',
56
+ 'esc_attr_e:1,2d',
57
  'esc_html_e:1,2d',
58
+ 'esc_attr_x:1,2c,3d',
59
  'esc_html_x:1,2c,3d'
60
  ]
61
  },
79
  pot.headers['last-translator'] = 'StudioPress <translations@studiopress.com>';
80
  pot.headers['language-team'] = 'English <translations@studiopress.com>';
81
  pot.headers['plural-forms'] = 'nplurals=2; plural=n != 1;';
82
+ pot.headers['x-generator'] = 'grunt-wp-i18n 0.4.4';
83
  pot.headers['x-poedit-basepath'] = '.';
84
  pot.headers['x-poedit-language'] = 'English';
85
  pot.headers['x-poedit-country'] = 'UNITED STATES';
README.md DELETED
@@ -1 +0,0 @@
1
-
 
genesis-simple-sidebars.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Genesis_Simple_Sidebars {
4
+
5
+ /**
6
+ * Plugin version
7
+ */
8
+ public $plugin_version = '2.1.0';
9
+
10
+ /**
11
+ * Minimum WordPress version.
12
+ */
13
+ public $min_wp_version = '4.7.2';
14
+
15
+ /**
16
+ * Minimum Genesis version.
17
+ */
18
+ public $min_genesis_version = '2.4.2';
19
+
20
+ /**
21
+ * The plugin textdomain, for translations.
22
+ */
23
+ public $plugin_textdomain = 'genesis-simple-sidebars';
24
+
25
+ /**
26
+ * The url to the plugin directory.
27
+ */
28
+ public $plugin_dir_url;
29
+
30
+ /**
31
+ * The path to the plugin directory.
32
+ */
33
+ public $plugin_dir_path;
34
+
35
+ /**
36
+ * The main settings field for this plugin.
37
+ */
38
+ public $settings_field = 'ss-settings';
39
+
40
+ /**
41
+ * Core functions of sidebar registration and output.
42
+ */
43
+ public $core;
44
+
45
+ /**
46
+ * Admin menu and settings page.
47
+ */
48
+ public $admin;
49
+
50
+ /**
51
+ * Entry settings and metadata.
52
+ */
53
+ public $entry;
54
+
55
+ /**
56
+ * Constructor.
57
+ *
58
+ * @since 2.1.0
59
+ */
60
+ public function __construct() {
61
+
62
+ $this->plugin_dir_url = plugin_dir_url( __FILE__ );
63
+ $this->plugin_dir_path = plugin_dir_path( __FILE__ );
64
+
65
+ // For backward compatibility
66
+ define( 'SS_PLUGIN_DIR', $this->plugin_dir_path );
67
+
68
+ }
69
+
70
+ /**
71
+ * Initialize.
72
+ *
73
+ * @since 2.1.0
74
+ */
75
+ public function init() {
76
+
77
+ $this->load_plugin_textdomain();
78
+
79
+ add_action( 'admin_notices', array( $this, 'requirements_notice' ) );
80
+
81
+ $this->includes();
82
+ $this->instantiate();
83
+
84
+ }
85
+
86
+ /**
87
+ * Show admin notice if minimum requirements aren't met.
88
+ *
89
+ * @since 2.1.0
90
+ */
91
+ public function requirements_notice() {
92
+
93
+ if ( ! defined( 'PARENT_THEME_VERSION' ) || ! version_compare( PARENT_THEME_VERSION, $this->min_genesis_version, '>=' ) ) {
94
+
95
+ $action = defined( 'PARENT_THEME_VERSION' ) ? __( 'upgrade to', 'genesis-simple-sidebars' ) : __( 'install and activate', 'genesis-simple-sidebars' );
96
+
97
+ $message = sprintf( __( 'Genesis Simple Sidebars requires WordPress %s and Genesis %s, or greater. Please %s the latest version of <a href="%s" target="_blank">Genesis</a> to use this plugin.', 'genesis-simple-sidebars' ), $this->min_wp_version, $this->min_genesis_version, $action, 'http://my.studiopress.com/?download_id=91046d629e74d525b3f2978e404e7ffa' );
98
+ echo '<div class="notice notice-warning"><p>' . $message . '</p></div>';
99
+
100
+ }
101
+
102
+ }
103
+
104
+ /**
105
+ * Load the plugin textdomain, for translation.
106
+ *
107
+ * @since 2.1.0
108
+ */
109
+ public function load_plugin_textdomain() {
110
+ load_plugin_textdomain( $this->plugin_textdomain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
111
+ }
112
+
113
+ /**
114
+ * All general includes.
115
+ *
116
+ * @since 2.1.0
117
+ */
118
+ public function includes() {
119
+
120
+ require_once( $this->plugin_dir_path . 'includes/functions.php' );
121
+ require_once( $this->plugin_dir_path . 'includes/deprecated.php' );
122
+
123
+ }
124
+
125
+ /**
126
+ * Include the class file, instantiate the classes, create objects.
127
+ *
128
+ * @since 2.1.0
129
+ */
130
+ public function instantiate() {
131
+
132
+ add_action( 'genesis_setup', array( $this, 'genesis_dependencies' ) );
133
+
134
+ }
135
+
136
+ /**
137
+ * Load and instantiate any Genesis dependencies.
138
+ *
139
+ * @since 2.1.0
140
+ */
141
+ public function genesis_dependencies() {
142
+
143
+ require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-core.php' );
144
+ $this->core = new Genesis_Simple_Sidebars_Core;
145
+ $this->core->init();
146
+
147
+ // Anything beyond this point should only be loaded if in the admin.
148
+ if ( ! is_admin() ) {
149
+ return;
150
+ }
151
+
152
+ require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-entry.php' );
153
+ $this->entry = new Genesis_Simple_Sidebars_Entry;
154
+ $this->entry->init();
155
+
156
+ require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-term.php' );
157
+ $this->term = new Genesis_Simple_Sidebars_Term;
158
+ $this->term->init();
159
+
160
+ require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-admin.php' );
161
+ $this->admin = new Genesis_Simple_Sidebars_Admin;
162
+ $this->admin->admin_menu();
163
+
164
+ // For backward compatibility
165
+ global $_genesis_simple_sidebars;
166
+ $_genesis_simple_sidebars = $this->admin;
167
+
168
+ }
169
+
170
+ }
171
+
172
+ /**
173
+ * Helper function to retrieve the static object without using globals.
174
+ *
175
+ * @since 2.1.0
176
+ */
177
+ function Genesis_Simple_Sidebars() {
178
+
179
+ static $object;
180
+
181
+ if ( null == $object ) {
182
+ $object = new Genesis_Simple_Sidebars;
183
+ }
184
+
185
+ return $object;
186
+ }
187
+ /**
188
+ * Initialize the object on `plugins_loaded`.
189
+ */
190
+ add_action( 'plugins_loaded', array( Genesis_Simple_Sidebars(), 'init' ) );
includes/{admin.php → class-genesis-simple-sidebars-admin.php} RENAMED
@@ -13,6 +13,25 @@
13
  */
14
  class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  /**
17
  * Create an admin menu item and settings page.
18
  *
@@ -22,7 +41,7 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
22
  *
23
  * @see Genesis_Admin_Import_Export::actions() Handle creating, editing, and deleting sidebars.
24
  */
25
- public function __construct() {
26
 
27
  $page_id = 'simple-sidebars';
28
 
@@ -34,14 +53,12 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
34
  )
35
  );
36
 
37
- //* Empty, as we'll be building the page manually
38
  $page_ops = array();
39
 
40
- $settings_field = SS_SETTINGS_FIELD;
41
 
42
- $this->create( $page_id, $menu_ops, $page_ops, $settings_field );
43
-
44
- //* Simpe Sidebar actions (create, edit, or delete)
45
  add_action( 'admin_init', array( $this, 'actions' ) );
46
 
47
  }
@@ -56,14 +73,14 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
56
  */
57
  public function admin() {
58
 
59
- $_sidebars = get_option( $this->settings_field );
60
-
61
  echo '<div class="wrap">';
62
 
63
- if ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] )
64
- require_once( SS_PLUGIN_DIR . '/includes/views/edit.php' );
65
- else
66
- require_once( SS_PLUGIN_DIR . '/includes/views/main.php' );
 
 
67
 
68
  echo '</div>';
69
 
@@ -129,8 +146,9 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
129
  */
130
  public function actions() {
131
 
132
- if ( ! genesis_is_menu_page( 'simple-sidebars' ) )
133
  return;
 
134
 
135
  /**
136
  * This section handles the data if a new sidebar is created
@@ -164,8 +182,9 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
164
  */
165
  public function notices() {
166
 
167
- if ( ! genesis_is_menu_page( 'simple-sidebars' ) )
168
  return;
 
169
 
170
  $pattern = '<div id="message" class="updated"><p><strong>%s</strong></p></div>';
171
 
@@ -196,34 +215,50 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
196
  */
197
  protected function create_sidebar( $args = array() ) {
198
 
199
- if ( empty( $args['name'] ) || empty( $args['id'] ) ) {
200
  wp_die( $this->error( 1 ) );
201
  exit;
202
  }
203
 
204
- //* nonce verification
205
  check_admin_referer( 'simple-sidebars-action_create-sidebar' );
206
 
207
- //* WP changes a numeric sidebar id to sidebar-id which makes it inaccessible to the user
208
- if ( is_numeric( $args['id'] ) )
209
- $args['id'] = sanitize_title_with_dashes( $args['name'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
 
211
- $db = (array) get_option( SS_SETTINGS_FIELD );
212
  $new = array(
213
- sanitize_title_with_dashes( $args['id'] ) => array(
214
- 'name' => esc_html( $args['name'] ),
215
  'description' => esc_html( $args['description'] )
216
- )
217
  );
218
 
219
- if ( array_key_exists( $args['id'], $db ) ) {
220
  wp_die( $this->error( 2 ) );
221
  exit;
222
  }
223
 
224
  $_sidebars = wp_parse_args( $new, $db );
225
 
226
- update_option( SS_SETTINGS_FIELD, $_sidebars );
227
  wp_redirect( admin_url( 'admin.php?page=simple-sidebars&created=true' ) );
228
  exit;
229
 
@@ -242,17 +277,13 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
242
  exit;
243
  }
244
 
245
- //* nonce verification
246
  check_admin_referer( 'simple-sidebars-action_edit-sidebar' );
247
 
248
- //* WP changes a numeric sidebar id to sidebar-id which makes it inaccessible to the user
249
- if ( is_numeric( $args['id'] ) )
250
- $args['id'] = sanitize_title_with_dashes( $args['name'] );
251
-
252
- $db = (array) get_option( SS_SETTINGS_FIELD );
253
  $new = array(
254
- sanitize_title_with_dashes( $args['id'] ) => array(
255
- 'name' => esc_html( $args['name'] ),
256
  'description' => esc_html( $args['description'] )
257
  )
258
  );
@@ -264,7 +295,7 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
264
 
265
  $_sidebars = wp_parse_args( $new, $db );
266
 
267
- update_option( SS_SETTINGS_FIELD, $_sidebars );
268
  wp_redirect( admin_url( 'admin.php?page=simple-sidebars&edited=true' ) );
269
  exit;
270
 
@@ -283,10 +314,10 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
283
  exit;
284
  }
285
 
286
- //* nonce verification
287
  check_admin_referer( 'simple-sidebars-action_delete-sidebar' );
288
 
289
- $_sidebars = (array) get_option( SS_SETTINGS_FIELD );
290
 
291
  if ( ! isset( $_sidebars[$id] ) ) {
292
  wp_die( $this->error( 4 ) );
@@ -295,7 +326,7 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
295
 
296
  unset( $_sidebars[$id] );
297
 
298
- update_option( SS_SETTINGS_FIELD, $_sidebars );
299
  wp_redirect( admin_url( 'admin.php?page=simple-sidebars&deleted=true' ) );
300
  exit;
301
 
@@ -316,7 +347,7 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
316
  switch( (int) $error ) {
317
 
318
  case 1:
319
- return __( 'Oops! Please choose a valid Name and ID for this sidebar', 'genesis-simple-sidebars' );
320
  break;
321
  case 2:
322
  return __( 'Oops! That sidebar ID already exists', 'genesis-simple-sidebars' );
@@ -335,17 +366,3 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
335
  }
336
 
337
  }
338
-
339
- add_action( 'genesis_admin_menu', 'simplesidebars_settings_menu' );
340
- /**
341
- * Instantiate the class to create the menu.
342
- *
343
- * @since 1.0.0
344
- */
345
- function simplesidebars_settings_menu() {
346
-
347
- global $_genesis_simple_sidebars_admin;
348
-
349
- $_genesis_simple_sidebars_admin = new Genesis_Simple_Sidebars_Admin;
350
-
351
- }
13
  */
14
  class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
15
 
16
+ /**
17
+ * Settings field.
18
+ *
19
+ * @since 2.1.0
20
+ */
21
+ public $settings_field;
22
+
23
+ /**
24
+ * Constructor.
25
+ */
26
+ public function __construct() {
27
+
28
+ $this->settings_field = Genesis_Simple_Sidebars()->settings_field;
29
+
30
+ // For backward compatibility
31
+ define( 'SS_SETTINGS_FIELD', $this->settings_field );
32
+
33
+ }
34
+
35
  /**
36
  * Create an admin menu item and settings page.
37
  *
41
  *
42
  * @see Genesis_Admin_Import_Export::actions() Handle creating, editing, and deleting sidebars.
43
  */
44
+ public function admin_menu() {
45
 
46
  $page_id = 'simple-sidebars';
47
 
53
  )
54
  );
55
 
56
+ // Empty, as we'll be building the page manually
57
  $page_ops = array();
58
 
59
+ $this->create( $page_id, $menu_ops, $page_ops, $this->settings_field );
60
 
61
+ // Simpe Sidebar actions (create, edit, or delete)
 
 
62
  add_action( 'admin_init', array( $this, 'actions' ) );
63
 
64
  }
73
  */
74
  public function admin() {
75
 
 
 
76
  echo '<div class="wrap">';
77
 
78
+ if ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] ) {
79
+ require_once( Genesis_Simple_Sidebars()->plugin_dir_path . '/includes/views/admin-edit.php' );
80
+ }
81
+ else {
82
+ require_once( Genesis_Simple_Sidebars()->plugin_dir_path . '/includes/views/admin-main.php' );
83
+ }
84
 
85
  echo '</div>';
86
 
146
  */
147
  public function actions() {
148
 
149
+ if ( ! genesis_is_menu_page( 'simple-sidebars' ) ) {
150
  return;
151
+ }
152
 
153
  /**
154
  * This section handles the data if a new sidebar is created
182
  */
183
  public function notices() {
184
 
185
+ if ( ! genesis_is_menu_page( 'simple-sidebars' ) ) {
186
  return;
187
+ }
188
 
189
  $pattern = '<div id="message" class="updated"><p><strong>%s</strong></p></div>';
190
 
215
  */
216
  protected function create_sidebar( $args = array() ) {
217
 
218
+ if ( empty( $args['name'] ) ) {
219
  wp_die( $this->error( 1 ) );
220
  exit;
221
  }
222
 
223
+ // nonce verification
224
  check_admin_referer( 'simple-sidebars-action_create-sidebar' );
225
 
226
+ $db = (array) get_option( $this->settings_field );
227
+
228
+ // Change empty or numeric IDs to the name, lowercased and separated by dashes.
229
+ if ( empty( $args['id'] ) || is_numeric( $args['id'] ) ) {
230
+ $args['id'] = $args['name'];
231
+ }
232
+
233
+ // Strip all but alphanumeric, sanitize with dashes.
234
+ $id = preg_replace( "/[^a-zA-Z0-9 -]+/", "", sanitize_title_with_dashes( $args['id'] ) );
235
+
236
+ // Preface numeric IDs with 'sidebar-'.
237
+ $id = is_numeric( $id ) ? 'gss-sidebar-' . $id : $id;
238
+
239
+ // If empty after all the sanitizing ...
240
+ if ( ! $id || is_registered_sidebar( $id ) ) {
241
+ $n = count( $db ) + 1;
242
+ do {
243
+ $id = 'gss-sidebar-' . $n++;
244
+ } while ( is_registered_sidebar( $id ) );
245
+ }
246
 
 
247
  $new = array(
248
+ $id => array(
249
+ 'name' => esc_html( $args['name'] ),
250
  'description' => esc_html( $args['description'] )
251
+ ),
252
  );
253
 
254
+ if ( array_key_exists( $id, $db ) ) {
255
  wp_die( $this->error( 2 ) );
256
  exit;
257
  }
258
 
259
  $_sidebars = wp_parse_args( $new, $db );
260
 
261
+ update_option( $this->settings_field, $_sidebars );
262
  wp_redirect( admin_url( 'admin.php?page=simple-sidebars&created=true' ) );
263
  exit;
264
 
277
  exit;
278
  }
279
 
280
+ // nonce verification
281
  check_admin_referer( 'simple-sidebars-action_edit-sidebar' );
282
 
283
+ $db = (array) get_option( $this->settings_field );
 
 
 
 
284
  $new = array(
285
+ $args['id'] => array(
286
+ 'name' => esc_html( $args['name'] ),
287
  'description' => esc_html( $args['description'] )
288
  )
289
  );
295
 
296
  $_sidebars = wp_parse_args( $new, $db );
297
 
298
+ update_option( $this->settings_field, $_sidebars );
299
  wp_redirect( admin_url( 'admin.php?page=simple-sidebars&edited=true' ) );
300
  exit;
301
 
314
  exit;
315
  }
316
 
317
+ // nonce verification
318
  check_admin_referer( 'simple-sidebars-action_delete-sidebar' );
319
 
320
+ $_sidebars = (array) get_option( $this->settings_field );
321
 
322
  if ( ! isset( $_sidebars[$id] ) ) {
323
  wp_die( $this->error( 4 ) );
326
 
327
  unset( $_sidebars[$id] );
328
 
329
+ update_option( $this->settings_field, $_sidebars );
330
  wp_redirect( admin_url( 'admin.php?page=simple-sidebars&deleted=true' ) );
331
  exit;
332
 
347
  switch( (int) $error ) {
348
 
349
  case 1:
350
+ return __( 'Oops! Please choose a valid Name for this sidebar', 'genesis-simple-sidebars' );
351
  break;
352
  case 2:
353
  return __( 'Oops! That sidebar ID already exists', 'genesis-simple-sidebars' );
366
  }
367
 
368
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-genesis-simple-sidebars-core.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Controls the core functions of registration and output of Sidebars
5
+ *
6
+ * @since 2.1.0
7
+ */
8
+ class Genesis_Simple_Sidebars_Core {
9
+
10
+ /**
11
+ * The created sidebars.
12
+ */
13
+ private $sidebars;
14
+
15
+ /**
16
+ * Public taxonomies.
17
+ */
18
+ private $public_taxonomies;
19
+
20
+ /**
21
+ * Initialize the class.
22
+ */
23
+ public function init() {
24
+
25
+ add_action( 'after_setup_theme', array( $this, 'backward_compatibility' ) );
26
+ add_action( 'widgets_init', array( $this, 'register_sidebars' ) );
27
+ add_filter( 'sidebars_widgets', array( $this, 'sidebars_widgets_filter' ) );
28
+
29
+ }
30
+
31
+ public function backward_compatibility() {
32
+
33
+ remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
34
+ add_action( 'genesis_sidebar', 'ss_do_sidebar' );
35
+ remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
36
+ add_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
37
+
38
+ }
39
+
40
+ /**
41
+ * Take created sidebars and register them with WordPress.
42
+ *
43
+ * @since 2.1.0
44
+ */
45
+ public function register_sidebars() {
46
+
47
+ $sidebars = $this->get_sidebars();
48
+
49
+ if ( ! $sidebars ) {
50
+ return;
51
+ }
52
+
53
+ // Cycle through created sidebars, register them as widget areas
54
+ foreach ( (array) $sidebars as $id => $info ) {
55
+
56
+ if ( ! isset( $info['name'] ) || ! isset( $info['description'] ) ) {
57
+ continue;
58
+ }
59
+
60
+ genesis_register_sidebar( array(
61
+ 'name' => esc_html( $info['name'] ),
62
+ 'id' => $id,
63
+ 'description' => esc_html( $info['description'] ),
64
+ 'editable' => 1,
65
+ ) );
66
+
67
+ }
68
+
69
+ }
70
+
71
+ /**
72
+ * Filter the widgets in each widget area.
73
+ *
74
+ * @since 2.1.0
75
+ */
76
+ public function sidebars_widgets_filter( $widgets ) {
77
+
78
+ $sidebars = array();
79
+
80
+ if ( is_singular() ) {
81
+
82
+ $sidebars = array(
83
+ 'sidebar' => genesis_get_custom_field( '_ss_sidebar' ),
84
+ 'sidebar-alt' => genesis_get_custom_field( '_ss_sidebar_alt' ),
85
+ 'header-right' => genesis_get_custom_field( '_ss_header' ),
86
+ );
87
+
88
+ }
89
+
90
+ if ( is_tax() || is_category() || is_tag() ) {
91
+
92
+ $sidebars = array(
93
+ 'sidebar' => get_term_meta( get_queried_object()->term_id, '_ss_sidebar', true ),
94
+ 'sidebar-alt' => get_term_meta( get_queried_object()->term_id, '_ss_sidebar_alt', true ),
95
+ 'header-right' => get_term_meta( get_queried_object()->term_id, '_ss_header', true ),
96
+ );
97
+
98
+ }
99
+
100
+ $widgets = $this->swap_widgets( $widgets, $sidebars );
101
+
102
+ return $widgets;
103
+
104
+ }
105
+
106
+ /**
107
+ * Take the $widgets array and swap the contents of each widget area with a custom widget area, if specified.
108
+ *
109
+ * @since 2.1.0
110
+ */
111
+ public function swap_widgets( $widgets, $sidebars ) {
112
+
113
+ if ( is_admin() ) {
114
+ return $widgets;
115
+ }
116
+
117
+ foreach ( (array) $sidebars as $old_sidebar => $new_sidebar ) {
118
+
119
+ if ( ! is_registered_sidebar( $old_sidebar ) ) {
120
+ continue;
121
+ }
122
+
123
+ if ( $new_sidebar && ! empty( $widgets[ $new_sidebar ] ) ) {
124
+ $widgets[ $old_sidebar ] = $widgets[ $new_sidebar ];
125
+ }
126
+
127
+ }
128
+
129
+ return $widgets;
130
+
131
+ }
132
+
133
+ /**
134
+ * Get all custom registered sidebars.
135
+ *
136
+ * @since 2.1.0
137
+ */
138
+ public function get_sidebars( $cache = true ) {
139
+
140
+ if ( ! $cache ) {
141
+ return stripslashes_deep( get_option( Genesis_Simple_Sidebars()->settings_field ) );
142
+ }
143
+
144
+ if ( is_null( $this->sidebars ) ) {
145
+ $this->sidebars = stripslashes_deep( get_option( Genesis_Simple_Sidebars()->settings_field ) );
146
+ }
147
+
148
+ return $this->sidebars;
149
+
150
+ }
151
+
152
+ /**
153
+ * Return taxonomy ids.
154
+ *
155
+ * Helper function to return the array keys from a taxonomy query.
156
+ *
157
+ * @since 2.1.0
158
+ */
159
+ public function get_public_taxonomies() {
160
+
161
+ if ( is_null( $this->public_taxonomies ) ) {
162
+ $this->public_taxonomies = get_taxonomies( array(
163
+ 'show_ui' => true,
164
+ 'public' => true,
165
+ ) );
166
+ }
167
+
168
+ $this->public_taxonomies = apply_filters( 'genesis_simple_sidebars_taxonomies', array_keys( $this->public_taxonomies ) );
169
+
170
+ return $this->public_taxonomies;
171
+
172
+ }
173
+
174
+ /**
175
+ * Determines if this site has disabled 3 column layouts or not.
176
+ *
177
+ * @since 2.1.0
178
+ */
179
+ public function has_3_column_layout() {
180
+
181
+ $layouts = genesis_get_layouts();
182
+
183
+ $three_column_layouts = array(
184
+ 'content-sidebar-sidebar',
185
+ 'sidebar-content-sidebar',
186
+ 'sidebar-sidebar-content',
187
+ );
188
+
189
+ foreach ( $three_column_layouts as $layout ) {
190
+ if ( array_key_exists( $layout, $layouts ) ) {
191
+ return true;
192
+ }
193
+ }
194
+
195
+ return false;
196
+
197
+ }
198
+
199
+ }
includes/class-genesis-simple-sidebars-entry.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Genesis_Simple_Sidebars_Entry {
4
+
5
+ public function init() {
6
+
7
+ add_action( 'admin_menu', array( $this, 'add_metaboxes' ) );
8
+ add_action( 'save_post', array( $this, 'metabox_save' ), 1, 2 );
9
+
10
+ }
11
+
12
+ /**
13
+ * Cycle through supported post types and add metaboxes.
14
+ *
15
+ * @since 2.1.0
16
+ */
17
+ public function add_metaboxes() {
18
+
19
+ foreach ( (array) get_post_types( array( 'public' => true ) ) as $type ) {
20
+
21
+ if ( post_type_supports( $type, 'genesis-simple-sidebars' ) || $type == 'post' || $type == 'page' ) {
22
+ add_meta_box( 'ss_inpost_metabox', __( 'Sidebar Selection', 'genesis-simple-sidebars' ), array( $this, 'metabox_content' ), $type, 'side', 'low' );
23
+ }
24
+
25
+ }
26
+
27
+ }
28
+
29
+ /**
30
+ * Include the metabox content.
31
+ *
32
+ * @since 2.1.0
33
+ */
34
+ public function metabox_content() {
35
+
36
+ require_once( Genesis_Simple_Sidebars()->plugin_dir_path . 'includes/views/entry-metabox-content.php' );
37
+
38
+ }
39
+
40
+ /**
41
+ * Save the metabox fields when the entry is saved.
42
+ *
43
+ * @since 2.1.0
44
+ */
45
+ public function metabox_save( $post_id, $post ) {
46
+
47
+ if ( ! isset( $_POST['genesis_simple_sidebars'] ) ) {
48
+ return;
49
+ }
50
+
51
+ $data = wp_parse_args( $_POST['genesis_simple_sidebars'], array(
52
+ '_ss_header' => '',
53
+ '_ss_sidebar' => '',
54
+ '_ss_sidebar_alt' => '',
55
+ ) );
56
+
57
+ genesis_save_custom_fields( $data, 'genesis-simple-sidebars-save-entry', 'genesis-simple-sidebars-save-entry-nonce', $post );
58
+
59
+ }
60
+
61
+ }
includes/class-genesis-simple-sidebars-term.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Genesis_Simple_Sidebars_Term {
4
+
5
+ public function init() {
6
+
7
+ add_action( 'init', array( $this, 'add_term_fields' ) );
8
+
9
+ }
10
+
11
+ public function add_term_fields() {
12
+
13
+ $taxonomies = Genesis_Simple_Sidebars()->core->get_public_taxonomies();
14
+
15
+ if ( ! empty( $taxonomies ) && is_admin() && is_array( $taxonomies ) ) {
16
+
17
+ foreach ( $taxonomies as $tax ) {
18
+ add_action( "{$tax}_edit_form", array( $this, 'term_sidebar_form' ), 9, 2 );
19
+ }
20
+
21
+ }
22
+
23
+ }
24
+
25
+ public function term_sidebar_form( $tag, $taxonomy ) {
26
+
27
+ require_once( Genesis_Simple_Sidebars()->plugin_dir_path . 'includes/views/term-edit-sidebar-form.php' );
28
+
29
+ }
30
+
31
+ }
includes/deprecated.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Deprecated.
5
+ *
6
+ * @since 0.9.0
7
+ * @deprecated 2.1.0
8
+ */
9
+ function ss_activation_check() {
10
+ _deprecated_function( __FUNCTION__, '2.1.0' );
11
+ }
12
+
13
+ /**
14
+ * Deprecated.
15
+ *
16
+ * @since 1.0.0
17
+ * @deprecated 2.1.0
18
+ */
19
+ function ss_deactivate() {
20
+ _deprecated_function( __FUNCTION__, '2.1.0' );
21
+ }
22
+
23
+ /**
24
+ * Deprecated.
25
+ *
26
+ * @since 0.9.0
27
+ * @deprecated 2.1.0
28
+ */
29
+ function ss_genesis_init() {
30
+ _deprecated_function( __FUNCTION__, '2.1.0' );
31
+ }
32
+
33
+ /**
34
+ * Deprecated.
35
+ *
36
+ * @since 0.9.0
37
+ * @deprecated 2.1.0
38
+ */
39
+ function ss_register_sidebars() {
40
+ _deprecated_function( __FUNCTION__, '2.1.0' );
41
+ }
42
+
43
+ /**
44
+ * Deprecated.
45
+ *
46
+ * @since 0.9.0
47
+ * @deprecated 2.1.0
48
+ */
49
+ function ss_sidebars_init() {
50
+ _deprecated_function( __FUNCTION__, '2.1.0' );
51
+ }
52
+
53
+ /**
54
+ * Deprecated.
55
+ *
56
+ * @since 0.9.0
57
+ * @deprecated 2.1.0
58
+ */
59
+ function ss_do_one_sidebar( $sidebar_key = '' ) {
60
+
61
+ _deprecated_function( __FUNCTION__, '2.1.0', __( 'dynamic_sidebar() with sidebars_widget filter', 'genesis-simple-sidebars' ) );
62
+
63
+ if ( '_ss_sidebar' == $sidebar_key ) {
64
+ genesis_do_sidebar();
65
+ return true;
66
+ }
67
+
68
+ if ( '_ss_sidebar_alt' == $sidebar_key ) {
69
+ genesis_do_sidebar_alt();
70
+ return true;
71
+ }
72
+
73
+ }
74
+
75
+ /**
76
+ * Deprecated.
77
+ *
78
+ * @since 0.9.0
79
+ * @deprecated 2.1.0
80
+ */
81
+ function ss_get_taxonomies() {
82
+ _deprecated_function( __FUNCTION__, '2.1.0' );
83
+ }
84
+
85
+ /**
86
+ * Deprecated.
87
+ *
88
+ * @since 0.9.2
89
+ * @deprecated 2.1.0
90
+ */
91
+ function ss_has_3_column_layouts() {
92
+ _deprecated_function( __FUNCTION__, '2.1.0' );
93
+ }
94
+
95
+ /**
96
+ * Deprecated.
97
+ *
98
+ * @since 1.0.0
99
+ * @deprecated 2.1.0
100
+ */
101
+ function simplesidebars_settings_menu() {
102
+ _deprecated_function( __FUNCTION__, '2.1.0' );
103
+ }
104
+
105
+ /**
106
+ * Deprecated.
107
+ *
108
+ * @since 0.9.0
109
+ * @deprecated 2.1.0
110
+ */
111
+ function ss_add_inpost_metabox() {
112
+ _deprecated_function( __FUNCTION__, '2.1.0' );
113
+ }
114
+
115
+ /**
116
+ * Deprecated.
117
+ *
118
+ * @since 0.9.0
119
+ * @deprecated 2.1.0
120
+ */
121
+ function ss_inpost_metabox() {
122
+ _deprecated_function( __FUNCTION__, '2.1.0' );
123
+ }
124
+
125
+ /**
126
+ * Deprecated.
127
+ *
128
+ * @since 0.9.0
129
+ * @deprecated 2.1.0
130
+ */
131
+ function ss_inpost_metabox_save() {
132
+ _deprecated_function( __FUNCTION__, '2.1.0' );
133
+ }
134
+
135
+ /**
136
+ * Deprecated.
137
+ *
138
+ * @since 0.9.0
139
+ * @deprecated 2.1.0
140
+ */
141
+ function ss_term_edit_init() {
142
+ _deprecated_function( __FUNCTION__, '2.1.0' );
143
+ }
144
+
145
+ /**
146
+ * Deprecated.
147
+ *
148
+ * @since 0.9.0
149
+ * @deprecated 2.1.0
150
+ */
151
+ function ss_term_sidebar() {
152
+ _deprecated_function( __FUNCTION__, '2.1.0' );
153
+ }
includes/functions.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Dummy function for backward compatibility. Outputs the primary sidebar.
5
+ *
6
+ * @since 0.9.0
7
+ */
8
+ function ss_do_sidebar() {
9
+ genesis_do_sidebar();
10
+ }
11
+
12
+ /**
13
+ * Dummy function for backward compatibility. Outputs the secondary sidebar.
14
+ *
15
+ * @since 0.9.0
16
+ */
17
+ function ss_do_sidebar_alt() {
18
+ genesis_do_sidebar_alt();
19
+ }
includes/inpost.php DELETED
@@ -1,102 +0,0 @@
1
- <?php
2
- add_action('admin_menu', 'ss_add_inpost_metabox');
3
- /**
4
- * This bit of code registers the meta box on posts/pages,
5
- * so that users can choose what sidebar to use.
6
- */
7
- function ss_add_inpost_metabox() {
8
-
9
- foreach ( (array) get_post_types( array( 'public' => true ) ) as $type ) {
10
-
11
- if ( post_type_supports( $type, 'genesis-simple-sidebars' ) || $type == 'post' || $type == 'page' ) {
12
- add_meta_box( 'ss_inpost_metabox', __( 'Sidebar Selection', 'genesis-simple-sidebars' ), 'ss_inpost_metabox', $type, 'side', 'low' );
13
- }
14
-
15
- }
16
-
17
- }
18
-
19
- function ss_inpost_metabox() {
20
-
21
- $_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
22
- global $wp_registered_sidebars;
23
-
24
- ?>
25
-
26
- <input type="hidden" name="ss_inpost_nonce" value="<?php echo wp_create_nonce( plugin_basename( __FILE__ ) ); ?>" />
27
-
28
- <?php
29
- if( isset( $wp_registered_sidebars['sidebar'] ) ) {
30
- ?>
31
-
32
- <p>
33
- <label class="howto" for="_ss_sidebar"><span><?php echo esc_attr( $wp_registered_sidebars['sidebar']['name'] ); ?><span></label>
34
- <select name="_ss_sidebar" id="_ss_sidebar" style="width: 99%">
35
- <option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
36
- <?php
37
- foreach ( (array) $_sidebars as $id => $info ) {
38
- printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field( '_ss_sidebar' ), false), esc_html( $info['name'] ) );
39
- }
40
- ?>
41
- </select>
42
- </p>
43
- <?php
44
- }
45
- if( isset( $wp_registered_sidebars['sidebar-alt'] ) ) {
46
- ?>
47
- <p>
48
- <label class="howto" for="_ss_sidebar_alt"><span><?php echo esc_attr( $wp_registered_sidebars['sidebar-alt']['name'] ); ?><span></label>
49
- <select name="_ss_sidebar_alt" id="_ss_sidebar_alt" style="width: 99%">
50
- <option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
51
- <?php
52
- foreach ( (array) $_sidebars as $id => $info ) {
53
- printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field( '_ss_sidebar_alt' ), false ), esc_html( $info['name'] ) );
54
- }
55
- ?>
56
- </select>
57
- </p>
58
-
59
- <?php
60
- }
61
- }
62
-
63
- add_action( 'save_post', 'ss_inpost_metabox_save', 1, 2 );
64
- /**
65
- * This bit of code saves the sidebars chosen as post meta.
66
- */
67
- function ss_inpost_metabox_save( $post_id, $post ) {
68
-
69
- //* verify the nonce
70
- if ( !isset($_POST['ss_inpost_nonce']) || !wp_verify_nonce( $_POST['ss_inpost_nonce'], plugin_basename(__FILE__) ) )
71
- return $post->ID;
72
-
73
- //* don't try to save the data under autosave, ajax, or future post.
74
- if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
75
- if ( defined('DOING_AJAX') && DOING_AJAX ) return;
76
- if ( defined('DOING_CRON') && DOING_CRON ) return;
77
-
78
- //* is the user allowed to edit the post or page?
79
- if ( ( 'page' == $_POST['post_type'] && ! current_user_can( 'edit_page', $post->ID ) ) || ! current_user_can( 'edit_post', $post->ID ) )
80
- return $post->ID;
81
-
82
- $_sidebars = array(
83
- '_ss_sidebar' => isset( $_POST['_ss_sidebar'] ) ? $_POST['_ss_sidebar'] : '',
84
- '_ss_sidebar_alt' => isset( $_POST['_ss_sidebar_alt'] ) ? $_POST['_ss_sidebar_alt'] : '',
85
- );
86
-
87
- //* store the custom fields
88
- foreach ( $_sidebars as $key => $value ) {
89
-
90
- //* don't try to store data during revision save
91
- if ( 'revision' === $post->post_type )
92
- return;
93
-
94
- if ( $value ) {
95
- update_post_meta($post->ID, $key, $value);
96
- } else {
97
- delete_post_meta($post->ID, $key);
98
- }
99
-
100
- }
101
-
102
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/term.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
- /**
3
- * This function, hooked to display on the category/tag edit forms,
4
- * adds new fields to select a sidebar. The variables $tag and $taxonomy
5
- * are passed via the hook so that we can use them.
6
- */
7
- function ss_term_edit_init() {
8
-
9
- $taxonomies = ss_get_taxonomies();
10
-
11
- if ( ! empty( $taxonomies ) && is_admin() && is_array( $taxonomies ) ) {
12
-
13
- foreach( $taxonomies as $tax )
14
- add_action( "{$tax}_edit_form", 'ss_term_sidebar', 9, 2 );
15
-
16
- }
17
-
18
- }
19
-
20
- function ss_term_sidebar($tag, $taxonomy) {
21
-
22
- //* Merge Defaults to prevent notices
23
- $tag->meta = wp_parse_args( $tag->meta, array( '_ss_sidebar' => '', '_ss_sidebar_alt' => '' ) );
24
-
25
- //* Pull custom sidebars
26
- $_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
27
-
28
- ?>
29
-
30
- <h3><?php _e( 'Sidebar Options', 'genesis-simple-sidebars' ); ?></h3>
31
- <table class="form-table">
32
-
33
- <tr class="form-field">
34
- <th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar]"><?php _e( 'Primary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
35
- <td>
36
- <select name="genesis-meta[_ss_sidebar]" id="genesis-meta[_ss_sidebar]" style="padding-right: 10px;">
37
- <option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
38
- <?php
39
- foreach ( (array) $_sidebars as $id => $info ) {
40
- printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_sidebar', true ), false), esc_html( $info['name'] ) );
41
- }
42
- ?>
43
- </select>
44
- </td>
45
- </tr>
46
- <?php
47
- //* don't show the option if there are no 3 column layouts registered
48
- if ( ss_has_3_column_layouts() ) {
49
- ?>
50
- <tr class="form-field">
51
- <th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar_alt]"><?php _e( 'Secondary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
52
- <td>
53
- <select name="genesis-meta[_ss_sidebar_alt]" id="genesis-meta[_ss_sidebar_alt]" style="padding-right: 10px;">
54
- <option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
55
- <?php
56
- foreach ( (array) $_sidebars as $id => $info ) {
57
- printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_sidebar_alt', true ), false), esc_html( $info['name'] ) );
58
- }
59
- ?>
60
- </select>
61
- </td>
62
- </tr>
63
- <?php
64
- }
65
- ?>
66
- </table>
67
-
68
- <?php
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/views/{edit.php → admin-edit.php} RENAMED
@@ -1,12 +1,13 @@
1
  <?php
2
- if ( array_key_exists( $_REQUEST['id'], (array) $_sidebars ) ) {
3
- $_sidebar = stripslashes_deep( $_sidebars[$_REQUEST['id']] );
 
 
4
  } else {
5
  wp_die( __( 'Nice try, partner. But that sidebar doesn\'t exist. Click back and try again.', 'genesis-simple-sidebars' ) );
6
  }
7
-
8
- screen_icon( 'themes' ); ?>
9
- <h2><?php _e( 'Edit Sidebar', 'genesis-simple-sidebars' ); ?></h2>
10
 
11
  <form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&amp;action=edit' ); ?>">
12
  <?php wp_nonce_field( 'simple-sidebars-action_edit-sidebar' ); ?>
@@ -15,21 +16,21 @@ screen_icon( 'themes' ); ?>
15
 
16
  <tr class="form-field">
17
  <th scope="row" valign="top"><label for="edit_sidebar[name]"><?php _e( 'Name', 'genesis-simple-sidebars' ); ?></label></th>
18
- <td><input name="edit_sidebar[name]" id="edit_sidebar[name]" type="text" value="<?php echo esc_html( $_sidebar['name'] ); ?>" size="40" />
19
  <p class="description"><?php _e( 'A recognizable name for your new sidebar widget area', 'genesis-simple-sidebars' ); ?></p></td>
20
  </tr>
21
 
22
  <tr class="form-field">
23
  <th scope="row" valign="top"><label for="edit_sidebar[id]"><?php _e( 'ID', 'genesis-simple-sidebars' ); ?></label></th>
24
  <td>
25
- <input type="text" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" disabled="disabled" />
26
  <input name="edit_sidebar[id]" id="edit_sidebar[id]" type="hidden" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" />
27
  <p class="description"><?php _e( 'The unique ID is used to register the sidebar widget area (cannot be changed)', 'genesis-simple-sidebars' ); ?></p></td>
28
  </tr>
29
 
30
  <tr class="form-field">
31
  <th scope="row" valign="top"><label for="edit_sidebar[description]"><?php _e( 'Description', 'genesis-simple-sidebars' ); ?></label></th>
32
- <td><textarea name="edit_sidebar[description]" id="edit_sidebar[description]" rows="3" cols="50" style="width: 97%;"><?php echo esc_html( $_sidebar['description'] ); ?></textarea></td>
33
  </tr>
34
 
35
  </table>
1
  <?php
2
+ $sidebars = Genesis_Simple_Sidebars()->core->get_sidebars();
3
+
4
+ if ( array_key_exists( $_REQUEST['id'], (array) $sidebars ) ) {
5
+ $sidebar = stripslashes_deep( $sidebars[ $_REQUEST['id'] ] );
6
  } else {
7
  wp_die( __( 'Nice try, partner. But that sidebar doesn\'t exist. Click back and try again.', 'genesis-simple-sidebars' ) );
8
  }
9
+ ?>
10
+ <h1><?php _e( 'Edit Sidebar', 'genesis-simple-sidebars' ); ?></h1>
 
11
 
12
  <form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&amp;action=edit' ); ?>">
13
  <?php wp_nonce_field( 'simple-sidebars-action_edit-sidebar' ); ?>
16
 
17
  <tr class="form-field">
18
  <th scope="row" valign="top"><label for="edit_sidebar[name]"><?php _e( 'Name', 'genesis-simple-sidebars' ); ?></label></th>
19
+ <td><input name="edit_sidebar[name]" id="edit_sidebar[name]" type="text" value="<?php echo esc_html( $sidebar['name'] ); ?>" size="40" />
20
  <p class="description"><?php _e( 'A recognizable name for your new sidebar widget area', 'genesis-simple-sidebars' ); ?></p></td>
21
  </tr>
22
 
23
  <tr class="form-field">
24
  <th scope="row" valign="top"><label for="edit_sidebar[id]"><?php _e( 'ID', 'genesis-simple-sidebars' ); ?></label></th>
25
  <td>
26
+ <input type="text" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" readonly />
27
  <input name="edit_sidebar[id]" id="edit_sidebar[id]" type="hidden" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" />
28
  <p class="description"><?php _e( 'The unique ID is used to register the sidebar widget area (cannot be changed)', 'genesis-simple-sidebars' ); ?></p></td>
29
  </tr>
30
 
31
  <tr class="form-field">
32
  <th scope="row" valign="top"><label for="edit_sidebar[description]"><?php _e( 'Description', 'genesis-simple-sidebars' ); ?></label></th>
33
+ <td><textarea name="edit_sidebar[description]" id="edit_sidebar[description]" rows="3" cols="50" style="width: 97%;"><?php echo esc_html( $sidebar['description'] ); ?></textarea></td>
34
  </tr>
35
 
36
  </table>
includes/views/{main.php → admin-main.php} RENAMED
@@ -1,5 +1,4 @@
1
- <?php screen_icon( 'themes' ); ?>
2
- <h2><?php _e( 'Genesis - Simple Sidebars', 'genesis-simple-sidebars' ); ?></h2>
3
 
4
  <div id="col-container">
5
 
@@ -67,4 +66,4 @@
67
  </div>
68
  </div><!-- /col-left -->
69
 
70
- </div><!-- /col-container -->
1
+ <h1><?php _e( 'Genesis - Simple Sidebars', 'genesis-simple-sidebars' ); ?></h1>
 
2
 
3
  <div id="col-container">
4
 
66
  </div>
67
  </div><!-- /col-left -->
68
 
69
+ </div><!-- /col-container -->
includes/views/entry-metabox-content.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $sidebars = Genesis_Simple_Sidebars()->core->get_sidebars();
3
+ global $wp_registered_sidebars;
4
+ wp_nonce_field( 'genesis-simple-sidebars-save-entry', 'genesis-simple-sidebars-save-entry-nonce' );
5
+
6
+ if ( is_registered_sidebar( 'header-right' ) ) : ?>
7
+ <p>
8
+ <label class="howto" for="genesis_simple_sidebars[_ss_header]"><span><?php echo esc_attr( $wp_registered_sidebars['header-right']['name'] ); ?><span></label>
9
+ <select name="genesis_simple_sidebars[_ss_header]" id="genesis_simple_sidebars[_ss_header]" style="width: 99%">
10
+ <option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
11
+ <?php
12
+ foreach ( (array) $sidebars as $id => $info ) {
13
+ printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field( '_ss_header' ), false), esc_html( $info['name'] ) );
14
+ }
15
+ ?>
16
+ </select>
17
+ </p>
18
+ <?php endif;
19
+
20
+ if ( is_registered_sidebar( 'sidebar' ) ) : ?>
21
+ <p>
22
+ <label class="howto" for="genesis_simple_sidebars[_ss_sidebar]"><span><?php echo esc_attr( $wp_registered_sidebars['sidebar']['name'] ); ?><span></label>
23
+ <select name="genesis_simple_sidebars[_ss_sidebar]" id="genesis_simple_sidebars[_ss_sidebar]" style="width: 99%">
24
+ <option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
25
+ <?php
26
+ foreach ( (array) $sidebars as $id => $info ) {
27
+ printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field( '_ss_sidebar' ), false), esc_html( $info['name'] ) );
28
+ }
29
+ ?>
30
+ </select>
31
+ </p>
32
+ <?php endif;
33
+
34
+ if ( is_registered_sidebar( 'sidebar-alt' ) ) : ?>
35
+ <p>
36
+ <label class="howto" for="genesis_simple_sidebars[_ss_sidebar_alt]"><span><?php echo esc_attr( $wp_registered_sidebars['sidebar-alt']['name'] ); ?><span></label>
37
+ <select name="genesis_simple_sidebars[_ss_sidebar_alt]" id="genesis_simple_sidebars[_ss_sidebar_alt]" style="width: 99%">
38
+ <option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
39
+ <?php
40
+ foreach ( (array) $sidebars as $id => $info ) {
41
+ printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field( '_ss_sidebar_alt' ), false ), esc_html( $info['name'] ) );
42
+ }
43
+ ?>
44
+ </select>
45
+ </p>
46
+ <?php endif;
includes/views/term-edit-sidebar-form.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $sidebars = Genesis_Simple_Sidebars()->core->get_sidebars(); ?>
2
+
3
+ <h3><?php _e( 'Sidebar Options', 'genesis-simple-sidebars' ); ?></h3>
4
+ <table class="form-table">
5
+
6
+ <?php if ( is_registered_sidebar( 'header-right' ) ) : ?>
7
+ <tr class="form-field">
8
+ <th scope="row" valign="top"><label for="genesis-meta[_ss_header]"><?php _e( 'Header Right', 'genesis-simple-sidebars' ); ?></label></th>
9
+ <td>
10
+ <select name="genesis-meta[_ss_header]" id="genesis-meta[_ss_header]" style="padding-right: 10px;">
11
+ <option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
12
+ <?php
13
+ foreach ( (array) $sidebars as $id => $info ) {
14
+ printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_header', true ), false), esc_html( $info['name'] ) );
15
+ }
16
+ ?>
17
+ </select>
18
+ </td>
19
+ </tr>
20
+ <?php endif; ?>
21
+
22
+ <tr class="form-field">
23
+ <th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar]"><?php _e( 'Primary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
24
+ <td>
25
+ <select name="genesis-meta[_ss_sidebar]" id="genesis-meta[_ss_sidebar]" style="padding-right: 10px;">
26
+ <option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
27
+ <?php
28
+ foreach ( (array) $sidebars as $id => $info ) {
29
+ printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_sidebar', true ), false), esc_html( $info['name'] ) );
30
+ }
31
+ ?>
32
+ </select>
33
+ </td>
34
+ </tr>
35
+
36
+ <?php if ( Genesis_Simple_Sidebars()->core->has_3_column_layout() ) : ?>
37
+ <tr class="form-field">
38
+ <th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar_alt]"><?php _e( 'Secondary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
39
+ <td>
40
+ <select name="genesis-meta[_ss_sidebar_alt]" id="genesis-meta[_ss_sidebar_alt]" style="padding-right: 10px;">
41
+ <option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
42
+ <?php
43
+ foreach ( (array) $sidebars as $id => $info ) {
44
+ printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_sidebar_alt', true ) , false), esc_html( $info['name'] ) );
45
+ }
46
+ ?>
47
+ </select>
48
+ </td>
49
+ </tr>
50
+ <?php endif; ?>
51
+ </table>
languages/genesis-simple-sidebars.pot CHANGED
@@ -1,17 +1,17 @@
1
- # Copyright (C) 2016 Nathan Rice
2
  # This file is distributed under the GNU General Public License v2.0 (or later).
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Genesis Simple Sidebars 2.0.3\n"
6
  "Report-Msgid-Bugs-To: StudioPress <translations@studiopress.com>\n"
7
- "POT-Creation-Date: 2016-02-24 19:51:21+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: StudioPress <translations@studiopress.com>\n"
13
  "Language-Team: English <translations@studiopress.com>\n"
14
- "X-Generator: grunt-wp-i18n\n"
15
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
16
  "X-Poedit-Basepath: .\n"
17
  "X-Poedit-Language: English\n"
1
+ # Copyright (C) 2015 Nathan Rice
2
  # This file is distributed under the GNU General Public License v2.0 (or later).
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Genesis Simple Sidebars 2.0.2\n"
6
  "Report-Msgid-Bugs-To: StudioPress <translations@studiopress.com>\n"
7
+ "POT-Creation-Date: 2015-09-29 20:53:32+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: 2015-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: StudioPress <translations@studiopress.com>\n"
13
  "Language-Team: English <translations@studiopress.com>\n"
14
+ "X-Generator: grunt-wp-i18n 0.4.4\n"
15
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
16
  "X-Poedit-Basepath: .\n"
17
  "X-Poedit-Language: English\n"
package.json CHANGED
@@ -7,21 +7,21 @@
7
  },
8
  "dependencies": {},
9
  "devDependencies": {
10
- "grunt": "*",
11
- "grunt-autoprefixer": "*",
12
- "grunt-checktextdomain": "*",
13
- "grunt-contrib-cssmin": "*",
14
- "grunt-contrib-imagemin": "*",
15
- "grunt-contrib-jshint": "*",
16
- "grunt-contrib-uglify": "*",
17
- "grunt-contrib-watch": "*",
18
- "grunt-csscomb": "*",
19
- "grunt-jsbeautifier": "*",
20
- "grunt-jsvalidate": "*",
21
- "grunt-phplint": "*",
22
- "grunt-styledocco": "*",
23
- "grunt-wp-i18n": "*",
24
- "load-grunt-tasks": "*"
25
  },
26
  "plugin": {
27
  "name": "Genesis Simple Sidebars",
@@ -29,7 +29,7 @@
29
  "description": "Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.",
30
  "author": "StudioPress",
31
  "authoruri": "http://www.studiopress.com/",
32
- "version": "2.0.4",
33
  "license": "GPL-2.0+",
34
  "licenseuri": "http://www.gnu.org/licenses/gpl-2.0.html",
35
  "textdomain": "genesis-simple-sidebars"
7
  },
8
  "dependencies": {},
9
  "devDependencies": {
10
+ "grunt": "^0.4.5",
11
+ "grunt-autoprefixer": "^0.8.1",
12
+ "grunt-checktextdomain": "^0.1.1",
13
+ "grunt-contrib-cssmin": "^0.10.0",
14
+ "grunt-contrib-imagemin": "^0.7.1",
15
+ "grunt-contrib-jshint": "^0.10.0",
16
+ "grunt-contrib-uglify": "^0.5.0",
17
+ "grunt-contrib-watch": "^0.6.1",
18
+ "grunt-csscomb": "~2.0.1",
19
+ "grunt-jsbeautifier": "^0.2.7",
20
+ "grunt-jsvalidate": "^0.2.2",
21
+ "grunt-phplint": "0.0.5",
22
+ "grunt-styledocco": "^0.1.4",
23
+ "grunt-wp-i18n": "^0.4.7",
24
+ "load-grunt-tasks": "^0.6.0"
25
  },
26
  "plugin": {
27
  "name": "Genesis Simple Sidebars",
29
  "description": "Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.",
30
  "author": "StudioPress",
31
  "authoruri": "http://www.studiopress.com/",
32
+ "version": "2.0.2",
33
  "license": "GPL-2.0+",
34
  "licenseuri": "http://www.gnu.org/licenses/gpl-2.0.html",
35
  "textdomain": "genesis-simple-sidebars"
plugin.php CHANGED
@@ -2,224 +2,19 @@
2
  /*
3
  Plugin Name: Genesis Simple Sidebars
4
  Plugin URI: http://www.studiopress.com/plugins/simple-sidebars
 
5
  Description: Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.
6
- Author: Nathan Rice
7
- Author URI: http://www.nathanrice.net/
8
 
9
- Text Domain: genesis-simple-sidebars
10
- Domain Path: /languages
 
 
11
 
12
- Version: 2.0.4
 
13
 
14
  License: GNU General Public License v2.0 (or later)
15
  License URI: http://www.opensource.org/licenses/gpl-license.php
16
  */
17
 
18
- /** Define our constants */
19
- define( 'SS_SETTINGS_FIELD', 'ss-settings' );
20
- define( 'SS_PLUGIN_DIR', dirname( __FILE__ ) );
21
-
22
- register_activation_hook( __FILE__, 'ss_activation_check' );
23
- /**
24
- * Activation hook callback.
25
- *
26
- * This functions runs when the plugin is activated. It checks to make sure the user is running
27
- * a minimum Genesis version, so there are no conflicts or fatal errors.
28
- *
29
- * @since 0.9.0
30
- */
31
- function ss_activation_check() {
32
-
33
- if ( ! defined( 'PARENT_THEME_VERSION' ) || ! version_compare( PARENT_THEME_VERSION, '2.3.0', '>=' ) )
34
- ss_deactivate( '2.3.0', '4.4.2' );
35
-
36
- }
37
-
38
- /**
39
- * Deactivate Simple Sidebars.
40
- *
41
- * This function deactivates Simple Sidebars.
42
- *
43
- * @since 1.0.0
44
- */
45
- function ss_deactivate( $genesis_version = '2.3.0', $wp_version = '4.4.2' ) {
46
-
47
- deactivate_plugins( plugin_basename( __FILE__ ) );
48
- wp_die( sprintf( __( 'Sorry, you cannot run Simple Sidebars without WordPress %s and <a href="%s">Genesis %s</a>, or greater.', 'genesis-simple-sidebars' ), $wp_version, 'http://my.studiopress.com/?download_id=91046d629e74d525b3f2978e404e7ffa', $genesis_version ) );
49
-
50
- }
51
-
52
- add_action( 'genesis_init', 'ss_genesis_init', 12 );
53
- /**
54
- * Plugin initialization.
55
- *
56
- * Initialize the plugin, set the constants, hook callbacks to actions, and include the plugin library.
57
- *
58
- * @since 0.9.0
59
- */
60
- function ss_genesis_init() {
61
-
62
- //* Deactivate if not running Genesis 1.8.0 or greater
63
- if ( ! class_exists( 'Genesis_Admin_Boxes' ) )
64
- add_action( 'admin_init', 'ss_deactivate', 10, 0 );
65
-
66
- //* Load translations
67
- load_plugin_textdomain( 'genesis-simple-sidebars', false, 'genesis-simple-sidebars/languages' );
68
-
69
- //* required hooks
70
- add_action( 'get_header', 'ss_sidebars_init' );
71
- add_action( 'widgets_init', 'ss_register_sidebars' );
72
-
73
- //* The rest is admin stuff, so load only if we're in the admin area
74
- if ( ! is_admin() )
75
- return;
76
-
77
- //* Include admin files
78
- require_once( SS_PLUGIN_DIR . '/includes/admin.php' );
79
- require_once( SS_PLUGIN_DIR . '/includes/inpost.php' );
80
- require_once( SS_PLUGIN_DIR . '/includes/term.php' );
81
-
82
- //* let the child theme hook the genesis_simple_sidebars_taxonomies filter before hooking term edit
83
- add_action( 'init', 'ss_term_edit_init' );
84
-
85
- }
86
- /**
87
- * Register widget areas.
88
- *
89
- * This function registers the created sidebars as widget areas
90
- *
91
- * @since 0.9.0
92
- */
93
- function ss_register_sidebars() {
94
-
95
- $_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
96
-
97
- //* If no sidebars have been created, do nothing
98
- if ( ! $_sidebars )
99
- return;
100
-
101
- //* Cycle through created sidebars, register them as widget areas
102
- foreach ( (array) $_sidebars as $id => $info ) {
103
-
104
- if ( ! isset( $info['name'] ) || ! isset( $info['description'] ) ) {
105
- continue;
106
- }
107
-
108
- genesis_register_sidebar( array(
109
- 'name' => esc_html( $info['name'] ),
110
- 'id' => $id,
111
- 'description' => esc_html( $info['description'] ),
112
- 'editable' => 1,
113
- ) );
114
-
115
- }
116
-
117
- }
118
-
119
- /**
120
- * Use custom sidebars.
121
- *
122
- * Remove the default sidebars, run some conditional logic,
123
- * use alternate sidebars if necessary, else fallback on default sidebars.
124
- *
125
- * @since 0.9.0
126
- */
127
- function ss_sidebars_init() {
128
-
129
- remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
130
- remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
131
- add_action( 'genesis_sidebar', 'ss_do_sidebar' );
132
- add_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
133
-
134
- }
135
-
136
- /**
137
- * Display primary sidebar.
138
- *
139
- * Display custom sidebar if one exists, else display default primary sidebar.
140
- *
141
- * @since 0.9.0
142
- */
143
- function ss_do_sidebar() {
144
-
145
- if ( ! ss_do_one_sidebar( '_ss_sidebar' ) )
146
- genesis_do_sidebar();
147
-
148
- }
149
-
150
- /**
151
- * Display secondary sidebar.
152
- *
153
- * Display custom sidebar if one exists, else display default secondary sidebar.
154
- *
155
- * @since 0.9.0
156
- */
157
- function ss_do_sidebar_alt() {
158
-
159
- if ( ! ss_do_one_sidebar( '_ss_sidebar_alt' ) )
160
- genesis_do_sidebar_alt();
161
-
162
- }
163
-
164
- /**
165
- * Sidebar widget area output.
166
- *
167
- * Helper function to show widgets in a particular sidebar.
168
- *
169
- * @param string $sidebar_key sidebar id you wish to output.
170
- *
171
- * @since 0.9.0
172
- *
173
- */
174
- function ss_do_one_sidebar( $sidebar_key = '_ss_sidebar' ) {
175
-
176
- if ( is_singular() && $sidebar_key = genesis_get_custom_field( $sidebar_key ) ) {
177
- if ( dynamic_sidebar( $sidebar_key ) ) {
178
- return true;
179
- }
180
- }
181
-
182
- if ( is_tax() || is_category() || is_tag() ) {
183
-
184
- if ( $sidebar_key = get_term_meta( get_queried_object()->term_id, $sidebar_key, true ) ) {
185
- dynamic_sidebar( $sidebar_key );
186
- return true;
187
- }
188
-
189
- }
190
-
191
- return false;
192
-
193
- }
194
-
195
- /**
196
- * Return taxonomy ids.
197
- *
198
- * Helper function to return the array keys from a taxonomy query.
199
- *
200
- * @since 0.9.0
201
- */
202
- function ss_get_taxonomies() {
203
-
204
- $taxonomies = get_taxonomies( array( 'show_ui' => true, 'public' => true ) );
205
- return apply_filters( 'genesis_simple_sidebars_taxonomies', array_keys( $taxonomies ) );
206
-
207
- }
208
-
209
- /**
210
- * Does this Genesis install have the 3 column layouts deactivated?
211
- *
212
- * This function checks to see if the Genesis install still has active 3 column layouts. Since
213
- * child themes and plugins can deregister layouts, we need to know if they have deregistered the 3 column layouts.
214
- *
215
- * @since 0.9.2
216
- */
217
- function ss_has_3_column_layouts() {
218
-
219
- $_layouts = (array) genesis_get_layouts();
220
- $_layouts = array_keys( $_layouts );
221
- $_3_column = array_intersect( $_layouts, array( 'content-sidebar-sidebar', 'sidebar-content-sidebar', 'sidebar-sidebar-content' ) );
222
-
223
- return ! empty( $_3_column );
224
-
225
- }
2
  /*
3
  Plugin Name: Genesis Simple Sidebars
4
  Plugin URI: http://www.studiopress.com/plugins/simple-sidebars
5
+
6
  Description: Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.
 
 
7
 
8
+ Author: StudioPress
9
+ Author URI: http://www.studiopress.com/
10
+
11
+ Version: 2.1.0
12
 
13
+ Text Domain: genesis-simple-sidebars
14
+ Domain Path: /languages/
15
 
16
  License: GNU General Public License v2.0 (or later)
17
  License URI: http://www.opensource.org/licenses/gpl-license.php
18
  */
19
 
20
+ require_once( plugin_dir_path( __FILE__ ) . 'genesis-simple-sidebars.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Plugin Name ===
2
- Contributors: nathanrice, wpmuguru, studiopress
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118
4
  Tags: hooks, genesis, genesiswp, studiopress
5
- Requires at least: 3.6
6
- Tested up to: 4.5
7
- Stable tag: 2.0.4
8
 
9
  This plugin allows you to create multiple, dynamic widget areas, and assign those widget areas to sidebar locations within the Genesis Framework on a per post, per page, or per tag/category archive basis.
10
 
@@ -37,49 +37,53 @@ Not in the way you're probably thinking. The markup surrounding the widget area
37
 
38
  == Changelog ==
39
 
40
- = 2.0.4 =
41
- * Update for WordPress 4.4+ and Genesis 2.3.0+
42
- * DO NOT upgrade to 2.0.4 unless you are running WordPress 4.4+ AND Genesis 2.3.0+
 
 
 
 
43
 
44
  = 2.0.3 =
45
- * Fix warnings and notices
46
 
47
  = 2.0.2 =
48
  * Change text domain, update POT file.
49
 
50
  = 2.0.1 =
51
- * Genesis 2.0.1 compatibility with term meta keys
52
- * Use actual sidebar name, instead of hard coded names
53
- * Fix incorrect textdomain
54
 
55
  = 2.0.0 =
56
- * Compatibility with Genesis 2.0
57
- * Standards
58
 
59
  = 1.0.0 =
60
- * Reorganize theme files
61
  * Standards
62
 
63
  = 0.9.2.1 =
64
- * Restore default tag/category support
65
- * Default custom taxonomy support to on for public taxonomies
66
- * Remove secondary selection when no 3 column layouts are enabled
67
 
68
  = 0.9.2 =
69
- * Added support for custom taxonomies
70
- * Added translation support
71
- * bug fix to prevent invalid sidebar creation
72
 
73
  = 0.9.1 =
74
- * Added support for custom post types
75
 
76
  = 0.9 =
77
- * Fixed "is not array" errors reported by users
78
- * Added nonce verification for security purposes
79
- * Added error and success messages
80
- * Bump to pre-release 0.9 branch
81
 
82
  = 0.1 =
83
- * Initial Alpha Release
84
 
85
 
1
  === Plugin Name ===
2
+ Contributors: nathanrice, wpmuguru
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118
4
  Tags: hooks, genesis, genesiswp, studiopress
5
+ Requires at least: 4.7.3
6
+ Tested up to: 4.7.3
7
+ Stable tag: 2.1.0
8
 
9
  This plugin allows you to create multiple, dynamic widget areas, and assign those widget areas to sidebar locations within the Genesis Framework on a per post, per page, or per tag/category archive basis.
10
 
37
 
38
  == Changelog ==
39
 
40
+ = 2.1.0 =
41
+ * Rewrite based on new plugin boilerplate.
42
+ * Make ID field readonly, rather than disabled.
43
+ * Add header widget area support.
44
+ * Allow for empty ID (auto-generate ID from name).
45
+ * Allow for only alphanumeric characters in ID.
46
+ * Use WordPress native term meta functions.
47
 
48
  = 2.0.3 =
49
+ * Fix warnings and notices.
50
 
51
  = 2.0.2 =
52
  * Change text domain, update POT file.
53
 
54
  = 2.0.1 =
55
+ * Genesis 2.0.1 compatibility with term meta keys.
56
+ * Use actual sidebar name, instead of hard coded names.
57
+ * Fix incorrect textdomain.
58
 
59
  = 2.0.0 =
60
+ * Compatibility with Genesis 2.0.0.
61
+ * Standards.
62
 
63
  = 1.0.0 =
64
+ * Reorganize theme files.
65
  * Standards
66
 
67
  = 0.9.2.1 =
68
+ * Restore default tag/category support.
69
+ * Default custom taxonomy support to on for public taxonomies.
70
+ * Remove secondary selection when no 3 column layouts are enabled.
71
 
72
  = 0.9.2 =
73
+ * Added support for custom taxonomies.
74
+ * Added translation support.
75
+ * bug fix to prevent invalid sidebar creation.
76
 
77
  = 0.9.1 =
78
+ * Added support for custom post types.
79
 
80
  = 0.9 =
81
+ * Fixed "is not array" errors reported by users.
82
+ * Added nonce verification for security purposes.
83
+ * Added error and success messages.
84
+ * Bump to pre-release 0.9 branch.
85
 
86
  = 0.1 =
87
+ * Initial Alpha Release.
88
 
89