Simple Page Sidebars - Version 0.2

Version Description

  • Added an option to define the default sidebar on the Reading options panel.
  • Removed the template change requirement. It's no longer recommended.
  • Refactored code, including function/hook names.
  • Deprecated simple_sidebar function. Replaced by simple_page_sidebar.
  • Deprecated simpsid_widget_areas filter. Replaced by simple_page_sidebars_widget_areas.
  • Deprecated simpsid_widget_area_defaults filter. Replaced by simple_page_sidebars_widget_area_defaults.
  • Deprecated simpsid_sidebar_name filter. Replaced with simple_page_sidebars_last_call.
Download this release

Release Info

Developer blazersix
Plugin Icon 128x128 Simple Page Sidebars
Version 0.2
Comparing to
See all releases

Code changes from version 0.1 to 0.2

admin/admin.php CHANGED
@@ -1,187 +1,302 @@
1
  <?php
2
- /*
3
- * Super function for saving page sidebars
4
- */
5
- add_action( 'save_post', 'simpsid_update_page_sidebar' );
6
- add_action( 'wp_ajax_simpsid_update_page_sidebar', 'simpsid_update_page_sidebar' );
7
- function simpsid_update_page_sidebar( $post_id = 0 ) {
8
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
9
- return $post_id;
10
-
11
- if ( $post_id == 0 ) {
12
- $post_id = $_POST['post_id'];
13
  }
14
 
15
- // verify either an individual post nonce or the bulk edit nonce
16
- // requests can come from a page update, ajax from the sidebar meta box, quick edit, or bulk edit
17
- if ( ! wp_verify_nonce( $_REQUEST['sidebar_name_nonce'], 'update-page-sidebar-name-' . $post_id ) && ! wp_verify_nonce( $_REQUEST['bulk_sidebar_name_nonce'], 'bulk-update-page-sidebar-name' ) ) {
18
- if ( defined( 'DOING AJAX' ) && DOING_AJAX ) {
19
- exit;
20
- } else {
21
- return;
22
- }
23
- }
24
 
25
- if ( ! wp_is_post_revision( $post_id ) && 'page' == get_post_type( $post_id ) ) {
26
- // if 'new_sidebar_name' is set and not empty, it supercedes any 'sidebar_name' setting
27
- // if 'sidebar_name' is blank or it equals 'default', delete meta
28
- // if 'sidebar_name' is set and not empty, update to new name
29
- // if 'sidebar_name' is -1, skip
30
 
31
- // bulk edit uses $_GET for some reason, so we use the $_REQUEST global
32
- if ( isset( $_REQUEST['new_sidebar_name' ] ) && ! empty( $_REQUEST['new_sidebar_name'] ) ) {
33
- update_post_meta( $post_id, '_sidebar_name', $_REQUEST['new_sidebar_name'] );
34
- } else {
35
- // if $_REQUEST['sidebar_name'] isn't set, we don't want to update the sidebar meta value
36
- $sidebar = ( isset( $_REQUEST['sidebar_name'] ) ) ? $_REQUEST['sidebar_name'] : -1;
37
-
38
- if ( empty( $sidebar ) || 'default' == $sidebar ) {
39
- delete_post_meta( $post_id, '_sidebar_name' );
40
- } elseif ( -1 != intval( $sidebar ) ) {
41
- update_post_meta( $post_id, '_sidebar_name', $_REQUEST['sidebar_name'] );
42
- }
43
- }
44
  }
45
 
46
- if ( defined( 'DOING AJAX' ) && DOING_AJAX )
47
- exit;
48
- }
49
-
50
-
51
- add_action( 'admin_menu', 'simpsid_admin_menu' );
52
- function simpsid_admin_menu() {
53
- add_action( 'admin_footer-post.php', 'simpsid_page_sidebar_script' );
54
 
55
- // wish the Page Attributes meta box had a hook. oh well.
56
- add_meta_box( 'simplepagesidebarsdiv', 'Sidebar', 'simpsid_page_sidebar_meta_box', 'page', 'side', 'core' );
57
- }
58
-
59
-
60
- function simpsid_page_sidebar_meta_box( $page ) {
61
- global $wpdb;
62
 
63
- $sidebar = get_post_meta( $page->ID, '_sidebar_name', true );
64
- $current_sidebars = simpsid_get_page_sidebars();
 
 
 
 
 
 
 
 
65
 
66
- wp_nonce_field( 'update-page-sidebar-name-' . $page->ID, 'sidebar_name_nonce', false );
67
- ?>
68
- <p>
69
- <label for="sidebar-name" class="screen-reader-text"><?php _e( 'Choose an existing sidebar:', 'simple-page-sidebars' ); ?></label>
70
- <select name="sidebar_name" id="sidebar-name" class="widefat">
71
- <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
 
 
 
72
  <?php
73
- foreach ( $current_sidebars as $sb ) {
74
- echo '<option value="' . esc_attr( $sb ) . '"';
75
- selected( $sb, $sidebar );
76
- echo '>' . esc_html( $sb ) . '</option>';
 
 
77
  }
78
  ?>
79
  </select>
80
- <label for="new-sidebar-name" class="screen-reader-text"><?php _e( 'Or create a new sidebar:', 'simple-page-sidebars' ); ?></label>
81
- <input type="text" name="new_sidebar_name" id="new-sidebar-name" class="widefat hide-if-js" value="" />
82
- <span id="sidebarnew" class="hide-if-no-js"><?php _e( 'Enter New', 'simple-page-sidebars' ); ?></span>
83
- <span id="sidebarcancel" class="hidden"><?php _e( 'Cancel', 'simple-page-sidebars' ); ?></span>
84
- </p>
85
 
86
- <p style="margin-top: 10px; margin-bottom: 0; text-align: right">
87
- <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" id="sidebar-update-feedback" style="display: none" />
88
- <button class="button"><?php _e( 'Update', 'simple-page-sidebars' ); ?></button>
89
- </p>
90
 
91
- <style type="text/css">
92
- #sidebar-update-feedback { display: none; margin: 0 5px 0 0; vertical-align: middle;}
93
- #sidebarcancel, #sidebarnew { cursor: pointer; float: left; margin: 3px 0 0 3px; color: #21759b; font-size: 12px;}
94
- #sidebarcancel, #sidebarnew:hover { color: #d54e21;}
95
- </style>
96
 
97
- <script type="text/javascript">
98
- jQuery(function($) {
99
- $('#sidebarcancel, #sidebarnew').click(function() {
100
- $('#new-sidebar-name, #sidebar-name, #sidebarcancel, #sidebarnew').toggle();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
- // clear the new sidebar name field when cancel is clicked
103
- if ( 'sidebarcancel' == $(this).attr('id') ) {
104
- $('#new-sidebar-name').val('');
 
 
 
 
 
 
 
 
 
105
  }
106
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
- $('#simplepagesidebarsdiv').find('button').click(function(e) {
109
- e.preventDefault();
 
 
 
 
 
 
 
 
110
 
111
- $('#sidebar-update-feedback').show();
112
- $.post(ajaxurl, {
113
- action : 'simpsid_update_page_sidebar',
114
- post_id : $('#post_ID').val(),
115
- sidebar_name : $('select[name="sidebar_name"]').val(),
116
- new_sidebar_name : $('input[name="new_sidebar_name"]').val(),
117
- sidebar_name_nonce : $('input[name="sidebar_name_nonce"]').val()
118
- },
119
- function(data){
120
- new_sidebar_name = $('#new-sidebar-name').val();
121
-
122
- if ( '' != new_sidebar_name ) {
123
- if ( $('#simplepagesidebarsdiv select option[value="' + new_sidebar_name + '"]').length < 1 ) {
124
- $('#simplepagesidebarsdiv select').append('<option selected="selected">' + new_sidebar_name + '</option>').val(new_sidebar_name);
125
- } else {
126
- $('#simplepagesidebarsdiv select option[value="' + new_sidebar_name + '"]').attr('selected','selected');
 
 
 
 
 
 
127
  }
128
 
129
- $('#new-sidebar-name, #sidebar-name, #sidebarcancel, #sidebarnew').toggle().filter('input').val('');
130
  }
131
-
132
- $('#sidebar-update-feedback').hide();
133
- }
134
- );
135
  });
136
- });
137
- </script>
 
 
 
138
 
139
- <br class="clear" />
140
- <?php
141
- }
142
-
143
-
144
- function simpsid_page_sidebar_script() {
145
- global $current_screen;
146
- if ( 'page' != $current_screen->id || 'page' != $current_screen->post_type ) { return; }
147
- ?>
148
 
149
- <?php
150
- }
151
-
152
-
153
- // quick edit ain't so quick to implement
154
- add_filter('manage_pages_columns', 'simpsid_manage_pages_columns');
155
- function simpsid_manage_pages_columns( $columns ) {
156
- $columns['sidebar'] = __( 'Sidebar', 'simple-page-sidebars' );
157
- return $columns;
158
- }
159
-
160
-
161
- add_action( 'manage_pages_custom_column', 'simpsid_manage_pages_custom_column', 10, 2 );
162
- function simpsid_manage_pages_custom_column( $column, $page_id ) {
163
- if ( 'sidebar' == $column ) {
164
- $sidebar = get_post_meta( $page_id, '_sidebar_name', true );
165
- echo ( $sidebar ) ? esc_html( $sidebar ) : '';
 
 
 
 
 
 
 
 
166
 
167
- // add the nonce here and copy it to the inline editor with javascript
168
- wp_nonce_field( 'update-page-sidebar-name-' . $page_id, 'sidebar_name_nonce', false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  }
170
- }
171
-
172
-
173
- add_action( 'quick_edit_custom_box', 'simpsid_quick_edit_custom_box', 10, 2 );
174
- function simpsid_quick_edit_custom_box( $column, $post_type ) {
175
- if ( 'page' != $post_type || 'sidebar' != $column ) { return; }
176
 
177
- $sidebars = simpsid_get_page_sidebars();
178
- ?>
179
- <fieldset class="inline-edit-col-left">
180
- <div class="inline-edit-col">
181
- <div class="inline-edit-group" id="sidebar-edit-group">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  <label>
183
  <span class="title"><?php _e( 'Sidebar', 'simple-page-sidebars' ); ?></span>
184
  <select name="sidebar_name" id="sidebar-name">
 
185
  <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
186
  <?php
187
  foreach ( $sidebars as $sb ) {
@@ -190,67 +305,11 @@ function simpsid_quick_edit_custom_box( $column, $post_type ) {
190
  ?>
191
  </select>
192
  </label>
 
193
  </div>
194
- </div>
195
- </fieldset>
196
- <?php
197
- }
198
-
199
-
200
- add_action( 'admin_footer-edit.php', 'simpsid_quick_edit_js' );
201
- function simpsid_quick_edit_js() {
202
- global $current_screen;
203
- if ( 'edit-page' != $current_screen->id || 'page' != $current_screen->post_type ) { return; }
204
- ?>
205
- <script type="text/javascript">
206
- jQuery(function($) {
207
- $('table.pages').delegate('a.editinline', 'click', function(e) {
208
- inlineEditPost.revert();
209
-
210
- var id = inlineEditPost.getId(this);
211
- var currentSidebar = $('#post-' + id + ' .sidebar').text();
212
-
213
- // select the current sidebar option
214
- $('select#sidebar-name option').attr('selected', false);
215
- if ( '' != currentSidebar ) {
216
- $('select#sidebar-name option:contains(' + currentSidebar + ')').attr('selected', true);
217
- }
218
-
219
- // copy the sidebar name nonce
220
- $('#sidebar-edit-group').find('input[name="sidebar_name_nonce"]').remove().end().append( $('#post-' + id + ' input[name="sidebar_name_nonce"]').clone() );
221
- });
222
- });
223
- </script>
224
- <style type="text/css">
225
- .widefat .column-sidebar { width: 15%;}
226
- </style>
227
- <?php
228
- }
229
-
230
-
231
- add_action( 'bulk_edit_custom_box', 'simpsid_bulk_edit_custom_box', 10, 2 );
232
- function simpsid_bulk_edit_custom_box( $column, $post_type ) {
233
- if ( 'page' != $post_type || 'sidebar' != $column ) { return; }
234
-
235
- $sidebars = simpsid_get_page_sidebars();
236
- ?>
237
- <fieldset class="inline-edit-col-right" style="margin-top: 0">
238
- <div class="inline-edit-col">
239
- <label>
240
- <span class="title"><?php _e( 'Sidebar', 'simple-page-sidebars' ); ?></span>
241
- <select name="sidebar_name" id="sidebar-name">
242
- <option value="-1"><?php _e( '&mdash; No Change &mdash;', 'simple-page-sidebars' ); ?></option>
243
- <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
244
- <?php
245
- foreach ( $sidebars as $sb ) {
246
- echo '<option value="' . $sb . '">' . $sb . '</option>';
247
- }
248
- ?>
249
- </select>
250
- </label>
251
- <?php wp_nonce_field( 'bulk-update-page-sidebar-name', 'bulk_sidebar_name_nonce', false ); ?>
252
- </div>
253
- </fieldset>
254
- <?php
255
  }
 
256
  ?>
1
  <?php
2
+ class Simple_Page_Sidebars_Admin {
3
+ function Simple_Page_Sidebars_Admin() {
4
+ add_action( 'init', array( &$this, 'init' ) );
5
+ add_action( 'admin_init', array( &$this, 'admin_init' ) );
 
 
 
 
 
 
 
6
  }
7
 
 
 
 
 
 
 
 
 
 
8
 
9
+ function init() {
10
+ add_action( 'save_post', array( &$this, 'update_sidebar' ) );
11
+ add_action( 'wp_ajax_simple_page_sidebars_update_page_sidebar', array( &$this, 'update_sidebar' ) );
 
 
12
 
13
+ add_action( 'admin_menu', array( &$this, 'add_sidebar_meta_box' ) );
14
+
15
+ add_filter( 'manage_pages_columns', array( &$this, 'manage_pages_columns' ) );
16
+ add_action( 'manage_pages_custom_column', array( &$this, 'manage_pages_custom_column' ), 10, 2 );
17
+ add_action( 'quick_edit_custom_box', array( &$this, 'quick_edit_custom_box' ), 10, 2 );
18
+ add_action( 'admin_footer-edit.php', array( &$this, 'quick_edit_js' ) );
19
+ add_action( 'bulk_edit_custom_box', array( &$this, 'bulk_edit_custom_box' ), 10, 2 );
 
 
 
 
 
 
20
  }
21
 
 
 
 
 
 
 
 
 
22
 
 
 
 
 
 
 
 
23
 
24
+ /*
25
+ * Methods for registering and saving the default sidebar on the Reading options panel
26
+ */
27
+ function admin_init() {
28
+ add_settings_field( 'simple_page_sidebars_default_sidebar', '<label for="simple-page-sidebars-default-sidebar">' . __( ' Default Sidebar', 'simple-page-sidebars' ) . '</label>', array( &$this, 'settings_field_default_sidebar_dropdown' ), 'reading' );
29
+ register_setting( 'reading', 'simple_page_sidebars_default_sidebar', array( &$this, 'register_reading_setting' ) );
30
+ }
31
+
32
+
33
+ function register_reading_setting( $input ) { return $input; }
34
 
35
+
36
+ function settings_field_default_sidebar_dropdown() {
37
+ global $wp_registered_sidebars;
38
+ $default_sidebar_id = get_option( 'simple_page_sidebars_default_sidebar' );
39
+
40
+ $custom_sidebars = simple_page_sidebars_get_names();
41
+ ?>
42
+ <select name="simple_page_sidebars_default_sidebar" id="simple-page-sidebars-default-sidebar">
43
+ <option value=""></option>
44
  <?php
45
+ foreach ( $wp_registered_sidebars as $sb ) {
46
+ if ( is_array( $custom_sidebars ) && ! in_array( $sb['name'], $custom_sidebars ) ) {
47
+ echo '<option value="' . esc_attr( $sb['id'] ) . '"';
48
+ selected( $sb['id'], $default_sidebar_id );
49
+ echo '>' . esc_html( $sb['name'] ) . '</option>';
50
+ }
51
  }
52
  ?>
53
  </select>
54
+ <span class="description"><?php _e( 'The sidebar that will replaced by custom sidebars.', 'simple-page-sidebars' ); ?></span>
55
+ <?php
56
+ }
 
 
57
 
 
 
 
 
58
 
 
 
 
 
 
59
 
60
+ /*
61
+ * Super method for saving page sidebars
62
+ */
63
+ function update_sidebar( $post_id = 0 ) {
64
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
65
+ return $post_id;
66
+
67
+ if ( $post_id == 0 )
68
+ $post_id = $_POST['post_id'];
69
+
70
+
71
+ // verify either an individual post nonce or the bulk edit nonce
72
+ // requests can come from a page update, ajax from the sidebar meta box, quick edit, or bulk edit
73
+ $sidebar_name_nonce = ( isset( $_REQUEST['sidebar_name_nonce'] ) && wp_verify_nonce( $_REQUEST['sidebar_name_nonce'], 'update-page-sidebar-name-' . $post_id ) ) ? true : false;
74
+ $bulk_sidebar_name_nonce = ( isset( $_REQUEST['bulk_sidebar_name_nonce'] ) && wp_verify_nonce( $_REQUEST['bulk_sidebar_name_nonce'], 'bulk-update-page-sidebar-name' ) ) ? true : false;
75
+ if ( ! $sidebar_name_nonce && ! $bulk_sidebar_name_nonce ) {
76
+ if ( defined( 'DOING AJAX' ) && DOING_AJAX ) {
77
+ exit;
78
+ } else {
79
+ return;
80
+ }
81
+ }
82
+
83
+ if ( ! wp_is_post_revision( $post_id ) && 'page' == get_post_type( $post_id ) ) {
84
+ // if 'new_sidebar_name' is set and not empty, it supercedes any 'sidebar_name' setting
85
+ // if 'sidebar_name' is blank or it equals 'default', delete meta
86
+ // if 'sidebar_name' is set and not empty, update to new name
87
+ // if 'sidebar_name' is -1, skip
88
 
89
+ // bulk edit uses $_GET for some reason, so we use the $_REQUEST global
90
+ if ( isset( $_REQUEST['new_sidebar_name' ] ) && ! empty( $_REQUEST['new_sidebar_name'] ) ) {
91
+ update_post_meta( $post_id, '_sidebar_name', $_REQUEST['new_sidebar_name'] );
92
+ } else {
93
+ // if $_REQUEST['sidebar_name'] isn't set, we don't want to update the sidebar meta value
94
+ $sidebar = ( isset( $_REQUEST['sidebar_name'] ) ) ? $_REQUEST['sidebar_name'] : -1;
95
+
96
+ if ( empty( $sidebar ) || 'default' == $sidebar ) {
97
+ delete_post_meta( $post_id, '_sidebar_name' );
98
+ } elseif ( -1 != intval( $sidebar ) ) {
99
+ update_post_meta( $post_id, '_sidebar_name', $_REQUEST['sidebar_name'] );
100
+ }
101
  }
102
+ }
103
+
104
+ if ( defined( 'DOING AJAX' ) && DOING_AJAX )
105
+ exit;
106
+ }
107
+
108
+
109
+ function add_sidebar_meta_box() {
110
+ // wish the Page Attributes meta box had a hook. oh well.
111
+ add_meta_box( 'simplepagesidebarsdiv', 'Sidebar', array( &$this, 'sidebar_meta_box' ), 'page', 'side', 'core' );
112
+ }
113
+
114
+
115
+ function sidebar_meta_box( $page ) {
116
+ global $wp_registered_sidebars, $wpdb;
117
+
118
+ $sidebar = get_post_meta( $page->ID, '_sidebar_name', true );
119
+
120
+ $custom_sidebars = simple_page_sidebars_get_names();
121
+
122
+ wp_nonce_field( 'update-page-sidebar-name-' . $page->ID, 'sidebar_name_nonce', false );
123
+
124
+ $default_sidebar_id = get_option( 'simple_page_sidebars_default_sidebar' );
125
+ if ( ! $default_sidebar_id ) {
126
+ echo '<p class="error">';
127
+ printf( __( 'For Simple Page Sidebars to work, a default sidebar needs to be selected on the %s', 'simple-page-sidebars' ),
128
+ ' <a href="' . admin_url( 'options-reading.php' ) . '">' . __( 'Reading options panel', 'simple-page-sidebars') . '</a>.'
129
+ );
130
+ echo '</p>';
131
+ }
132
+ ?>
133
+ <p>
134
+ <label for="sidebar-name"><?php _e( 'Current sidebar:', 'simple-page-sidebars' ); ?></label>
135
+ <select name="sidebar_name" id="sidebar-name" class="widefat">
136
+ <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
137
+ <?php
138
+ foreach ( $custom_sidebars as $sb ) {
139
+ echo '<option value="' . esc_attr( $sb ) . '"';
140
+ selected( $sb, $sidebar );
141
+ echo '>' . esc_html( $sb ) . '</option>';
142
+ }
143
+ ?>
144
+ </select>
145
+ <label for="new-sidebar-name" class="screen-reader-text"><?php _e( 'Or create a new sidebar:', 'simple-page-sidebars' ); ?></label>
146
+ <input type="text" name="new_sidebar_name" id="new-sidebar-name" class="widefat hide-if-js" value="" />
147
+ <span id="sidebarnew" class="hide-if-no-js"><?php _e( 'Enter New', 'simple-page-sidebars' ); ?></span>
148
+ <span id="sidebarcancel" class="hidden"><?php _e( 'Cancel', 'simple-page-sidebars' ); ?></span>
149
+ </p>
150
+
151
+ <p style="margin-top: 10px; margin-bottom: 0; text-align: right">
152
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" id="sidebar-update-feedback" style="display: none" />
153
+ <button class="button"><?php _e( 'Update', 'simple-page-sidebars' ); ?></button>
154
+ </p>
155
+
156
+ <style type="text/css">
157
+ #sidebar-update-feedback { display: none; margin: 0 5px 0 0; vertical-align: middle;}
158
+ #sidebarcancel, #sidebarnew { cursor: pointer; float: left; margin: 3px 3px 0 3px; color: #21759b; font-size: 12px;}
159
+ #sidebarcancel, #sidebarnew:hover { color: #d54e21;}
160
+ #simplepagesidebarsdiv .error { color: #ee0000;}
161
+ </style>
162
 
163
+ <script type="text/javascript">
164
+ jQuery(function($) {
165
+ $('#sidebarcancel, #sidebarnew').click(function() {
166
+ $('#new-sidebar-name, #sidebar-name, #sidebarcancel, #sidebarnew').toggle();
167
+
168
+ // clear the new sidebar name field when cancel is clicked
169
+ if ( 'sidebarcancel' == $(this).attr('id') ) {
170
+ $('#new-sidebar-name').val('');
171
+ }
172
+ });
173
 
174
+ $('#simplepagesidebarsdiv').find('button').click(function(e) {
175
+ e.preventDefault();
176
+
177
+ $('#sidebar-update-feedback').show();
178
+ $.post(ajaxurl, {
179
+ action : 'simple_page_sidebars_update_page_sidebar',
180
+ post_id : $('#post_ID').val(),
181
+ sidebar_name : $('select[name="sidebar_name"]').val(),
182
+ new_sidebar_name : $('input[name="new_sidebar_name"]').val(),
183
+ sidebar_name_nonce : $('input[name="sidebar_name_nonce"]').val()
184
+ },
185
+ function(data){
186
+ new_sidebar_name = $('#new-sidebar-name').val();
187
+
188
+ if ( '' != new_sidebar_name ) {
189
+ if ( $('#simplepagesidebarsdiv select option[value="' + new_sidebar_name + '"]').length < 1 ) {
190
+ $('#simplepagesidebarsdiv select').append('<option selected="selected">' + new_sidebar_name + '</option>').val(new_sidebar_name);
191
+ } else {
192
+ $('#simplepagesidebarsdiv select option[value="' + new_sidebar_name + '"]').attr('selected','selected');
193
+ }
194
+
195
+ $('#new-sidebar-name, #sidebar-name, #sidebarcancel, #sidebarnew').toggle().filter('input').val('');
196
  }
197
 
198
+ $('#sidebar-update-feedback').hide();
199
  }
200
+ );
201
+ });
 
 
202
  });
203
+ </script>
204
+
205
+ <br class="clear" />
206
+ <?php
207
+ }
208
 
 
 
 
 
 
 
 
 
 
209
 
210
+
211
+ /*
212
+ * Quick Edit & Bulk Edit Implementation
213
+ *
214
+ * quick edit ain't so quick to implement
215
+ */
216
+ function manage_pages_columns( $columns ) {
217
+ $columns['sidebar'] = __( 'Sidebar', 'simple-page-sidebars' );
218
+ return $columns;
219
+ }
220
+
221
+
222
+ function manage_pages_custom_column( $column, $page_id ) {
223
+ if ( 'sidebar' == $column ) {
224
+ $sidebar = get_post_meta( $page_id, '_sidebar_name', true );
225
+ echo ( $sidebar ) ? esc_html( $sidebar ) : '';
226
+
227
+ // add the nonce here and copy it to the inline editor with javascript
228
+ wp_nonce_field( 'update-page-sidebar-name-' . $page_id, 'sidebar_name_nonce', false );
229
+ }
230
+ }
231
+
232
+
233
+ function quick_edit_custom_box( $column, $post_type ) {
234
+ if ( 'page' != $post_type || 'sidebar' != $column ) { return; }
235
 
236
+ $sidebars = simple_page_sidebars_get_names();
237
+ ?>
238
+ <fieldset class="inline-edit-col-left">
239
+ <div class="inline-edit-col">
240
+ <div class="inline-edit-group" id="sidebar-edit-group">
241
+ <label>
242
+ <span class="title"><?php _e( 'Sidebar', 'simple-page-sidebars' ); ?></span>
243
+ <select name="sidebar_name" id="sidebar-name">
244
+ <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
245
+ <?php
246
+ foreach ( $sidebars as $sb ) {
247
+ echo '<option value="' . $sb . '">' . $sb . '</option>';
248
+ }
249
+ ?>
250
+ </select>
251
+ </label>
252
+ </div>
253
+ </div>
254
+ </fieldset>
255
+ <?php
256
  }
 
 
 
 
 
 
257
 
258
+
259
+ function quick_edit_js() {
260
+ global $current_screen;
261
+ if ( 'edit-page' != $current_screen->id || 'page' != $current_screen->post_type ) { return; }
262
+ ?>
263
+ <script type="text/javascript">
264
+ jQuery(function($) {
265
+ $('table.pages').delegate('a.editinline', 'click', function(e) {
266
+ inlineEditPost.revert();
267
+
268
+ var id = inlineEditPost.getId(this);
269
+ var currentSidebar = $('#post-' + id + ' .sidebar').text();
270
+
271
+ // select the current sidebar option
272
+ $('select#sidebar-name option').attr('selected', false);
273
+ if ( '' != currentSidebar ) {
274
+ $('select#sidebar-name option:contains(' + currentSidebar + ')').attr('selected', true);
275
+ }
276
+
277
+ // copy the sidebar name nonce
278
+ $('#sidebar-edit-group').find('input[name="sidebar_name_nonce"]').remove().end().append( $('#post-' + id + ' input[name="sidebar_name_nonce"]').clone() );
279
+ });
280
+ });
281
+ </script>
282
+ <style type="text/css">
283
+ .widefat .column-sidebar { width: 15%;}
284
+ </style>
285
+ <?php
286
+ }
287
+
288
+
289
+ function bulk_edit_custom_box( $column, $post_type ) {
290
+ if ( 'page' != $post_type || 'sidebar' != $column ) { return; }
291
+
292
+ $sidebars = simple_page_sidebars_get_names();
293
+ ?>
294
+ <fieldset class="inline-edit-col-right" style="margin-top: 0">
295
+ <div class="inline-edit-col">
296
  <label>
297
  <span class="title"><?php _e( 'Sidebar', 'simple-page-sidebars' ); ?></span>
298
  <select name="sidebar_name" id="sidebar-name">
299
+ <option value="-1"><?php _e( '&mdash; No Change &mdash;', 'simple-page-sidebars' ); ?></option>
300
  <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
301
  <?php
302
  foreach ( $sidebars as $sb ) {
305
  ?>
306
  </select>
307
  </label>
308
+ <?php wp_nonce_field( 'bulk-update-page-sidebar-name', 'bulk_sidebar_name_nonce', false ); ?>
309
  </div>
310
+ </fieldset>
311
+ <?php
312
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  }
314
+ $simple_page_sidebars_admin = new Simple_Page_Sidebars_Admin();
315
  ?>
languages/simple-page-sidebars.mo DELETED
Binary file
languages/simple-page-sidebars.pot CHANGED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Simple Page Sidebars\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-11-09 09:41-0800\n"
6
- "PO-Revision-Date: 2011-11-09 09:42-0800\n"
7
  "Last-Translator: Brady Vercher <brady@blazersix.com>\n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
@@ -13,39 +13,56 @@ msgstr ""
13
  "X-Poedit-Basepath: ../\n"
14
  "X-Poedit-SearchPath-0: .\n"
15
 
16
- #: admin/admin.php:67
17
- msgid "Choose an existing sidebar:"
18
  msgstr ""
19
 
20
- #: admin/admin.php:69
21
- #: admin/admin.php:183
22
- #: admin/admin.php:241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  msgid "Default Sidebar"
24
  msgstr ""
25
 
26
- #: admin/admin.php:78
27
  msgid "Or create a new sidebar:"
28
  msgstr ""
29
 
30
- #: admin/admin.php:80
31
  msgid "Enter New"
32
  msgstr ""
33
 
34
- #: admin/admin.php:81
35
  msgid "Cancel"
36
  msgstr ""
37
 
38
- #: admin/admin.php:86
39
  msgid "Update"
40
  msgstr ""
41
 
42
- #: admin/admin.php:154
43
- #: admin/admin.php:181
44
- #: admin/admin.php:238
45
  msgid "Sidebar"
46
  msgstr ""
47
 
48
- #: admin/admin.php:240
49
  msgid "&mdash; No Change &mdash;"
50
  msgstr ""
51
 
2
  msgstr ""
3
  "Project-Id-Version: Simple Page Sidebars\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-12-08 14:42-0800\n"
6
+ "PO-Revision-Date: 2011-12-08 14:42-0800\n"
7
  "Last-Translator: Brady Vercher <brady@blazersix.com>\n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
13
  "X-Poedit-Basepath: ../\n"
14
  "X-Poedit-SearchPath-0: .\n"
15
 
16
+ #: admin/admin.php:28
17
+ msgid " Default Sidebar"
18
  msgstr ""
19
 
20
+ #: admin/admin.php:54
21
+ msgid "The sidebar that will replaced by custom sidebars."
22
+ msgstr ""
23
+
24
+ #: admin/admin.php:127
25
+ #, php-format
26
+ msgid "For Simple Page Sidebars to work, a default sidebar needs to be selected on the %s"
27
+ msgstr ""
28
+
29
+ #: admin/admin.php:128
30
+ msgid "Reading options panel"
31
+ msgstr ""
32
+
33
+ #: admin/admin.php:134
34
+ msgid "Current sidebar:"
35
+ msgstr ""
36
+
37
+ #: admin/admin.php:136
38
+ #: admin/admin.php:244
39
+ #: admin/admin.php:300
40
  msgid "Default Sidebar"
41
  msgstr ""
42
 
43
+ #: admin/admin.php:145
44
  msgid "Or create a new sidebar:"
45
  msgstr ""
46
 
47
+ #: admin/admin.php:147
48
  msgid "Enter New"
49
  msgstr ""
50
 
51
+ #: admin/admin.php:148
52
  msgid "Cancel"
53
  msgstr ""
54
 
55
+ #: admin/admin.php:153
56
  msgid "Update"
57
  msgstr ""
58
 
59
+ #: admin/admin.php:217
60
+ #: admin/admin.php:242
61
+ #: admin/admin.php:297
62
  msgid "Sidebar"
63
  msgstr ""
64
 
65
+ #: admin/admin.php:299
66
  msgid "&mdash; No Change &mdash;"
67
  msgstr ""
68
 
readme.txt CHANGED
@@ -3,26 +3,25 @@ Contributors: blazersix
3
  Donate link: http://bit.ly/s2zcgD
4
  Tags: sidebars, custom sidebars, dynamic sidebar, simple, widget, widgets
5
  Requires at least: 3.2.1
6
- Tested up to: 3.2.1
7
- Stable tag: 0.1
8
 
9
  Assign custom, widget-enabled sidebars to any page with ease.
10
 
11
  == Description ==
12
 
13
- Designed for simplicity and flexibility, Simple Page Sidebars gives WordPress users and theme authors the ability to assign custom sidebars to individual pages. Existing sidebars can be assigned in quick edit and bulk edit modes, helping save you time.
14
 
15
- Also included is a widget to allow a sidebar to include all the widgets from any other widget area. Don't worry if that didn't make sense, because without a sanity check, a Widget Area widget including it's parent widget area would create an infinite loop.
16
 
17
  == Installation ==
18
 
19
  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.
20
 
21
  #### Setup
22
- You'll need to include the following function call within your sidebar template in order for the plugin to know which sidebar to replace.
23
 
24
- `if ( function_exists( 'simple_sidebar' )
25
- simple_sidebar( 'Default Sidebar Name' );`
26
 
27
  == Screenshots ==
28
 
@@ -32,5 +31,14 @@ You'll need to include the following function call within your sidebar template
32
 
33
  == Changelog ==
34
 
 
 
 
 
 
 
 
 
 
35
  = 0.1 =
36
- Initial release.
3
  Donate link: http://bit.ly/s2zcgD
4
  Tags: sidebars, custom sidebars, dynamic sidebar, simple, widget, widgets
5
  Requires at least: 3.2.1
6
+ Tested up to: 3.3
7
+ Stable tag: 0.2
8
 
9
  Assign custom, widget-enabled sidebars to any page with ease.
10
 
11
  == Description ==
12
 
13
+ Designed for simplicity and flexibility, Simple Page Sidebars gives WordPress users and theme authors the ability to assign custom sidebars to individual pages--without making any template changes. Existing sidebars can be assigned in quick edit and bulk edit modes, helping save you time.
14
 
15
+ Also included is a widget to allow a sidebar to include all the widgets from any other widget area.
16
 
17
  == Installation ==
18
 
19
  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.
20
 
21
  #### Setup
22
+ After installation, go to the Reading options panel (the Reading link under Settings) and choose the default sidebar.
23
 
24
+ *Note: The initial version of Simple Page Sidebars required a template change that is no longer needed in the latest release. It's recommended that any code changes be reverted.*
 
25
 
26
  == Screenshots ==
27
 
31
 
32
  == Changelog ==
33
 
34
+ = 0.2 =
35
+ * Added an option to define the default sidebar on the Reading options panel.
36
+ * Removed the template change requirement. It's no longer recommended.
37
+ * Refactored code, including function/hook names.
38
+ * Deprecated `simple_sidebar` function. Replaced by `simple_page_sidebar`.
39
+ * Deprecated `simpsid_widget_areas` filter. Replaced by `simple_page_sidebars_widget_areas`.
40
+ * Deprecated `simpsid_widget_area_defaults` filter. Replaced by `simple_page_sidebars_widget_area_defaults`.
41
+ * Deprecated `simpsid_sidebar_name` filter. Replaced with `simple_page_sidebars_last_call`.
42
+
43
  = 0.1 =
44
+ * Initial release.
simple-page-sidebars.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Simple Page Sidebars
4
- Version: 0.1
5
  Plugin URI: http://wordpress.org/extend/plugins/simple-page-sidebars/
6
  Description: Assign custom, widget-enabled sidebars to any page with ease.
7
  Author: Blazer Six, Inc.
@@ -9,19 +9,118 @@ Author URI: http://www.blazersix.com/
9
  */
10
 
11
 
12
- load_plugin_textdomain( 'simple-page-sidebars', false, 'simple-page-sidebars/languages' );
13
-
14
- require_once( plugin_dir_path( __FILE__ ) .'/includes/widget-area.php' );
15
-
16
- // Lower priority registers sidebars below those typically added in themes
17
- add_action( 'widgets_init', 'simpsid_register_sidebars', 20 );
18
-
19
- if ( is_admin() ) {
20
- require_once( plugin_dir_path( __FILE__ ) .'/admin/admin.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
 
22
 
23
 
24
- function simpsid_get_page_sidebars() {
 
25
  global $wpdb;
26
 
27
  $sql = "SELECT meta_value
@@ -43,68 +142,6 @@ function simpsid_get_page_sidebars() {
43
  }
44
 
45
 
46
- /**
47
- * Add widget areas and automatically register page sidebars
48
- */
49
- function simpsid_register_sidebars() {
50
- global $wpdb;
51
-
52
- $widget_areas = array();
53
-
54
- // Add widget areas using this filter
55
- $widget_areas = apply_filters( 'simpsid_widget_areas', $widget_areas );
56
-
57
- // Verify id's exist, otherwise create them
58
- // Helps ensure widgets don't get mixed up if widget areas are added or removed
59
- if ( is_array( $widget_areas ) ) {
60
- foreach ( $widget_areas as $key => $area ) {
61
- if ( is_numeric( $key ) ) {
62
- $widget_areas[ 'widget-area-' . sanitize_key( $area['name'] ) ] = $area;
63
- unset( $widget_areas[ $key ] );
64
- }
65
- }
66
- }
67
-
68
- // Override the default widget properties
69
- $widget_area_defaults = array(
70
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
71
- 'after_widget' => '</div>',
72
- 'before_title' => '<h4 class="title">',
73
- 'after_title' => '</h4>'
74
- );
75
- $widget_area_defaults = apply_filters( 'simpsid_widget_area_defaults', $widget_area_defaults );
76
-
77
- // If any custom sidebars have been assigned to pages, merge them with widget areas defined above
78
- $sidebars = simpsid_get_page_sidebars();
79
- if ( count( $sidebars ) ) {
80
- foreach ( $sidebars as $sidebar ) {
81
- $page_sidebars[ 'page-sidebar-' . sanitize_key( $sidebar ) ] = array(
82
- 'name' => $sidebar,
83
- 'description' => NULL
84
- );
85
- }
86
-
87
- ksort($page_sidebars);
88
- $widget_areas = array_merge_recursive($widget_areas, $page_sidebars);
89
- }
90
-
91
- if ( is_array( $widget_areas ) ) {
92
- // Register the widget areas
93
- foreach ( $widget_areas as $key => $area ) {
94
- register_sidebar(array(
95
- 'id' => $key,
96
- 'name' => $area['name'],
97
- 'description' => $area['description'],
98
- 'before_widget' => ( ! isset( $area['before_widget'] ) ) ? $widget_area_defaults['before_widget'] : $area['before_widget'],
99
- 'after_widget' => ( ! isset( $area['after_widget'] ) ) ? $widget_area_defaults['after_widget'] : $area['after_widget'],
100
- 'before_title' => ( ! isset( $area['before_title'] ) ) ? $widget_area_defaults['before_title'] : $area['before_title'],
101
- 'after_title' => ( ! isset( $area['after_title'] ) ) ? $widget_area_defaults['after_title'] : $area['after_title']
102
- ));
103
- }
104
- }
105
- }
106
-
107
-
108
 
109
  /*
110
  * Sidebar display template tag
@@ -113,15 +150,18 @@ function simpsid_register_sidebars() {
113
  * If a custom sidebar hasn't been defined, the sidebar name passed as the parameter
114
  * will be served as a fallback.
115
  *
 
 
116
  * @param string $default_sidebar
117
  */
118
- function simple_sidebar( $default_sidebar ) {
119
  global $post, $wp_registered_sidebars;
120
 
121
  $sidebar_name = get_post_meta( $post->ID, '_sidebar_name', true );
122
 
123
  // Last chance to override which sidebar is displayed
124
- $sidebar_name = apply_filters( 'simpsid_sidebar_name', $sidebar_name );
 
125
 
126
  if ( is_page() && ! empty( $sidebar_name ) ) {
127
  $sidebars_widgets = wp_get_sidebars_widgets();
@@ -140,4 +180,15 @@ function simple_sidebar( $default_sidebar ) {
140
  dynamic_sidebar( $default_sidebar );
141
  }
142
  }
 
 
 
 
 
 
 
 
 
 
 
143
  ?>
1
  <?php
2
  /*
3
  Plugin Name: Simple Page Sidebars
4
+ Version: 0.2
5
  Plugin URI: http://wordpress.org/extend/plugins/simple-page-sidebars/
6
  Description: Assign custom, widget-enabled sidebars to any page with ease.
7
  Author: Blazer Six, Inc.
9
  */
10
 
11
 
12
+ class Simple_Page_Sidebars {
13
+
14
+ function __construct() {
15
+ add_action( 'plugins_loaded', array( &$this, 'load_plugin' ) );
16
+ }
17
+
18
+
19
+ function load_plugin() {
20
+ load_plugin_textdomain( 'simple-page-sidebars', false, 'simple-page-sidebars/languages' );
21
+
22
+ require_once( plugin_dir_path( __FILE__ ) .'/includes/widget-area.php' );
23
+
24
+ if ( is_admin() ) {
25
+ require_once( plugin_dir_path( __FILE__ ) . 'admin/admin.php' );
26
+ }
27
+
28
+ // Lower priority registers sidebars below those typically added in themes
29
+ add_action( 'widgets_init', array( &$this, 'register_sidebars' ), 20 );
30
+
31
+ if ( ! is_admin() ) {
32
+ add_filter( 'sidebars_widgets', array( &$this, 'replace_sidebar' ) );
33
+ }
34
+ }
35
+
36
+
37
+ /**
38
+ * Add widget areas and automatically register page sidebars
39
+ */
40
+ function register_sidebars() {
41
+ $widget_areas = array();
42
+
43
+ // Add widget areas using this filter
44
+ $widget_areas = apply_filters( 'simpsid_widget_areas', $widget_areas ); // deprecated
45
+ $widget_areas = apply_filters( 'simple_page_sidebars_widget_areas', $widget_areas );
46
+
47
+ // Verify id's exist, otherwise create them
48
+ // Helps ensure widgets don't get mixed up if widget areas are added or removed
49
+ if ( is_array( $widget_areas ) ) {
50
+ foreach ( $widget_areas as $key => $area ) {
51
+ if ( is_numeric( $key ) ) {
52
+ $widget_areas[ 'widget-area-' . sanitize_key( $area['name'] ) ] = $area;
53
+ unset( $widget_areas[ $key ] );
54
+ }
55
+ }
56
+ }
57
+
58
+ // Override the default widget properties
59
+ $widget_area_defaults = array(
60
+ 'before_widget' => '<div id="%1$s" class="widget %2$s">',
61
+ 'after_widget' => '</div>',
62
+ 'before_title' => '<h4 class="title">',
63
+ 'after_title' => '</h4>'
64
+ );
65
+ $widget_area_defaults = apply_filters( 'simpsid_widget_area_defaults', $widget_area_defaults ); // deprecated
66
+ $widget_area_defaults = apply_filters( 'simple_page_sidebars_widget_defaults', $widget_area_defaults );
67
+
68
+ // If any custom sidebars have been assigned to pages, merge them with widget areas defined above
69
+ $sidebars = simple_page_sidebars_get_names();
70
+ if ( count( $sidebars ) ) {
71
+ foreach ( $sidebars as $sidebar ) {
72
+ $page_sidebars[ 'page-sidebar-' . sanitize_key( $sidebar ) ] = array(
73
+ 'name' => $sidebar,
74
+ 'description' => NULL
75
+ );
76
+ }
77
+
78
+ ksort($page_sidebars);
79
+ $widget_areas = array_merge_recursive($widget_areas, $page_sidebars);
80
+ }
81
+
82
+ if ( is_array( $widget_areas ) ) {
83
+ // Register the widget areas
84
+ foreach ( $widget_areas as $key => $area ) {
85
+ register_sidebar(array(
86
+ 'id' => $key,
87
+ 'name' => $area['name'],
88
+ 'description' => $area['description'],
89
+ 'before_widget' => ( ! isset( $area['before_widget'] ) ) ? $widget_area_defaults['before_widget'] : $area['before_widget'],
90
+ 'after_widget' => ( ! isset( $area['after_widget'] ) ) ? $widget_area_defaults['after_widget'] : $area['after_widget'],
91
+ 'before_title' => ( ! isset( $area['before_title'] ) ) ? $widget_area_defaults['before_title'] : $area['before_title'],
92
+ 'after_title' => ( ! isset( $area['after_title'] ) ) ? $widget_area_defaults['after_title'] : $area['after_title']
93
+ ));
94
+ }
95
+ }
96
+ }
97
+
98
+
99
+ function replace_sidebar( $sidebars_widgets ) {
100
+ global $post;
101
+
102
+ if ( is_page() ) {
103
+ $custom_sidebar = get_post_meta( $post->ID, '_sidebar_name', true );
104
+ $default_sidebar_id = get_option( 'simple_page_sidebars_default_sidebar' );
105
+
106
+ if ( $custom_sidebar && $default_sidebar_id ) {
107
+ $custom_sidebar_id = 'page-sidebar-' . sanitize_key( $custom_sidebar );
108
+
109
+ // only replace the default sidebar if the custom sidebar has widgets
110
+ if ( ! empty( $sidebars_widgets[ $custom_sidebar_id ] ) ) {
111
+ $sidebars_widgets[ $default_sidebar_id ] = $sidebars_widgets[ $custom_sidebar_id ];
112
+ }
113
+ }
114
+ }
115
+
116
+ return $sidebars_widgets;
117
+ }
118
  }
119
+ $simple_page_sidebars = new Simple_Page_Sidebars();
120
 
121
 
122
+
123
+ function simple_page_sidebars_get_names() {
124
  global $wpdb;
125
 
126
  $sql = "SELECT meta_value
142
  }
143
 
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
  /*
147
  * Sidebar display template tag
150
  * If a custom sidebar hasn't been defined, the sidebar name passed as the parameter
151
  * will be served as a fallback.
152
  *
153
+ * This is no longer the recommended usage. No code changes are required.
154
+ *
155
  * @param string $default_sidebar
156
  */
157
+ function simple_page_sidebar( $default_sidebar ) {
158
  global $post, $wp_registered_sidebars;
159
 
160
  $sidebar_name = get_post_meta( $post->ID, '_sidebar_name', true );
161
 
162
  // Last chance to override which sidebar is displayed
163
+ $sidebar_name = apply_filters( 'simpsid_sidebar_name', $sidebar_name ); // deprecated
164
+ $sidebar_name = apply_filters( 'simple_page_sidebars_last_call', $sidebar_name );
165
 
166
  if ( is_page() && ! empty( $sidebar_name ) ) {
167
  $sidebars_widgets = wp_get_sidebars_widgets();
180
  dynamic_sidebar( $default_sidebar );
181
  }
182
  }
183
+
184
+ /*
185
+ * Deprecated
186
+ */
187
+ if ( ! function_exists( 'simple_sidebar' ) ) :
188
+ function simple_sidebar( $default_sidebar ) {
189
+ _deprecated_function( __FUNCTION__, '0.1.1', 'simple_page_sidebar()' );
190
+
191
+ simple_page_sidebar( $default_sidebar );
192
+ }
193
+ endif;
194
  ?>
uninstall.php CHANGED
@@ -6,4 +6,5 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
6
  global $wpdb;
7
 
8
  $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key='_sidebar_name'");
 
9
  ?>
6
  global $wpdb;
7
 
8
  $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key='_sidebar_name'");
9
+ delete_option( 'simple_page_sidebars_default_sidebar' );
10
  ?>