WooSidebars - Version 1.2.2

Version Description

"Widget Areas" menu is now only visible to users who can add/modify widgets.

Download this release

Release Info

Developer mattyza
Plugin Icon wp plugin WooSidebars
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

assets/css/admin.css CHANGED
@@ -1,5 +1,7 @@
1
  .conditions-tabs li { display: inline; margin: 5px 0; padding: 5px; }
 
2
  .woo-conditions .ui-tabs-hide { display: none !important; }
 
3
  .woo-conditions .conditions-tabs { background:#eaeaea;padding:3px 9px 0;margin:0;overflow:hidden;zoom:1;line-height:1em;-webkit-box-shadow:inset 0 -1px 0 0 #d5d5d5;-moz-box-shadow:inset 0 -1px 0 0 x #d5d5d5;box-shadow:inset 0 -1px 0 0 #d5d5d5; }
4
  .woo-conditions .conditions-tabs li { float:left;padding:0;margin:0 5px 0 0; }
5
  .woo-conditions .conditions-tabs li.alignright { float: right; }
1
  .conditions-tabs li { display: inline; margin: 5px 0; padding: 5px; }
2
+ .woo-conditions.ui-tabs { padding: 0; }
3
  .woo-conditions .ui-tabs-hide { display: none !important; }
4
+ .woo-conditions .ui-widget-header { border: none; }
5
  .woo-conditions .conditions-tabs { background:#eaeaea;padding:3px 9px 0;margin:0;overflow:hidden;zoom:1;line-height:1em;-webkit-box-shadow:inset 0 -1px 0 0 #d5d5d5;-moz-box-shadow:inset 0 -1px 0 0 x #d5d5d5;box-shadow:inset 0 -1px 0 0 #d5d5d5; }
6
  .woo-conditions .conditions-tabs li { float:left;padding:0;margin:0 5px 0 0; }
7
  .woo-conditions .conditions-tabs li.alignright { float: right; }
changelog.txt CHANGED
@@ -1,5 +1,9 @@
1
  *** WooSidebars Changelog ***
2
 
 
 
 
 
3
  2013.01.09 - version 1.2.1
4
  * /classes/class-woo-conditions.php - Update script version. Update conditions meta box HTML to move the "advanced" button to it's own list instead of being a part of the tabs. Add "post_type" condition without the "post-type-" prefix. Fixes the "Template Hierarchy -> Pages" bug.
5
  * /classes/class-woo-sidebars.php - If WordPress SEO is active, remove the unused meta box styling, as it conflicts with the custom WooSidebars meta box styling. Set "has_archive" to "sidebars". Make sure only users with the "switch_themes" capability can see the "Widget Areas" admin menu.
@@ -7,7 +11,7 @@
7
 
8
  2012.08.14 - version 1.1.2
9
  * /integrations/integration-woocommerce.php - Added logic to stop undefined index notices in foreach(). Prevent direct file access.
10
- * /classes/class.wooconditions.php,
11
  /classes/class.woosidebars.php - Prevent direct file access.
12
  * /classes/class.updater.php - Prevent direct file access. Return $false instead of false when checking for updates, if not WooSidebars.
13
  * /lang/woosidebars-en_GB.po - Rescanned language file.
1
  *** WooSidebars Changelog ***
2
 
3
+ 2013.03.08 - version 1.2.2
4
+ * /classes/class-woo-sidebars.php - Changed capability for displaying the "Widget Areas" menu to use "edit_theme_options" instead of "switch_themes".
5
+ * /assets/css/admin.css - Minor styling adjustments. Fixes admin styling when jquery-ui-fresh CSS is loaded by other plugins.
6
+
7
  2013.01.09 - version 1.2.1
8
  * /classes/class-woo-conditions.php - Update script version. Update conditions meta box HTML to move the "advanced" button to it's own list instead of being a part of the tabs. Add "post_type" condition without the "post-type-" prefix. Fixes the "Template Hierarchy -> Pages" bug.
9
  * /classes/class-woo-sidebars.php - If WordPress SEO is active, remove the unused meta box styling, as it conflicts with the custom WooSidebars meta box styling. Set "has_archive" to "sidebars". Make sure only users with the "switch_themes" capability can see the "Widget Areas" admin menu.
11
 
12
  2012.08.14 - version 1.1.2
13
  * /integrations/integration-woocommerce.php - Added logic to stop undefined index notices in foreach(). Prevent direct file access.
14
+ * /classes/class.wooconditions.php,
15
  /classes/class.woosidebars.php - Prevent direct file access.
16
  * /classes/class.updater.php - Prevent direct file access. Return $false instead of false when checking for updates, if not WooSidebars.
17
  * /lang/woosidebars-en_GB.po - Rescanned language file.
classes/class-woo-sidebars.php CHANGED
@@ -19,7 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
19
  * private $token
20
  * private $prefix
21
  * public $conditions
22
- *
23
  * private $plugin_url
24
  * private $assets_url
25
  *
@@ -58,13 +58,13 @@ class Woo_Sidebars {
58
  private $token;
59
  private $prefix;
60
  public $conditions;
61
-
62
  private $plugin_url;
63
  private $assets_url;
64
 
65
  /**
66
  * __construct function.
67
- *
68
  * @access public
69
  * @return void
70
  */
@@ -74,7 +74,7 @@ class Woo_Sidebars {
74
 
75
  $this->token = 'sidebar';
76
  $this->prefix = 'woo_sidebar_';
77
-
78
  /* Plugin URL/path settings. */
79
  $this->plugin_url = str_replace( '/classes', '', plugins_url( plugin_basename( dirname( __FILE__ ) ) ) );
80
  $this->assets_url = $this->plugin_url . '/assets';
@@ -82,10 +82,10 @@ class Woo_Sidebars {
82
  $this->conditions = new Woo_Conditions();
83
  $this->conditions->token = $this->token;
84
  } // End __construct()
85
-
86
  /**
87
  * init function.
88
- *
89
  * @access public
90
  * @return void
91
  */
@@ -110,12 +110,12 @@ class Woo_Sidebars {
110
  add_action( 'manage_posts_custom_column', array( &$this, 'register_custom_columns' ), 10, 2 );
111
  }
112
  }
113
-
114
  // By default, add post type support for sidebars to the "post" post type.
115
  add_post_type_support( 'post', 'woosidebars' );
116
-
117
  add_action( 'admin_head', array( &$this, 'register_post_type_columns' ) );
118
-
119
  add_action( 'wp_ajax_woosidebars-post-enable', array( &$this, 'enable_custom_post_sidebars' ) );
120
 
121
  // Run this on activation.
@@ -124,29 +124,29 @@ class Woo_Sidebars {
124
 
125
  /**
126
  * register_post_type_columns function.
127
- *
128
  * @access public
129
  * @return void
130
  */
131
  public function register_post_type_columns () {
132
  $post_type = get_post_type();
133
-
134
  if ( $post_type != '' && post_type_supports( $post_type, 'woosidebars' ) ) {
135
  add_filter( 'manage_edit-' . $post_type . '_columns', array( &$this, 'add_post_column_headings' ), 10, 1 );
136
  add_action( 'manage_posts_custom_column', array( &$this, 'add_post_column_data' ), 10, 2 );
137
  add_action( 'manage_pages_custom_column', array( &$this, 'add_post_column_data' ), 10, 2 );
138
  }
139
  } // End register_post_type_columns()
140
-
141
  /**
142
  * register_post_type function.
143
- *
144
  * @access public
145
  * @return void
146
  */
147
  public function register_post_type () {
148
  // Allow only users who can adjust the theme to view the WooSidebars admin.
149
- if ( ! current_user_can( 'switch_themes' ) ) return;
150
 
151
  $page = 'themes.php';
152
 
@@ -154,9 +154,9 @@ class Woo_Sidebars {
154
  $plural = __( 'Widget Areas', 'woosidebars' );
155
  $rewrite = array( 'slug' => 'sidebars' );
156
  $supports = array( 'title', 'excerpt' );
157
-
158
  if ( $rewrite == '' ) { $rewrite = $this->token; }
159
-
160
  $labels = array(
161
  'name' => _x( 'Widget Areas', 'post type general name', 'woosidebars' ),
162
  'singular_name' => _x( 'Widget Area', 'post type singular name', 'woosidebars' ),
@@ -171,15 +171,15 @@ class Woo_Sidebars {
171
  'not_found_in_trash' => sprintf( __( 'No %s Found In Trash', 'woosidebars' ), $plural ),
172
  'parent_item_colon' => '',
173
  'menu_name' => $plural
174
-
175
  );
176
  $args = array(
177
  'labels' => $labels,
178
  'public' => false,
179
  'publicly_queryable' => true,
180
  'show_ui' => true,
181
- 'show_in_nav_menus' => false,
182
- 'show_in_admin_bar' => false,
183
  'show_in_menu' => $page,
184
  'query_var' => true,
185
  'rewrite' => $rewrite,
@@ -191,10 +191,10 @@ class Woo_Sidebars {
191
  );
192
  register_post_type( $this->token, $args );
193
  } // End register_post_type()
194
-
195
  /**
196
  * register_custom_columns function.
197
- *
198
  * @access public
199
  * @param string $column_name
200
  * @param int $id
@@ -202,20 +202,20 @@ class Woo_Sidebars {
202
  */
203
  public function register_custom_columns ( $column_name, $id ) {
204
  global $wpdb, $post;
205
-
206
  $meta = get_post_custom( $id );
207
  $sidebars = $this->get_registered_sidebars();
208
 
209
  $this->conditions->setup_default_conditions_reference();
210
 
211
  switch ( $column_name ) {
212
-
213
  case 'sidebar_to_replace':
214
  $value = '';
215
 
216
  if ( isset( $meta['_sidebar_to_replace'] ) && ( $meta['_sidebar_to_replace'][0] != '' ) ) {
217
  $value = $meta['_sidebar_to_replace'][0];
218
-
219
  if ( isset( $sidebars[$value] ) ) {
220
  $value = $sidebars[$value]['name'];
221
  } else {
@@ -225,7 +225,7 @@ class Woo_Sidebars {
225
 
226
  echo $value;
227
  break;
228
-
229
  case 'condition':
230
  $value = '';
231
 
@@ -240,52 +240,52 @@ class Woo_Sidebars {
240
 
241
  default:
242
  break;
243
-
244
  }
245
  } // End register_custom_columns()
246
-
247
  /**
248
  * register_custom_column_headings function.
249
- *
250
  * @access public
251
  * @param array $defaults
252
  * @return void
253
  */
254
  public function register_custom_column_headings ( $defaults ) {
255
  $this->conditions->setup_default_conditions_reference();
256
-
257
  $new_columns = array( 'sidebar_to_replace' => __( 'Sidebar To Replace', 'woosidebars' ), 'condition' => __( 'Condition(s)', 'woosidebars' ) );
258
-
259
  $last_item = '';
260
 
261
  if ( isset( $defaults['date'] ) ) { unset( $defaults['date'] ); }
262
 
263
- if ( count( $defaults ) > 2 ) {
264
  $last_item = array_slice( $defaults, -1 );
265
 
266
  array_pop( $defaults );
267
  }
268
  $defaults = array_merge( $defaults, $new_columns );
269
-
270
  if ( $last_item != '' ) {
271
  foreach ( $last_item as $k => $v ) {
272
  $defaults[$k] = $v;
273
  break;
274
  }
275
  }
276
-
277
  return $defaults;
278
  } // End register_custom_column_headings()
279
-
280
  /**
281
  * meta_box_setup function.
282
- *
283
  * @access public
284
  * @return void
285
  */
286
- public function meta_box_setup () {
287
  add_meta_box( 'sidebar-to-replace', __( 'Sidebar To Replace', 'woosidebars' ), array( &$this, 'meta_box_content' ), $this->token, 'side', 'low' );
288
-
289
  // Remove "Custom Settings" meta box.
290
  remove_meta_box( 'woothemes-settings', 'sidebar', 'normal' );
291
 
@@ -293,24 +293,24 @@ class Woo_Sidebars {
293
  remove_meta_box( 'postexcerpt', $this->token, 'normal' );
294
  add_meta_box( 'sidebar-description', __( 'Description', 'woosidebars' ), array( &$this, 'description_meta_box' ), $this->token, 'normal', 'core' );
295
  } // End meta_box_setup()
296
-
297
  /**
298
  * meta_box_content function.
299
- *
300
  * @access public
301
  * @return void
302
  */
303
  public function meta_box_content () {
304
  global $post_id;
305
-
306
  $sidebars = $this->get_registered_sidebars();
307
-
308
  $selected_sidebar = get_post_meta( $post_id, '_sidebar_to_replace', true );
309
-
310
  $html = '';
311
-
312
  $html .= '<input type="hidden" name="woo_' . $this->token . '_noonce" id="woo_' . $this->token . '_noonce" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
313
-
314
  if ( count( $sidebars ) > 0 ) {
315
  $html .= '<select name="sidebar_to_replace" class="widefat">' . "\n";
316
  foreach ( $sidebars as $k => $v ) {
@@ -320,52 +320,52 @@ class Woo_Sidebars {
320
  } else {
321
  $html .= '<p>' . __( 'No sidebars are available with this theme.', 'woosidebars' ) . '</p>';
322
  }
323
-
324
- echo $html;
325
-
326
  } // End meta_box_content()
327
-
328
  /**
329
  * meta_box_save function.
330
- *
331
  * @access public
332
  * @param int $post_id
333
  * @return void
334
  */
335
  public function meta_box_save ( $post_id ) {
336
  global $post, $messages;
337
-
338
  // Verify
339
- if ( ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_noonce'], plugin_basename( __FILE__ ) ) ) {
340
- return $post_id;
341
  }
342
-
343
- if ( 'page' == $_POST['post_type'] ) {
344
- if ( ! current_user_can( 'edit_page', $post_id ) ) {
345
  return $post_id;
346
  }
347
- } else {
348
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
349
  return $post_id;
350
  }
351
  }
352
-
353
  $fields = array( 'sidebar_to_replace' );
354
-
355
  foreach ( $fields as $f ) {
356
-
357
  ${$f} = strip_tags(trim($_POST[$f]));
358
-
359
- if ( get_post_meta( $post_id, '_' . $f ) == '' ) {
360
- add_post_meta( $post_id, '_' . $f, ${$f}, true );
361
- } elseif( ${$f} != get_post_meta( $post_id, '_' . $f, true ) ) {
362
  update_post_meta( $post_id, '_' . $f, ${$f} );
363
- } elseif ( ${$f} == '' ) {
364
  delete_post_meta( $post_id, '_' . $f, get_post_meta( $post_id, '_' . $f, true ) );
365
- }
366
  }
367
  } // End meta_box_save()
368
-
369
  /**
370
  * description_meta_box function.
371
  *
@@ -380,7 +380,7 @@ class Woo_Sidebars {
380
 
381
  /**
382
  * enter_title_here function.
383
- *
384
  * @access public
385
  * @param string $title
386
  * @return void
@@ -391,10 +391,10 @@ class Woo_Sidebars {
391
  }
392
  return $title;
393
  } // End enter_title_here()
394
-
395
  /**
396
  * update_messages function.
397
- *
398
  * @access public
399
  * @param array $messages
400
  * @return void
@@ -403,24 +403,24 @@ class Woo_Sidebars {
403
  if ( get_post_type() != $this->token ) {
404
  return $messages;
405
  }
406
-
407
- $messages[$this->token][1] = __( 'Widget Area updated.', 'woosidebars' );
408
-
409
  return $messages;
410
  } // End update_messages()
411
-
412
  /**
413
  * get_registered_sidebars function.
414
- *
415
  * @access public
416
  * @return void
417
  */
418
  public function get_registered_sidebars () {
419
  global $wp_registered_sidebars;
420
-
421
  $sidebars = array();
422
  $to_ignore = array();
423
-
424
  $custom_sidebars = get_posts( 'post_type=sidebar&numberposts=-1' );
425
  if ( ! is_wp_error( $custom_sidebars ) && count( $custom_sidebars ) > 0 ) {
426
  foreach ( $custom_sidebars as $k => $v ) {
@@ -435,19 +435,19 @@ class Woo_Sidebars {
435
  }
436
  }
437
  }
438
-
439
  return $sidebars;
440
  } // End get_registered_sidebars()
441
-
442
  /**
443
  * register_custom_sidebars function.
444
- *
445
  * @access public
446
  * @return void
447
  */
448
  public function register_custom_sidebars () {
449
  $sidebars = get_posts( array( 'post_type' => 'sidebar', 'posts_per_page' => -1 ) );
450
-
451
  if ( count( $sidebars ) > 0 ) {
452
  foreach ( $sidebars as $k => $v ) {
453
  $sidebar_id = $v->post_name;
@@ -456,20 +456,20 @@ class Woo_Sidebars {
456
  }
457
  }
458
  } // End register_custom_sidebars()
459
-
460
  /**
461
  * init_sidebar_replacement function.
462
- *
463
  * @access public
464
  * @return void
465
  */
466
  public function init_sidebar_replacement () {
467
  add_filter( 'sidebars_widgets', array( &$this, 'replace_sidebars' ) );
468
  } // End init_sidebar_replacement()
469
-
470
  /**
471
  * replace_sidebars function.
472
- *
473
  * @access public
474
  * @param array $sidebars_widgets
475
  * @return void
@@ -485,32 +485,32 @@ class Woo_Sidebars {
485
  if ( ! isset( $this->conditions->conditions ) || count( $this->conditions->conditions ) <= 0 ) {
486
  return $sidebars_widgets;
487
  }
488
-
489
  global $woo_custom_sidebar_data;
490
-
491
  if ( ! isset( $woo_custom_sidebar_data ) ) {
492
-
493
  $conditions_str = join( ', ', $conditions );
494
-
495
  $args = array(
496
- 'post_type' => $this->token,
497
  'posts_per_page' => -1
498
  );
499
-
500
  $meta_query = array(
501
- 'key' => '_sidebar_to_replace',
502
- 'compare' => '!=',
503
  'value' => ''
504
  );
505
-
506
  $args['meta_query'][] = $meta_query;
507
-
508
  $meta_query = array(
509
- 'key' => '_condition',
510
- 'compare' => 'IN',
511
  'value' => $conditions
512
  );
513
-
514
  $args['meta_query'][] = $meta_query;
515
 
516
  $sidebars = get_posts( $args );
@@ -519,11 +519,11 @@ class Woo_Sidebars {
519
  foreach ( $sidebars as $k => $v ) {
520
  $to_replace = get_post_meta( $v->ID, '_sidebar_to_replace', true );
521
  $sidebars[$k]->to_replace = $to_replace;
522
-
523
  $conditions = get_post_meta( $v->ID, '_condition', false );
524
-
525
  $sidebars[$k]->conditions = array();
526
-
527
  // Remove any irrelevant conditions from the array.
528
  if ( is_array( $conditions ) ) {
529
  foreach ( $conditions as $i => $j ) {
@@ -532,17 +532,17 @@ class Woo_Sidebars {
532
  }
533
  }
534
  }
535
-
536
  }
537
  }
538
-
539
- $woo_custom_sidebar_data = $sidebars;
540
  }
541
-
542
  // Make sure only the most appropriate sidebars are kept.
543
  // $woo_custom_sidebar_data = $this->remove_unwanted_sidebars( $woo_custom_sidebar_data );
544
- $woo_custom_sidebar_data = $this->find_best_sidebars( $woo_custom_sidebar_data );
545
-
546
  if ( count( $woo_custom_sidebar_data ) > 0 ) {
547
  foreach ( $woo_custom_sidebar_data as $k => $v ) {
548
  $sidebar_id = $v->post_name;
@@ -557,28 +557,28 @@ class Woo_Sidebars {
557
 
558
  return $sidebars_widgets;
559
  } // End replace_sidebars()
560
-
561
  /**
562
  * find_best_sidebars function.
563
- *
564
  * @access public
565
  * @param array $sidebars
566
  * @return array $sorted_sidebars
567
  */
568
  public function find_best_sidebars ( $sidebars ) {
569
  $sorted_sidebars = array();
570
-
571
  if ( ! isset( $this->conditions->conditions ) || count( $this->conditions->conditions ) <= 0 ) {
572
  return $sidebars;
573
  }
574
-
575
  // Keep track of each sidebar we'd like to replace widgets for.
576
  foreach ( $sidebars as $k => $v ) {
577
  if ( isset( $v->to_replace ) && ( $v->to_replace != '' ) && ! isset( $sorted_sidebars[$v->to_replace] ) ) {
578
  $sorted_sidebars[$v->to_replace] = '';
579
  }
580
  }
581
-
582
  foreach ( $sidebars as $k => $v ) {
583
  if ( isset( $sorted_sidebars[$v->to_replace] ) && ( $sorted_sidebars[$v->to_replace] == '' ) ) {
584
  $sorted_sidebars[$v->to_replace] = $v;
@@ -586,26 +586,26 @@ class Woo_Sidebars {
586
  continue;
587
  }
588
  }
589
-
590
  return $sorted_sidebars;
591
  } // End find_best_sidebars()
592
 
593
  /**
594
  * enqueue_styles function.
595
- *
596
  * @access public
597
  * @return void
598
  */
599
  public function enqueue_styles () {
600
  global $pagenow;
601
-
602
  if ( in_array( $pagenow, array( 'edit.php', 'post.php', 'post-new.php' ) ) ) {
603
  if ( get_post_type() != $this->token ) { return; }
604
  wp_enqueue_style( 'jquery-ui-tabs' );
605
-
606
  wp_register_style( $this->token . '-admin', $this->assets_url . '/css/admin.css', array(), '1.0.0' );
607
  wp_enqueue_style( $this->token . '-admin' );
608
-
609
  wp_dequeue_style( 'jquery-ui-datepicker' );
610
 
611
  if ( class_exists( 'WPSEO_Metabox' ) ) {
@@ -619,16 +619,16 @@ class Woo_Sidebars {
619
  wp_dequeue_style( 'metabox-' . $color );
620
  }
621
  }
622
-
623
  if ( in_array( $pagenow, array( 'edit.php' ) ) ) {
624
  wp_register_style( $this->token . '-admin-posts', $this->assets_url . '/css/admin-posts.css', array(), '1.0.0' );
625
  wp_enqueue_style( $this->token . '-admin-posts' );
626
  }
627
  } // End enqueue_styles()
628
-
629
  /**
630
  * add_post_column_headings function.
631
- *
632
  * @access public
633
  * @param array $defaults
634
  * @return array $new_columns
@@ -637,10 +637,10 @@ class Woo_Sidebars {
637
  $defaults['woosidebars_enable'] = __( 'Custom Sidebars', 'woosidebars' );
638
  return $defaults;
639
  } // End add_post_column_headings()
640
-
641
  /**
642
  * add_post_column_data function.
643
- *
644
  * @access public
645
  * @param string $column_name
646
  * @param int $id
@@ -649,21 +649,21 @@ class Woo_Sidebars {
649
  public function add_post_column_data ( $column_name, $id ) {
650
  global $wpdb, $post;
651
  $meta = get_post_custom( $id );
652
-
653
  switch ( $column_name ) {
654
  case 'woosidebars_enable':
655
  $image = 'success-off';
656
  $value = '';
657
  $class = 'custom-sidebars-disabled';
658
-
659
  if ( isset( $meta['_enable_sidebar'] ) && ( $meta['_enable_sidebar'][0] != '' ) && ( $meta['_enable_sidebar'][0] == 'yes' ) ) {
660
  $image = 'success';
661
  $class = 'custom-sidebars-enabled';
662
  }
663
-
664
  $url = wp_nonce_url( admin_url( 'admin-ajax.php?action=woosidebars-post-enable&post_id=' . $post->ID ), 'woosidebars-post-enable' );
665
  $value = '<span class="' . esc_attr( $class ) . '"><a href="' . esc_url( $url ) . '"><img src="' . $this->assets_url . '/images/' . $image . '.png" /></a></span>';
666
-
667
  echo $value;
668
  break;
669
 
@@ -671,10 +671,10 @@ class Woo_Sidebars {
671
  break;
672
  }
673
  } // End add_post_column_data()
674
-
675
  /**
676
  * enable_custom_post_sidebars function.
677
- *
678
  * @access public
679
  * @return void
680
  */
@@ -682,29 +682,29 @@ class Woo_Sidebars {
682
  if( ! is_admin() ) die;
683
  if( ! current_user_can( 'edit_posts' ) ) wp_die( __( 'You do not have sufficient permissions to access this page.', 'woosidebars' ) );
684
  if( ! check_admin_referer( 'woosidebars-post-enable' ) ) wp_die( __( 'You have taken too long. Please go back and retry.', 'woosidebars' ) );
685
-
686
  $post_id = isset( $_GET['post_id'] ) && (int)$_GET['post_id'] ? (int)$_GET['post_id'] : '';
687
-
688
  if( ! $post_id ) die;
689
-
690
  $post = get_post( $post_id );
691
  if( ! $post ) die;
692
-
693
  $meta = get_post_meta( $post->ID, '_enable_sidebar', true );
694
-
695
- if ( $meta == 'yes' ) {
696
  update_post_meta($post->ID, '_enable_sidebar', 'no' );
697
  } else {
698
  update_post_meta($post->ID, '_enable_sidebar', 'yes' );
699
  }
700
-
701
  $sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids' ), wp_get_referer() );
702
  wp_safe_redirect( $sendback );
703
  } // End enable_custom_post_sidebars()
704
-
705
  /**
706
  * multidimensional_search function.
707
- *
708
  * @access public
709
  * @param string $needle
710
  * @param array $haystack
@@ -714,7 +714,7 @@ class Woo_Sidebars {
714
  if (empty( $needle ) || empty( $haystack ) ) {
715
  return false;
716
  }
717
-
718
  foreach ( $haystack as $key => $value ) {
719
  $exists = 0;
720
  foreach ( (array)$needle as $nkey => $nvalue) {
@@ -723,7 +723,7 @@ class Woo_Sidebars {
723
  }
724
  }
725
  }
726
-
727
  return false;
728
  } // End multidimensional_search()
729
 
@@ -748,26 +748,26 @@ class Woo_Sidebars {
748
  'id' => 'wooframework-sbm',
749
  'title' => __( 'Sidebar Manager', 'woosidebars' ),
750
  'content' =>
751
- '<p>' . __( 'WooSidebars is intended to replace the Sidebar Manager found in the WooFramework. Please ensure that all sidebars have been transferred over from the Sidebar Manager, if you choose to use WooSidebars instead.', 'woosidebars' ) . '</p>' .
752
- '<p>' . __( 'To transfer a sidebar from the Sidebar Manager:', 'woosidebars' ) . '</p>' .
753
- '<ul>' . "\n" .
754
- '<li>' . __( 'Create a new custom widget area in WooSidebars.', 'woosidebars' ) . '</li>' . "\n" .
755
- '<li>' . sprintf( __( 'Visit the %sAppearance &rarr; Widgets%s screen and drag the widgets from the old sidebar into the newly created sidebar.', 'woosidebars' ), '<a href="' . esc_url( admin_url( 'widgets.php' ) ) . '">', '</a>' ) . '</li>' . "\n" .
756
- '<li>' . __( 'Repeat this process for each of your custom sidebars, including dependencies if necessary (the WooSidebars conditions system replaces the need for dependencies).', 'woosidebars' ) . '</li>' . "\n" .
757
- '<li>' . __( 'Once you are certain that you widgets have been moved across for all widget areas, remove the sidebar from the Sidebar Manager (don\'t forget to transfer any dependencies over as well, if necessary).', 'woosidebars' ) . '</li>' . "\n" .
758
  '</ul>' . "\n"
759
  ) );
760
 
761
  get_current_screen()->set_help_sidebar(
762
  '<p><strong>' . __( 'For more information:', 'woosidebars' ) . '</strong></p>' .
763
- '<p><a href="http://support.woothemes.com/?ref=' . 'woosidebars' . '" target="_blank">' . __( 'Support HelpDesk', 'woosidebars' ) . '</a></p>' .
764
  '<p><a href="http://dojodocs.woothemes.com/woosidebars/?ref=' . 'woosidebars' . '" target="_blank">' . __( 'WooSidebars Documentation', 'woosidebars' ) . '</a></p>'
765
  );
766
  } // End add_contextual_help()
767
 
768
  /**
769
  * load_localisation function.
770
- *
771
  * @access public
772
  * @since 1.0.0
773
  * @return void
@@ -779,7 +779,7 @@ class Woo_Sidebars {
779
 
780
  /**
781
  * activation function.
782
- *
783
  * @access public
784
  * @since 1.0.0
785
  * @return void
@@ -790,7 +790,7 @@ class Woo_Sidebars {
790
 
791
  /**
792
  * register_plugin_version function.
793
- *
794
  * @access public
795
  * @since 1.0.0
796
  * @return void
19
  * private $token
20
  * private $prefix
21
  * public $conditions
22
+ *
23
  * private $plugin_url
24
  * private $assets_url
25
  *
58
  private $token;
59
  private $prefix;
60
  public $conditions;
61
+
62
  private $plugin_url;
63
  private $assets_url;
64
 
65
  /**
66
  * __construct function.
67
+ *
68
  * @access public
69
  * @return void
70
  */
74
 
75
  $this->token = 'sidebar';
76
  $this->prefix = 'woo_sidebar_';
77
+
78
  /* Plugin URL/path settings. */
79
  $this->plugin_url = str_replace( '/classes', '', plugins_url( plugin_basename( dirname( __FILE__ ) ) ) );
80
  $this->assets_url = $this->plugin_url . '/assets';
82
  $this->conditions = new Woo_Conditions();
83
  $this->conditions->token = $this->token;
84
  } // End __construct()
85
+
86
  /**
87
  * init function.
88
+ *
89
  * @access public
90
  * @return void
91
  */
110
  add_action( 'manage_posts_custom_column', array( &$this, 'register_custom_columns' ), 10, 2 );
111
  }
112
  }
113
+
114
  // By default, add post type support for sidebars to the "post" post type.
115
  add_post_type_support( 'post', 'woosidebars' );
116
+
117
  add_action( 'admin_head', array( &$this, 'register_post_type_columns' ) );
118
+
119
  add_action( 'wp_ajax_woosidebars-post-enable', array( &$this, 'enable_custom_post_sidebars' ) );
120
 
121
  // Run this on activation.
124
 
125
  /**
126
  * register_post_type_columns function.
127
+ *
128
  * @access public
129
  * @return void
130
  */
131
  public function register_post_type_columns () {
132
  $post_type = get_post_type();
133
+
134
  if ( $post_type != '' && post_type_supports( $post_type, 'woosidebars' ) ) {
135
  add_filter( 'manage_edit-' . $post_type . '_columns', array( &$this, 'add_post_column_headings' ), 10, 1 );
136
  add_action( 'manage_posts_custom_column', array( &$this, 'add_post_column_data' ), 10, 2 );
137
  add_action( 'manage_pages_custom_column', array( &$this, 'add_post_column_data' ), 10, 2 );
138
  }
139
  } // End register_post_type_columns()
140
+
141
  /**
142
  * register_post_type function.
143
+ *
144
  * @access public
145
  * @return void
146
  */
147
  public function register_post_type () {
148
  // Allow only users who can adjust the theme to view the WooSidebars admin.
149
+ if ( ! current_user_can( 'edit_theme_options' ) ) return;
150
 
151
  $page = 'themes.php';
152
 
154
  $plural = __( 'Widget Areas', 'woosidebars' );
155
  $rewrite = array( 'slug' => 'sidebars' );
156
  $supports = array( 'title', 'excerpt' );
157
+
158
  if ( $rewrite == '' ) { $rewrite = $this->token; }
159
+
160
  $labels = array(
161
  'name' => _x( 'Widget Areas', 'post type general name', 'woosidebars' ),
162
  'singular_name' => _x( 'Widget Area', 'post type singular name', 'woosidebars' ),
171
  'not_found_in_trash' => sprintf( __( 'No %s Found In Trash', 'woosidebars' ), $plural ),
172
  'parent_item_colon' => '',
173
  'menu_name' => $plural
174
+
175
  );
176
  $args = array(
177
  'labels' => $labels,
178
  'public' => false,
179
  'publicly_queryable' => true,
180
  'show_ui' => true,
181
+ 'show_in_nav_menus' => false,
182
+ 'show_in_admin_bar' => false,
183
  'show_in_menu' => $page,
184
  'query_var' => true,
185
  'rewrite' => $rewrite,
191
  );
192
  register_post_type( $this->token, $args );
193
  } // End register_post_type()
194
+
195
  /**
196
  * register_custom_columns function.
197
+ *
198
  * @access public
199
  * @param string $column_name
200
  * @param int $id
202
  */
203
  public function register_custom_columns ( $column_name, $id ) {
204
  global $wpdb, $post;
205
+
206
  $meta = get_post_custom( $id );
207
  $sidebars = $this->get_registered_sidebars();
208
 
209
  $this->conditions->setup_default_conditions_reference();
210
 
211
  switch ( $column_name ) {
212
+
213
  case 'sidebar_to_replace':
214
  $value = '';
215
 
216
  if ( isset( $meta['_sidebar_to_replace'] ) && ( $meta['_sidebar_to_replace'][0] != '' ) ) {
217
  $value = $meta['_sidebar_to_replace'][0];
218
+
219
  if ( isset( $sidebars[$value] ) ) {
220
  $value = $sidebars[$value]['name'];
221
  } else {
225
 
226
  echo $value;
227
  break;
228
+
229
  case 'condition':
230
  $value = '';
231
 
240
 
241
  default:
242
  break;
243
+
244
  }
245
  } // End register_custom_columns()
246
+
247
  /**
248
  * register_custom_column_headings function.
249
+ *
250
  * @access public
251
  * @param array $defaults
252
  * @return void
253
  */
254
  public function register_custom_column_headings ( $defaults ) {
255
  $this->conditions->setup_default_conditions_reference();
256
+
257
  $new_columns = array( 'sidebar_to_replace' => __( 'Sidebar To Replace', 'woosidebars' ), 'condition' => __( 'Condition(s)', 'woosidebars' ) );
258
+
259
  $last_item = '';
260
 
261
  if ( isset( $defaults['date'] ) ) { unset( $defaults['date'] ); }
262
 
263
+ if ( count( $defaults ) > 2 ) {
264
  $last_item = array_slice( $defaults, -1 );
265
 
266
  array_pop( $defaults );
267
  }
268
  $defaults = array_merge( $defaults, $new_columns );
269
+
270
  if ( $last_item != '' ) {
271
  foreach ( $last_item as $k => $v ) {
272
  $defaults[$k] = $v;
273
  break;
274
  }
275
  }
276
+
277
  return $defaults;
278
  } // End register_custom_column_headings()
279
+
280
  /**
281
  * meta_box_setup function.
282
+ *
283
  * @access public
284
  * @return void
285
  */
286
+ public function meta_box_setup () {
287
  add_meta_box( 'sidebar-to-replace', __( 'Sidebar To Replace', 'woosidebars' ), array( &$this, 'meta_box_content' ), $this->token, 'side', 'low' );
288
+
289
  // Remove "Custom Settings" meta box.
290
  remove_meta_box( 'woothemes-settings', 'sidebar', 'normal' );
291
 
293
  remove_meta_box( 'postexcerpt', $this->token, 'normal' );
294
  add_meta_box( 'sidebar-description', __( 'Description', 'woosidebars' ), array( &$this, 'description_meta_box' ), $this->token, 'normal', 'core' );
295
  } // End meta_box_setup()
296
+
297
  /**
298
  * meta_box_content function.
299
+ *
300
  * @access public
301
  * @return void
302
  */
303
  public function meta_box_content () {
304
  global $post_id;
305
+
306
  $sidebars = $this->get_registered_sidebars();
307
+
308
  $selected_sidebar = get_post_meta( $post_id, '_sidebar_to_replace', true );
309
+
310
  $html = '';
311
+
312
  $html .= '<input type="hidden" name="woo_' . $this->token . '_noonce" id="woo_' . $this->token . '_noonce" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
313
+
314
  if ( count( $sidebars ) > 0 ) {
315
  $html .= '<select name="sidebar_to_replace" class="widefat">' . "\n";
316
  foreach ( $sidebars as $k => $v ) {
320
  } else {
321
  $html .= '<p>' . __( 'No sidebars are available with this theme.', 'woosidebars' ) . '</p>';
322
  }
323
+
324
+ echo $html;
325
+
326
  } // End meta_box_content()
327
+
328
  /**
329
  * meta_box_save function.
330
+ *
331
  * @access public
332
  * @param int $post_id
333
  * @return void
334
  */
335
  public function meta_box_save ( $post_id ) {
336
  global $post, $messages;
337
+
338
  // Verify
339
+ if ( ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_noonce'], plugin_basename( __FILE__ ) ) ) {
340
+ return $post_id;
341
  }
342
+
343
+ if ( 'page' == $_POST['post_type'] ) {
344
+ if ( ! current_user_can( 'edit_page', $post_id ) ) {
345
  return $post_id;
346
  }
347
+ } else {
348
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
349
  return $post_id;
350
  }
351
  }
352
+
353
  $fields = array( 'sidebar_to_replace' );
354
+
355
  foreach ( $fields as $f ) {
356
+
357
  ${$f} = strip_tags(trim($_POST[$f]));
358
+
359
+ if ( get_post_meta( $post_id, '_' . $f ) == '' ) {
360
+ add_post_meta( $post_id, '_' . $f, ${$f}, true );
361
+ } elseif( ${$f} != get_post_meta( $post_id, '_' . $f, true ) ) {
362
  update_post_meta( $post_id, '_' . $f, ${$f} );
363
+ } elseif ( ${$f} == '' ) {
364
  delete_post_meta( $post_id, '_' . $f, get_post_meta( $post_id, '_' . $f, true ) );
365
+ }
366
  }
367
  } // End meta_box_save()
368
+
369
  /**
370
  * description_meta_box function.
371
  *
380
 
381
  /**
382
  * enter_title_here function.
383
+ *
384
  * @access public
385
  * @param string $title
386
  * @return void
391
  }
392
  return $title;
393
  } // End enter_title_here()
394
+
395
  /**
396
  * update_messages function.
397
+ *
398
  * @access public
399
  * @param array $messages
400
  * @return void
403
  if ( get_post_type() != $this->token ) {
404
  return $messages;
405
  }
406
+
407
+ $messages[$this->token][1] = __( 'Widget Area updated.', 'woosidebars' );
408
+
409
  return $messages;
410
  } // End update_messages()
411
+
412
  /**
413
  * get_registered_sidebars function.
414
+ *
415
  * @access public
416
  * @return void
417
  */
418
  public function get_registered_sidebars () {
419
  global $wp_registered_sidebars;
420
+
421
  $sidebars = array();
422
  $to_ignore = array();
423
+
424
  $custom_sidebars = get_posts( 'post_type=sidebar&numberposts=-1' );
425
  if ( ! is_wp_error( $custom_sidebars ) && count( $custom_sidebars ) > 0 ) {
426
  foreach ( $custom_sidebars as $k => $v ) {
435
  }
436
  }
437
  }
438
+
439
  return $sidebars;
440
  } // End get_registered_sidebars()
441
+
442
  /**
443
  * register_custom_sidebars function.
444
+ *
445
  * @access public
446
  * @return void
447
  */
448
  public function register_custom_sidebars () {
449
  $sidebars = get_posts( array( 'post_type' => 'sidebar', 'posts_per_page' => -1 ) );
450
+
451
  if ( count( $sidebars ) > 0 ) {
452
  foreach ( $sidebars as $k => $v ) {
453
  $sidebar_id = $v->post_name;
456
  }
457
  }
458
  } // End register_custom_sidebars()
459
+
460
  /**
461
  * init_sidebar_replacement function.
462
+ *
463
  * @access public
464
  * @return void
465
  */
466
  public function init_sidebar_replacement () {
467
  add_filter( 'sidebars_widgets', array( &$this, 'replace_sidebars' ) );
468
  } // End init_sidebar_replacement()
469
+
470
  /**
471
  * replace_sidebars function.
472
+ *
473
  * @access public
474
  * @param array $sidebars_widgets
475
  * @return void
485
  if ( ! isset( $this->conditions->conditions ) || count( $this->conditions->conditions ) <= 0 ) {
486
  return $sidebars_widgets;
487
  }
488
+
489
  global $woo_custom_sidebar_data;
490
+
491
  if ( ! isset( $woo_custom_sidebar_data ) ) {
492
+
493
  $conditions_str = join( ', ', $conditions );
494
+
495
  $args = array(
496
+ 'post_type' => $this->token,
497
  'posts_per_page' => -1
498
  );
499
+
500
  $meta_query = array(
501
+ 'key' => '_sidebar_to_replace',
502
+ 'compare' => '!=',
503
  'value' => ''
504
  );
505
+
506
  $args['meta_query'][] = $meta_query;
507
+
508
  $meta_query = array(
509
+ 'key' => '_condition',
510
+ 'compare' => 'IN',
511
  'value' => $conditions
512
  );
513
+
514
  $args['meta_query'][] = $meta_query;
515
 
516
  $sidebars = get_posts( $args );
519
  foreach ( $sidebars as $k => $v ) {
520
  $to_replace = get_post_meta( $v->ID, '_sidebar_to_replace', true );
521
  $sidebars[$k]->to_replace = $to_replace;
522
+
523
  $conditions = get_post_meta( $v->ID, '_condition', false );
524
+
525
  $sidebars[$k]->conditions = array();
526
+
527
  // Remove any irrelevant conditions from the array.
528
  if ( is_array( $conditions ) ) {
529
  foreach ( $conditions as $i => $j ) {
532
  }
533
  }
534
  }
535
+
536
  }
537
  }
538
+
539
+ $woo_custom_sidebar_data = $sidebars;
540
  }
541
+
542
  // Make sure only the most appropriate sidebars are kept.
543
  // $woo_custom_sidebar_data = $this->remove_unwanted_sidebars( $woo_custom_sidebar_data );
544
+ $woo_custom_sidebar_data = $this->find_best_sidebars( $woo_custom_sidebar_data );
545
+
546
  if ( count( $woo_custom_sidebar_data ) > 0 ) {
547
  foreach ( $woo_custom_sidebar_data as $k => $v ) {
548
  $sidebar_id = $v->post_name;
557
 
558
  return $sidebars_widgets;
559
  } // End replace_sidebars()
560
+
561
  /**
562
  * find_best_sidebars function.
563
+ *
564
  * @access public
565
  * @param array $sidebars
566
  * @return array $sorted_sidebars
567
  */
568
  public function find_best_sidebars ( $sidebars ) {
569
  $sorted_sidebars = array();
570
+
571
  if ( ! isset( $this->conditions->conditions ) || count( $this->conditions->conditions ) <= 0 ) {
572
  return $sidebars;
573
  }
574
+
575
  // Keep track of each sidebar we'd like to replace widgets for.
576
  foreach ( $sidebars as $k => $v ) {
577
  if ( isset( $v->to_replace ) && ( $v->to_replace != '' ) && ! isset( $sorted_sidebars[$v->to_replace] ) ) {
578
  $sorted_sidebars[$v->to_replace] = '';
579
  }
580
  }
581
+
582
  foreach ( $sidebars as $k => $v ) {
583
  if ( isset( $sorted_sidebars[$v->to_replace] ) && ( $sorted_sidebars[$v->to_replace] == '' ) ) {
584
  $sorted_sidebars[$v->to_replace] = $v;
586
  continue;
587
  }
588
  }
589
+
590
  return $sorted_sidebars;
591
  } // End find_best_sidebars()
592
 
593
  /**
594
  * enqueue_styles function.
595
+ *
596
  * @access public
597
  * @return void
598
  */
599
  public function enqueue_styles () {
600
  global $pagenow;
601
+
602
  if ( in_array( $pagenow, array( 'edit.php', 'post.php', 'post-new.php' ) ) ) {
603
  if ( get_post_type() != $this->token ) { return; }
604
  wp_enqueue_style( 'jquery-ui-tabs' );
605
+
606
  wp_register_style( $this->token . '-admin', $this->assets_url . '/css/admin.css', array(), '1.0.0' );
607
  wp_enqueue_style( $this->token . '-admin' );
608
+
609
  wp_dequeue_style( 'jquery-ui-datepicker' );
610
 
611
  if ( class_exists( 'WPSEO_Metabox' ) ) {
619
  wp_dequeue_style( 'metabox-' . $color );
620
  }
621
  }
622
+
623
  if ( in_array( $pagenow, array( 'edit.php' ) ) ) {
624
  wp_register_style( $this->token . '-admin-posts', $this->assets_url . '/css/admin-posts.css', array(), '1.0.0' );
625
  wp_enqueue_style( $this->token . '-admin-posts' );
626
  }
627
  } // End enqueue_styles()
628
+
629
  /**
630
  * add_post_column_headings function.
631
+ *
632
  * @access public
633
  * @param array $defaults
634
  * @return array $new_columns
637
  $defaults['woosidebars_enable'] = __( 'Custom Sidebars', 'woosidebars' );
638
  return $defaults;
639
  } // End add_post_column_headings()
640
+
641
  /**
642
  * add_post_column_data function.
643
+ *
644
  * @access public
645
  * @param string $column_name
646
  * @param int $id
649
  public function add_post_column_data ( $column_name, $id ) {
650
  global $wpdb, $post;
651
  $meta = get_post_custom( $id );
652
+
653
  switch ( $column_name ) {
654
  case 'woosidebars_enable':
655
  $image = 'success-off';
656
  $value = '';
657
  $class = 'custom-sidebars-disabled';
658
+
659
  if ( isset( $meta['_enable_sidebar'] ) && ( $meta['_enable_sidebar'][0] != '' ) && ( $meta['_enable_sidebar'][0] == 'yes' ) ) {
660
  $image = 'success';
661
  $class = 'custom-sidebars-enabled';
662
  }
663
+
664
  $url = wp_nonce_url( admin_url( 'admin-ajax.php?action=woosidebars-post-enable&post_id=' . $post->ID ), 'woosidebars-post-enable' );
665
  $value = '<span class="' . esc_attr( $class ) . '"><a href="' . esc_url( $url ) . '"><img src="' . $this->assets_url . '/images/' . $image . '.png" /></a></span>';
666
+
667
  echo $value;
668
  break;
669
 
671
  break;
672
  }
673
  } // End add_post_column_data()
674
+
675
  /**
676
  * enable_custom_post_sidebars function.
677
+ *
678
  * @access public
679
  * @return void
680
  */
682
  if( ! is_admin() ) die;
683
  if( ! current_user_can( 'edit_posts' ) ) wp_die( __( 'You do not have sufficient permissions to access this page.', 'woosidebars' ) );
684
  if( ! check_admin_referer( 'woosidebars-post-enable' ) ) wp_die( __( 'You have taken too long. Please go back and retry.', 'woosidebars' ) );
685
+
686
  $post_id = isset( $_GET['post_id'] ) && (int)$_GET['post_id'] ? (int)$_GET['post_id'] : '';
687
+
688
  if( ! $post_id ) die;
689
+
690
  $post = get_post( $post_id );
691
  if( ! $post ) die;
692
+
693
  $meta = get_post_meta( $post->ID, '_enable_sidebar', true );
694
+
695
+ if ( $meta == 'yes' ) {
696
  update_post_meta($post->ID, '_enable_sidebar', 'no' );
697
  } else {
698
  update_post_meta($post->ID, '_enable_sidebar', 'yes' );
699
  }
700
+
701
  $sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids' ), wp_get_referer() );
702
  wp_safe_redirect( $sendback );
703
  } // End enable_custom_post_sidebars()
704
+
705
  /**
706
  * multidimensional_search function.
707
+ *
708
  * @access public
709
  * @param string $needle
710
  * @param array $haystack
714
  if (empty( $needle ) || empty( $haystack ) ) {
715
  return false;
716
  }
717
+
718
  foreach ( $haystack as $key => $value ) {
719
  $exists = 0;
720
  foreach ( (array)$needle as $nkey => $nvalue) {
723
  }
724
  }
725
  }
726
+
727
  return false;
728
  } // End multidimensional_search()
729
 
748
  'id' => 'wooframework-sbm',
749
  'title' => __( 'Sidebar Manager', 'woosidebars' ),
750
  'content' =>
751
+ '<p>' . __( 'WooSidebars is intended to replace the Sidebar Manager found in the WooFramework. Please ensure that all sidebars have been transferred over from the Sidebar Manager, if you choose to use WooSidebars instead.', 'woosidebars' ) . '</p>' .
752
+ '<p>' . __( 'To transfer a sidebar from the Sidebar Manager:', 'woosidebars' ) . '</p>' .
753
+ '<ul>' . "\n" .
754
+ '<li>' . __( 'Create a new custom widget area in WooSidebars.', 'woosidebars' ) . '</li>' . "\n" .
755
+ '<li>' . sprintf( __( 'Visit the %sAppearance &rarr; Widgets%s screen and drag the widgets from the old sidebar into the newly created sidebar.', 'woosidebars' ), '<a href="' . esc_url( admin_url( 'widgets.php' ) ) . '">', '</a>' ) . '</li>' . "\n" .
756
+ '<li>' . __( 'Repeat this process for each of your custom sidebars, including dependencies if necessary (the WooSidebars conditions system replaces the need for dependencies).', 'woosidebars' ) . '</li>' . "\n" .
757
+ '<li>' . __( 'Once you are certain that you widgets have been moved across for all widget areas, remove the sidebar from the Sidebar Manager (don\'t forget to transfer any dependencies over as well, if necessary).', 'woosidebars' ) . '</li>' . "\n" .
758
  '</ul>' . "\n"
759
  ) );
760
 
761
  get_current_screen()->set_help_sidebar(
762
  '<p><strong>' . __( 'For more information:', 'woosidebars' ) . '</strong></p>' .
763
+ '<p><a href="http://support.woothemes.com/?ref=' . 'woosidebars' . '" target="_blank">' . __( 'Support HelpDesk', 'woosidebars' ) . '</a></p>' .
764
  '<p><a href="http://dojodocs.woothemes.com/woosidebars/?ref=' . 'woosidebars' . '" target="_blank">' . __( 'WooSidebars Documentation', 'woosidebars' ) . '</a></p>'
765
  );
766
  } // End add_contextual_help()
767
 
768
  /**
769
  * load_localisation function.
770
+ *
771
  * @access public
772
  * @since 1.0.0
773
  * @return void
779
 
780
  /**
781
  * activation function.
782
+ *
783
  * @access public
784
  * @since 1.0.0
785
  * @return void
790
 
791
  /**
792
  * register_plugin_version function.
793
+ *
794
  * @access public
795
  * @since 1.0.0
796
  * @return void
integrations/integration-woocommerce.php CHANGED
@@ -12,7 +12,7 @@ class WooSidebars_Integration_WooCommerce {
12
  add_filter( 'woo_conditions', array( &$this, 'register_conditions' ) );
13
  add_filter( 'woo_conditions_headings', array( &$this, 'register_conditions_headings' ) );
14
  add_filter( 'woo_conditions_reference', array( &$this, 'register_conditions_reference' ) );
15
-
16
  add_post_type_support( 'product', 'woosidebars' );
17
  } // End __construct()
18
 
@@ -71,7 +71,7 @@ class WooSidebars_Integration_WooCommerce {
71
  */
72
  public function register_conditions_headings ( $headings ) {
73
  $headings['woocommerce'] = __( 'WooCommerce', 'woosidebars' );
74
-
75
  return $headings;
76
  } // End register_conditions_headings()
77
 
@@ -121,7 +121,7 @@ class WooSidebars_Integration_WooCommerce {
121
 
122
  // Setup terminologies for the "in category" and "tagged with" conditions.
123
  $terminologies = array(
124
- 'taxonomy-product_cat' => __( 'Products in the "%s" category', 'woosidebars' ),
125
  'taxonomy-product_tag' => __( 'Products tagged "%s"', 'woosidebars' )
126
  );
127
 
12
  add_filter( 'woo_conditions', array( &$this, 'register_conditions' ) );
13
  add_filter( 'woo_conditions_headings', array( &$this, 'register_conditions_headings' ) );
14
  add_filter( 'woo_conditions_reference', array( &$this, 'register_conditions_reference' ) );
15
+
16
  add_post_type_support( 'product', 'woosidebars' );
17
  } // End __construct()
18
 
71
  */
72
  public function register_conditions_headings ( $headings ) {
73
  $headings['woocommerce'] = __( 'WooCommerce', 'woosidebars' );
74
+
75
  return $headings;
76
  } // End register_conditions_headings()
77
 
121
 
122
  // Setup terminologies for the "in category" and "tagged with" conditions.
123
  $terminologies = array(
124
+ 'taxonomy-product_cat' => __( 'Products in the "%s" category', 'woosidebars' ),
125
  'taxonomy-product_tag' => __( 'Products tagged "%s"', 'woosidebars' )
126
  );
127
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: woothemes, mattyza
3
  Tags: widgets, sidebars, widget-areas
4
  Requires at least: 3.3
5
- Tested up to: 3.5
6
- Stable tag: 1.2.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -30,9 +30,9 @@ Looking to contribute code to this plugin? [Fork the repository over at GitHub](
30
 
31
  = Automatic installation =
32
 
33
- Automatic installation is the easiest option as WordPress handles the file transfers itself and you don’t even need to leave your web browser. To do an automatic install of WooSidebars, log in to your WordPress admin panel, navigate to the Plugins menu and click Add New.
34
 
35
- In the search field type "WooSidebars" and click Search Plugins. Once you’ve found our widget areas plugin you can view details about it such as the the point release, rating and description. Most importantly of course, you can install it by simply clicking Install Now. After clicking that link you will be asked if you’re sure you want to install the plugin. Click yes and WordPress will automatically complete the installation.
36
 
37
  = Manual installation =
38
 
@@ -48,9 +48,9 @@ Once WooSidebars has been installed and activated, please visit the "Appearance
48
 
49
  = Upgrading =
50
 
51
- Automatic updates should work a charm; as always though, ensure you backup your site just in case.
52
 
53
- == Frequently Asked Questions ==
54
 
55
  = Where can I find WooSidebars documentation and user guides? =
56
 
@@ -72,6 +72,9 @@ Looking to contribute code to this plugin? [Fork the repository over at GitHub](
72
 
73
  == Upgrade Notice ==
74
 
 
 
 
75
  = 1.2.1 =
76
  Updated for WordPress 3.5+ compatibility. Adjusted "Advanced" tab logic. Fixed bug where "Template Hierarchy -> Pages" condition wasn't being applied correctly. Dequeue WordPress SEO admin stylesheets from the "Widget Areas" "Add" and "Edit" screens.
77
 
@@ -80,7 +83,11 @@ Moved to WordPress.org. Woo! Added scope to methods and properties where missing
80
 
81
  == Changelog ==
82
 
83
- = 1.2.1 =
 
 
 
 
84
  * 2013-01-09
85
  * Updated admin JavaScript for WordPress 3.5+ compatibility. Moved "Advanced" tab outside of the tabs list.
86
  * Fixed bug with the "Template Hierarchy -> Pages" condition that wasn't applying.
2
  Contributors: woothemes, mattyza
3
  Tags: widgets, sidebars, widget-areas
4
  Requires at least: 3.3
5
+ Tested up to: 3.5.1
6
+ Stable tag: 1.2.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
30
 
31
  = Automatic installation =
32
 
33
+ Automatic installation is the easiest option as WordPress handles the file transfers itself and you don’t even need to leave your web browser. To do an automatic install of WooSidebars, log in to your WordPress admin panel, navigate to the Plugins menu and click Add New.
34
 
35
+ In the search field type "WooSidebars" and click Search Plugins. Once you’ve found our widget areas plugin you can view details about it such as the the point release, rating and description. Most importantly of course, you can install it by simply clicking Install Now. After clicking that link you will be asked if you’re sure you want to install the plugin. Click yes and WordPress will automatically complete the installation.
36
 
37
  = Manual installation =
38
 
48
 
49
  = Upgrading =
50
 
51
+ Automatic updates should work a charm; as always though, ensure you backup your site just in case.
52
 
53
+ == Frequently Asked Questions ==
54
 
55
  = Where can I find WooSidebars documentation and user guides? =
56
 
72
 
73
  == Upgrade Notice ==
74
 
75
+ = 1.2.2 =
76
+ "Widget Areas" menu is now only visible to users who can add/modify widgets.
77
+
78
  = 1.2.1 =
79
  Updated for WordPress 3.5+ compatibility. Adjusted "Advanced" tab logic. Fixed bug where "Template Hierarchy -> Pages" condition wasn't being applied correctly. Dequeue WordPress SEO admin stylesheets from the "Widget Areas" "Add" and "Edit" screens.
80
 
83
 
84
  == Changelog ==
85
 
86
+ = 1.2.2 =
87
+ * 2013-03-08
88
+ * Changes capability for displaying the menu to "edit_theme_options" in line with the "Widgets" menu capability.
89
+
90
+ = 1.2.1 =
91
  * 2013-01-09
92
  * Updated admin JavaScript for WordPress 3.5+ compatibility. Moved "Advanced" tab outside of the tabs list.
93
  * Fixed bug with the "Template Hierarchy -> Pages" condition that wasn't applying.
woosidebars.php CHANGED
@@ -5,23 +5,23 @@
5
  * Description: Replace widget areas in your theme for specific pages, archives and other sections of WordPress.
6
  * Author: WooThemes
7
  * Author URI: http://woothemes.com/
8
- * Version: 1.2.1
9
- * Stable tag: 1.2.1
10
  * License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11
  */
12
-
13
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
 
15
  if ( ! class_exists( 'Woo_Conditions' ) ) {
16
  require_once( 'classes/class-woo-conditions.php' );
17
  }
18
  require_once( 'classes/class-woo-sidebars.php' );
19
-
20
  // Third-party integrations.
21
  if ( class_exists( 'Woocommerce' ) ) require_once( 'integrations/integration-woocommerce.php' );
22
 
23
  global $woosidebars;
24
  $woosidebars = new Woo_Sidebars( __FILE__ );
25
- $woosidebars->version = '1.2.1';
26
  $woosidebars->init();
27
  ?>
5
  * Description: Replace widget areas in your theme for specific pages, archives and other sections of WordPress.
6
  * Author: WooThemes
7
  * Author URI: http://woothemes.com/
8
+ * Version: 1.2.2
9
+ * Stable tag: 1.2.2
10
  * License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11
  */
12
+
13
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
 
15
  if ( ! class_exists( 'Woo_Conditions' ) ) {
16
  require_once( 'classes/class-woo-conditions.php' );
17
  }
18
  require_once( 'classes/class-woo-sidebars.php' );
19
+
20
  // Third-party integrations.
21
  if ( class_exists( 'Woocommerce' ) ) require_once( 'integrations/integration-woocommerce.php' );
22
 
23
  global $woosidebars;
24
  $woosidebars = new Woo_Sidebars( __FILE__ );
25
+ $woosidebars->version = '1.2.2';
26
  $woosidebars->init();
27
  ?>