Simple Page Sidebars - Version 1.1.5

Version Description

  • Added Serbo-Croatian translation.
Download this release

Release Info

Developer bradyvercher
Plugin Icon 128x128 Simple Page Sidebars
Version 1.1.5
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.5

admin/admin.php CHANGED
@@ -11,41 +11,39 @@
11
  * Main admin class. Contains all the functionality to handle the various
12
  * administrative tasks for creating, editing, and assigning sidebars to
13
  * pages.
14
- *
15
  * @since 1.1.0
16
  */
17
  class Simple_Page_Sidebars_Admin {
18
  /**
19
  * Load the admin functionality.
20
- *
21
  * @since 1.1.0
22
  */
23
  public static function load() {
24
  add_action( 'init', array( __CLASS__, 'init' ) );
25
  }
26
-
27
  /**
28
  * Attaches the various hooks and methods for integrating with the
29
  * dashboard.
30
- *
31
  * @since 0.2.0
32
  */
33
  public static function init() {
34
  // Process submissions from custom Sidebar Edit screen.
35
  self::process_sidebar_update();
36
-
37
  // Process Add/Edit Page screen submissions.
38
  add_action( 'save_post', array( __CLASS__, 'update_page_sidebar' ) );
39
  // Process quick edit and bulk edit from All Pages screen.
40
  add_action( 'wp_ajax_simplepagesidebars_update_page_sidebar', array( __CLASS__, 'update_page_sidebar' ) );
41
-
42
  add_action( 'admin_menu', array( __CLASS__, 'add_sidebar_edit_screen' ) );
43
  add_action( 'add_meta_boxes', array( __CLASS__, 'add_page_sidebar_meta_box' ) );
44
-
45
  add_action( 'admin_init', array( __CLASS__, 'register_default_sidebar_setting' ) );
46
-
47
- add_action( 'parent_file', array( __CLASS__, 'highlight_widget_submenu' ) );
48
-
49
  add_filter( 'parse_query', array( __CLASS__, 'parse_admin_query' ) );
50
  add_filter( 'manage_pages_columns', array( __CLASS__, 'register_columns' ) );
51
  add_action( 'manage_edit-page_sortable_columns', array( __CLASS__, 'register_sortable_columns' ) );
@@ -53,13 +51,13 @@ class Simple_Page_Sidebars_Admin {
53
  add_action( 'quick_edit_custom_box', array( __CLASS__, 'quick_edit_custom_box' ), 10, 2 );
54
  add_action( 'bulk_edit_custom_box', array( __CLASS__, 'bulk_edit_custom_box' ), 10, 2 );
55
  add_action( 'admin_footer-edit.php', array( __CLASS__, 'quick_edit_js' ) );
56
-
57
  add_action( 'widgets_admin_page', array( __CLASS__, 'widgets_page_messages' ) );
58
  }
59
-
60
  /**
61
  * Register setting for choosing the default sidebar.
62
- *
63
  * @since 0.2.0
64
  */
65
  public static function register_default_sidebar_setting() {
@@ -67,7 +65,7 @@ class Simple_Page_Sidebars_Admin {
67
  'reading',
68
  'simple_page_sidebars_default_sidebar'
69
  );
70
-
71
  add_settings_field(
72
  'simple_page_sidebars_default_sidebar',
73
  '<label for="simple-page-sidebars-default-sidebar">' . __( 'Default Sidebar', 'simple-page-sidebars' ) . '</label>',
@@ -75,16 +73,16 @@ class Simple_Page_Sidebars_Admin {
75
  'reading'
76
  );
77
  }
78
-
79
  /**
80
  * Default sidebar option dropdown.
81
- *
82
  * @since 0.2.0
83
  * @uses $wp_registered_sidebars
84
  */
85
  public static function default_sidebar_settings_field() {
86
  global $wp_registered_sidebars;
87
-
88
  $default_sidebar_id = get_option( 'simple_page_sidebars_default_sidebar' );
89
  $custom_sidebars = simple_page_sidebars_get_names();
90
  ?>
@@ -105,10 +103,10 @@ class Simple_Page_Sidebars_Admin {
105
  <span class="description"><?php _e( 'The sidebar that should be replaced by custom sidebars.', 'simple-page-sidebars' ); ?></span>
106
  <?php
107
  }
108
-
109
  /**
110
  * Register page sidebar meta box.
111
- *
112
  * @since 0.2.0
113
  */
114
  public static function add_page_sidebar_meta_box( $post_type ) {
@@ -116,10 +114,10 @@ class Simple_Page_Sidebars_Admin {
116
  add_meta_box( 'simplepagesidebarsdiv', __( 'Sidebar', 'simple-page-sidebars' ), array( __CLASS__, 'page_sidebar_meta_box' ), $post_type, 'side', 'default' );
117
  }
118
  }
119
-
120
  /**
121
  * Meta box for adding a new sidebar or choosing an existing sidebar.
122
- *
123
  * @since 0.2.0
124
  * @uses $wpdb, $wp_registered_sidebars
125
  * @todo Improve the update message delivery and only show it on success.
@@ -128,34 +126,34 @@ class Simple_Page_Sidebars_Admin {
128
  */
129
  public static function page_sidebar_meta_box( $page ) {
130
  global $wpdb, $wp_registered_sidebars;
131
-
132
  $sidebar = self::get_page_sidebar( $page->ID );
133
  $custom_sidebars = simple_page_sidebars_get_names();
134
-
135
  // Show an error message if a default sidebar hasn't been selected on the Reading settings screen.
136
  if ( ! get_option( 'simple_page_sidebars_default_sidebar' )) {
137
  echo '<div class="simple-page-sidebars-page-sidebar-feedback simple-page-sidebars-page-sidebar-feedback-error"><p>';
138
  echo self::get_empty_default_sidebar_error();
139
  echo '</p></div>';
140
  }
141
-
142
  wp_nonce_field( 'update-page-sidebar_' . $page->ID, 'simplepagesidebars_page_sidebar_update_nonce', false );
143
-
144
  include_once( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/views/meta-box-page-sidebar.php' );
145
  }
146
-
147
  /**
148
  * Custom sort the pages on the All Pages screen.
149
- *
150
  * Any pages without the '_sidebar_name' meta field won't appear in the
151
  * list when the pages are custom sorted.
152
- *
153
  * The $wp_query object is passed be reference and any changes made to it
154
  * will be reflected globally.
155
- *
156
  * @since 1.1.0
157
  * @link http://codex.wordpress.org/Class_Reference/WP_Query
158
- *
159
  * @param object $wp_query The WP_Query object passed by reference.
160
  */
161
  public static function parse_admin_query( $wp_query ) {
@@ -165,17 +163,17 @@ class Simple_Page_Sidebars_Admin {
165
  // An example to sort results by a custom meta field.
166
  $wp_query->set( 'meta_key', '_sidebar_name' );
167
  $wp_query->set( 'orderby', 'meta_value' );
168
-
169
  // Set the order.
170
  $order = ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) ? 'desc' : 'asc';
171
  $wp_query->set( 'order', $order );
172
  }
173
  }
174
  }
175
-
176
  /**
177
  * Register sidebar column on the All Pages screen.
178
- *
179
  * @since 0.2.0
180
  * @param array $columns Array of column names and corresponding IDs as keys.
181
  * @param array $columns The filtered columns array.
@@ -184,20 +182,20 @@ class Simple_Page_Sidebars_Admin {
184
  $columns['simple-page-sidebar'] = __( 'Sidebar', 'simple-page-sidebars' );
185
  return $columns;
186
  }
187
-
188
  /**
189
  * Register sortable columns on the All Pages screen.
190
- *
191
  * @since 1.1.0
192
  * @param array $columns Array of query vars and corresponding column IDs as keys.
193
  * @return array $columns The filtered columns array.
194
  */
195
  public static function register_sortable_columns( $columns ) {
196
  $columns['simple-page-sidebar'] = 'simple-page-sidebar';
197
-
198
  return $columns;
199
  }
200
-
201
  /**
202
  * Display sidebar column on All Pages screen.
203
  *
@@ -219,15 +217,15 @@ class Simple_Page_Sidebars_Admin {
219
  echo $sidebar;
220
  }
221
  }
222
-
223
  // Add the nonce here and copy it to the inline editor with javascript.
224
  wp_nonce_field( 'update-page-sidebar_' . $page_id, 'simplepagesidebars_page_sidebar_update_nonce', false );
225
  }
226
  }
227
-
228
  /**
229
  * Sidebar dropdown field for quick edit mode.
230
- *
231
  * @since 0.2.0
232
  * @param string $column The ID of the column being rendered.
233
  * @param string $post_type The type of post being updated.
@@ -236,7 +234,7 @@ class Simple_Page_Sidebars_Admin {
236
  if ( 'page' != $post_type || 'simple-page-sidebar' != $column ) {
237
  return;
238
  }
239
-
240
  $sidebars = simple_page_sidebars_get_names();
241
  ?>
242
  <fieldset class="inline-edit-col-left">
@@ -258,51 +256,57 @@ class Simple_Page_Sidebars_Admin {
258
  </fieldset>
259
  <?php
260
  }
261
-
262
  /**
263
  * Quick edit javascript.
264
- *
265
  * Selects the correct sidebar during quick edit and copies the nonce for
266
  * saving.
267
- *
268
  * @since 0.2.0
269
  */
270
  public static function quick_edit_js() {
271
  $screen = get_current_screen();
272
-
273
  if ( 'edit-page' != $screen->id || 'page' != $screen->post_type ) {
274
  return;
275
  }
276
  ?>
277
  <script type="text/javascript">
278
- jQuery(function($) {
279
- $('table.pages').on('click', 'a.editinline', function(e) {
280
- inlineEditPost.revert();
281
-
282
- var id = inlineEditPost.getId(this),
283
- currentSidebar = $('#post-' + id + ' .simple-page-sidebar').text(),
284
- sidebarNameField = $('#simple-page-sidebars-page-sidebar-name');
285
-
 
 
 
 
286
  // Select the current sidebar option.
287
- sidebarNameField.find('option').attr('selected', false);
288
  if ( '' != currentSidebar ) {
289
- sidebarNameField.find('option:contains(' + currentSidebar + ')').attr('selected', true);
290
  }
291
-
292
  // Copy the sidebar name nonce.
293
- $('#simple-page-sidebars-page-sidebar-edit-group').find('input[name="simplepagesidebars_page_sidebar_update_nonce"]').remove().end().append( $('#post-' + id + ' input[name="simplepagesidebars_page_sidebar_update_nonce"]').clone() );
294
- });
295
- });
 
 
296
  </script>
297
  <style type="text/css">
298
  .widefat .column-simple-page-sidebar { width: 15%;}
299
  </style>
300
  <?php
301
  }
302
-
303
  /**
304
  * Sidebar dropdown field for bulk edit mode.
305
- *
306
  * @since 0.2.0
307
  * @param string $column The ID of the column being rendered.
308
  * @param string $post_type The type of post being updated.
@@ -311,7 +315,7 @@ class Simple_Page_Sidebars_Admin {
311
  if ( 'page' != $post_type || 'simple-page-sidebar' != $column ) {
312
  return;
313
  }
314
-
315
  $sidebars = simple_page_sidebars_get_names();
316
  ?>
317
  <fieldset class="inline-edit-col-right" style="margin-top: 0">
@@ -323,7 +327,7 @@ class Simple_Page_Sidebars_Admin {
323
  <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
324
  <?php
325
  foreach ( $sidebars as $sb ) {
326
- printf( '<option value="%1$s">%1$s</option>', $sb );
327
  }
328
  ?>
329
  </select>
@@ -333,13 +337,13 @@ class Simple_Page_Sidebars_Admin {
333
  </fieldset>
334
  <?php
335
  }
336
-
337
  /**
338
  * Save custom page sidebar.
339
- *
340
  * Processes requests coming from normal page edits, quick edit, and bulk
341
  * edit. Requires a valid nonce.
342
- *
343
  * @since 0.2.0
344
  * @param int $post_id Optional. The ID of the page whose sidebar should be updated.
345
  */
@@ -347,27 +351,27 @@ class Simple_Page_Sidebars_Admin {
347
  if ( empty( $post_id ) ) {
348
  $post_id = $_REQUEST['post_id'];
349
  }
350
-
351
  // Verify either an individual post nonce or the bulk edit nonce.
352
  // Requests can come from a page update, AJAX from the sidebar meta box, quick edit, or bulk edit.
353
  $is_nonce_valid = ( isset( $_REQUEST['simplepagesidebars_page_sidebar_update_nonce'] ) && wp_verify_nonce( $_REQUEST['simplepagesidebars_page_sidebar_update_nonce'], 'update-page-sidebar_' . $post_id ) ) ? true : false;
354
  $is_bulk_nonce_valid = ( isset( $_REQUEST['simplepagesidebars_bulk_update_nonce'] ) && wp_verify_nonce( $_REQUEST['simplepagesidebars_bulk_update_nonce'], 'bulk-update-page-sidebar' ) ) ? true : false;
355
  $is_autosave = ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ? true : false;
356
  $is_revision = wp_is_post_revision( $post_id );
357
-
358
  if ( ( $is_autosave || $is_revision ) || ( ! $is_nonce_valid && ! $is_bulk_nonce_valid ) ) {
359
  return $post_id;
360
  }
361
-
362
  // If 'new_sidebar_name' is set and not empty, it supercedes any 'sidebar_name' setting.
363
  // If 'sidebar_name' is blank or it equals 'default', delete meta.
364
  // If 'sidebar_name' is set and not empty, update to new name.
365
  // If 'sidebar_name' is -1, skip.
366
-
367
  // Bulk edit uses $_GET for some reason, so we use the $_REQUEST global to catch everything.
368
  $sidebar = ( isset( $_REQUEST['simplepagesidebars_page_sidebar_name'] ) ) ? self::sanitize_sidebar_name( $_REQUEST['simplepagesidebars_page_sidebar_name'] ) : -1;
369
  $new_sidebar_name = ( isset( $_REQUEST['simplepagesidebars_page_sidebar_name_new'] ) ) ? self::sanitize_sidebar_name( $_REQUEST['simplepagesidebars_page_sidebar_name_new'] ) : '';
370
-
371
  if ( isset( $new_sidebar_name ) && ! empty( $new_sidebar_name ) ) {
372
  update_post_meta( $post_id, '_sidebar_name', $new_sidebar_name );
373
  } elseif ( empty( $sidebar ) || 'default' == $sidebar ) {
@@ -376,101 +380,80 @@ class Simple_Page_Sidebars_Admin {
376
  update_post_meta( $post_id, '_sidebar_name', $sidebar );
377
  }
378
  }
379
-
380
  /**
381
  * Add a custom Sidebar Edit screen.
382
- *
383
  * The menu title argument in add_submenu_page() is null so the page won't
384
  * appear in the admin menu. It simply registers the screen so it's
385
  * available when visited.
386
- *
387
  * @since 1.1.0
388
  */
389
  public static function add_sidebar_edit_screen() {
390
- add_submenu_page( 'themes.php', __( 'Edit Sidebar', 'simple-page-sidebars' ), null, 'edit_theme_options', 'simple-page-sidebars', array( __CLASS__, 'edit_sidebar_screen' ) );
391
-
392
- add_meta_box( 'simplepagesidebarseditdiv', 'Pages', array( __CLASS__, 'edit_sidebar_pages_meta_box' ), 'appearance_page_simple-page-sidebars', 'normal', 'default' );
393
- }
394
-
395
- /**
396
- * Highlight the widget submenu when the Edit Sidebar screen is being
397
- * iewed.
398
- *
399
- * @since 1.1.0
400
- * @uses $submenu_file
401
- *
402
- * @param string $parent_file The top level menu item being viewed.
403
- * @return string $parent_file
404
- */
405
- public static function highlight_widget_submenu( $parent_file ) {
406
- global $submenu_file;
407
-
408
- $screen = get_current_screen();
409
- if ( 'appearance_page_simple-page-sidebars' == $screen->id ) {
410
- $submenu_file = 'widgets.php';
411
- }
412
-
413
- return $parent_file;
414
  }
415
-
416
  /**
417
  * Display the Edit Sidebar screen.
418
- *
419
  * The sidebar being edited is passed as a variable through the query
420
  * string. If it's determined that the sidebar isn't valid, an error will
421
  * be shown.
422
- *
423
  * @since 1.1.0
424
  */
425
  public static function edit_sidebar_screen() {
426
  global $wpdb;
427
-
428
  wp_enqueue_script( 'post' );
429
-
430
  $screen = get_current_screen();
431
  $sidebar_name = self::sanitize_sidebar_name( stripslashes( $_GET['sidebar'] ) );
432
-
433
  include( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/views/edit-sidebar-screen.php' );
434
  }
435
-
436
  /**
437
  * Add a page checbox list meta box to the Edit Sidebar screen.
438
- *
439
  * @since 1.1.0
440
  * @param object $post The post being edited.
441
  * @param array $metabox Any additional arguments passed during the meta box registration.
442
  */
443
  public static function edit_sidebar_pages_meta_box( $post, $metabox ) {
444
  $default_sidebar = get_option( 'simple_page_sidebars_default_sidebar' );
445
-
446
  include_once( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/includes/class-simple-page-sidebars-walker-page-checklist.php' );
447
  include_once( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/views/meta-box-sidebar-pages.php' );
448
  }
449
-
450
  /**
451
  * Process submissions for the Edit Sidebar screen.
452
- *
453
  * Handles cases where the sidebar is renamed, reassigns pages, and
454
  * removes the sidebar if no pages are selected. Requires a valid nonce.
455
- *
456
  * @since 1.1.0
457
  */
458
  public static function process_sidebar_update() {
459
  global $wpdb;
460
-
461
  if ( isset( $_POST['simplepagesidebars_sidebar_name'] ) ) {
462
  $current_name = stripslashes( $_POST['simplepagesidebars_sidebar_name'] );
463
-
464
  check_admin_referer( 'update-sidebar_' . $current_name, 'simplepagesidebars_sidebar_update_nonce' );
465
-
466
  $new_name = stripslashes( $_POST['simplepagesidebars_sidebar_name_new'] );
467
  $new_name = ( ! empty( $new_name ) && $new_name != $current_name ) ? trim( wp_strip_all_tags( $new_name ) ) : null;
468
-
469
  $pages = ( isset( $_POST['simplepagesidebars_sidebar_pages'] ) ) ? wp_parse_id_list( $_POST['simplepagesidebars_sidebar_pages'] ) : array();
470
-
471
  // Retrieve IDs of pages using the existing sidebar name.
472
  $current_pages = self::get_page_ids_using_sidebar( $current_name );
473
-
474
  // Pages to reset to the default sidebar.
475
  $reset_pages = array_diff( $current_pages, $pages );
476
  if ( $reset_pages ) {
@@ -478,7 +461,7 @@ class Simple_Page_Sidebars_Admin {
478
  delete_post_meta( $page_id, '_sidebar_name' );
479
  }
480
  }
481
-
482
  // Update all sidebars if there is a new sidebar name.
483
  if ( $new_name ) {
484
  $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value=%s WHERE meta_key='_sidebar_name' AND meta_value=%s", $new_name, $current_name ) );
@@ -489,21 +472,21 @@ class Simple_Page_Sidebars_Admin {
489
  update_post_meta( $page_id, '_sidebar_name', addslashes( $current_name ) );
490
  }
491
  }
492
-
493
  // The sidebar should have been removed from all pages.
494
  // Let WordPress move widgets to Inactive Sidebar, redirect to Widgets screen, and notify user.
495
  if ( empty( $pages ) ) {
496
  wp_safe_redirect( esc_url_raw( add_query_arg( 'simple-page-sidebars-message', 1, admin_url( 'widgets.php' ) ) ) );
497
  exit;
498
  }
499
-
500
  // Migrate widgets if the sidebar name was changed.
501
  if ( $new_name ) {
502
  $sidebars_widgets = wp_get_sidebars_widgets();
503
-
504
  $old_id = 'page-sidebar-' . sanitize_key( $current_name );
505
  $new_id = 'page-sidebar-' . sanitize_key( $new_name );
506
-
507
  // If new id matches an existing id, merge old widgets with new.
508
  if ( isset( $sidebars_widgets[ $new_id ] ) ) {
509
  $sidebars_widgets[ $new_id ] = array_merge( $sidebars_widgets[ $new_id ], $sidebars_widgets[ $old_id ] );
@@ -512,13 +495,13 @@ class Simple_Page_Sidebars_Admin {
512
  elseif ( isset( $sidebars_widgets[ $old_id ] ) ) {
513
  $sidebars_widgets[ $new_id ] = $sidebars_widgets[ $old_id ];
514
  }
515
-
516
  // Remove old widget area and save.
517
  unset( $sidebars_widgets[ $old_id ] );
518
  #echo '<pre>'; print_r( $sidebars_widgets ); echo '</pre>'; exit;
519
  wp_set_sidebars_widgets( $sidebars_widgets );
520
  }
521
-
522
  // Redirect back to sidebar edit screen with an update message.
523
  $name = ( ! empty( $new_name ) ) ? $new_name : $current_name;
524
  $redirect_link = self::get_sidebar_edit_link( $name, array( 'message' => 1 ) );
@@ -526,20 +509,20 @@ class Simple_Page_Sidebars_Admin {
526
  exit;
527
  }
528
  }
529
-
530
  /**
531
  * Display messages on the widgets page.
532
- *
533
  * @since 1.1.0
534
  */
535
  public static function widgets_page_messages() {
536
  $sidebars = simple_page_sidebars_get_names();
537
-
538
  // Display an error message if a default sidebar hasn't been selected on the Reading settings screen.
539
  if ( ! get_option( 'simple_page_sidebars_default_sidebar' ) && ! empty( $sidebars ) ) {
540
  echo '<div class="error"><p>' . self::get_empty_default_sidebar_error() . '</p></div>';
541
  }
542
-
543
  // Display any custom update messages.
544
  if ( isset( $_REQUEST['simple-page-sidebars-message'] ) && ! empty( $_REQUEST['simple-page-sidebars-message'] ) ) {
545
  ?>
@@ -549,7 +532,7 @@ class Simple_Page_Sidebars_Admin {
549
  $messages = array(
550
  1 => __( 'The sidebar you were editing is no longer assigned to any pages and has been removed. Any widgets it contained should be in an "Inactive Widgets" area below.', 'simple-page-sidebars' )
551
  );
552
-
553
  $message_id = $_REQUEST['simple-page-sidebars-message'];
554
  if ( isset( $messages[ $message_id ] ) ) {
555
  echo $messages[ $message_id ];
@@ -560,12 +543,12 @@ class Simple_Page_Sidebars_Admin {
560
  <?php
561
  }
562
  }
563
-
564
  /**
565
  * Get a page's sidebar.
566
- *
567
  * Sanitizes the sidebar name before returning it.
568
- *
569
  * @since 1.1.0
570
  * @param int $page_id ID of the page whose sidebar should be returned.
571
  * @return string Sanitized sidebar name.
@@ -573,30 +556,30 @@ class Simple_Page_Sidebars_Admin {
573
  public static function get_page_sidebar( $page_id ) {
574
  return self::sanitize_sidebar_name( get_post_meta( $page_id, '_sidebar_name', true ) );
575
  }
576
-
577
  /**
578
  * Retrieve IDs of pages using a particular sidebar.
579
- *
580
  * @since 1.1.0
581
  * @param string $sidebar The sidebar name.
582
  * @return array An array of page IDs or an empty array.
583
  */
584
  public static function get_page_ids_using_sidebar( $sidebar ) {
585
  global $wpdb;
586
-
587
  $ids = $wpdb->get_col( $wpdb->prepare( "SELECT p.ID
588
  FROM $wpdb->posts p
589
  INNER JOIN $wpdb->postmeta pm ON p.ID=pm.post_id
590
  WHERE p.post_type='page' AND p.post_status!='auto-draft' AND pm.meta_key='_sidebar_name' AND pm.meta_value=%s",
591
  $sidebar
592
  ) );
593
-
594
  return ( empty( $ids ) ) ? array() : $ids;
595
  }
596
-
597
  /**
598
  * Sanitize a sidebar name.
599
- *
600
  * @since 1.1.0
601
  * @param string $name The sidebar name.
602
  * @return string Sanitized sidebar name.
@@ -604,10 +587,10 @@ class Simple_Page_Sidebars_Admin {
604
  public static function sanitize_sidebar_name( $name ) {
605
  return trim( wp_strip_all_tags( $name ) );
606
  }
607
-
608
  /**
609
  * Get the edit link for a sidebar.
610
- *
611
  * @since 1.1.0
612
  * @param string $sidebar The sidebar name.
613
  * @param array $query_args Optional. An array of additional query args to append to the edit link.
@@ -618,18 +601,18 @@ class Simple_Page_Sidebars_Admin {
618
  'page' => 'simple-page-sidebars',
619
  'sidebar' => rawurlencode( $sidebar )
620
  ) );
621
-
622
- $link = add_query_arg( $query_args, admin_url( 'themes.php' ) );
623
-
624
  return $link;
625
  }
626
-
627
  /**
628
  * The error message to display if a default sidebar hasn't been selected.
629
- *
630
  * This is used a few times throughout the dashboard, so the string is
631
  * abstracted out here.
632
- *
633
  * @since 1.1.0
634
  * @return string Error message
635
  */
@@ -638,10 +621,10 @@ class Simple_Page_Sidebars_Admin {
638
  ' <a href="' . admin_url( 'options-reading.php' ) . '">' . __( 'Reading settings screen', 'simple-page-sidebars' ) . '</a>.'
639
  );
640
  }
641
-
642
  /**
643
  * Backward compatible AJAX spinner.
644
- *
645
  * Displays the correct AJAX spinner depending on the version of WordPress.
646
  *
647
  * @since 1.1.0
@@ -653,7 +636,7 @@ class Simple_Page_Sidebars_Admin {
653
  'id' => '',
654
  'class' => ''
655
  ) );
656
-
657
  if ( version_compare( get_bloginfo( 'version' ), '3.5-beta-1', '<' ) ) {
658
  printf( '<img src="%1$s" id="%2$s" class="%3$s" alt="">',
659
  esc_url( SIMPLE_PAGE_SIDEBARS_URL . 'admin/images/wpspin_light.gif' ),
@@ -665,4 +648,3 @@ class Simple_Page_Sidebars_Admin {
665
  }
666
  }
667
  }
668
- ?>
11
  * Main admin class. Contains all the functionality to handle the various
12
  * administrative tasks for creating, editing, and assigning sidebars to
13
  * pages.
14
+ *
15
  * @since 1.1.0
16
  */
17
  class Simple_Page_Sidebars_Admin {
18
  /**
19
  * Load the admin functionality.
20
+ *
21
  * @since 1.1.0
22
  */
23
  public static function load() {
24
  add_action( 'init', array( __CLASS__, 'init' ) );
25
  }
26
+
27
  /**
28
  * Attaches the various hooks and methods for integrating with the
29
  * dashboard.
30
+ *
31
  * @since 0.2.0
32
  */
33
  public static function init() {
34
  // Process submissions from custom Sidebar Edit screen.
35
  self::process_sidebar_update();
36
+
37
  // Process Add/Edit Page screen submissions.
38
  add_action( 'save_post', array( __CLASS__, 'update_page_sidebar' ) );
39
  // Process quick edit and bulk edit from All Pages screen.
40
  add_action( 'wp_ajax_simplepagesidebars_update_page_sidebar', array( __CLASS__, 'update_page_sidebar' ) );
41
+
42
  add_action( 'admin_menu', array( __CLASS__, 'add_sidebar_edit_screen' ) );
43
  add_action( 'add_meta_boxes', array( __CLASS__, 'add_page_sidebar_meta_box' ) );
44
+
45
  add_action( 'admin_init', array( __CLASS__, 'register_default_sidebar_setting' ) );
46
+
 
 
47
  add_filter( 'parse_query', array( __CLASS__, 'parse_admin_query' ) );
48
  add_filter( 'manage_pages_columns', array( __CLASS__, 'register_columns' ) );
49
  add_action( 'manage_edit-page_sortable_columns', array( __CLASS__, 'register_sortable_columns' ) );
51
  add_action( 'quick_edit_custom_box', array( __CLASS__, 'quick_edit_custom_box' ), 10, 2 );
52
  add_action( 'bulk_edit_custom_box', array( __CLASS__, 'bulk_edit_custom_box' ), 10, 2 );
53
  add_action( 'admin_footer-edit.php', array( __CLASS__, 'quick_edit_js' ) );
54
+
55
  add_action( 'widgets_admin_page', array( __CLASS__, 'widgets_page_messages' ) );
56
  }
57
+
58
  /**
59
  * Register setting for choosing the default sidebar.
60
+ *
61
  * @since 0.2.0
62
  */
63
  public static function register_default_sidebar_setting() {
65
  'reading',
66
  'simple_page_sidebars_default_sidebar'
67
  );
68
+
69
  add_settings_field(
70
  'simple_page_sidebars_default_sidebar',
71
  '<label for="simple-page-sidebars-default-sidebar">' . __( 'Default Sidebar', 'simple-page-sidebars' ) . '</label>',
73
  'reading'
74
  );
75
  }
76
+
77
  /**
78
  * Default sidebar option dropdown.
79
+ *
80
  * @since 0.2.0
81
  * @uses $wp_registered_sidebars
82
  */
83
  public static function default_sidebar_settings_field() {
84
  global $wp_registered_sidebars;
85
+
86
  $default_sidebar_id = get_option( 'simple_page_sidebars_default_sidebar' );
87
  $custom_sidebars = simple_page_sidebars_get_names();
88
  ?>
103
  <span class="description"><?php _e( 'The sidebar that should be replaced by custom sidebars.', 'simple-page-sidebars' ); ?></span>
104
  <?php
105
  }
106
+
107
  /**
108
  * Register page sidebar meta box.
109
+ *
110
  * @since 0.2.0
111
  */
112
  public static function add_page_sidebar_meta_box( $post_type ) {
114
  add_meta_box( 'simplepagesidebarsdiv', __( 'Sidebar', 'simple-page-sidebars' ), array( __CLASS__, 'page_sidebar_meta_box' ), $post_type, 'side', 'default' );
115
  }
116
  }
117
+
118
  /**
119
  * Meta box for adding a new sidebar or choosing an existing sidebar.
120
+ *
121
  * @since 0.2.0
122
  * @uses $wpdb, $wp_registered_sidebars
123
  * @todo Improve the update message delivery and only show it on success.
126
  */
127
  public static function page_sidebar_meta_box( $page ) {
128
  global $wpdb, $wp_registered_sidebars;
129
+
130
  $sidebar = self::get_page_sidebar( $page->ID );
131
  $custom_sidebars = simple_page_sidebars_get_names();
132
+
133
  // Show an error message if a default sidebar hasn't been selected on the Reading settings screen.
134
  if ( ! get_option( 'simple_page_sidebars_default_sidebar' )) {
135
  echo '<div class="simple-page-sidebars-page-sidebar-feedback simple-page-sidebars-page-sidebar-feedback-error"><p>';
136
  echo self::get_empty_default_sidebar_error();
137
  echo '</p></div>';
138
  }
139
+
140
  wp_nonce_field( 'update-page-sidebar_' . $page->ID, 'simplepagesidebars_page_sidebar_update_nonce', false );
141
+
142
  include_once( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/views/meta-box-page-sidebar.php' );
143
  }
144
+
145
  /**
146
  * Custom sort the pages on the All Pages screen.
147
+ *
148
  * Any pages without the '_sidebar_name' meta field won't appear in the
149
  * list when the pages are custom sorted.
150
+ *
151
  * The $wp_query object is passed be reference and any changes made to it
152
  * will be reflected globally.
153
+ *
154
  * @since 1.1.0
155
  * @link http://codex.wordpress.org/Class_Reference/WP_Query
156
+ *
157
  * @param object $wp_query The WP_Query object passed by reference.
158
  */
159
  public static function parse_admin_query( $wp_query ) {
163
  // An example to sort results by a custom meta field.
164
  $wp_query->set( 'meta_key', '_sidebar_name' );
165
  $wp_query->set( 'orderby', 'meta_value' );
166
+
167
  // Set the order.
168
  $order = ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) ? 'desc' : 'asc';
169
  $wp_query->set( 'order', $order );
170
  }
171
  }
172
  }
173
+
174
  /**
175
  * Register sidebar column on the All Pages screen.
176
+ *
177
  * @since 0.2.0
178
  * @param array $columns Array of column names and corresponding IDs as keys.
179
  * @param array $columns The filtered columns array.
182
  $columns['simple-page-sidebar'] = __( 'Sidebar', 'simple-page-sidebars' );
183
  return $columns;
184
  }
185
+
186
  /**
187
  * Register sortable columns on the All Pages screen.
188
+ *
189
  * @since 1.1.0
190
  * @param array $columns Array of query vars and corresponding column IDs as keys.
191
  * @return array $columns The filtered columns array.
192
  */
193
  public static function register_sortable_columns( $columns ) {
194
  $columns['simple-page-sidebar'] = 'simple-page-sidebar';
195
+
196
  return $columns;
197
  }
198
+
199
  /**
200
  * Display sidebar column on All Pages screen.
201
  *
217
  echo $sidebar;
218
  }
219
  }
220
+
221
  // Add the nonce here and copy it to the inline editor with javascript.
222
  wp_nonce_field( 'update-page-sidebar_' . $page_id, 'simplepagesidebars_page_sidebar_update_nonce', false );
223
  }
224
  }
225
+
226
  /**
227
  * Sidebar dropdown field for quick edit mode.
228
+ *
229
  * @since 0.2.0
230
  * @param string $column The ID of the column being rendered.
231
  * @param string $post_type The type of post being updated.
234
  if ( 'page' != $post_type || 'simple-page-sidebar' != $column ) {
235
  return;
236
  }
237
+
238
  $sidebars = simple_page_sidebars_get_names();
239
  ?>
240
  <fieldset class="inline-edit-col-left">
256
  </fieldset>
257
  <?php
258
  }
259
+
260
  /**
261
  * Quick edit javascript.
262
+ *
263
  * Selects the correct sidebar during quick edit and copies the nonce for
264
  * saving.
265
+ *
266
  * @since 0.2.0
267
  */
268
  public static function quick_edit_js() {
269
  $screen = get_current_screen();
270
+
271
  if ( 'edit-page' != $screen->id || 'page' != $screen->post_type ) {
272
  return;
273
  }
274
  ?>
275
  <script type="text/javascript">
276
+ ( function( window, $, undefined ) {
277
+ 'use strict';
278
+
279
+ var wpInlineEdit = inlineEditPost.edit;
280
+
281
+ inlineEditPost.edit = function( id ) {
282
+ wpInlineEdit.apply( this, arguments );
283
+
284
+ var postId = inlineEditPost.getId( id ),
285
+ currentSidebar = $( '#post-' + postId + ' .simple-page-sidebar' ).text(),
286
+ sidebarNameField = $( '#simple-page-sidebars-page-sidebar-name' );
287
+
288
  // Select the current sidebar option.
289
+ sidebarNameField.find( 'option' ).attr( 'selected', false );
290
  if ( '' != currentSidebar ) {
291
+ sidebarNameField.find( 'option:contains(' + currentSidebar + ')' ).attr( 'selected', true );
292
  }
293
+
294
  // Copy the sidebar name nonce.
295
+ $( '#simple-page-sidebars-page-sidebar-edit-group' )
296
+ .find( 'input[name="simplepagesidebars_page_sidebar_update_nonce"]' ).remove().end()
297
+ .append( $( '#post-' + postId + ' input[name="simplepagesidebars_page_sidebar_update_nonce"]' ).clone() );
298
+ };
299
+ } )( window, jQuery );
300
  </script>
301
  <style type="text/css">
302
  .widefat .column-simple-page-sidebar { width: 15%;}
303
  </style>
304
  <?php
305
  }
306
+
307
  /**
308
  * Sidebar dropdown field for bulk edit mode.
309
+ *
310
  * @since 0.2.0
311
  * @param string $column The ID of the column being rendered.
312
  * @param string $post_type The type of post being updated.
315
  if ( 'page' != $post_type || 'simple-page-sidebar' != $column ) {
316
  return;
317
  }
318
+
319
  $sidebars = simple_page_sidebars_get_names();
320
  ?>
321
  <fieldset class="inline-edit-col-right" style="margin-top: 0">
327
  <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
328
  <?php
329
  foreach ( $sidebars as $sb ) {
330
+ printf( '<option value="%1$s">%2$s</option>', esc_attr( $sb ), esc_html( $sb ) );
331
  }
332
  ?>
333
  </select>
337
  </fieldset>
338
  <?php
339
  }
340
+
341
  /**
342
  * Save custom page sidebar.
343
+ *
344
  * Processes requests coming from normal page edits, quick edit, and bulk
345
  * edit. Requires a valid nonce.
346
+ *
347
  * @since 0.2.0
348
  * @param int $post_id Optional. The ID of the page whose sidebar should be updated.
349
  */
351
  if ( empty( $post_id ) ) {
352
  $post_id = $_REQUEST['post_id'];
353
  }
354
+
355
  // Verify either an individual post nonce or the bulk edit nonce.
356
  // Requests can come from a page update, AJAX from the sidebar meta box, quick edit, or bulk edit.
357
  $is_nonce_valid = ( isset( $_REQUEST['simplepagesidebars_page_sidebar_update_nonce'] ) && wp_verify_nonce( $_REQUEST['simplepagesidebars_page_sidebar_update_nonce'], 'update-page-sidebar_' . $post_id ) ) ? true : false;
358
  $is_bulk_nonce_valid = ( isset( $_REQUEST['simplepagesidebars_bulk_update_nonce'] ) && wp_verify_nonce( $_REQUEST['simplepagesidebars_bulk_update_nonce'], 'bulk-update-page-sidebar' ) ) ? true : false;
359
  $is_autosave = ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ? true : false;
360
  $is_revision = wp_is_post_revision( $post_id );
361
+
362
  if ( ( $is_autosave || $is_revision ) || ( ! $is_nonce_valid && ! $is_bulk_nonce_valid ) ) {
363
  return $post_id;
364
  }
365
+
366
  // If 'new_sidebar_name' is set and not empty, it supercedes any 'sidebar_name' setting.
367
  // If 'sidebar_name' is blank or it equals 'default', delete meta.
368
  // If 'sidebar_name' is set and not empty, update to new name.
369
  // If 'sidebar_name' is -1, skip.
370
+
371
  // Bulk edit uses $_GET for some reason, so we use the $_REQUEST global to catch everything.
372
  $sidebar = ( isset( $_REQUEST['simplepagesidebars_page_sidebar_name'] ) ) ? self::sanitize_sidebar_name( $_REQUEST['simplepagesidebars_page_sidebar_name'] ) : -1;
373
  $new_sidebar_name = ( isset( $_REQUEST['simplepagesidebars_page_sidebar_name_new'] ) ) ? self::sanitize_sidebar_name( $_REQUEST['simplepagesidebars_page_sidebar_name_new'] ) : '';
374
+
375
  if ( isset( $new_sidebar_name ) && ! empty( $new_sidebar_name ) ) {
376
  update_post_meta( $post_id, '_sidebar_name', $new_sidebar_name );
377
  } elseif ( empty( $sidebar ) || 'default' == $sidebar ) {
380
  update_post_meta( $post_id, '_sidebar_name', $sidebar );
381
  }
382
  }
383
+
384
  /**
385
  * Add a custom Sidebar Edit screen.
386
+ *
387
  * The menu title argument in add_submenu_page() is null so the page won't
388
  * appear in the admin menu. It simply registers the screen so it's
389
  * available when visited.
390
+ *
391
  * @since 1.1.0
392
  */
393
  public static function add_sidebar_edit_screen() {
394
+ add_submenu_page( 'admin.php', __( 'Edit Sidebar', 'simple-page-sidebars' ), null, 'edit_theme_options', 'simple-page-sidebars', array( __CLASS__, 'edit_sidebar_screen' ) );
395
+
396
+ add_meta_box( 'simplepagesidebarseditdiv', 'Pages', array( __CLASS__, 'edit_sidebar_pages_meta_box' ), 'admin_page_simple-page-sidebars', 'normal', 'default' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397
  }
398
+
399
  /**
400
  * Display the Edit Sidebar screen.
401
+ *
402
  * The sidebar being edited is passed as a variable through the query
403
  * string. If it's determined that the sidebar isn't valid, an error will
404
  * be shown.
405
+ *
406
  * @since 1.1.0
407
  */
408
  public static function edit_sidebar_screen() {
409
  global $wpdb;
410
+
411
  wp_enqueue_script( 'post' );
412
+
413
  $screen = get_current_screen();
414
  $sidebar_name = self::sanitize_sidebar_name( stripslashes( $_GET['sidebar'] ) );
415
+
416
  include( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/views/edit-sidebar-screen.php' );
417
  }
418
+
419
  /**
420
  * Add a page checbox list meta box to the Edit Sidebar screen.
421
+ *
422
  * @since 1.1.0
423
  * @param object $post The post being edited.
424
  * @param array $metabox Any additional arguments passed during the meta box registration.
425
  */
426
  public static function edit_sidebar_pages_meta_box( $post, $metabox ) {
427
  $default_sidebar = get_option( 'simple_page_sidebars_default_sidebar' );
428
+
429
  include_once( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/includes/class-simple-page-sidebars-walker-page-checklist.php' );
430
  include_once( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/views/meta-box-sidebar-pages.php' );
431
  }
432
+
433
  /**
434
  * Process submissions for the Edit Sidebar screen.
435
+ *
436
  * Handles cases where the sidebar is renamed, reassigns pages, and
437
  * removes the sidebar if no pages are selected. Requires a valid nonce.
438
+ *
439
  * @since 1.1.0
440
  */
441
  public static function process_sidebar_update() {
442
  global $wpdb;
443
+
444
  if ( isset( $_POST['simplepagesidebars_sidebar_name'] ) ) {
445
  $current_name = stripslashes( $_POST['simplepagesidebars_sidebar_name'] );
446
+
447
  check_admin_referer( 'update-sidebar_' . $current_name, 'simplepagesidebars_sidebar_update_nonce' );
448
+
449
  $new_name = stripslashes( $_POST['simplepagesidebars_sidebar_name_new'] );
450
  $new_name = ( ! empty( $new_name ) && $new_name != $current_name ) ? trim( wp_strip_all_tags( $new_name ) ) : null;
451
+
452
  $pages = ( isset( $_POST['simplepagesidebars_sidebar_pages'] ) ) ? wp_parse_id_list( $_POST['simplepagesidebars_sidebar_pages'] ) : array();
453
+
454
  // Retrieve IDs of pages using the existing sidebar name.
455
  $current_pages = self::get_page_ids_using_sidebar( $current_name );
456
+
457
  // Pages to reset to the default sidebar.
458
  $reset_pages = array_diff( $current_pages, $pages );
459
  if ( $reset_pages ) {
461
  delete_post_meta( $page_id, '_sidebar_name' );
462
  }
463
  }
464
+
465
  // Update all sidebars if there is a new sidebar name.
466
  if ( $new_name ) {
467
  $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value=%s WHERE meta_key='_sidebar_name' AND meta_value=%s", $new_name, $current_name ) );
472
  update_post_meta( $page_id, '_sidebar_name', addslashes( $current_name ) );
473
  }
474
  }
475
+
476
  // The sidebar should have been removed from all pages.
477
  // Let WordPress move widgets to Inactive Sidebar, redirect to Widgets screen, and notify user.
478
  if ( empty( $pages ) ) {
479
  wp_safe_redirect( esc_url_raw( add_query_arg( 'simple-page-sidebars-message', 1, admin_url( 'widgets.php' ) ) ) );
480
  exit;
481
  }
482
+
483
  // Migrate widgets if the sidebar name was changed.
484
  if ( $new_name ) {
485
  $sidebars_widgets = wp_get_sidebars_widgets();
486
+
487
  $old_id = 'page-sidebar-' . sanitize_key( $current_name );
488
  $new_id = 'page-sidebar-' . sanitize_key( $new_name );
489
+
490
  // If new id matches an existing id, merge old widgets with new.
491
  if ( isset( $sidebars_widgets[ $new_id ] ) ) {
492
  $sidebars_widgets[ $new_id ] = array_merge( $sidebars_widgets[ $new_id ], $sidebars_widgets[ $old_id ] );
495
  elseif ( isset( $sidebars_widgets[ $old_id ] ) ) {
496
  $sidebars_widgets[ $new_id ] = $sidebars_widgets[ $old_id ];
497
  }
498
+
499
  // Remove old widget area and save.
500
  unset( $sidebars_widgets[ $old_id ] );
501
  #echo '<pre>'; print_r( $sidebars_widgets ); echo '</pre>'; exit;
502
  wp_set_sidebars_widgets( $sidebars_widgets );
503
  }
504
+
505
  // Redirect back to sidebar edit screen with an update message.
506
  $name = ( ! empty( $new_name ) ) ? $new_name : $current_name;
507
  $redirect_link = self::get_sidebar_edit_link( $name, array( 'message' => 1 ) );
509
  exit;
510
  }
511
  }
512
+
513
  /**
514
  * Display messages on the widgets page.
515
+ *
516
  * @since 1.1.0
517
  */
518
  public static function widgets_page_messages() {
519
  $sidebars = simple_page_sidebars_get_names();
520
+
521
  // Display an error message if a default sidebar hasn't been selected on the Reading settings screen.
522
  if ( ! get_option( 'simple_page_sidebars_default_sidebar' ) && ! empty( $sidebars ) ) {
523
  echo '<div class="error"><p>' . self::get_empty_default_sidebar_error() . '</p></div>';
524
  }
525
+
526
  // Display any custom update messages.
527
  if ( isset( $_REQUEST['simple-page-sidebars-message'] ) && ! empty( $_REQUEST['simple-page-sidebars-message'] ) ) {
528
  ?>
532
  $messages = array(
533
  1 => __( 'The sidebar you were editing is no longer assigned to any pages and has been removed. Any widgets it contained should be in an "Inactive Widgets" area below.', 'simple-page-sidebars' )
534
  );
535
+
536
  $message_id = $_REQUEST['simple-page-sidebars-message'];
537
  if ( isset( $messages[ $message_id ] ) ) {
538
  echo $messages[ $message_id ];
543
  <?php
544
  }
545
  }
546
+
547
  /**
548
  * Get a page's sidebar.
549
+ *
550
  * Sanitizes the sidebar name before returning it.
551
+ *
552
  * @since 1.1.0
553
  * @param int $page_id ID of the page whose sidebar should be returned.
554
  * @return string Sanitized sidebar name.
556
  public static function get_page_sidebar( $page_id ) {
557
  return self::sanitize_sidebar_name( get_post_meta( $page_id, '_sidebar_name', true ) );
558
  }
559
+
560
  /**
561
  * Retrieve IDs of pages using a particular sidebar.
562
+ *
563
  * @since 1.1.0
564
  * @param string $sidebar The sidebar name.
565
  * @return array An array of page IDs or an empty array.
566
  */
567
  public static function get_page_ids_using_sidebar( $sidebar ) {
568
  global $wpdb;
569
+
570
  $ids = $wpdb->get_col( $wpdb->prepare( "SELECT p.ID
571
  FROM $wpdb->posts p
572
  INNER JOIN $wpdb->postmeta pm ON p.ID=pm.post_id
573
  WHERE p.post_type='page' AND p.post_status!='auto-draft' AND pm.meta_key='_sidebar_name' AND pm.meta_value=%s",
574
  $sidebar
575
  ) );
576
+
577
  return ( empty( $ids ) ) ? array() : $ids;
578
  }
579
+
580
  /**
581
  * Sanitize a sidebar name.
582
+ *
583
  * @since 1.1.0
584
  * @param string $name The sidebar name.
585
  * @return string Sanitized sidebar name.
587
  public static function sanitize_sidebar_name( $name ) {
588
  return trim( wp_strip_all_tags( $name ) );
589
  }
590
+
591
  /**
592
  * Get the edit link for a sidebar.
593
+ *
594
  * @since 1.1.0
595
  * @param string $sidebar The sidebar name.
596
  * @param array $query_args Optional. An array of additional query args to append to the edit link.
601
  'page' => 'simple-page-sidebars',
602
  'sidebar' => rawurlencode( $sidebar )
603
  ) );
604
+
605
+ $link = add_query_arg( $query_args, admin_url( 'admin.php' ) );
606
+
607
  return $link;
608
  }
609
+
610
  /**
611
  * The error message to display if a default sidebar hasn't been selected.
612
+ *
613
  * This is used a few times throughout the dashboard, so the string is
614
  * abstracted out here.
615
+ *
616
  * @since 1.1.0
617
  * @return string Error message
618
  */
621
  ' <a href="' . admin_url( 'options-reading.php' ) . '">' . __( 'Reading settings screen', 'simple-page-sidebars' ) . '</a>.'
622
  );
623
  }
624
+
625
  /**
626
  * Backward compatible AJAX spinner.
627
+ *
628
  * Displays the correct AJAX spinner depending on the version of WordPress.
629
  *
630
  * @since 1.1.0
636
  'id' => '',
637
  'class' => ''
638
  ) );
639
+
640
  if ( version_compare( get_bloginfo( 'version' ), '3.5-beta-1', '<' ) ) {
641
  printf( '<img src="%1$s" id="%2$s" class="%3$s" alt="">',
642
  esc_url( SIMPLE_PAGE_SIDEBARS_URL . 'admin/images/wpspin_light.gif' ),
648
  }
649
  }
650
  }
 
admin/includes/class-simple-page-sidebars-walker-page-checklist.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Custom page checklist walker.
4
- *
5
  * @since 1.1.0
6
  */
7
  class Simple_Page_Siders_Walker_Page_Checklist extends Walker_Page {
@@ -15,15 +15,15 @@ class Simple_Page_Siders_Walker_Page_Checklist extends Walker_Page {
15
  * @param int $current_page Page ID.
16
  * @param array $args
17
  */
18
- function start_el( &$output, $page, $depth, $args, $current_page = 0 ) {
19
  if ( $depth ) {
20
  $indent = str_repeat( "\t", $depth );
21
  } else {
22
  $indent = '';
23
  }
24
-
25
  $current_sidebar = Simple_Page_Sidebars_Admin::get_page_sidebar( $page->ID );
26
-
27
  $output .= sprintf( '%s<li><label class="selectit"><input type="checkbox" name="simplepagesidebars_sidebar_pages[]" value="%d"%s> %s%s</label>',
28
  $indent,
29
  $page->ID,
@@ -33,4 +33,3 @@ class Simple_Page_Siders_Walker_Page_Checklist extends Walker_Page {
33
  );
34
  }
35
  }
36
- ?>
1
  <?php
2
  /**
3
  * Custom page checklist walker.
4
+ *
5
  * @since 1.1.0
6
  */
7
  class Simple_Page_Siders_Walker_Page_Checklist extends Walker_Page {
15
  * @param int $current_page Page ID.
16
  * @param array $args
17
  */
18
+ function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
19
  if ( $depth ) {
20
  $indent = str_repeat( "\t", $depth );
21
  } else {
22
  $indent = '';
23
  }
24
+
25
  $current_sidebar = Simple_Page_Sidebars_Admin::get_page_sidebar( $page->ID );
26
+
27
  $output .= sprintf( '%s<li><label class="selectit"><input type="checkbox" name="simplepagesidebars_sidebar_pages[]" value="%d"%s> %s%s</label>',
28
  $indent,
29
  $page->ID,
33
  );
34
  }
35
  }
 
admin/views/edit-sidebar-screen.php CHANGED
@@ -1,20 +1,20 @@
1
  <div class="wrap simple-page-sidebars-edit-sidebar">
2
  <div id="icon-tools" class="icon32"><br></div>
3
- <h2>Edit Sidebar</h2>
4
-
5
  <?php
6
  // Display an error message if a default sidebar hasn't been selected on the Reading settings screen.
7
  if ( ! get_option( 'simple_page_sidebars_default_sidebar' ) ) {
8
  echo '<div class="error"><p>' . self::get_empty_default_sidebar_error() . '</p></div>';
9
  }
10
-
11
  // Display an error message and stop rendering the screen if the requested sidebar is not valid.
12
  if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sidebar_name' AND meta_value=%s", $sidebar_name ) ) ) {
13
  echo '<div class="error"><p>' . __( 'Whoops, that doesn\'t appear to be a sidebar that can be edited.', 'simple-page-sidebars' ) . '</p></div>';
14
  echo '</div>'; // close div.wrap
15
  return;
16
  }
17
-
18
  // Display any custom update messages.
19
  if ( isset( $_REQUEST['message'] ) ) {
20
  ?>
@@ -39,20 +39,20 @@
39
  <?php
40
  }
41
  ?>
42
-
43
  <form action="" method="post">
44
  <div id="poststuff">
45
  <div id="post-body" class="metabox-holder"><!--columns-2-->
46
-
47
  <div id="post-body-content">
48
  <div class="sidebar-name-wrap">
49
- <label for="simple-page-sidebars-sidebar-name-new" class="screen-reader-text">Sidebar Name:</label>
50
- <input type="text" name="simplepagesidebars_sidebar_name_new" id="simple-page-sidebars-sidebar-name-new" value="<?php echo esc_attr( $sidebar_name ); ?>" placeholder="Enter sidebar name here" autocomplete="off">
51
  <input type="hidden" name="simplepagesidebars_sidebar_name" value="<?php echo esc_attr( $sidebar_name ); ?>">
52
  </div>
53
-
54
  <?php do_meta_boxes( $screen->id, 'normal', '' ); ?>
55
-
56
  <p class="submit">
57
  <?php
58
  wp_nonce_field( 'update-sidebar_' . $sidebar_name, 'simplepagesidebars_sidebar_update_nonce', true );
@@ -63,12 +63,12 @@
63
  <!--<a href="#">Delete Sidebar</a>-->
64
  </p>
65
  </div>
66
-
67
  <!--<div id="postbox-container-1" class="postbox-container"></div>-->
68
  </div>
69
  </div>
70
  </form>
71
-
72
  </div>
73
 
74
  <style type="text/css">
1
  <div class="wrap simple-page-sidebars-edit-sidebar">
2
  <div id="icon-tools" class="icon32"><br></div>
3
+ <h2><?php _e( 'Edit Sidebar', 'simple-page-sidebars' ); ?></h2>
4
+
5
  <?php
6
  // Display an error message if a default sidebar hasn't been selected on the Reading settings screen.
7
  if ( ! get_option( 'simple_page_sidebars_default_sidebar' ) ) {
8
  echo '<div class="error"><p>' . self::get_empty_default_sidebar_error() . '</p></div>';
9
  }
10
+
11
  // Display an error message and stop rendering the screen if the requested sidebar is not valid.
12
  if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sidebar_name' AND meta_value=%s", $sidebar_name ) ) ) {
13
  echo '<div class="error"><p>' . __( 'Whoops, that doesn\'t appear to be a sidebar that can be edited.', 'simple-page-sidebars' ) . '</p></div>';
14
  echo '</div>'; // close div.wrap
15
  return;
16
  }
17
+
18
  // Display any custom update messages.
19
  if ( isset( $_REQUEST['message'] ) ) {
20
  ?>
39
  <?php
40
  }
41
  ?>
42
+
43
  <form action="" method="post">
44
  <div id="poststuff">
45
  <div id="post-body" class="metabox-holder"><!--columns-2-->
46
+
47
  <div id="post-body-content">
48
  <div class="sidebar-name-wrap">
49
+ <label for="simple-page-sidebars-sidebar-name-new" class="screen-reader-text"><?php _e( 'Sidebar Name:', 'simple-page-sidebars' ); ?></label>
50
+ <input type="text" name="simplepagesidebars_sidebar_name_new" id="simple-page-sidebars-sidebar-name-new" value="<?php echo esc_attr( $sidebar_name ); ?>" placeholder="<?php esc_attr_e( 'Enter sidebar name here', 'simple-page-sidebars' ); ?>" autocomplete="off">
51
  <input type="hidden" name="simplepagesidebars_sidebar_name" value="<?php echo esc_attr( $sidebar_name ); ?>">
52
  </div>
53
+
54
  <?php do_meta_boxes( $screen->id, 'normal', '' ); ?>
55
+
56
  <p class="submit">
57
  <?php
58
  wp_nonce_field( 'update-sidebar_' . $sidebar_name, 'simplepagesidebars_sidebar_update_nonce', true );
63
  <!--<a href="#">Delete Sidebar</a>-->
64
  </p>
65
  </div>
66
+
67
  <!--<div id="postbox-container-1" class="postbox-container"></div>-->
68
  </div>
69
  </div>
70
  </form>
71
+
72
  </div>
73
 
74
  <style type="text/css">
admin/views/meta-box-page-sidebar.php CHANGED
@@ -19,10 +19,10 @@
19
  }
20
  ?>
21
  </select>
22
-
23
  <label for="simple-page-sidebars-page-sidebar-name-new" class="screen-reader-text"><?php _e( 'Or create a new sidebar:', 'simple-page-sidebars' ); ?></label>
24
  <input type="text" name="simplepagesidebars_page_sidebar_name_new" id="simple-page-sidebars-page-sidebar-name-new" class="widefat hide-if-js" value="">
25
-
26
  <span id="sidebarnew" class="hide-if-no-js"><?php _e( 'Enter New', 'simple-page-sidebars' ); ?></span>
27
  <span id="sidebarcancel" class="hidden"><?php _e( 'Cancel', 'simple-page-sidebars' ); ?></span>
28
  </p>
@@ -53,26 +53,26 @@ jQuery(function($) {
53
  spinner : $('#simple-page-sidebars-page-sidebar-update-spinner'),
54
  nameField : $('#simple-page-sidebars-page-sidebar-name'),
55
  nameFieldNew : $('#simple-page-sidebars-page-sidebar-name-new'),
56
-
57
  init : function() {
58
  $('#sidebarcancel, #sidebarnew').on('click', function(e) {
59
  e.preventDefault();
60
-
61
  simplePageSidebars.nameField.toggle();
62
  simplePageSidebars.nameFieldNew.toggle();
63
-
64
  $('#sidebarcancel, #sidebarnew').toggle();
65
-
66
  // Clear the new sidebar name field when cancel is clicked.
67
  if ( 'sidebarcancel' == $(this).attr('id') ) {
68
  simplePageSidebars.nameFieldNew.val('');
69
  }
70
  });
71
  },
72
-
73
  update : function() {
74
  simplePageSidebars.spinner.show();
75
-
76
  $.post(
77
  ajaxurl,
78
  {
@@ -84,28 +84,28 @@ jQuery(function($) {
84
  },
85
  function( data ){
86
  var newName = simplePageSidebars.nameFieldNew.val();
87
-
88
  if ( '' != newName ) {
89
  if ( simplePageSidebars.nameField.find('option[value="' + newName + '"]').length < 1 ) {
90
  simplePageSidebars.nameField.append('<option selected="selected">' + newName + '</option>').val( newName );
91
  } else {
92
  simplePageSidebars.nameField.find('option[value="' + newName + '"]').attr('selected', 'selected');
93
  }
94
-
95
  simplePageSidebars.nameField.toggle();
96
  simplePageSidebars.nameFieldNew.toggle().val('');
97
  $('#sidebarcancel, #sidebarnew').toggle();
98
  }
99
-
100
  $('#simple-page-sidebars-page-sidebar-update-message').show();
101
  simplePageSidebars.spinner.hide();
102
  }
103
  );
104
  }
105
  };
106
-
107
  simplePageSidebars.init();
108
-
109
  $('#simplepagesidebarsdiv').find('button').on( 'click', function(e) {
110
  e.preventDefault();
111
  simplePageSidebars.update();
19
  }
20
  ?>
21
  </select>
22
+
23
  <label for="simple-page-sidebars-page-sidebar-name-new" class="screen-reader-text"><?php _e( 'Or create a new sidebar:', 'simple-page-sidebars' ); ?></label>
24
  <input type="text" name="simplepagesidebars_page_sidebar_name_new" id="simple-page-sidebars-page-sidebar-name-new" class="widefat hide-if-js" value="">
25
+
26
  <span id="sidebarnew" class="hide-if-no-js"><?php _e( 'Enter New', 'simple-page-sidebars' ); ?></span>
27
  <span id="sidebarcancel" class="hidden"><?php _e( 'Cancel', 'simple-page-sidebars' ); ?></span>
28
  </p>
53
  spinner : $('#simple-page-sidebars-page-sidebar-update-spinner'),
54
  nameField : $('#simple-page-sidebars-page-sidebar-name'),
55
  nameFieldNew : $('#simple-page-sidebars-page-sidebar-name-new'),
56
+
57
  init : function() {
58
  $('#sidebarcancel, #sidebarnew').on('click', function(e) {
59
  e.preventDefault();
60
+
61
  simplePageSidebars.nameField.toggle();
62
  simplePageSidebars.nameFieldNew.toggle();
63
+
64
  $('#sidebarcancel, #sidebarnew').toggle();
65
+
66
  // Clear the new sidebar name field when cancel is clicked.
67
  if ( 'sidebarcancel' == $(this).attr('id') ) {
68
  simplePageSidebars.nameFieldNew.val('');
69
  }
70
  });
71
  },
72
+
73
  update : function() {
74
  simplePageSidebars.spinner.show();
75
+
76
  $.post(
77
  ajaxurl,
78
  {
84
  },
85
  function( data ){
86
  var newName = simplePageSidebars.nameFieldNew.val();
87
+
88
  if ( '' != newName ) {
89
  if ( simplePageSidebars.nameField.find('option[value="' + newName + '"]').length < 1 ) {
90
  simplePageSidebars.nameField.append('<option selected="selected">' + newName + '</option>').val( newName );
91
  } else {
92
  simplePageSidebars.nameField.find('option[value="' + newName + '"]').attr('selected', 'selected');
93
  }
94
+
95
  simplePageSidebars.nameField.toggle();
96
  simplePageSidebars.nameFieldNew.toggle().val('');
97
  $('#sidebarcancel, #sidebarnew').toggle();
98
  }
99
+
100
  $('#simple-page-sidebars-page-sidebar-update-message').show();
101
  simplePageSidebars.spinner.hide();
102
  }
103
  );
104
  }
105
  };
106
+
107
  simplePageSidebars.init();
108
+
109
  $('#simplepagesidebarsdiv').find('button').on( 'click', function(e) {
110
  e.preventDefault();
111
  simplePageSidebars.update();
admin/views/meta-box-sidebar-pages.php CHANGED
@@ -6,7 +6,7 @@
6
  _e( 'Any currently assigned custom sidebars will also be overridden for the selected pages.', 'simple-page-sidebars' );
7
  ?>
8
  </p>
9
-
10
  <div id="page-all" class="tabs-panel tabs-panel-view-all tabs-panel-active">
11
  <ul id="pagechecklist" class="list:page categorychecklist form-no-clear">
12
  <?php
@@ -18,17 +18,17 @@
18
  'suppress_filters' => true,
19
  'cache_results' => false
20
  ) );
21
-
22
  $args['sidebar'] = self::sanitize_sidebar_name( stripslashes( $_GET['sidebar'] ) );
23
  $args['selected'] = self::get_page_ids_using_sidebar( $args['sidebar'] );
24
  $args['walker'] = new Simple_Page_Siders_Walker_Page_Checklist;
25
-
26
  $items = walk_page_tree( $posts, 0, 0, $args );
27
  echo $items;
28
  ?>
29
  </ul>
30
  </div><!-- end div.tabs-panel -->
31
-
32
  <p style="margin: 5px 0 0 0">
33
  <span class="description"><?php _e( 'To delete this sidebar, simply uncheck all pages and click the "Update Sidebar" button.', 'simple-page-sidebars' ); ?></span>
34
  </p>
6
  _e( 'Any currently assigned custom sidebars will also be overridden for the selected pages.', 'simple-page-sidebars' );
7
  ?>
8
  </p>
9
+
10
  <div id="page-all" class="tabs-panel tabs-panel-view-all tabs-panel-active">
11
  <ul id="pagechecklist" class="list:page categorychecklist form-no-clear">
12
  <?php
18
  'suppress_filters' => true,
19
  'cache_results' => false
20
  ) );
21
+
22
  $args['sidebar'] = self::sanitize_sidebar_name( stripslashes( $_GET['sidebar'] ) );
23
  $args['selected'] = self::get_page_ids_using_sidebar( $args['sidebar'] );
24
  $args['walker'] = new Simple_Page_Siders_Walker_Page_Checklist;
25
+
26
  $items = walk_page_tree( $posts, 0, 0, $args );
27
  echo $items;
28
  ?>
29
  </ul>
30
  </div><!-- end div.tabs-panel -->
31
+
32
  <p style="margin: 5px 0 0 0">
33
  <span class="description"><?php _e( 'To delete this sidebar, simply uncheck all pages and click the "Update Sidebar" button.', 'simple-page-sidebars' ); ?></span>
34
  </p>
includes/widget-area.php CHANGED
@@ -1,15 +1,15 @@
1
  <?php
2
  /**
3
  * Area widget class.
4
- *
5
  * A widget for display another widget area within a sidebar.
6
- *
7
  * @since 0.2.0
8
  */
9
  class Simple_Page_Sidebars_Widget_Area extends WP_Widget {
10
  /**
11
  * Widget constructor method.
12
- *
13
  * @since 0.2.0
14
  */
15
  function __construct() {
@@ -17,42 +17,42 @@ class Simple_Page_Sidebars_Widget_Area extends WP_Widget {
17
  'classname' => 'widget_area',
18
  'description' => __( 'Include all widgets from another widget area', 'simple-page-sidebars' )
19
  );
20
-
21
  // Call the parent constructor.
22
  $this->WP_Widget( 'area', __( 'Widget Area', 'simple-page-sidebars' ), $widget_ops );
23
  }
24
-
25
  /**
26
  * Display the widget.
27
- *
28
  * @since 0.2.0
29
  */
30
  function widget( $args, $instance ) {
31
  extract( $args );
32
-
33
  // Don't allow an infinite loop.
34
  if ( $id != $instance['area_id'] ) {
35
  echo $before_widget;
36
-
37
  $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
38
  echo ( empty( $title ) ) ? '' : $before_title . $title . $after_title;
39
-
40
  echo '<div class="widget-area-inside">';
41
  dynamic_sidebar( $instance['area_id'] );
42
  echo '</div>';
43
-
44
  echo $after_widget;
45
  }
46
  }
47
-
48
  /**
49
  * Display the form for modifying the widget settings.
50
- *
51
  * @since 0.2.0
52
  */
53
  function form( $instance ) {
54
  global $wp_registered_sidebars;
55
-
56
  $instance = wp_parse_args( (array) $instance, array(
57
  'area_id' => '',
58
  'title' => ''
@@ -81,19 +81,18 @@ class Simple_Page_Sidebars_Widget_Area extends WP_Widget {
81
  </p>
82
  <?php
83
  }
84
-
85
  /**
86
  * Update the widget settings.
87
- *
88
  * @since 0.2.0
89
  */
90
  function update( $new_instance, $old_instance ) {
91
  $instance = $old_instance;
92
-
93
  $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
94
  $instance['area_id'] = $new_instance['area_id'];
95
-
96
  return $instance;
97
  }
98
  }
99
- ?>
1
  <?php
2
  /**
3
  * Area widget class.
4
+ *
5
  * A widget for display another widget area within a sidebar.
6
+ *
7
  * @since 0.2.0
8
  */
9
  class Simple_Page_Sidebars_Widget_Area extends WP_Widget {
10
  /**
11
  * Widget constructor method.
12
+ *
13
  * @since 0.2.0
14
  */
15
  function __construct() {
17
  'classname' => 'widget_area',
18
  'description' => __( 'Include all widgets from another widget area', 'simple-page-sidebars' )
19
  );
20
+
21
  // Call the parent constructor.
22
  $this->WP_Widget( 'area', __( 'Widget Area', 'simple-page-sidebars' ), $widget_ops );
23
  }
24
+
25
  /**
26
  * Display the widget.
27
+ *
28
  * @since 0.2.0
29
  */
30
  function widget( $args, $instance ) {
31
  extract( $args );
32
+
33
  // Don't allow an infinite loop.
34
  if ( $id != $instance['area_id'] ) {
35
  echo $before_widget;
36
+
37
  $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
38
  echo ( empty( $title ) ) ? '' : $before_title . $title . $after_title;
39
+
40
  echo '<div class="widget-area-inside">';
41
  dynamic_sidebar( $instance['area_id'] );
42
  echo '</div>';
43
+
44
  echo $after_widget;
45
  }
46
  }
47
+
48
  /**
49
  * Display the form for modifying the widget settings.
50
+ *
51
  * @since 0.2.0
52
  */
53
  function form( $instance ) {
54
  global $wp_registered_sidebars;
55
+
56
  $instance = wp_parse_args( (array) $instance, array(
57
  'area_id' => '',
58
  'title' => ''
81
  </p>
82
  <?php
83
  }
84
+
85
  /**
86
  * Update the widget settings.
87
+ *
88
  * @since 0.2.0
89
  */
90
  function update( $new_instance, $old_instance ) {
91
  $instance = $old_instance;
92
+
93
  $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
94
  $instance['area_id'] = $new_instance['area_id'];
95
+
96
  return $instance;
97
  }
98
  }
 
languages/simple-page-sidebars-sr_RS.mo ADDED
Binary file
languages/simple-page-sidebars-sr_RS.po ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Simple Page Sidebars\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-11-13 06:36-0800\n"
6
+ "PO-Revision-Date: 2013-11-19 09:43+0100\n"
7
+ "Last-Translator: Borisa Djuraskovic <borisad@webhostinghub.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: _e;__;esc_attr_e;esc_attr__;esc_html_e;esc_html__\n"
13
+ "X-Poedit-Basepath: ../\n"
14
+ "X-Generator: Poedit 1.5.7\n"
15
+ "X-Poedit-SearchPath-0: .\n"
16
+
17
+ #: admin/admin.php:74 admin/admin.php:242 admin/admin.php:317
18
+ #: admin/views/meta-box-page-sidebar.php:11
19
+ msgid "Default Sidebar"
20
+ msgstr "Default Sidebar"
21
+
22
+ #: admin/admin.php:106
23
+ msgid "The sidebar that should be replaced by custom sidebars."
24
+ msgstr "Sidebar koji bi trebao da bude zamenjen sa custom sidebars."
25
+
26
+ #: admin/admin.php:116 admin/admin.php:183 admin/admin.php:240
27
+ #: admin/admin.php:314
28
+ msgid "Sidebar"
29
+ msgstr "Sidebar"
30
+
31
+ #: admin/admin.php:316
32
+ msgid "&mdash; No Change &mdash;"
33
+ msgstr "&mdash; Nema promene &mdash;"
34
+
35
+ #: admin/admin.php:384
36
+ msgid "Edit Sidebar"
37
+ msgstr "Edituj Sidebar"
38
+
39
+ #: admin/admin.php:544
40
+ msgid ""
41
+ "The sidebar you were editing is no longer assigned to any pages and has been "
42
+ "removed. Any widgets it contained should be in an \"Inactive Widgets\" area "
43
+ "below."
44
+ msgstr ""
45
+ "Sidebar koji editujete više nije dodeljen nijednoj stranici i uklonjen je. "
46
+ "Bilo koji widget koji ga sadrži će biti u \"Inactive Widgets\" području "
47
+ "ispod."
48
+
49
+ #: admin/admin.php:631
50
+ #, php-format
51
+ msgid ""
52
+ "For Simple Page Sidebars to work, a default sidebar needs to be selected on "
53
+ "the %s"
54
+ msgstr ""
55
+ "Da bi Simple Page Sidebars radio default sidebar trba da bude izabran na %s"
56
+
57
+ #: admin/admin.php:632
58
+ msgid "Reading settings screen"
59
+ msgstr "Postavke za čitanje sa ekrana"
60
+
61
+ #: admin/views/edit-sidebar-screen.php:13
62
+ msgid "Whoops, that doesn't appear to be a sidebar that can be edited."
63
+ msgstr "Ups, to izgleda nije sidebar koji može da se edituje"
64
+
65
+ #: admin/views/edit-sidebar-screen.php:26
66
+ msgid "Sidebar settings updated."
67
+ msgstr "Postavke sidebara sačuvane. "
68
+
69
+ #: admin/views/edit-sidebar-screen.php:27
70
+ #: admin/views/meta-box-page-sidebar.php:4
71
+ msgid "Update widgets now."
72
+ msgstr "Update widgete sada."
73
+
74
+ #: admin/views/edit-sidebar-screen.php:62
75
+ msgid "Update Sidebar"
76
+ msgstr "Update Sidebar"
77
+
78
+ #: admin/views/meta-box-page-sidebar.php:3
79
+ msgid "Page sidebar saved."
80
+ msgstr "Sidebar stranice sačuvan. "
81
+
82
+ #: admin/views/meta-box-page-sidebar.php:9
83
+ msgid "Current sidebar:"
84
+ msgstr "Trenutni sidebar:"
85
+
86
+ #: admin/views/meta-box-page-sidebar.php:23
87
+ msgid "Or create a new sidebar:"
88
+ msgstr "Ili stvoriti novi sidebar:"
89
+
90
+ #: admin/views/meta-box-page-sidebar.php:26
91
+ msgid "Enter New"
92
+ msgstr "Uneti novo"
93
+
94
+ #: admin/views/meta-box-page-sidebar.php:27
95
+ msgid "Cancel"
96
+ msgstr "Ukinuti"
97
+
98
+ #: admin/views/meta-box-page-sidebar.php:32
99
+ msgid "Update"
100
+ msgstr "Update"
101
+
102
+ #: admin/views/meta-box-sidebar-pages.php:4
103
+ #, php-format
104
+ msgid ""
105
+ "The above sidebar will replace the \"<strong>%s</strong>\" sidebar for all "
106
+ "pages selected below."
107
+ msgstr ""
108
+ "Sidebar iznad će zameniti \"<strong>%s</strong>\" sidebar za sve stranice "
109
+ "izabrane ispod."
110
+
111
+ #: admin/views/meta-box-sidebar-pages.php:6
112
+ msgid ""
113
+ "Any currently assigned custom sidebars will also be overridden for the "
114
+ "selected pages."
115
+ msgstr ""
116
+ "Bilo koja dodeljena custom sidebars će takodje biti prepisana za izabranu "
117
+ "stranicu."
118
+
119
+ #: admin/views/meta-box-sidebar-pages.php:33
120
+ msgid ""
121
+ "To delete this sidebar, simply uncheck all pages and click the \"Update "
122
+ "Sidebar\" button."
123
+ msgstr ""
124
+ "To delete this sidebar, simply uncheck all pages and click the \"Update "
125
+ "Sidebar\" button."
126
+
127
+ #: includes/widget-area.php:18
128
+ msgid "Include all widgets from another widget area"
129
+ msgstr "Uključiti sve widgete izvan widget područja"
130
+
131
+ #: includes/widget-area.php:22
132
+ msgid "Widget Area"
133
+ msgstr "Widget oblast"
134
+
135
+ #: includes/widget-area.php:62
136
+ msgid "Title:"
137
+ msgstr "Naslov:"
138
+
139
+ #: includes/widget-area.php:66
140
+ msgid "Area Name:"
141
+ msgstr "Ime oblasti:"
languages/simple-page-sidebars.pot CHANGED
@@ -1,124 +1,124 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Simple Page Sidebars\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2012-11-13 06:36-0800\n"
6
- "PO-Revision-Date: 2012-11-13 06:50-0800\n"
7
- "Last-Translator: Brady Vercher <brady@blazersix.com>\n"
8
- "Language-Team: \n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Poedit-KeywordsList: _e;__;esc_attr_e;esc_attr__;esc_html_e;esc_html__\n"
13
- "X-Poedit-Basepath: ../\n"
14
- "X-Poedit-SearchPath-0: .\n"
15
-
16
- #: admin/admin.php:74
17
- #: admin/admin.php:242
18
- #: admin/admin.php:317
19
- #: admin/views/meta-box-page-sidebar.php:11
20
- msgid "Default Sidebar"
21
- msgstr ""
22
-
23
- #: admin/admin.php:106
24
- msgid "The sidebar that should be replaced by custom sidebars."
25
- msgstr ""
26
-
27
- #: admin/admin.php:116
28
- #: admin/admin.php:183
29
- #: admin/admin.php:240
30
- #: admin/admin.php:314
31
- msgid "Sidebar"
32
- msgstr ""
33
-
34
- #: admin/admin.php:316
35
- msgid "&mdash; No Change &mdash;"
36
- msgstr ""
37
-
38
- #: admin/admin.php:384
39
- msgid "Edit Sidebar"
40
- msgstr ""
41
-
42
- #: admin/admin.php:544
43
- msgid "The sidebar you were editing is no longer assigned to any pages and has been removed. Any widgets it contained should be in an \"Inactive Widgets\" area below."
44
- msgstr ""
45
-
46
- #: admin/admin.php:631
47
- #, php-format
48
- msgid "For Simple Page Sidebars to work, a default sidebar needs to be selected on the %s"
49
- msgstr ""
50
-
51
- #: admin/admin.php:632
52
- msgid "Reading settings screen"
53
- msgstr ""
54
-
55
- #: admin/views/edit-sidebar-screen.php:13
56
- msgid "Whoops, that doesn't appear to be a sidebar that can be edited."
57
- msgstr ""
58
-
59
- #: admin/views/edit-sidebar-screen.php:26
60
- msgid "Sidebar settings updated."
61
- msgstr ""
62
-
63
- #: admin/views/edit-sidebar-screen.php:27
64
- #: admin/views/meta-box-page-sidebar.php:4
65
- msgid "Update widgets now."
66
- msgstr ""
67
-
68
- #: admin/views/edit-sidebar-screen.php:62
69
- msgid "Update Sidebar"
70
- msgstr ""
71
-
72
- #: admin/views/meta-box-page-sidebar.php:3
73
- msgid "Page sidebar saved."
74
- msgstr ""
75
-
76
- #: admin/views/meta-box-page-sidebar.php:9
77
- msgid "Current sidebar:"
78
- msgstr ""
79
-
80
- #: admin/views/meta-box-page-sidebar.php:23
81
- msgid "Or create a new sidebar:"
82
- msgstr ""
83
-
84
- #: admin/views/meta-box-page-sidebar.php:26
85
- msgid "Enter New"
86
- msgstr ""
87
-
88
- #: admin/views/meta-box-page-sidebar.php:27
89
- msgid "Cancel"
90
- msgstr ""
91
-
92
- #: admin/views/meta-box-page-sidebar.php:32
93
- msgid "Update"
94
- msgstr ""
95
-
96
- #: admin/views/meta-box-sidebar-pages.php:4
97
- #, php-format
98
- msgid "The above sidebar will replace the \"<strong>%s</strong>\" sidebar for all pages selected below."
99
- msgstr ""
100
-
101
- #: admin/views/meta-box-sidebar-pages.php:6
102
- msgid "Any currently assigned custom sidebars will also be overridden for the selected pages."
103
- msgstr ""
104
-
105
- #: admin/views/meta-box-sidebar-pages.php:33
106
- msgid "To delete this sidebar, simply uncheck all pages and click the \"Update Sidebar\" button."
107
- msgstr ""
108
-
109
- #: includes/widget-area.php:18
110
- msgid "Include all widgets from another widget area"
111
- msgstr ""
112
-
113
- #: includes/widget-area.php:22
114
- msgid "Widget Area"
115
- msgstr ""
116
-
117
- #: includes/widget-area.php:62
118
- msgid "Title:"
119
- msgstr ""
120
-
121
- #: includes/widget-area.php:66
122
- msgid "Area Name:"
123
- msgstr ""
124
-
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Simple Page Sidebars\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-11-13 06:36-0800\n"
6
+ "PO-Revision-Date: 2012-11-13 06:50-0800\n"
7
+ "Last-Translator: Brady Vercher <brady@blazersix.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: _e;__;esc_attr_e;esc_attr__;esc_html_e;esc_html__\n"
13
+ "X-Poedit-Basepath: ../\n"
14
+ "X-Poedit-SearchPath-0: .\n"
15
+
16
+ #: admin/admin.php:74
17
+ #: admin/admin.php:242
18
+ #: admin/admin.php:317
19
+ #: admin/views/meta-box-page-sidebar.php:11
20
+ msgid "Default Sidebar"
21
+ msgstr ""
22
+
23
+ #: admin/admin.php:106
24
+ msgid "The sidebar that should be replaced by custom sidebars."
25
+ msgstr ""
26
+
27
+ #: admin/admin.php:116
28
+ #: admin/admin.php:183
29
+ #: admin/admin.php:240
30
+ #: admin/admin.php:314
31
+ msgid "Sidebar"
32
+ msgstr ""
33
+
34
+ #: admin/admin.php:316
35
+ msgid "&mdash; No Change &mdash;"
36
+ msgstr ""
37
+
38
+ #: admin/admin.php:384
39
+ msgid "Edit Sidebar"
40
+ msgstr ""
41
+
42
+ #: admin/admin.php:544
43
+ msgid "The sidebar you were editing is no longer assigned to any pages and has been removed. Any widgets it contained should be in an \"Inactive Widgets\" area below."
44
+ msgstr ""
45
+
46
+ #: admin/admin.php:631
47
+ #, php-format
48
+ msgid "For Simple Page Sidebars to work, a default sidebar needs to be selected on the %s"
49
+ msgstr ""
50
+
51
+ #: admin/admin.php:632
52
+ msgid "Reading settings screen"
53
+ msgstr ""
54
+
55
+ #: admin/views/edit-sidebar-screen.php:13
56
+ msgid "Whoops, that doesn't appear to be a sidebar that can be edited."
57
+ msgstr ""
58
+
59
+ #: admin/views/edit-sidebar-screen.php:26
60
+ msgid "Sidebar settings updated."
61
+ msgstr ""
62
+
63
+ #: admin/views/edit-sidebar-screen.php:27
64
+ #: admin/views/meta-box-page-sidebar.php:4
65
+ msgid "Update widgets now."
66
+ msgstr ""
67
+
68
+ #: admin/views/edit-sidebar-screen.php:62
69
+ msgid "Update Sidebar"
70
+ msgstr ""
71
+
72
+ #: admin/views/meta-box-page-sidebar.php:3
73
+ msgid "Page sidebar saved."
74
+ msgstr ""
75
+
76
+ #: admin/views/meta-box-page-sidebar.php:9
77
+ msgid "Current sidebar:"
78
+ msgstr ""
79
+
80
+ #: admin/views/meta-box-page-sidebar.php:23
81
+ msgid "Or create a new sidebar:"
82
+ msgstr ""
83
+
84
+ #: admin/views/meta-box-page-sidebar.php:26
85
+ msgid "Enter New"
86
+ msgstr ""
87
+
88
+ #: admin/views/meta-box-page-sidebar.php:27
89
+ msgid "Cancel"
90
+ msgstr ""
91
+
92
+ #: admin/views/meta-box-page-sidebar.php:32
93
+ msgid "Update"
94
+ msgstr ""
95
+
96
+ #: admin/views/meta-box-sidebar-pages.php:4
97
+ #, php-format
98
+ msgid "The above sidebar will replace the \"<strong>%s</strong>\" sidebar for all pages selected below."
99
+ msgstr ""
100
+
101
+ #: admin/views/meta-box-sidebar-pages.php:6
102
+ msgid "Any currently assigned custom sidebars will also be overridden for the selected pages."
103
+ msgstr ""
104
+
105
+ #: admin/views/meta-box-sidebar-pages.php:33
106
+ msgid "To delete this sidebar, simply uncheck all pages and click the \"Update Sidebar\" button."
107
+ msgstr ""
108
+
109
+ #: includes/widget-area.php:18
110
+ msgid "Include all widgets from another widget area"
111
+ msgstr ""
112
+
113
+ #: includes/widget-area.php:22
114
+ msgid "Widget Area"
115
+ msgstr ""
116
+
117
+ #: includes/widget-area.php:62
118
+ msgid "Title:"
119
+ msgstr ""
120
+
121
+ #: includes/widget-area.php:66
122
+ msgid "Area Name:"
123
+ msgstr ""
124
+
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: blazersix, bradyvercher
3
  Donate link: http://bit.ly/s2zcgD
4
  Tags: sidebars, custom sidebars, dynamic sidebar, simple, widget, widgets
5
  Requires at least: 3.4.2
6
- Tested up to: 3.5
7
- Stable tag: 1.1.1
8
- License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Easily assign custom, widget-enabled sidebars to any page.
@@ -14,27 +14,50 @@ Easily assign custom, widget-enabled sidebars to any page.
14
 
15
  Designed for simplicity and flexibility, Simple Page Sidebars gives WordPress users, designers, and developers the ability to assign custom sidebars to individual pages--without making any template changes. Existing sidebars can also be assigned in quick edit and bulk edit modes, helping save you time.
16
 
 
 
 
 
17
  = Benefits =
18
 
19
  * No more site-wide, generic sidebars. Each page (or section) can have its own widgets.
20
- * Complete control over sidebar names.
21
  * Assign the same sidebar to multiple pages.
22
- * A page's sidebar can be modified without creating a pointless revision.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- Simple Page Sidebars also comes with a "Widget Area" widget for including all the widgets from one sidebar into another.
 
 
25
 
26
  == Installation ==
27
 
28
  Installing Simple Page Sidebars is just like installing most other plugins. [Check out the codex](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins) if you have any questions.
29
 
30
  #### Setup
31
- After installation, go to the Reading options panel (the Reading link under Settings) and choose which registered sidebar is the default sidebar.
32
 
33
  == Frequently Asked Questions ==
34
 
35
  = Why is the default sidebar still showing after I've created a custom sidebar for a page? =
36
 
37
- If you haven't added any widgets to your new custom sidebar, the default sidebar will continue to display. If you really want a blank sidebar, just add an empty text widget.
38
 
39
  = How do I give my blog a different sidebar? =
40
 
@@ -54,20 +77,30 @@ Yes, just click the "Screen Options" tab in the upper right corner of your scree
54
 
55
  == Notes ==
56
 
57
- The philosphy behind creating this plugin was to make it easy to use and integrate it into the WordPress admin panel as seamlessly as possible. It's not the end-all, be-all solution for custom sidebars, but should handle the majority of use cases. We contemplated adding additional features and could have created an options page, but wanted to keep it simple and probably would have polluted it with credit meta boxes and whatnot.
58
-
59
- The aim is basic, core-like functionality and integration.
60
-
61
  = Custom Loops =
62
 
63
- If your page has any custom loops or queries, they need to be followed by `wp_reset_query()`, otherwise the global `$post` variable will no longer reference the correct post and by the time the sidebar is displayed, Simple Page Sidebars won't know which page is being viewed, which can lead to an unexpected sidebar being displayed.
64
 
65
  = Theme Sidebars =
66
 
67
- Some themes create different sidebars for their various page templates, which means there isn't a default sidebar that can be replaced. The only workaround to continue using Simple Page Sidebars in this instance is to create a child theme to force page templates with custom sidebars to use the default sidebar.
68
 
69
  == Changelog ==
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  = 1.1.1 =
72
  * Worked around the slashing weirdness in WordPress API.
73
  * Implemented a method to allow developers to easily add support for additional post types. No plans to build this out further, it's just here for additional flexibility if more complex solutions aren't wanted.
3
  Donate link: http://bit.ly/s2zcgD
4
  Tags: sidebars, custom sidebars, dynamic sidebar, simple, widget, widgets
5
  Requires at least: 3.4.2
6
+ Tested up to: 3.7.1
7
+ Stable tag: trunk
8
+ License: GPL-2.0+
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Easily assign custom, widget-enabled sidebars to any page.
14
 
15
  Designed for simplicity and flexibility, Simple Page Sidebars gives WordPress users, designers, and developers the ability to assign custom sidebars to individual pages--without making any template changes. Existing sidebars can also be assigned in quick edit and bulk edit modes, helping save you time.
16
 
17
+ In contrast to some of the more complicated plugins available, Simple Page Sidebars aims for basic, core-like functionality and integration that's easy to use without polluting your admin panel. And due to the way sidebars are saved, it utilizes built-in WordPress caching, so your site won't be bogged down with additional queries.
18
+
19
+ Simple Page Sidebars also ships with a "Widget Area" widget for pulling all the widgets from one sidebar into another.
20
+
21
  = Benefits =
22
 
23
  * No more site-wide, generic sidebars. Each page (or section) can have its own widgets.
24
+ * Complete control over the names of your custom sidebars.
25
  * Assign the same sidebar to multiple pages.
26
+ * Modify a page's sidebar without creating an unnecessary revision.
27
+
28
+ = Advanced Usage =
29
+
30
+ If you want to assign custom sidebars to archive pages or replace multiple sidebars per page, this plugin likely won't be the best solution. However it's flexible enough to handle a wide range of page-based use cases. It can even be configured to work with Custom Post Types by adding a couple lines of code:
31
+
32
+ `function myprefix_init() {
33
+ add_post_type_support( '{{post_type}}', 'simple-page-sidebars' );
34
+ }
35
+ add_action( 'init', 'myprefix_init' );`
36
+
37
+ = Additional Resources =
38
+
39
+ * [Write a review](http://wordpress.org/support/view/plugin-reviews/simple-page-sidebars#postform)
40
+ * [Have a question?](http://wordpress.org/support/plugin/simple-page-sidebars)
41
+ * [Contribute on GitHub](https://github.com/blazersix/simple-page-sidebars)
42
+ * [Follow @bradyvercher](https://twitter.com/bradyvercher)
43
+ * [Hire Blazer Six](http://www.blazersix.com/)
44
 
45
+ = Translation Credits =
46
+
47
+ * Serbo-Croation (sr_RS) - Borisa Djuraskovic [v1.1.5]
48
 
49
  == Installation ==
50
 
51
  Installing Simple Page Sidebars is just like installing most other plugins. [Check out the codex](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins) if you have any questions.
52
 
53
  #### Setup
54
+ After installation, go to the Reading options panel (the Reading link under Settings) and choose which of your registered sidebars is the default sidebar.
55
 
56
  == Frequently Asked Questions ==
57
 
58
  = Why is the default sidebar still showing after I've created a custom sidebar for a page? =
59
 
60
+ If you haven't added any widgets to your new custom sidebar, the default sidebar will continue to display. If you really want a blank sidebar, try adding an empty text widget.
61
 
62
  = How do I give my blog a different sidebar? =
63
 
77
 
78
  == Notes ==
79
 
 
 
 
 
80
  = Custom Loops =
81
 
82
+ If your page has any custom loops or queries, they need to be followed by `wp_reset_query()`, otherwise the global `$post` variable will no longer reference the correct post and by the time the sidebar is displayed, Simple Page Sidebars won't know which page is being viewed, possibly leading to an unexpected sidebar being displayed.
83
 
84
  = Theme Sidebars =
85
 
86
+ Some themes register different sidebars for their page templates, which means there isn't a default sidebar that can be replaced. To use Simple Page Sidebars in this instance, you can create a child theme and force page templates with custom sidebars to use the default sidebar.
87
 
88
  == Changelog ==
89
 
90
+ = 1.1.5 =
91
+ * Added Serbo-Croatian translation.
92
+
93
+ = 1.1.4 =
94
+ * Really fix the Quick Edit functionality.
95
+ * Update text domain loading order to get ready for language packs.
96
+ * Fix a strict PHP notice.
97
+
98
+ = 1.1.3 =
99
+ * Fixed Quick Edit functionality in WordPress 3.6.
100
+
101
+ = 1.1.2 =
102
+ * Changed the parent file of the "Edit Sidebar" screen to remove the small gap between submenu items.
103
+
104
  = 1.1.1 =
105
  * Worked around the slashing weirdness in WordPress API.
106
  * Implemented a method to allow developers to easily add support for additional post types. No plans to build this out further, it's just here for additional flexibility if more complex solutions aren't wanted.
screenshot-1.png DELETED
Binary file
screenshot-2.png DELETED
Binary file
screenshot-3.png DELETED
Binary file
simple-page-sidebars.php CHANGED
@@ -3,30 +3,18 @@
3
  * Plugin Name: Simple Page Sidebars
4
  * Plugin URI: http://wordpress.org/extend/plugins/simple-page-sidebars/
5
  * Description: Assign custom, widget-enabled sidebars to any page with ease.
6
- * Version: 1.1.1
7
- * Author: Blazer Six, Inc.
8
  * Author URI: http://www.blazersix.com/
9
- * License: GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
 
 
11
  *
12
- * This program is free software; you can redistribute it and/or modify it
13
- * under the terms of the GNU General Public License as published by the Free
14
- * Software Foundation; either version 2 of the License, or (at your option)
15
- * any later version.
16
- *
17
- * This program is distributed in the hope that it will be useful, but WITHOUT
18
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20
- * more details.
21
- *
22
- * You should have received a copy of the GNU General Public License along
23
- * with this program; if not, write to the Free Software Foundation, Inc., 59
24
- * Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
- *
26
- * @package Simple_Page_Sidebars
27
  * @author Brady Vercher <brady@blazersix.com>
28
- * @copyright Copyright (c) 2012, Blazer Six, Inc.
29
- * @license http://www.gnu.org/licenses/gpl-2.0.html
30
  */
31
 
32
  /**
@@ -41,69 +29,75 @@ if ( ! defined( 'SIMPLE_PAGE_SIDEBARS_DIR' ) )
41
  if ( ! defined( 'SIMPLE_PAGE_SIDEBARS_URL' ) )
42
  define( 'SIMPLE_PAGE_SIDEBARS_URL', plugin_dir_url( __FILE__ ) );
43
 
44
- /**
45
- * Load the plugin whens plugins are loaded.
46
- */
47
- add_action( 'plugins_loaded', array( 'Simple_Page_Sidebars', 'load' ) );
48
-
49
  /**
50
  * Main plugin class.
51
- *
52
  * @since 0.2.0
53
  */
54
  class Simple_Page_Sidebars {
55
  /**
56
  * Setup the plugin.
57
- *
58
  * @since 0.2.0
59
  */
60
  public static function load() {
61
- load_plugin_textdomain( 'simple-page-sidebars', false, 'simple-page-sidebars/languages' );
62
-
63
  require_once( plugin_dir_path( __FILE__ ) . 'includes/widget-area.php' );
64
-
65
  // Load the admin functionality.
66
  if ( is_admin() ) {
67
  add_action( 'admin_init', array( __CLASS__, 'upgrade' ) );
68
-
69
  require_once( plugin_dir_path( __FILE__ ) . 'admin/admin.php' );
70
  Simple_Page_Sidebars_Admin::load();
71
  }
72
-
73
  // Lower priority registers sidebars below those typically added by themes.
74
  add_action( 'widgets_init', array( __CLASS__, 'register_sidebars' ), 20 );
75
  add_action( 'widgets_init', array( __CLASS__, 'register_widgets' ) );
76
-
77
  if ( ! is_admin() ) {
78
  add_filter( 'sidebars_widgets', array( __CLASS__, 'replace_sidebar' ) );
79
  }
80
  }
81
-
 
 
 
 
 
 
 
 
 
 
 
82
  /**
83
  * Register the Area widget.
84
- *
85
  * @since 1.1.0
86
  */
87
  public static function register_widgets() {
88
  register_widget( 'Simple_Page_Sidebars_Widget_Area' );
89
  }
90
-
91
  /**
92
  * Add custom widget areas and automatically register page sidebars.
93
- *
94
  * @todo Try to insert a link into the description of custom sidebars so
95
  * they can be edited. It'd be useful for when the Sidebar column is
96
  * disabled, since there isn't any other way to access the Edit
97
  * Sidebar screen.
98
- *
99
  * @since 0.2.0
100
  */
101
  public static function register_sidebars() {
102
  $widget_areas = array();
103
-
104
  // Add widget areas using this filter.
105
  $widget_areas = apply_filters( 'simple_page_sidebars_widget_areas', $widget_areas );
106
-
107
  // Verify id's exist, otherwise create them.
108
  // Help ensure widgets don't get mixed up if widget areas are added or removed.
109
  if ( ! empty( $widget_areas ) && is_array( $widget_areas ) ) {
@@ -114,7 +108,7 @@ class Simple_Page_Sidebars {
114
  }
115
  }
116
  }
117
-
118
  // Override the default widget properties.
119
  $widget_area_defaults = array(
120
  'before_widget' => '<div id="%1$s" class="widget %2$s">',
@@ -122,9 +116,9 @@ class Simple_Page_Sidebars {
122
  'before_title' => '<h4 class="title">',
123
  'after_title' => '</h4>'
124
  );
125
-
126
  $widget_area_defaults = apply_filters( 'simple_page_sidebars_widget_defaults', $widget_area_defaults );
127
-
128
  // If any custom sidebars have been assigned to pages, merge them with already defined widget areas.
129
  $sidebars = simple_page_sidebars_get_names();
130
  if ( ! empty( $sidebars ) ) {
@@ -134,11 +128,11 @@ class Simple_Page_Sidebars {
134
  'description' => ''
135
  );
136
  }
137
-
138
  ksort( $page_sidebars );
139
  $widget_areas = array_merge_recursive( $widget_areas, $page_sidebars );
140
  }
141
-
142
  if ( ! empty( $widget_areas ) && is_array( $widget_areas ) ) {
143
  // Register the widget areas.
144
  foreach ( $widget_areas as $key => $area ) {
@@ -154,7 +148,7 @@ class Simple_Page_Sidebars {
154
  }
155
  }
156
  }
157
-
158
  /**
159
  * Replaces the default sidebar with a custom defined page sidebar.
160
  *
@@ -163,31 +157,31 @@ class Simple_Page_Sidebars {
163
  */
164
  public static function replace_sidebar( $sidebars_widgets ) {
165
  global $post;
166
-
167
  $supports = ( isset( $post->post_type ) && post_type_supports( $post->post_type, 'simple-page-sidebars' ) ) ? true : false;
168
-
169
  if ( is_page() || $supports || ( is_home() && $posts_page = get_option( 'page_for_posts' ) ) ) {
170
  $post_id = ( ! empty( $posts_page ) ) ? $posts_page : $post->ID;
171
-
172
  $custom_sidebar = get_post_meta( $post_id, '_sidebar_name', true );
173
  $default_sidebar_id = get_option( 'simple_page_sidebars_default_sidebar' );
174
-
175
  if ( $custom_sidebar && $default_sidebar_id ) {
176
  $custom_sidebar_id = 'page-sidebar-' . sanitize_key( $custom_sidebar );
177
-
178
  // Only replace the default sidebar if the custom sidebar has widgets.
179
  if ( ! empty( $sidebars_widgets[ $custom_sidebar_id ] ) ) {
180
  $sidebars_widgets[ $default_sidebar_id ] = $sidebars_widgets[ $custom_sidebar_id ];
181
  }
182
  }
183
  }
184
-
185
  return $sidebars_widgets;
186
  }
187
-
188
  /**
189
  * Save version information for future upgrades.
190
- *
191
  * @since 1.1.0
192
  */
193
  public static function upgrade() {
@@ -196,12 +190,13 @@ class Simple_Page_Sidebars {
196
  // If the plugin version setting isn't set or if it's less than or equal to 1.1.0, update the saved version.
197
  if ( ! $saved_version || version_compare( $saved_version, '1.1.0', '<=' ) ) {
198
  $plugin_data = get_plugin_data( __FILE__ );
199
-
200
  // Update saved version number.
201
  update_option( 'simple_page_sidebars_version', $plugin_data['Version'] );
202
  }
203
  }
204
  }
 
205
 
206
  /**
207
  * Get an array of custom sidebar names.
@@ -211,19 +206,19 @@ class Simple_Page_Sidebars {
211
  */
212
  function simple_page_sidebars_get_names() {
213
  global $wpdb;
214
-
215
  $sidebar_names = $wpdb->get_results( "SELECT DISTINCT meta_value
216
  FROM $wpdb->posts p, $wpdb->postmeta pm
217
  WHERE p.post_status!='auto-draft' AND p.ID=pm.post_id AND pm.meta_key='_sidebar_name'
218
  ORDER BY pm.meta_value ASC" );
219
-
220
  $sidebars = array();
221
  if ( ! empty( $sidebar_names ) ) {
222
  foreach ( $sidebar_names as $meta ) {
223
  $sidebars[] = $meta->meta_value;
224
  }
225
  }
226
-
227
  return $sidebars;
228
  }
229
 
@@ -242,12 +237,12 @@ function simple_page_sidebars_get_names() {
242
  */
243
  function simple_page_sidebar( $default_sidebar ) {
244
  global $post, $wp_registered_sidebars;
245
-
246
  $sidebar_name = get_post_meta( $post->ID, '_sidebar_name', true );
247
-
248
  // Last chance to override which sidebar is displayed.
249
  $sidebar_name = apply_filters( 'simple_page_sidebars_last_call', $sidebar_name );
250
-
251
  if ( is_page() && ! empty( $sidebar_name ) ) {
252
  $sidebars_widgets = wp_get_sidebars_widgets();
253
  if ( count( $sidebars_widgets ) ) {
@@ -272,8 +267,7 @@ function simple_page_sidebar( $default_sidebar ) {
272
  if ( ! function_exists( 'simple_sidebar' ) ) :
273
  function simple_sidebar( $default_sidebar ) {
274
  _deprecated_function( __FUNCTION__, '0.1.1', 'simple_page_sidebar()' );
275
-
276
  simple_page_sidebar( $default_sidebar );
277
  }
278
  endif;
279
- ?>
3
  * Plugin Name: Simple Page Sidebars
4
  * Plugin URI: http://wordpress.org/extend/plugins/simple-page-sidebars/
5
  * Description: Assign custom, widget-enabled sidebars to any page with ease.
6
+ * Version: 1.1.5
7
+ * Author: Blazer Six
8
  * Author URI: http://www.blazersix.com/
9
+ * License: GPL-2.0+
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ * Text Domain: simple-page-sidebars
12
+ * Domain Path: /languages
13
  *
14
+ * @package SimplePageSidebars
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  * @author Brady Vercher <brady@blazersix.com>
16
+ * @copyright Copyright (c) 2013, Blazer Six, Inc.
17
+ * @license GPL-2.0+
18
  */
19
 
20
  /**
29
  if ( ! defined( 'SIMPLE_PAGE_SIDEBARS_URL' ) )
30
  define( 'SIMPLE_PAGE_SIDEBARS_URL', plugin_dir_url( __FILE__ ) );
31
 
 
 
 
 
 
32
  /**
33
  * Main plugin class.
34
+ *
35
  * @since 0.2.0
36
  */
37
  class Simple_Page_Sidebars {
38
  /**
39
  * Setup the plugin.
40
+ *
41
  * @since 0.2.0
42
  */
43
  public static function load() {
44
+ self::load_textdomain();
45
+
46
  require_once( plugin_dir_path( __FILE__ ) . 'includes/widget-area.php' );
47
+
48
  // Load the admin functionality.
49
  if ( is_admin() ) {
50
  add_action( 'admin_init', array( __CLASS__, 'upgrade' ) );
51
+
52
  require_once( plugin_dir_path( __FILE__ ) . 'admin/admin.php' );
53
  Simple_Page_Sidebars_Admin::load();
54
  }
55
+
56
  // Lower priority registers sidebars below those typically added by themes.
57
  add_action( 'widgets_init', array( __CLASS__, 'register_sidebars' ), 20 );
58
  add_action( 'widgets_init', array( __CLASS__, 'register_widgets' ) );
59
+
60
  if ( ! is_admin() ) {
61
  add_filter( 'sidebars_widgets', array( __CLASS__, 'replace_sidebar' ) );
62
  }
63
  }
64
+
65
+ /**
66
+ * Plugin localization support.
67
+ *
68
+ * @since 1.1.4
69
+ */
70
+ public static function load_textdomain() {
71
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'simple-page-sidebars' );
72
+ load_textdomain( 'simple-page-sidebars', WP_LANG_DIR . '/simple-page-sidebars/' . $locale . '.mo' );
73
+ load_plugin_textdomain( 'simple-page-sidebars', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
74
+ }
75
+
76
  /**
77
  * Register the Area widget.
78
+ *
79
  * @since 1.1.0
80
  */
81
  public static function register_widgets() {
82
  register_widget( 'Simple_Page_Sidebars_Widget_Area' );
83
  }
84
+
85
  /**
86
  * Add custom widget areas and automatically register page sidebars.
87
+ *
88
  * @todo Try to insert a link into the description of custom sidebars so
89
  * they can be edited. It'd be useful for when the Sidebar column is
90
  * disabled, since there isn't any other way to access the Edit
91
  * Sidebar screen.
92
+ *
93
  * @since 0.2.0
94
  */
95
  public static function register_sidebars() {
96
  $widget_areas = array();
97
+
98
  // Add widget areas using this filter.
99
  $widget_areas = apply_filters( 'simple_page_sidebars_widget_areas', $widget_areas );
100
+
101
  // Verify id's exist, otherwise create them.
102
  // Help ensure widgets don't get mixed up if widget areas are added or removed.
103
  if ( ! empty( $widget_areas ) && is_array( $widget_areas ) ) {
108
  }
109
  }
110
  }
111
+
112
  // Override the default widget properties.
113
  $widget_area_defaults = array(
114
  'before_widget' => '<div id="%1$s" class="widget %2$s">',
116
  'before_title' => '<h4 class="title">',
117
  'after_title' => '</h4>'
118
  );
119
+
120
  $widget_area_defaults = apply_filters( 'simple_page_sidebars_widget_defaults', $widget_area_defaults );
121
+
122
  // If any custom sidebars have been assigned to pages, merge them with already defined widget areas.
123
  $sidebars = simple_page_sidebars_get_names();
124
  if ( ! empty( $sidebars ) ) {
128
  'description' => ''
129
  );
130
  }
131
+
132
  ksort( $page_sidebars );
133
  $widget_areas = array_merge_recursive( $widget_areas, $page_sidebars );
134
  }
135
+
136
  if ( ! empty( $widget_areas ) && is_array( $widget_areas ) ) {
137
  // Register the widget areas.
138
  foreach ( $widget_areas as $key => $area ) {
148
  }
149
  }
150
  }
151
+
152
  /**
153
  * Replaces the default sidebar with a custom defined page sidebar.
154
  *
157
  */
158
  public static function replace_sidebar( $sidebars_widgets ) {
159
  global $post;
160
+
161
  $supports = ( isset( $post->post_type ) && post_type_supports( $post->post_type, 'simple-page-sidebars' ) ) ? true : false;
162
+
163
  if ( is_page() || $supports || ( is_home() && $posts_page = get_option( 'page_for_posts' ) ) ) {
164
  $post_id = ( ! empty( $posts_page ) ) ? $posts_page : $post->ID;
165
+
166
  $custom_sidebar = get_post_meta( $post_id, '_sidebar_name', true );
167
  $default_sidebar_id = get_option( 'simple_page_sidebars_default_sidebar' );
168
+
169
  if ( $custom_sidebar && $default_sidebar_id ) {
170
  $custom_sidebar_id = 'page-sidebar-' . sanitize_key( $custom_sidebar );
171
+
172
  // Only replace the default sidebar if the custom sidebar has widgets.
173
  if ( ! empty( $sidebars_widgets[ $custom_sidebar_id ] ) ) {
174
  $sidebars_widgets[ $default_sidebar_id ] = $sidebars_widgets[ $custom_sidebar_id ];
175
  }
176
  }
177
  }
178
+
179
  return $sidebars_widgets;
180
  }
181
+
182
  /**
183
  * Save version information for future upgrades.
184
+ *
185
  * @since 1.1.0
186
  */
187
  public static function upgrade() {
190
  // If the plugin version setting isn't set or if it's less than or equal to 1.1.0, update the saved version.
191
  if ( ! $saved_version || version_compare( $saved_version, '1.1.0', '<=' ) ) {
192
  $plugin_data = get_plugin_data( __FILE__ );
193
+
194
  // Update saved version number.
195
  update_option( 'simple_page_sidebars_version', $plugin_data['Version'] );
196
  }
197
  }
198
  }
199
+ add_action( 'plugins_loaded', array( 'Simple_Page_Sidebars', 'load' ) );
200
 
201
  /**
202
  * Get an array of custom sidebar names.
206
  */
207
  function simple_page_sidebars_get_names() {
208
  global $wpdb;
209
+
210
  $sidebar_names = $wpdb->get_results( "SELECT DISTINCT meta_value
211
  FROM $wpdb->posts p, $wpdb->postmeta pm
212
  WHERE p.post_status!='auto-draft' AND p.ID=pm.post_id AND pm.meta_key='_sidebar_name'
213
  ORDER BY pm.meta_value ASC" );
214
+
215
  $sidebars = array();
216
  if ( ! empty( $sidebar_names ) ) {
217
  foreach ( $sidebar_names as $meta ) {
218
  $sidebars[] = $meta->meta_value;
219
  }
220
  }
221
+
222
  return $sidebars;
223
  }
224
 
237
  */
238
  function simple_page_sidebar( $default_sidebar ) {
239
  global $post, $wp_registered_sidebars;
240
+
241
  $sidebar_name = get_post_meta( $post->ID, '_sidebar_name', true );
242
+
243
  // Last chance to override which sidebar is displayed.
244
  $sidebar_name = apply_filters( 'simple_page_sidebars_last_call', $sidebar_name );
245
+
246
  if ( is_page() && ! empty( $sidebar_name ) ) {
247
  $sidebars_widgets = wp_get_sidebars_widgets();
248
  if ( count( $sidebars_widgets ) ) {
267
  if ( ! function_exists( 'simple_sidebar' ) ) :
268
  function simple_sidebar( $default_sidebar ) {
269
  _deprecated_function( __FUNCTION__, '0.1.1', 'simple_page_sidebar()' );
270
+
271
  simple_page_sidebar( $default_sidebar );
272
  }
273
  endif;