Simple Page Sidebars - Version 1.2.1

Version Description

Download this release

Release Info

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

Code changes from version 1.2.0 to 1.2.1

admin/admin.php CHANGED
@@ -1,651 +1,651 @@
1
- <?php
2
- /**
3
- * @package Simple_Page_Sidebars
4
- *
5
- * @todo Consider adding a Sidebars submenu to the Appearance menu for
6
- * selecting and editing a sidebar.
7
- * @todo Consider how to report any sidebars that get wiped out.
8
- */
9
-
10
- /**
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' ) );
50
- add_action( 'manage_pages_custom_column', array( __CLASS__, 'display_columns' ), 10, 2 );
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() {
64
- register_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>',
72
- array( __CLASS__, 'default_sidebar_settings_field' ),
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
- ?>
89
- <select name="simple_page_sidebars_default_sidebar" id="simple-page-sidebars-default-sidebar">
90
- <option value=""></option>
91
- <?php
92
- foreach ( $wp_registered_sidebars as $sb ) {
93
- if ( is_array( $custom_sidebars ) && ! in_array( $sb['name'], $custom_sidebars ) ) {
94
- printf( '<option value="%s"%s>%s</option>',
95
- esc_attr( $sb['id'] ),
96
- selected( $sb['id'], $default_sidebar_id, false ),
97
- esc_html( $sb['name'] )
98
- );
99
- }
100
- }
101
- ?>
102
- </select>
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 ) {
113
- if ( 'page' == $post_type || post_type_supports( $post_type, 'simple-page-sidebars' ) ) {
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.
124
- *
125
- * @param object $page The post object being added or edited.
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 ) {
160
- // Ensure this only affects requests in the dashboard.
161
- if ( is_admin() && isset( $_GET['post_type'] ) && 'page' == $_GET['post_type'] ) {
162
- if ( ! empty( $_GET['orderby'] ) && 'simple-page-sidebar' == $_GET['orderby'] ) {
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.
180
- */
181
- public static function register_columns( $columns ) {
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
- *
202
- * @since 0.2.0
203
- * @param string $column The ID of the column being displayed.
204
- * @param int $page_id The ID of the page the column is associated with.
205
- */
206
- public static function display_columns( $column, $page_id ) {
207
- if ( 'simple-page-sidebar' == $column ) {
208
- $sidebar = self::get_page_sidebar( $page_id );
209
- if ( $sidebar ) {
210
- // The edit link can be disabled to prevent confusion if support is added to other post types.
211
- if ( apply_filters( 'simple_page_sidebars_show_edit_link_in_column', true ) ) {
212
- printf( '<a href="%s">%s</a>',
213
- esc_url( self::get_sidebar_edit_link( $sidebar ) ),
214
- $sidebar
215
- );
216
- } else {
217
- echo $sidebar;
218
- }
219
- }
220
-
221
- // Add the nonce here and copy it to the inline editor with javascript.
222
- $nonce = wp_create_nonce( 'update-page-sidebar_' . $page_id );
223
- printf( '<input type="hidden" value="%s" class="simplepagesidebars_page_sidebar_update_nonce">', esc_attr( $nonce ) );
224
- }
225
- }
226
-
227
- /**
228
- * Sidebar dropdown field for quick edit mode.
229
- *
230
- * @since 0.2.0
231
- * @param string $column The ID of the column being rendered.
232
- * @param string $post_type The type of post being updated.
233
- */
234
- public static function quick_edit_custom_box( $column, $post_type ) {
235
- if ( 'page' != $post_type || 'simple-page-sidebar' != $column ) {
236
- return;
237
- }
238
-
239
- $sidebars = simple_page_sidebars_get_names();
240
- ?>
241
- <fieldset class="inline-edit-col-left">
242
- <div class="inline-edit-col">
243
- <div class="inline-edit-group" id="simple-page-sidebars-page-sidebar-edit-group">
244
- <label>
245
- <span class="title"><?php _e( 'Sidebar', 'simple-page-sidebars' ); ?></span>
246
- <select name="simplepagesidebars_page_sidebar_name" id="simple-page-sidebars-page-sidebar-name">
247
- <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
248
- <?php
249
- foreach ( $sidebars as $sb ) {
250
- printf( '<option value="%1$s">%1$s</option>', $sb );
251
- }
252
- ?>
253
- </select>
254
- </label>
255
- <?php wp_nonce_field( 'update-page-sidebar', 'simplepagesidebars_page_sidebar_update_nonce', false ); ?>
256
- </div>
257
- </div>
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
- ( function( window, $, undefined ) {
279
- 'use strict';
280
-
281
- var wpInlineEdit = inlineEditPost.edit;
282
-
283
- inlineEditPost.edit = function( id ) {
284
- wpInlineEdit.apply( this, arguments );
285
-
286
- var postId = inlineEditPost.getId( id ),
287
- currentSidebar = $( '#post-' + postId + ' .simple-page-sidebar' ).text(),
288
- sidebarNameField = $( '#simple-page-sidebars-page-sidebar-name' ),
289
- $nonceField = $( '#simple-page-sidebars-page-sidebar-edit-group' ).find( 'input[name="simplepagesidebars_page_sidebar_update_nonce"]' );
290
-
291
- // Select the current sidebar option.
292
- sidebarNameField.find( 'option' ).attr( 'selected', false );
293
- if ( '' != currentSidebar ) {
294
- sidebarNameField.find( 'option:contains(' + currentSidebar + ')' ).attr( 'selected', true );
295
- }
296
-
297
- // Copy the sidebar name nonce.
298
- $nonceField.val( $( '#post-' + postId + ' .simplepagesidebars_page_sidebar_update_nonce' ).val() );
299
- };
300
- } )( window, jQuery );
301
- </script>
302
- <style type="text/css">
303
- .widefat .column-simple-page-sidebar { width: 15%;}
304
- </style>
305
- <?php
306
- }
307
-
308
- /**
309
- * Sidebar dropdown field for bulk edit mode.
310
- *
311
- * @since 0.2.0
312
- * @param string $column The ID of the column being rendered.
313
- * @param string $post_type The type of post being updated.
314
- */
315
- public static function bulk_edit_custom_box( $column, $post_type ) {
316
- if ( 'page' != $post_type || 'simple-page-sidebar' != $column ) {
317
- return;
318
- }
319
-
320
- $sidebars = simple_page_sidebars_get_names();
321
- ?>
322
- <fieldset class="inline-edit-col-right" style="margin-top: 0">
323
- <div class="inline-edit-col">
324
- <label>
325
- <span class="title"><?php _e( 'Sidebar', 'simple-page-sidebars' ); ?></span>
326
- <select name="simplepagesidebars_page_sidebar_name" id="simple-page-sidebars-page-sidebar-name">
327
- <option value="-1"><?php _e( '&mdash; No Change &mdash;', 'simple-page-sidebars' ); ?></option>
328
- <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
329
- <?php
330
- foreach ( $sidebars as $sb ) {
331
- printf( '<option value="%1$s">%2$s</option>', esc_attr( $sb ), esc_html( $sb ) );
332
- }
333
- ?>
334
- </select>
335
- </label>
336
- <?php wp_nonce_field( 'bulk-update-page-sidebar', 'simplepagesidebars_bulk_update_nonce', false ); ?>
337
- </div>
338
- </fieldset>
339
- <?php
340
- }
341
-
342
- /**
343
- * Save custom page sidebar.
344
- *
345
- * Processes requests coming from normal page edits, quick edit, and bulk
346
- * edit. Requires a valid nonce.
347
- *
348
- * @since 0.2.0
349
- * @param int $post_id Optional. The ID of the page whose sidebar should be updated.
350
- */
351
- public static function update_page_sidebar( $post_id = null ) {
352
- if ( empty( $post_id ) ) {
353
- $post_id = $_REQUEST['post_id'];
354
- }
355
-
356
- // Verify either an individual post nonce or the bulk edit nonce.
357
- // Requests can come from a page update, AJAX from the sidebar meta box, quick edit, or bulk edit.
358
- $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;
359
- $is_bulk_nonce_valid = ( isset( $_REQUEST['simplepagesidebars_bulk_update_nonce'] ) && wp_verify_nonce( $_REQUEST['simplepagesidebars_bulk_update_nonce'], 'bulk-update-page-sidebar' ) ) ? true : false;
360
- $is_autosave = ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ? true : false;
361
- $is_revision = wp_is_post_revision( $post_id );
362
-
363
- if ( ( $is_autosave || $is_revision ) || ( ! $is_nonce_valid && ! $is_bulk_nonce_valid ) ) {
364
- return $post_id;
365
- }
366
-
367
- // If 'new_sidebar_name' is set and not empty, it supercedes any 'sidebar_name' setting.
368
- // If 'sidebar_name' is blank or it equals 'default', delete meta.
369
- // If 'sidebar_name' is set and not empty, update to new name.
370
- // If 'sidebar_name' is -1, skip.
371
-
372
- // Bulk edit uses $_GET for some reason, so we use the $_REQUEST global to catch everything.
373
- $sidebar = ( isset( $_REQUEST['simplepagesidebars_page_sidebar_name'] ) ) ? self::sanitize_sidebar_name( $_REQUEST['simplepagesidebars_page_sidebar_name'] ) : -1;
374
- $new_sidebar_name = ( isset( $_REQUEST['simplepagesidebars_page_sidebar_name_new'] ) ) ? self::sanitize_sidebar_name( $_REQUEST['simplepagesidebars_page_sidebar_name_new'] ) : '';
375
-
376
- if ( isset( $new_sidebar_name ) && ! empty( $new_sidebar_name ) ) {
377
- update_post_meta( $post_id, '_sidebar_name', $new_sidebar_name );
378
- } elseif ( empty( $sidebar ) || 'default' == $sidebar ) {
379
- delete_post_meta( $post_id, '_sidebar_name' );
380
- } elseif ( -1 != intval( $sidebar ) ) {
381
- update_post_meta( $post_id, '_sidebar_name', $sidebar );
382
- }
383
- }
384
-
385
- /**
386
- * Add a custom Sidebar Edit screen.
387
- *
388
- * The menu title argument in add_submenu_page() is null so the page won't
389
- * appear in the admin menu. It simply registers the screen so it's
390
- * available when visited.
391
- *
392
- * @since 1.1.0
393
- */
394
- public static function add_sidebar_edit_screen() {
395
- add_submenu_page( 'admin.php', __( 'Edit Sidebar', 'simple-page-sidebars' ), null, 'edit_theme_options', 'simple-page-sidebars', array( __CLASS__, 'edit_sidebar_screen' ) );
396
-
397
- add_meta_box( 'simplepagesidebarseditdiv', 'Pages', array( __CLASS__, 'edit_sidebar_pages_meta_box' ), 'admin_page_simple-page-sidebars', 'normal', 'default' );
398
- }
399
-
400
- /**
401
- * Display the Edit Sidebar screen.
402
- *
403
- * The sidebar being edited is passed as a variable through the query
404
- * string. If it's determined that the sidebar isn't valid, an error will
405
- * be shown.
406
- *
407
- * @since 1.1.0
408
- */
409
- public static function edit_sidebar_screen() {
410
- global $wpdb;
411
-
412
- wp_enqueue_script( 'post' );
413
-
414
- $screen = get_current_screen();
415
- $sidebar_name = self::sanitize_sidebar_name( stripslashes( $_GET['sidebar'] ) );
416
-
417
- include( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/views/edit-sidebar-screen.php' );
418
- }
419
-
420
- /**
421
- * Add a page checbox list meta box to the Edit Sidebar screen.
422
- *
423
- * @since 1.1.0
424
- * @param object $post The post being edited.
425
- * @param array $metabox Any additional arguments passed during the meta box registration.
426
- */
427
- public static function edit_sidebar_pages_meta_box( $post, $metabox ) {
428
- $default_sidebar = get_option( 'simple_page_sidebars_default_sidebar' );
429
-
430
- include_once( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/includes/class-simple-page-sidebars-walker-page-checklist.php' );
431
- include_once( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/views/meta-box-sidebar-pages.php' );
432
- }
433
-
434
- /**
435
- * Process submissions for the Edit Sidebar screen.
436
- *
437
- * Handles cases where the sidebar is renamed, reassigns pages, and
438
- * removes the sidebar if no pages are selected. Requires a valid nonce.
439
- *
440
- * @since 1.1.0
441
- */
442
- public static function process_sidebar_update() {
443
- global $wpdb;
444
-
445
- if ( isset( $_POST['simplepagesidebars_sidebar_name'] ) ) {
446
- $current_name = stripslashes( $_POST['simplepagesidebars_sidebar_name'] );
447
-
448
- check_admin_referer( 'update-sidebar_' . $current_name, 'simplepagesidebars_sidebar_update_nonce' );
449
-
450
- $new_name = stripslashes( $_POST['simplepagesidebars_sidebar_name_new'] );
451
- $new_name = ( ! empty( $new_name ) && $new_name != $current_name ) ? trim( wp_strip_all_tags( $new_name ) ) : null;
452
-
453
- $pages = ( isset( $_POST['simplepagesidebars_sidebar_pages'] ) ) ? wp_parse_id_list( $_POST['simplepagesidebars_sidebar_pages'] ) : array();
454
-
455
- // Retrieve IDs of pages using the existing sidebar name.
456
- $current_pages = self::get_page_ids_using_sidebar( $current_name );
457
-
458
- // Pages to reset to the default sidebar.
459
- $reset_pages = array_diff( $current_pages, $pages );
460
- if ( $reset_pages ) {
461
- foreach( $reset_pages as $page_id ) {
462
- delete_post_meta( $page_id, '_sidebar_name' );
463
- }
464
- }
465
-
466
- // Update all sidebars if there is a new sidebar name.
467
- if ( $new_name ) {
468
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value=%s WHERE meta_key='_sidebar_name' AND meta_value=%s", $new_name, $current_name ) );
469
- }
470
- // Update newly selected pages with the current sidebar name.
471
- elseif ( $update_pages = array_diff( $pages, $current_pages ) ) {
472
- foreach( $update_pages as $page_id ) {
473
- update_post_meta( $page_id, '_sidebar_name', addslashes( $current_name ) );
474
- }
475
- }
476
-
477
- // The sidebar should have been removed from all pages.
478
- // Let WordPress move widgets to Inactive Sidebar, redirect to Widgets screen, and notify user.
479
- if ( empty( $pages ) ) {
480
- wp_safe_redirect( esc_url_raw( add_query_arg( 'simple-page-sidebars-message', 1, admin_url( 'widgets.php' ) ) ) );
481
- exit;
482
- }
483
-
484
- // Migrate widgets if the sidebar name was changed.
485
- if ( $new_name ) {
486
- $sidebars_widgets = wp_get_sidebars_widgets();
487
-
488
- $old_id = 'page-sidebar-' . sanitize_key( $current_name );
489
- $new_id = 'page-sidebar-' . sanitize_key( $new_name );
490
-
491
- // If new id matches an existing id, merge old widgets with new.
492
- if ( isset( $sidebars_widgets[ $new_id ] ) ) {
493
- $sidebars_widgets[ $new_id ] = array_merge( $sidebars_widgets[ $new_id ], $sidebars_widgets[ $old_id ] );
494
- }
495
- // Otherwise, copy old widgets to new.
496
- elseif ( isset( $sidebars_widgets[ $old_id ] ) ) {
497
- $sidebars_widgets[ $new_id ] = $sidebars_widgets[ $old_id ];
498
- }
499
-
500
- // Remove old widget area and save.
501
- unset( $sidebars_widgets[ $old_id ] );
502
- #echo '<pre>'; print_r( $sidebars_widgets ); echo '</pre>'; exit;
503
- wp_set_sidebars_widgets( $sidebars_widgets );
504
- }
505
-
506
- // Redirect back to sidebar edit screen with an update message.
507
- $name = ( ! empty( $new_name ) ) ? $new_name : $current_name;
508
- $redirect_link = self::get_sidebar_edit_link( $name, array( 'message' => 1 ) );
509
- wp_safe_redirect( esc_url_raw( $redirect_link ) );
510
- exit;
511
- }
512
- }
513
-
514
- /**
515
- * Display messages on the widgets page.
516
- *
517
- * @since 1.1.0
518
- */
519
- public static function widgets_page_messages() {
520
- $sidebars = simple_page_sidebars_get_names();
521
-
522
- // Display an error message if a default sidebar hasn't been selected on the Reading settings screen.
523
- if ( ! get_option( 'simple_page_sidebars_default_sidebar' ) && ! empty( $sidebars ) ) {
524
- echo '<div class="error"><p>' . self::get_empty_default_sidebar_error() . '</p></div>';
525
- }
526
-
527
- // Display any custom update messages.
528
- if ( isset( $_REQUEST['simple-page-sidebars-message'] ) && ! empty( $_REQUEST['simple-page-sidebars-message'] ) ) {
529
- ?>
530
- <div id="message" class="updated">
531
- <p>
532
- <?php
533
- $messages = array(
534
- 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' )
535
- );
536
-
537
- $message_id = $_REQUEST['simple-page-sidebars-message'];
538
- if ( isset( $messages[ $message_id ] ) ) {
539
- echo $messages[ $message_id ];
540
- }
541
- ?>
542
- </p>
543
- </div>
544
- <?php
545
- }
546
- }
547
-
548
- /**
549
- * Get a page's sidebar.
550
- *
551
- * Sanitizes the sidebar name before returning it.
552
- *
553
- * @since 1.1.0
554
- * @param int $page_id ID of the page whose sidebar should be returned.
555
- * @return string Sanitized sidebar name.
556
- */
557
- public static function get_page_sidebar( $page_id ) {
558
- return self::sanitize_sidebar_name( get_post_meta( $page_id, '_sidebar_name', true ) );
559
- }
560
-
561
- /**
562
- * Retrieve IDs of pages using a particular sidebar.
563
- *
564
- * @since 1.1.0
565
- * @param string $sidebar The sidebar name.
566
- * @return array An array of page IDs or an empty array.
567
- */
568
- public static function get_page_ids_using_sidebar( $sidebar ) {
569
- global $wpdb;
570
-
571
- $ids = $wpdb->get_col( $wpdb->prepare( "SELECT p.ID
572
- FROM $wpdb->posts p
573
- INNER JOIN $wpdb->postmeta pm ON p.ID=pm.post_id
574
- WHERE p.post_type='page' AND p.post_status!='auto-draft' AND pm.meta_key='_sidebar_name' AND pm.meta_value=%s",
575
- $sidebar
576
- ) );
577
-
578
- return ( empty( $ids ) ) ? array() : $ids;
579
- }
580
-
581
- /**
582
- * Sanitize a sidebar name.
583
- *
584
- * @since 1.1.0
585
- * @param string $name The sidebar name.
586
- * @return string Sanitized sidebar name.
587
- */
588
- public static function sanitize_sidebar_name( $name ) {
589
- return trim( wp_strip_all_tags( $name ) );
590
- }
591
-
592
- /**
593
- * Get the edit link for a sidebar.
594
- *
595
- * @since 1.1.0
596
- * @param string $sidebar The sidebar name.
597
- * @param array $query_args Optional. An array of additional query args to append to the edit link.
598
- * @return string The URL to edit the sidebar.
599
- */
600
- public static function get_sidebar_edit_link( $sidebar, $query_args = array() ) {
601
- $query_args = wp_parse_args( $query_args, array(
602
- 'page' => 'simple-page-sidebars',
603
- 'sidebar' => rawurlencode( $sidebar )
604
- ) );
605
-
606
- $link = add_query_arg( $query_args, admin_url( 'admin.php' ) );
607
-
608
- return $link;
609
- }
610
-
611
- /**
612
- * The error message to display if a default sidebar hasn't been selected.
613
- *
614
- * This is used a few times throughout the dashboard, so the string is
615
- * abstracted out here.
616
- *
617
- * @since 1.1.0
618
- * @return string Error message
619
- */
620
- public static function get_empty_default_sidebar_error() {
621
- return sprintf( __( 'For Simple Page Sidebars to work, a default sidebar needs to be selected on the %s', 'simple-page-sidebars' ),
622
- ' <a href="' . admin_url( 'options-reading.php' ) . '">' . __( 'Reading settings screen', 'simple-page-sidebars' ) . '</a>.'
623
- );
624
- }
625
-
626
- /**
627
- * Backward compatible AJAX spinner.
628
- *
629
- * Displays the correct AJAX spinner depending on the version of WordPress.
630
- *
631
- * @since 1.1.0
632
- *
633
- * @param array $args Array of args to modify output.
634
- */
635
- public static function spinner( $args = array() ) {
636
- $args = wp_parse_args( $args, array(
637
- 'id' => '',
638
- 'class' => ''
639
- ) );
640
-
641
- if ( version_compare( get_bloginfo( 'version' ), '3.5-beta-1', '<' ) ) {
642
- printf( '<img src="%1$s" id="%2$s" class="%3$s" alt="">',
643
- esc_url( SIMPLE_PAGE_SIDEBARS_URL . 'admin/images/wpspin_light.gif' ),
644
- esc_attr( $args['id'] ),
645
- esc_attr( $args['class'] )
646
- );
647
- } else {
648
- printf( '<span id="%s" class="spinner"></span>', esc_attr( $args['id'] ) );
649
- }
650
- }
651
- }
1
+ <?php
2
+ /**
3
+ * @package Simple_Page_Sidebars
4
+ *
5
+ * @todo Consider adding a Sidebars submenu to the Appearance menu for
6
+ * selecting and editing a sidebar.
7
+ * @todo Consider how to report any sidebars that get wiped out.
8
+ */
9
+
10
+ /**
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' ) );
50
+ add_action( 'manage_pages_custom_column', array( __CLASS__, 'display_columns' ), 10, 2 );
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() {
64
+ register_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>',
72
+ array( __CLASS__, 'default_sidebar_settings_field' ),
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
+ ?>
89
+ <select name="simple_page_sidebars_default_sidebar" id="simple-page-sidebars-default-sidebar">
90
+ <option value=""></option>
91
+ <?php
92
+ foreach ( $wp_registered_sidebars as $sb ) {
93
+ if ( is_array( $custom_sidebars ) && ! in_array( $sb['name'], $custom_sidebars ) ) {
94
+ printf( '<option value="%s"%s>%s</option>',
95
+ esc_attr( $sb['id'] ),
96
+ selected( $sb['id'], $default_sidebar_id, false ),
97
+ esc_html( $sb['name'] )
98
+ );
99
+ }
100
+ }
101
+ ?>
102
+ </select>
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 ) {
113
+ if ( 'page' == $post_type || post_type_supports( $post_type, 'simple-page-sidebars' ) ) {
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.
124
+ *
125
+ * @param object $page The post object being added or edited.
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 https://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 ) {
160
+ // Ensure this only affects requests in the dashboard.
161
+ if ( is_admin() && isset( $_GET['post_type'] ) && 'page' == $_GET['post_type'] ) {
162
+ if ( ! empty( $_GET['orderby'] ) && 'simple-page-sidebar' == $_GET['orderby'] ) {
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.
180
+ */
181
+ public static function register_columns( $columns ) {
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
+ *
202
+ * @since 0.2.0
203
+ * @param string $column The ID of the column being displayed.
204
+ * @param int $page_id The ID of the page the column is associated with.
205
+ */
206
+ public static function display_columns( $column, $page_id ) {
207
+ if ( 'simple-page-sidebar' == $column ) {
208
+ $sidebar = self::get_page_sidebar( $page_id );
209
+ if ( $sidebar ) {
210
+ // The edit link can be disabled to prevent confusion if support is added to other post types.
211
+ if ( apply_filters( 'simple_page_sidebars_show_edit_link_in_column', true ) ) {
212
+ printf( '<a href="%s">%s</a>',
213
+ esc_url( self::get_sidebar_edit_link( $sidebar ) ),
214
+ $sidebar
215
+ );
216
+ } else {
217
+ echo $sidebar;
218
+ }
219
+ }
220
+
221
+ // Add the nonce here and copy it to the inline editor with javascript.
222
+ $nonce = wp_create_nonce( 'update-page-sidebar_' . $page_id );
223
+ printf( '<input type="hidden" value="%s" class="simplepagesidebars_page_sidebar_update_nonce">', esc_attr( $nonce ) );
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Sidebar dropdown field for quick edit mode.
229
+ *
230
+ * @since 0.2.0
231
+ * @param string $column The ID of the column being rendered.
232
+ * @param string $post_type The type of post being updated.
233
+ */
234
+ public static function quick_edit_custom_box( $column, $post_type ) {
235
+ if ( 'page' != $post_type || 'simple-page-sidebar' != $column ) {
236
+ return;
237
+ }
238
+
239
+ $sidebars = simple_page_sidebars_get_names();
240
+ ?>
241
+ <fieldset class="inline-edit-col-left">
242
+ <div class="inline-edit-col">
243
+ <div class="inline-edit-group" id="simple-page-sidebars-page-sidebar-edit-group">
244
+ <label>
245
+ <span class="title"><?php _e( 'Sidebar', 'simple-page-sidebars' ); ?></span>
246
+ <select name="simplepagesidebars_page_sidebar_name" id="simple-page-sidebars-page-sidebar-name">
247
+ <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
248
+ <?php
249
+ foreach ( $sidebars as $sb ) {
250
+ printf( '<option value="%1$s">%1$s</option>', $sb );
251
+ }
252
+ ?>
253
+ </select>
254
+ </label>
255
+ <?php wp_nonce_field( 'update-page-sidebar', 'simplepagesidebars_page_sidebar_update_nonce', false ); ?>
256
+ </div>
257
+ </div>
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
+ ( function( window, $, undefined ) {
279
+ 'use strict';
280
+
281
+ var wpInlineEdit = inlineEditPost.edit;
282
+
283
+ inlineEditPost.edit = function( id ) {
284
+ wpInlineEdit.apply( this, arguments );
285
+
286
+ var postId = inlineEditPost.getId( id ),
287
+ currentSidebar = $( '#post-' + postId + ' .simple-page-sidebar' ).text(),
288
+ sidebarNameField = $( '#simple-page-sidebars-page-sidebar-name' ),
289
+ $nonceField = $( '#simple-page-sidebars-page-sidebar-edit-group' ).find( 'input[name="simplepagesidebars_page_sidebar_update_nonce"]' );
290
+
291
+ // Select the current sidebar option.
292
+ sidebarNameField.find( 'option' ).attr( 'selected', false );
293
+ if ( '' != currentSidebar ) {
294
+ sidebarNameField.find( 'option:contains(' + currentSidebar + ')' ).attr( 'selected', true );
295
+ }
296
+
297
+ // Copy the sidebar name nonce.
298
+ $nonceField.val( $( '#post-' + postId + ' .simplepagesidebars_page_sidebar_update_nonce' ).val() );
299
+ };
300
+ } )( window, jQuery );
301
+ </script>
302
+ <style type="text/css">
303
+ .widefat .column-simple-page-sidebar { width: 15%;}
304
+ </style>
305
+ <?php
306
+ }
307
+
308
+ /**
309
+ * Sidebar dropdown field for bulk edit mode.
310
+ *
311
+ * @since 0.2.0
312
+ * @param string $column The ID of the column being rendered.
313
+ * @param string $post_type The type of post being updated.
314
+ */
315
+ public static function bulk_edit_custom_box( $column, $post_type ) {
316
+ if ( 'page' != $post_type || 'simple-page-sidebar' != $column ) {
317
+ return;
318
+ }
319
+
320
+ $sidebars = simple_page_sidebars_get_names();
321
+ ?>
322
+ <fieldset class="inline-edit-col-right" style="margin-top: 0">
323
+ <div class="inline-edit-col">
324
+ <label>
325
+ <span class="title"><?php _e( 'Sidebar', 'simple-page-sidebars' ); ?></span>
326
+ <select name="simplepagesidebars_page_sidebar_name" id="simple-page-sidebars-page-sidebar-name">
327
+ <option value="-1"><?php _e( '&mdash; No Change &mdash;', 'simple-page-sidebars' ); ?></option>
328
+ <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
329
+ <?php
330
+ foreach ( $sidebars as $sb ) {
331
+ printf( '<option value="%1$s">%2$s</option>', esc_attr( $sb ), esc_html( $sb ) );
332
+ }
333
+ ?>
334
+ </select>
335
+ </label>
336
+ <?php wp_nonce_field( 'bulk-update-page-sidebar', 'simplepagesidebars_bulk_update_nonce', false ); ?>
337
+ </div>
338
+ </fieldset>
339
+ <?php
340
+ }
341
+
342
+ /**
343
+ * Save custom page sidebar.
344
+ *
345
+ * Processes requests coming from normal page edits, quick edit, and bulk
346
+ * edit. Requires a valid nonce.
347
+ *
348
+ * @since 0.2.0
349
+ * @param int $post_id Optional. The ID of the page whose sidebar should be updated.
350
+ */
351
+ public static function update_page_sidebar( $post_id = null ) {
352
+ if ( empty( $post_id ) ) {
353
+ $post_id = $_REQUEST['post_id'];
354
+ }
355
+
356
+ // Verify either an individual post nonce or the bulk edit nonce.
357
+ // Requests can come from a page update, AJAX from the sidebar meta box, quick edit, or bulk edit.
358
+ $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;
359
+ $is_bulk_nonce_valid = ( isset( $_REQUEST['simplepagesidebars_bulk_update_nonce'] ) && wp_verify_nonce( $_REQUEST['simplepagesidebars_bulk_update_nonce'], 'bulk-update-page-sidebar' ) ) ? true : false;
360
+ $is_autosave = ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ? true : false;
361
+ $is_revision = wp_is_post_revision( $post_id );
362
+
363
+ if ( ( $is_autosave || $is_revision ) || ( ! $is_nonce_valid && ! $is_bulk_nonce_valid ) ) {
364
+ return $post_id;
365
+ }
366
+
367
+ // If 'new_sidebar_name' is set and not empty, it supercedes any 'sidebar_name' setting.
368
+ // If 'sidebar_name' is blank or it equals 'default', delete meta.
369
+ // If 'sidebar_name' is set and not empty, update to new name.
370
+ // If 'sidebar_name' is -1, skip.
371
+
372
+ // Bulk edit uses $_GET for some reason, so we use the $_REQUEST global to catch everything.
373
+ $sidebar = ( isset( $_REQUEST['simplepagesidebars_page_sidebar_name'] ) ) ? self::sanitize_sidebar_name( $_REQUEST['simplepagesidebars_page_sidebar_name'] ) : -1;
374
+ $new_sidebar_name = ( isset( $_REQUEST['simplepagesidebars_page_sidebar_name_new'] ) ) ? self::sanitize_sidebar_name( $_REQUEST['simplepagesidebars_page_sidebar_name_new'] ) : '';
375
+
376
+ if ( isset( $new_sidebar_name ) && ! empty( $new_sidebar_name ) ) {
377
+ update_post_meta( $post_id, '_sidebar_name', $new_sidebar_name );
378
+ } elseif ( empty( $sidebar ) || 'default' == $sidebar ) {
379
+ delete_post_meta( $post_id, '_sidebar_name' );
380
+ } elseif ( -1 != intval( $sidebar ) ) {
381
+ update_post_meta( $post_id, '_sidebar_name', $sidebar );
382
+ }
383
+ }
384
+
385
+ /**
386
+ * Add a custom Sidebar Edit screen.
387
+ *
388
+ * The menu title argument in add_submenu_page() is null so the page won't
389
+ * appear in the admin menu. It simply registers the screen so it's
390
+ * available when visited.
391
+ *
392
+ * @since 1.1.0
393
+ */
394
+ public static function add_sidebar_edit_screen() {
395
+ add_submenu_page( 'admin.php', __( 'Edit Sidebar', 'simple-page-sidebars' ), null, 'edit_theme_options', 'simple-page-sidebars', array( __CLASS__, 'edit_sidebar_screen' ) );
396
+
397
+ add_meta_box( 'simplepagesidebarseditdiv', 'Pages', array( __CLASS__, 'edit_sidebar_pages_meta_box' ), 'admin_page_simple-page-sidebars', 'normal', 'default' );
398
+ }
399
+
400
+ /**
401
+ * Display the Edit Sidebar screen.
402
+ *
403
+ * The sidebar being edited is passed as a variable through the query
404
+ * string. If it's determined that the sidebar isn't valid, an error will
405
+ * be shown.
406
+ *
407
+ * @since 1.1.0
408
+ */
409
+ public static function edit_sidebar_screen() {
410
+ global $wpdb;
411
+
412
+ wp_enqueue_script( 'post' );
413
+
414
+ $screen = get_current_screen();
415
+ $sidebar_name = self::sanitize_sidebar_name( stripslashes( $_GET['sidebar'] ) );
416
+
417
+ include( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/views/edit-sidebar-screen.php' );
418
+ }
419
+
420
+ /**
421
+ * Add a page checbox list meta box to the Edit Sidebar screen.
422
+ *
423
+ * @since 1.1.0
424
+ * @param object $post The post being edited.
425
+ * @param array $metabox Any additional arguments passed during the meta box registration.
426
+ */
427
+ public static function edit_sidebar_pages_meta_box( $post, $metabox ) {
428
+ $default_sidebar = get_option( 'simple_page_sidebars_default_sidebar' );
429
+
430
+ include_once( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/includes/class-simple-page-sidebars-walker-page-checklist.php' );
431
+ include_once( SIMPLE_PAGE_SIDEBARS_DIR . 'admin/views/meta-box-sidebar-pages.php' );
432
+ }
433
+
434
+ /**
435
+ * Process submissions for the Edit Sidebar screen.
436
+ *
437
+ * Handles cases where the sidebar is renamed, reassigns pages, and
438
+ * removes the sidebar if no pages are selected. Requires a valid nonce.
439
+ *
440
+ * @since 1.1.0
441
+ */
442
+ public static function process_sidebar_update() {
443
+ global $wpdb;
444
+
445
+ if ( isset( $_POST['simplepagesidebars_sidebar_name'] ) ) {
446
+ $current_name = stripslashes( $_POST['simplepagesidebars_sidebar_name'] );
447
+
448
+ check_admin_referer( 'update-sidebar_' . $current_name, 'simplepagesidebars_sidebar_update_nonce' );
449
+
450
+ $new_name = stripslashes( $_POST['simplepagesidebars_sidebar_name_new'] );
451
+ $new_name = ( ! empty( $new_name ) && $new_name != $current_name ) ? trim( wp_strip_all_tags( $new_name ) ) : null;
452
+
453
+ $pages = ( isset( $_POST['simplepagesidebars_sidebar_pages'] ) ) ? wp_parse_id_list( $_POST['simplepagesidebars_sidebar_pages'] ) : array();
454
+
455
+ // Retrieve IDs of pages using the existing sidebar name.
456
+ $current_pages = self::get_page_ids_using_sidebar( $current_name );
457
+
458
+ // Pages to reset to the default sidebar.
459
+ $reset_pages = array_diff( $current_pages, $pages );
460
+ if ( $reset_pages ) {
461
+ foreach( $reset_pages as $page_id ) {
462
+ delete_post_meta( $page_id, '_sidebar_name' );
463
+ }
464
+ }
465
+
466
+ // Update all sidebars if there is a new sidebar name.
467
+ if ( $new_name ) {
468
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value=%s WHERE meta_key='_sidebar_name' AND meta_value=%s", $new_name, $current_name ) );
469
+ }
470
+ // Update newly selected pages with the current sidebar name.
471
+ elseif ( $update_pages = array_diff( $pages, $current_pages ) ) {
472
+ foreach( $update_pages as $page_id ) {
473
+ update_post_meta( $page_id, '_sidebar_name', addslashes( $current_name ) );
474
+ }
475
+ }
476
+
477
+ // The sidebar should have been removed from all pages.
478
+ // Let WordPress move widgets to Inactive Sidebar, redirect to Widgets screen, and notify user.
479
+ if ( empty( $pages ) ) {
480
+ wp_safe_redirect( esc_url_raw( add_query_arg( 'simple-page-sidebars-message', 1, admin_url( 'widgets.php' ) ) ) );
481
+ exit;
482
+ }
483
+
484
+ // Migrate widgets if the sidebar name was changed.
485
+ if ( $new_name ) {
486
+ $sidebars_widgets = wp_get_sidebars_widgets();
487
+
488
+ $old_id = 'page-sidebar-' . sanitize_key( $current_name );
489
+ $new_id = 'page-sidebar-' . sanitize_key( $new_name );
490
+
491
+ // If new id matches an existing id, merge old widgets with new.
492
+ if ( isset( $sidebars_widgets[ $new_id ] ) ) {
493
+ $sidebars_widgets[ $new_id ] = array_merge( $sidebars_widgets[ $new_id ], $sidebars_widgets[ $old_id ] );
494
+ }
495
+ // Otherwise, copy old widgets to new.
496
+ elseif ( isset( $sidebars_widgets[ $old_id ] ) ) {
497
+ $sidebars_widgets[ $new_id ] = $sidebars_widgets[ $old_id ];
498
+ }
499
+
500
+ // Remove old widget area and save.
501
+ unset( $sidebars_widgets[ $old_id ] );
502
+ #echo '<pre>'; print_r( $sidebars_widgets ); echo '</pre>'; exit;
503
+ wp_set_sidebars_widgets( $sidebars_widgets );
504
+ }
505
+
506
+ // Redirect back to sidebar edit screen with an update message.
507
+ $name = ( ! empty( $new_name ) ) ? $new_name : $current_name;
508
+ $redirect_link = self::get_sidebar_edit_link( $name, array( 'message' => 1 ) );
509
+ wp_safe_redirect( esc_url_raw( $redirect_link ) );
510
+ exit;
511
+ }
512
+ }
513
+
514
+ /**
515
+ * Display messages on the widgets page.
516
+ *
517
+ * @since 1.1.0
518
+ */
519
+ public static function widgets_page_messages() {
520
+ $sidebars = simple_page_sidebars_get_names();
521
+
522
+ // Display an error message if a default sidebar hasn't been selected on the Reading settings screen.
523
+ if ( ! get_option( 'simple_page_sidebars_default_sidebar' ) && ! empty( $sidebars ) ) {
524
+ echo '<div class="error"><p>' . self::get_empty_default_sidebar_error() . '</p></div>';
525
+ }
526
+
527
+ // Display any custom update messages.
528
+ if ( isset( $_REQUEST['simple-page-sidebars-message'] ) && ! empty( $_REQUEST['simple-page-sidebars-message'] ) ) {
529
+ ?>
530
+ <div id="message" class="updated">
531
+ <p>
532
+ <?php
533
+ $messages = array(
534
+ 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' )
535
+ );
536
+
537
+ $message_id = $_REQUEST['simple-page-sidebars-message'];
538
+ if ( isset( $messages[ $message_id ] ) ) {
539
+ echo $messages[ $message_id ];
540
+ }
541
+ ?>
542
+ </p>
543
+ </div>
544
+ <?php
545
+ }
546
+ }
547
+
548
+ /**
549
+ * Get a page's sidebar.
550
+ *
551
+ * Sanitizes the sidebar name before returning it.
552
+ *
553
+ * @since 1.1.0
554
+ * @param int $page_id ID of the page whose sidebar should be returned.
555
+ * @return string Sanitized sidebar name.
556
+ */
557
+ public static function get_page_sidebar( $page_id ) {
558
+ return self::sanitize_sidebar_name( get_post_meta( $page_id, '_sidebar_name', true ) );
559
+ }
560
+
561
+ /**
562
+ * Retrieve IDs of pages using a particular sidebar.
563
+ *
564
+ * @since 1.1.0
565
+ * @param string $sidebar The sidebar name.
566
+ * @return array An array of page IDs or an empty array.
567
+ */
568
+ public static function get_page_ids_using_sidebar( $sidebar ) {
569
+ global $wpdb;
570
+
571
+ $ids = $wpdb->get_col( $wpdb->prepare( "SELECT p.ID
572
+ FROM $wpdb->posts p
573
+ INNER JOIN $wpdb->postmeta pm ON p.ID=pm.post_id
574
+ WHERE p.post_type='page' AND p.post_status!='auto-draft' AND pm.meta_key='_sidebar_name' AND pm.meta_value=%s",
575
+ $sidebar
576
+ ) );
577
+
578
+ return ( empty( $ids ) ) ? array() : $ids;
579
+ }
580
+
581
+ /**
582
+ * Sanitize a sidebar name.
583
+ *
584
+ * @since 1.1.0
585
+ * @param string $name The sidebar name.
586
+ * @return string Sanitized sidebar name.
587
+ */
588
+ public static function sanitize_sidebar_name( $name ) {
589
+ return trim( wp_strip_all_tags( $name ) );
590
+ }
591
+
592
+ /**
593
+ * Get the edit link for a sidebar.
594
+ *
595
+ * @since 1.1.0
596
+ * @param string $sidebar The sidebar name.
597
+ * @param array $query_args Optional. An array of additional query args to append to the edit link.
598
+ * @return string The URL to edit the sidebar.
599
+ */
600
+ public static function get_sidebar_edit_link( $sidebar, $query_args = array() ) {
601
+ $query_args = wp_parse_args( $query_args, array(
602
+ 'page' => 'simple-page-sidebars',
603
+ 'sidebar' => rawurlencode( $sidebar )
604
+ ) );
605
+
606
+ $link = add_query_arg( $query_args, admin_url( 'admin.php' ) );
607
+
608
+ return $link;
609
+ }
610
+
611
+ /**
612
+ * The error message to display if a default sidebar hasn't been selected.
613
+ *
614
+ * This is used a few times throughout the dashboard, so the string is
615
+ * abstracted out here.
616
+ *
617
+ * @since 1.1.0
618
+ * @return string Error message
619
+ */
620
+ public static function get_empty_default_sidebar_error() {
621
+ return sprintf( __( 'For Simple Page Sidebars to work, a default sidebar needs to be selected on the %s', 'simple-page-sidebars' ),
622
+ ' <a href="' . admin_url( 'options-reading.php' ) . '">' . __( 'Reading settings screen', 'simple-page-sidebars' ) . '</a>.'
623
+ );
624
+ }
625
+
626
+ /**
627
+ * Backward compatible AJAX spinner.
628
+ *
629
+ * Displays the correct AJAX spinner depending on the version of WordPress.
630
+ *
631
+ * @since 1.1.0
632
+ *
633
+ * @param array $args Array of args to modify output.
634
+ */
635
+ public static function spinner( $args = array() ) {
636
+ $args = wp_parse_args( $args, array(
637
+ 'id' => '',
638
+ 'class' => ''
639
+ ) );
640
+
641
+ if ( version_compare( get_bloginfo( 'version' ), '3.5-beta-1', '<' ) ) {
642
+ printf( '<img src="%1$s" id="%2$s" class="%3$s" alt="">',
643
+ esc_url( SIMPLE_PAGE_SIDEBARS_URL . 'admin/images/wpspin_light.gif' ),
644
+ esc_attr( $args['id'] ),
645
+ esc_attr( $args['class'] )
646
+ );
647
+ } else {
648
+ printf( '<span id="%s" class="spinner"></span>', esc_attr( $args['id'] ) );
649
+ }
650
+ }
651
+ }
admin/includes/class-simple-page-sidebars-walker-page-checklist.php CHANGED
@@ -1,35 +1,35 @@
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 {
8
- /**
9
- * @see Walker::start_el()
10
- * @since 1.1.0
11
- *
12
- * @param string $output Passed by reference. Used to append additional content.
13
- * @param object $page Page data object.
14
- * @param int $depth Depth of page. Used for padding.
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,
30
- checked( in_array( $page->ID, $args['selected'] ), true, false ),
31
- apply_filters( 'the_title', $page->post_title, $page->ID ),
32
- ( $current_sidebar ) ? ' <em class="description" style="font-size: 11px">(' . $current_sidebar . ')</em>' : ''
33
- );
34
- }
35
- }
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 {
8
+ /**
9
+ * @see Walker::start_el()
10
+ * @since 1.1.0
11
+ *
12
+ * @param string $output Passed by reference. Used to append additional content.
13
+ * @param object $page Page data object.
14
+ * @param int $depth Depth of page. Used for padding.
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,
30
+ checked( in_array( $page->ID, $args['selected'] ), true, false ),
31
+ apply_filters( 'the_title', $page->post_title, $page->ID ),
32
+ ( $current_sidebar ) ? ' <em class="description" style="font-size: 11px">(' . $current_sidebar . ')</em>' : ''
33
+ );
34
+ }
35
+ }
admin/views/edit-sidebar-screen.php CHANGED
@@ -1,79 +1,79 @@
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
- ?>
21
- <div id="message" class="updated">
22
- <p>
23
- <?php
24
- $messages = array(
25
- 1 => sprintf( '%s <a href="' . esc_url( admin_url( 'widgets.php' ) ) . '">%s</a>',
26
- __( 'Sidebar settings updated.', 'simple-page-sidebars' ),
27
- __( 'Update widgets now.', 'simple-page-sidebars' )
28
- )
29
- );
30
-
31
- if ( ! empty( $_REQUEST['message'] ) && isset( $messages[ $_REQUEST['message'] ] ) ) {
32
- echo $messages[ $_REQUEST['message'] ];
33
- }
34
-
35
- $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message' ), $_SERVER['REQUEST_URI'] );
36
- ?>
37
- </p>
38
- </div>
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 );
59
- wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
60
- wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
61
- ?>
62
- <input type="submit" name="simplepagesidebars_sidebar_update" value="<?php esc_attr_e( 'Update Sidebar', 'simple-page-sidebars' ); ?>" class="button-primary">
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">
75
- .sidebar-name-wrap { margin: 0 0 20px 0;}
76
- .sidebar-name-wrap input { padding: 3px 8px; width: 100%; font-size: 1.7em;}
77
- .sidebar-name-wrap input:-moz-placeholder { color: #a9a9a9;}
78
- .sidebar-name-wrap input::-webkit-input-placeholder { padding: 3px 0; color: #a9a9a9;}
79
  </style>
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
+ ?>
21
+ <div id="message" class="updated">
22
+ <p>
23
+ <?php
24
+ $messages = array(
25
+ 1 => sprintf( '%s <a href="' . esc_url( admin_url( 'widgets.php' ) ) . '">%s</a>',
26
+ __( 'Sidebar settings updated.', 'simple-page-sidebars' ),
27
+ __( 'Update widgets now.', 'simple-page-sidebars' )
28
+ )
29
+ );
30
+
31
+ if ( ! empty( $_REQUEST['message'] ) && isset( $messages[ $_REQUEST['message'] ] ) ) {
32
+ echo $messages[ $_REQUEST['message'] ];
33
+ }
34
+
35
+ $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message' ), $_SERVER['REQUEST_URI'] );
36
+ ?>
37
+ </p>
38
+ </div>
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 );
59
+ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
60
+ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
61
+ ?>
62
+ <input type="submit" name="simplepagesidebars_sidebar_update" value="<?php esc_attr_e( 'Update Sidebar', 'simple-page-sidebars' ); ?>" class="button-primary">
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">
75
+ .sidebar-name-wrap { margin: 0 0 20px 0;}
76
+ .sidebar-name-wrap input { padding: 3px 8px; width: 100%; font-size: 1.7em;}
77
+ .sidebar-name-wrap input:-moz-placeholder { color: #a9a9a9;}
78
+ .sidebar-name-wrap input::-webkit-input-placeholder { padding: 3px 0; color: #a9a9a9;}
79
  </style>
admin/views/meta-box-page-sidebar.php CHANGED
@@ -1,115 +1,115 @@
1
- <div id="simple-page-sidebars-page-sidebar-update-message" class="simple-page-sidebars-page-sidebar-feedback" style="display: none">
2
- <p>
3
- <?php _e( 'Sidebar saved.', 'simple-page-sidebars' ); ?>
4
- <a href="<?php echo admin_url( 'widgets.php' ); ?>"><?php _e( 'Update widgets now.', 'simple-page-sidebars' ); ?></a>
5
- </p>
6
- </div>
7
-
8
- <p>
9
- <label for="simple-page-sidebars-page-sidebar-name"><?php _e( 'Current sidebar:', 'simple-page-sidebars' ); ?></label>
10
- <select name="simplepagesidebars_page_sidebar_name" id="simple-page-sidebars-page-sidebar-name" class="widefat">
11
- <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
12
- <?php
13
- foreach ( $custom_sidebars as $sb ) {
14
- printf( '<option value="%s"%s>%s</option>',
15
- esc_attr( $sb ),
16
- selected( $sb, $sidebar, false ),
17
- esc_html( $sb )
18
- );
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>
29
-
30
- <p style="margin-top: 10px; margin-bottom: 0; text-align: right">
31
- <?php self::spinner( array( 'id' => 'simple-page-sidebars-page-sidebar-update-spinner' ) ); ?>
32
- <button class="button"><?php _e( 'Update', 'simple-page-sidebars' ); ?></button>
33
- </p>
34
-
35
- <style type="text/css">
36
- #sidebarcancel, #sidebarnew { cursor: pointer; float: left; margin: 3px 3px 0 3px; color: #21759b; font-size: 12px;}
37
- #sidebarcancel, #sidebarnew:hover { color: #d54e21;}
38
- #simple-page-sidebars-page-sidebar-update-spinner { display: none; margin: 0 5px 0 0; vertical-align: middle;}
39
-
40
- .simple-page-sidebars-page-sidebar-feedback { clear: both; margin: 1em 0; padding: 0 0.6em; color: #333; background-color: #ffffe0; border: 1px solid #e6db55;
41
- -moz-border-radius: 3px;
42
- -webkit-border-radius: 3px;
43
- border-radius: 3px;}
44
- .simple-page-sidebars-page-sidebar-feedback a { text-decoration: none;}
45
- .simple-page-sidebars-page-sidebar-feedback p { margin: 0.5em 0; padding: 2px;}
46
- .simple-page-sidebars-page-sidebar-feedback-error { background-color: #ffebe8; border-color: #cc0000;}
47
- .simple-page-sidebars-page-sidebar-feedback-error a { color: #cc0000; text-decoration: underline;}
48
- </style>
49
-
50
- <script type="text/javascript">
51
- jQuery(function($) {
52
- var simplePageSidebars = {
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
- {
79
- action : 'simplepagesidebars_update_page_sidebar',
80
- post_id : $('#post_ID').val(),
81
- simplepagesidebars_page_sidebar_name : simplePageSidebars.nameField.val(),
82
- simplepagesidebars_page_sidebar_name_new : simplePageSidebars.nameFieldNew.val(),
83
- simplepagesidebars_page_sidebar_update_nonce : $('input[name="simplepagesidebars_page_sidebar_update_nonce"]').val()
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();
112
- });
113
- });
114
- </script>
115
  <div class="clear"></div>
1
+ <div id="simple-page-sidebars-page-sidebar-update-message" class="simple-page-sidebars-page-sidebar-feedback" style="display: none">
2
+ <p>
3
+ <?php _e( 'Sidebar saved.', 'simple-page-sidebars' ); ?>
4
+ <a href="<?php echo admin_url( 'widgets.php' ); ?>"><?php _e( 'Update widgets now.', 'simple-page-sidebars' ); ?></a>
5
+ </p>
6
+ </div>
7
+
8
+ <p>
9
+ <label for="simple-page-sidebars-page-sidebar-name"><?php _e( 'Current sidebar:', 'simple-page-sidebars' ); ?></label>
10
+ <select name="simplepagesidebars_page_sidebar_name" id="simple-page-sidebars-page-sidebar-name" class="widefat">
11
+ <option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
12
+ <?php
13
+ foreach ( $custom_sidebars as $sb ) {
14
+ printf( '<option value="%s"%s>%s</option>',
15
+ esc_attr( $sb ),
16
+ selected( $sb, $sidebar, false ),
17
+ esc_html( $sb )
18
+ );
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>
29
+
30
+ <p style="margin-top: 10px; margin-bottom: 0; text-align: right">
31
+ <?php self::spinner( array( 'id' => 'simple-page-sidebars-page-sidebar-update-spinner' ) ); ?>
32
+ <button class="button"><?php _e( 'Update', 'simple-page-sidebars' ); ?></button>
33
+ </p>
34
+
35
+ <style type="text/css">
36
+ #sidebarcancel, #sidebarnew { cursor: pointer; float: left; margin: 3px 3px 0 3px; color: #21759b; font-size: 12px;}
37
+ #sidebarcancel, #sidebarnew:hover { color: #d54e21;}
38
+ #simple-page-sidebars-page-sidebar-update-spinner { display: none; margin: 0 5px 0 0; vertical-align: middle;}
39
+
40
+ .simple-page-sidebars-page-sidebar-feedback { clear: both; margin: 1em 0; padding: 0 0.6em; color: #333; background-color: #ffffe0; border: 1px solid #e6db55;
41
+ -moz-border-radius: 3px;
42
+ -webkit-border-radius: 3px;
43
+ border-radius: 3px;}
44
+ .simple-page-sidebars-page-sidebar-feedback a { text-decoration: none;}
45
+ .simple-page-sidebars-page-sidebar-feedback p { margin: 0.5em 0; padding: 2px;}
46
+ .simple-page-sidebars-page-sidebar-feedback-error { background-color: #ffebe8; border-color: #cc0000;}
47
+ .simple-page-sidebars-page-sidebar-feedback-error a { color: #cc0000; text-decoration: underline;}
48
+ </style>
49
+
50
+ <script type="text/javascript">
51
+ jQuery(function($) {
52
+ var simplePageSidebars = {
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
+ {
79
+ action : 'simplepagesidebars_update_page_sidebar',
80
+ post_id : $('#post_ID').val(),
81
+ simplepagesidebars_page_sidebar_name : simplePageSidebars.nameField.val(),
82
+ simplepagesidebars_page_sidebar_name_new : simplePageSidebars.nameFieldNew.val(),
83
+ simplepagesidebars_page_sidebar_update_nonce : $('input[name="simplepagesidebars_page_sidebar_update_nonce"]').val()
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();
112
+ });
113
+ });
114
+ </script>
115
  <div class="clear"></div>
admin/views/meta-box-sidebar-pages.php CHANGED
@@ -1,35 +1,35 @@
1
- <div id="posttype-page" class="posttypediv">
2
- <p>
3
- <?php
4
- printf( __( 'The above sidebar will replace the "<strong>%s</strong>" sidebar for all pages selected below.', 'simple-page-sidebars' ), $default_sidebar );
5
- echo ' ';
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
13
- $posts = get_posts( array(
14
- 'post_type' => 'page',
15
- 'order' => 'ASC',
16
- 'orderby' => 'title',
17
- 'posts_per_page' => -1,
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>
35
  </div><!-- end div.posttypediv -->
1
+ <div id="posttype-page" class="posttypediv">
2
+ <p>
3
+ <?php
4
+ printf( __( 'The above sidebar will replace the "<strong>%s</strong>" sidebar for all pages selected below.', 'simple-page-sidebars' ), $default_sidebar );
5
+ echo ' ';
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
13
+ $posts = get_posts( array(
14
+ 'post_type' => 'page',
15
+ 'order' => 'ASC',
16
+ 'orderby' => 'title',
17
+ 'posts_per_page' => -1,
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>
35
  </div><!-- end div.posttypediv -->
includes/widget-area.php CHANGED
@@ -1,98 +1,98 @@
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
- public function __construct() {
16
- $widget_ops = array(
17
- 'classname' => 'widget_area',
18
- 'description' => __( 'Include all widgets from another widget area', 'simple-page-sidebars' )
19
- );
20
-
21
- // Call the parent constructor.
22
- parent::__construct( 'area', __( 'Widget Area', 'simple-page-sidebars' ), $widget_ops );
23
- }
24
-
25
- /**
26
- * Display the widget.
27
- *
28
- * @since 0.2.0
29
- */
30
- public 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
- public function form( $instance ) {
54
- global $wp_registered_sidebars;
55
-
56
- $instance = wp_parse_args( (array) $instance, array(
57
- 'area_id' => '',
58
- 'title' => ''
59
- ) );
60
- ?>
61
- <p>
62
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'simple-page-sidebars' ); ?></label>
63
- <input type="text" name="<?php echo $this->get_field_name( 'title' ); ?>" id="<?php echo $this->get_field_id('title'); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat">
64
- </p>
65
- <p>
66
- <label for="<?php echo $this->get_field_id( 'area_id' ); ?>"><?php _e( 'Area Name:', 'simple-page-sidebars' ); ?></label>
67
- <select name="<?php echo $this->get_field_name( 'area_id' ); ?>" id="<?php echo $this->get_field_id( 'area_id' ); ?>" class="widefat">
68
- <option value=""></option>
69
- <?php
70
- foreach ( $wp_registered_sidebars as $id => $area ) {
71
- if ( false === strpos( $id, 'orphaned_widgets_' ) && 'wp_inactive_widgets' != $id ) {
72
- printf( '<option value="%s"%s>%s</option>',
73
- esc_attr( $id ),
74
- selected( $id, $instance['area_id'], false ),
75
- esc_html( $area['name'] )
76
- );
77
- }
78
- }
79
- ?>
80
- </select>
81
- </p>
82
- <?php
83
- }
84
-
85
- /**
86
- * Update the widget settings.
87
- *
88
- * @since 0.2.0
89
- */
90
- public 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
- }
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
+ public function __construct() {
16
+ $widget_ops = array(
17
+ 'classname' => 'widget_area',
18
+ 'description' => __( 'Include all widgets from another widget area', 'simple-page-sidebars' )
19
+ );
20
+
21
+ // Call the parent constructor.
22
+ parent::__construct( 'area', __( 'Widget Area', 'simple-page-sidebars' ), $widget_ops );
23
+ }
24
+
25
+ /**
26
+ * Display the widget.
27
+ *
28
+ * @since 0.2.0
29
+ */
30
+ public 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
+ public function form( $instance ) {
54
+ global $wp_registered_sidebars;
55
+
56
+ $instance = wp_parse_args( (array) $instance, array(
57
+ 'area_id' => '',
58
+ 'title' => ''
59
+ ) );
60
+ ?>
61
+ <p>
62
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'simple-page-sidebars' ); ?></label>
63
+ <input type="text" name="<?php echo $this->get_field_name( 'title' ); ?>" id="<?php echo $this->get_field_id('title'); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat">
64
+ </p>
65
+ <p>
66
+ <label for="<?php echo $this->get_field_id( 'area_id' ); ?>"><?php _e( 'Area Name:', 'simple-page-sidebars' ); ?></label>
67
+ <select name="<?php echo $this->get_field_name( 'area_id' ); ?>" id="<?php echo $this->get_field_id( 'area_id' ); ?>" class="widefat">
68
+ <option value=""></option>
69
+ <?php
70
+ foreach ( $wp_registered_sidebars as $id => $area ) {
71
+ if ( false === strpos( $id, 'orphaned_widgets_' ) && 'wp_inactive_widgets' != $id ) {
72
+ printf( '<option value="%s"%s>%s</option>',
73
+ esc_attr( $id ),
74
+ selected( $id, $instance['area_id'], false ),
75
+ esc_html( $area['name'] )
76
+ );
77
+ }
78
+ }
79
+ ?>
80
+ </select>
81
+ </p>
82
+ <?php
83
+ }
84
+
85
+ /**
86
+ * Update the widget settings.
87
+ *
88
+ * @since 0.2.0
89
+ */
90
+ public 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-es_ES.mo DELETED
Binary file
languages/simple-page-sidebars-es_ES.po DELETED
@@ -1,179 +0,0 @@
1
- # Copyright (C) 2014 Blazer Six
2
- # This file is distributed under the GPL-2.0+.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Simple Page Sidebars 1.1.7\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/simple-page-"
7
- "sidebars\n"
8
- "POT-Creation-Date: 2012-11-13 06:36-0800\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "PO-Revision-Date: 2015-01-18 23:37+0100\n"
13
- "Last-Translator: David <david@closemarketing.es>\n"
14
- "Language-Team: Closemarketing <david@closemarketing.es>\n"
15
- "X-Generator: Poedit 1.7.3\n"
16
- "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
17
- "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
18
- "esc_html_x:1,2c\n"
19
- "Language: es\n"
20
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
21
- "X-Poedit-SourceCharset: UTF-8\n"
22
- "X-Poedit-Basepath: ../\n"
23
- "X-Textdomain-Support: yes\n"
24
- "X-Poedit-SearchPath-0: .\n"
25
-
26
- #: admin/admin.php:71 admin/admin.php:247 admin/admin.php:328
27
- #: admin/views/meta-box-page-sidebar.php:11
28
- msgid "Default Sidebar"
29
- msgstr "Sidebar por defecto"
30
-
31
- #: admin/admin.php:103
32
- msgid "The sidebar that should be replaced by custom sidebars."
33
- msgstr "El sidebar que debería ser sustituida por una personalizada."
34
-
35
- #: admin/admin.php:114 admin/admin.php:182 admin/admin.php:245
36
- #: admin/admin.php:325
37
- msgid "Sidebar"
38
- msgstr "Sidebar"
39
-
40
- #: admin/admin.php:327
41
- msgid "&mdash; No Change &mdash;"
42
- msgstr "&mdash; Sin cambios &mdash;"
43
-
44
- #: admin/admin.php:395 admin/views/edit-sidebar-screen.php:3
45
- msgid "Edit Sidebar"
46
- msgstr "Editar Sidebar"
47
-
48
- #: admin/admin.php:534
49
- msgid ""
50
- "The sidebar you were editing is no longer assigned to any pages and has "
51
- "been removed. Any widgets it contained should be in an \"Inactive Widgets\" "
52
- "area below."
53
- msgstr ""
54
- "El Sidebar que estabas editando ya no está asignado a ninguna de las "
55
- "páginas y se ha eliminado. Cualquiera de los widgets desactivados deberían "
56
- "estar en la zona \"Widgets inactivos\" más abajo."
57
-
58
- #: admin/admin.php:621
59
- msgid ""
60
- "For Simple Page Sidebars to work, a default sidebar needs to be selected on "
61
- "the %s"
62
- msgstr ""
63
- "Para que funcione Simple Page Sidebars, un sidebar por defecto es necesario "
64
- "que sea seleccionado en %s"
65
-
66
- #: admin/admin.php:622
67
- msgid "Reading settings screen"
68
- msgstr "Pantalla de configuración de lectura"
69
-
70
- #: admin/views/edit-sidebar-screen.php:13
71
- msgid "Whoops, that doesn't appear to be a sidebar that can be edited."
72
- msgstr "Ups, no parece que el sidebar pueda ser editado."
73
-
74
- #: admin/views/edit-sidebar-screen.php:26
75
- msgid "Sidebar settings updated."
76
- msgstr "Configuración actualizada"
77
-
78
- #: admin/views/edit-sidebar-screen.php:27
79
- #: admin/views/meta-box-page-sidebar.php:4
80
- msgid "Update widgets now."
81
- msgstr "Actualizar widgets ahora."
82
-
83
- #: admin/views/edit-sidebar-screen.php:49
84
- msgid "Sidebar Name:"
85
- msgstr "Nombre Sidebar:"
86
-
87
- #: admin/views/edit-sidebar-screen.php:50
88
- msgid "Enter sidebar name here"
89
- msgstr "Introduzca aquí el nombre del sidebar"
90
-
91
- #: admin/views/edit-sidebar-screen.php:62
92
- msgid "Update Sidebar"
93
- msgstr "Actualizar Sidebar"
94
-
95
- #: admin/views/meta-box-page-sidebar.php:3
96
- msgid "Sidebar saved."
97
- msgstr "Sidebar guardado."
98
-
99
- #: admin/views/meta-box-page-sidebar.php:9
100
- msgid "Current sidebar:"
101
- msgstr "Sidebar actual:"
102
-
103
- #: admin/views/meta-box-page-sidebar.php:23
104
- msgid "Or create a new sidebar:"
105
- msgstr "O crear un nuevo sidebar:"
106
-
107
- #: admin/views/meta-box-page-sidebar.php:26
108
- msgid "Enter New"
109
- msgstr "Introducir Nuevo"
110
-
111
- #: admin/views/meta-box-page-sidebar.php:27
112
- msgid "Cancel"
113
- msgstr "Cancelar"
114
-
115
- #: admin/views/meta-box-page-sidebar.php:32
116
- msgid "Update"
117
- msgstr "Actualizar"
118
-
119
- #: admin/views/meta-box-sidebar-pages.php:4
120
- msgid ""
121
- "The above sidebar will replace the \"<strong>%s</strong>\" sidebar for all "
122
- "pages selected below."
123
- msgstr ""
124
- "El sidebar anterior reemplazará la barra lateral \"<strong>%s</strong>\" "
125
- "para todas las páginas seleccionadas por debajo."
126
-
127
- #: admin/views/meta-box-sidebar-pages.php:6
128
- msgid ""
129
- "Any currently assigned custom sidebars will also be overridden for the "
130
- "selected pages."
131
- msgstr ""
132
- "Cualquier sidebar personalizado también se sustituirá para las páginas "
133
- "seleccionadas."
134
-
135
- #: admin/views/meta-box-sidebar-pages.php:33
136
- msgid ""
137
- "To delete this sidebar, simply uncheck all pages and click the \"Update "
138
- "Sidebar\" button."
139
- msgstr ""
140
- "Para eliminar esta barra lateral, simplemente desactive todas las páginas y "
141
- "haga clic en el botón \"Actualizar Sidebar\"."
142
-
143
- #: includes/widget-area.php:18
144
- msgid "Include all widgets from another widget area"
145
- msgstr "Incluyen todos los widgets desde otra área widget"
146
-
147
- #: includes/widget-area.php:22
148
- msgid "Widget Area"
149
- msgstr "Área Widget"
150
-
151
- #: includes/widget-area.php:62
152
- msgid "Title:"
153
- msgstr "Título:"
154
-
155
- #: includes/widget-area.php:66
156
- msgid "Area Name:"
157
- msgstr "Nombre Área:"
158
-
159
- #. Plugin Name of the plugin/theme
160
- msgid "Simple Page Sidebars"
161
- msgstr "Simple Page Sidebars"
162
-
163
- #. Plugin URI of the plugin/theme
164
- msgid "http://wordpress.org/extend/plugins/simple-page-sidebars/"
165
- msgstr "http://wordpress.org/extend/plugins/simple-page-sidebars/"
166
-
167
- #. Description of the plugin/theme
168
- msgid "Assign custom, widget-enabled sidebars to any page with ease."
169
- msgstr ""
170
- "Asignar personalizadas, basados en el widget de las barras laterales a "
171
- "cualquier página con facilidad."
172
-
173
- #. Author of the plugin/theme
174
- msgid "Blazer Six"
175
- msgstr "Blazer Six"
176
-
177
- #. Author URI of the plugin/theme
178
- msgid "http://www.blazersix.com/"
179
- msgstr "http://www.blazersix.com/"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/simple-page-sidebars-id_ID.mo DELETED
Binary file
languages/simple-page-sidebars-id_ID.po DELETED
@@ -1,140 +0,0 @@
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: 2014-09-03 15:53+0700\n"
7
- "Last-Translator: Satrya <satrya@satrya.me>\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.6.9\n"
15
- "Plural-Forms: nplurals=1; plural=0;\n"
16
- "Language: id_ID\n"
17
- "X-Poedit-SearchPath-0: .\n"
18
-
19
- #: admin/admin.php:74 admin/admin.php:242 admin/admin.php:317
20
- #: admin/views/meta-box-page-sidebar.php:11
21
- msgid "Default Sidebar"
22
- msgstr "Sidebar Standar"
23
-
24
- #: admin/admin.php:106
25
- msgid "The sidebar that should be replaced by custom sidebars."
26
- msgstr "Sidebar yang harus diganti dengan sidebar kustom."
27
-
28
- #: admin/admin.php:116 admin/admin.php:183 admin/admin.php:240
29
- #: admin/admin.php:314
30
- msgid "Sidebar"
31
- msgstr "Sidebar"
32
-
33
- #: admin/admin.php:316
34
- msgid "&mdash; No Change &mdash;"
35
- msgstr "&mdash; Tidak Ada Perubahan &mdash;"
36
-
37
- #: admin/admin.php:384
38
- msgid "Edit Sidebar"
39
- msgstr "Edit Sidebar"
40
-
41
- #: admin/admin.php:544
42
- msgid ""
43
- "The sidebar you were editing is no longer assigned to any pages and has been "
44
- "removed. Any widgets it contained should be in an \"Inactive Widgets\" area "
45
- "below."
46
- msgstr ""
47
- "Sidebar yang sedang anda edit tidak lagi ada and telah dihapus. Setiap "
48
- "widget yang berisi harus di \"Inactive Widgets\" area dibawah ini."
49
-
50
- #: admin/admin.php:631
51
- #, php-format
52
- msgid ""
53
- "For Simple Page Sidebars to work, a default sidebar needs to be selected on "
54
- "the %s"
55
- msgstr "Agar Simple Page Sidebars bekerja, standar sidebar harus dipilih di %s"
56
-
57
- #: admin/admin.php:632
58
- msgid "Reading settings screen"
59
- msgstr "Layar pengaturan Reading"
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, itu tidak tampak sidebar yang dapat diedit."
64
-
65
- #: admin/views/edit-sidebar-screen.php:26
66
- msgid "Sidebar settings updated."
67
- msgstr "Pengaturan Sidebar diperbarui."
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 "Perbaharui widget sekarang."
73
-
74
- #: admin/views/edit-sidebar-screen.php:62
75
- msgid "Update Sidebar"
76
- msgstr "Perbaharui Sidebar"
77
-
78
- #: admin/views/meta-box-page-sidebar.php:3
79
- msgid "Page sidebar saved."
80
- msgstr "Halaman sidebar disimpan."
81
-
82
- #: admin/views/meta-box-page-sidebar.php:9
83
- msgid "Current sidebar:"
84
- msgstr "Sidebar sekarang:"
85
-
86
- #: admin/views/meta-box-page-sidebar.php:23
87
- msgid "Or create a new sidebar:"
88
- msgstr "Atau buat sidebar baru:"
89
-
90
- #: admin/views/meta-box-page-sidebar.php:26
91
- msgid "Enter New"
92
- msgstr "Buat Baru"
93
-
94
- #: admin/views/meta-box-page-sidebar.php:27
95
- msgid "Cancel"
96
- msgstr "Batal"
97
-
98
- #: admin/views/meta-box-page-sidebar.php:32
99
- msgid "Update"
100
- msgstr "Perbarui"
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 atas akan menggantikan \"<strong>%s</strong>\" sidebar untuk semua "
109
- "halaman yang dipilih di bawah ini."
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
- "Setiap sidebar kustom yang aktif juga akan diganti untuk halaman yang dipilih"
117
-
118
- #: admin/views/meta-box-sidebar-pages.php:33
119
- msgid ""
120
- "To delete this sidebar, simply uncheck all pages and click the \"Update "
121
- "Sidebar\" button."
122
- msgstr ""
123
- "Untuk menghapus sidebar ini, cukup hapus centang semua halaman dan klik "
124
- "\"Perbaharui Sidebar\" tombol."
125
-
126
- #: includes/widget-area.php:18
127
- msgid "Include all widgets from another widget area"
128
- msgstr "Sertakan semua widget dari area widget lain"
129
-
130
- #: includes/widget-area.php:22
131
- msgid "Widget Area"
132
- msgstr "Lokasi Widget"
133
-
134
- #: includes/widget-area.php:62
135
- msgid "Title:"
136
- msgstr "Judul:"
137
-
138
- #: includes/widget-area.php:66
139
- msgid "Area Name:"
140
- msgstr "Nama Area:"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/simple-page-sidebars-sr_RS.mo DELETED
Binary file
languages/simple-page-sidebars-sr_RS.po DELETED
@@ -1,141 +0,0 @@
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 DELETED
@@ -1,170 +0,0 @@
1
- # Copyright (C) 2015 Cedaro
2
- # This file is distributed under the GPL-2.0+.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Simple Page Sidebars 1.2.0\n"
6
- "Report-Msgid-Bugs-To: "
7
- "http://wordpress.org/support/plugin/simple-page-sidebars\n"
8
- "POT-Creation-Date: 2012-11-13 06:36-0800\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=utf-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
13
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
- "Language-Team: LANGUAGE <LL@li.org>\n"
15
- "X-Generator: grunt-wp-i18n 0.5.2\n"
16
- "X-Poedit-KeywordsList: "
17
- "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
18
- "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
19
- "Language: en\n"
20
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
21
- "X-Poedit-Country: United States\n"
22
- "X-Poedit-SourceCharset: UTF-8\n"
23
- "X-Poedit-Basepath: ../\n"
24
- "X-Poedit-SearchPath-0: .\n"
25
- "X-Poedit-Bookmarks: \n"
26
- "X-Textdomain-Support: yes\n"
27
-
28
- #: admin/admin.php:71 admin/admin.php:247 admin/admin.php:328
29
- #: admin/views/meta-box-page-sidebar.php:11
30
- msgid "Default Sidebar"
31
- msgstr ""
32
-
33
- #: admin/admin.php:103
34
- msgid "The sidebar that should be replaced by custom sidebars."
35
- msgstr ""
36
-
37
- #: admin/admin.php:114 admin/admin.php:182 admin/admin.php:245
38
- #: admin/admin.php:325
39
- msgid "Sidebar"
40
- msgstr ""
41
-
42
- #: admin/admin.php:327
43
- msgid "&mdash; No Change &mdash;"
44
- msgstr ""
45
-
46
- #: admin/admin.php:395 admin/views/edit-sidebar-screen.php:3
47
- msgid "Edit Sidebar"
48
- msgstr ""
49
-
50
- #: admin/admin.php:534
51
- msgid ""
52
- "The sidebar you were editing is no longer assigned to any pages and has "
53
- "been removed. Any widgets it contained should be in an \"Inactive Widgets\" "
54
- "area below."
55
- msgstr ""
56
-
57
- #: admin/admin.php:621
58
- msgid ""
59
- "For Simple Page Sidebars to work, a default sidebar needs to be selected on "
60
- "the %s"
61
- msgstr ""
62
-
63
- #: admin/admin.php:622
64
- msgid "Reading settings screen"
65
- msgstr ""
66
-
67
- #: admin/views/edit-sidebar-screen.php:13
68
- msgid "Whoops, that doesn't appear to be a sidebar that can be edited."
69
- msgstr ""
70
-
71
- #: admin/views/edit-sidebar-screen.php:26
72
- msgid "Sidebar settings updated."
73
- msgstr ""
74
-
75
- #: admin/views/edit-sidebar-screen.php:27
76
- #: admin/views/meta-box-page-sidebar.php:4
77
- msgid "Update widgets now."
78
- msgstr ""
79
-
80
- #: admin/views/edit-sidebar-screen.php:49
81
- msgid "Sidebar Name:"
82
- msgstr ""
83
-
84
- #: admin/views/edit-sidebar-screen.php:50
85
- msgid "Enter sidebar name here"
86
- msgstr ""
87
-
88
- #: admin/views/edit-sidebar-screen.php:62
89
- msgid "Update Sidebar"
90
- msgstr ""
91
-
92
- #: admin/views/meta-box-page-sidebar.php:3
93
- msgid "Sidebar saved."
94
- msgstr ""
95
-
96
- #: admin/views/meta-box-page-sidebar.php:9
97
- msgid "Current sidebar:"
98
- msgstr ""
99
-
100
- #: admin/views/meta-box-page-sidebar.php:23
101
- msgid "Or create a new sidebar:"
102
- msgstr ""
103
-
104
- #: admin/views/meta-box-page-sidebar.php:26
105
- msgid "Enter New"
106
- msgstr ""
107
-
108
- #: admin/views/meta-box-page-sidebar.php:27
109
- msgid "Cancel"
110
- msgstr ""
111
-
112
- #: admin/views/meta-box-page-sidebar.php:32
113
- msgid "Update"
114
- msgstr ""
115
-
116
- #: admin/views/meta-box-sidebar-pages.php:4
117
- msgid ""
118
- "The above sidebar will replace the \"<strong>%s</strong>\" sidebar for all "
119
- "pages selected below."
120
- msgstr ""
121
-
122
- #: admin/views/meta-box-sidebar-pages.php:6
123
- msgid ""
124
- "Any currently assigned custom sidebars will also be overridden for the "
125
- "selected pages."
126
- msgstr ""
127
-
128
- #: admin/views/meta-box-sidebar-pages.php:33
129
- msgid ""
130
- "To delete this sidebar, simply uncheck all pages and click the \"Update "
131
- "Sidebar\" button."
132
- msgstr ""
133
-
134
- #: includes/widget-area.php:18
135
- msgid "Include all widgets from another widget area"
136
- msgstr ""
137
-
138
- #: includes/widget-area.php:22
139
- msgid "Widget Area"
140
- msgstr ""
141
-
142
- #: includes/widget-area.php:62
143
- msgid "Title:"
144
- msgstr ""
145
-
146
- #: includes/widget-area.php:66
147
- msgid "Area Name:"
148
- msgstr ""
149
-
150
- #. Plugin Name of the plugin/theme
151
- msgid "Simple Page Sidebars"
152
- msgstr ""
153
-
154
- #. Plugin URI of the plugin/theme
155
- msgid "https://wordpress.org/plugins/simple-page-sidebars/"
156
- msgstr ""
157
-
158
- #. Description of the plugin/theme
159
- msgid "Assign custom, widget-enabled sidebars to any page with ease."
160
- msgstr ""
161
-
162
- #. Author of the plugin/theme
163
- msgid "Cedaro"
164
- msgstr ""
165
-
166
- #. Author URI of the plugin/theme
167
- msgid ""
168
- "http://www.cedaro.com/?utm_source=wordpress-plugin&utm_medium=link&utm_"
169
- "content=simple-page-sidebars-author-uri&utm_campaign=plugins"
170
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,151 +1,150 @@
1
- === Simple Page Sidebars ===
2
- Contributors: cedaro, bradyvercher
3
- Tags: sidebars, custom sidebars, dynamic sidebar, simple, widget, widgets
4
- Requires at least: 4.0
5
- Tested up to: 4.5
6
- Stable tag: trunk
7
- License: GPL-2.0+
8
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
-
10
- Easily assign custom, widget-enabled sidebars to any page.
11
-
12
- == Description ==
13
-
14
- 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.
15
-
16
- 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.
17
-
18
- Simple Page Sidebars also ships with a "Widget Area" widget for pulling all the widgets from one sidebar into another.
19
-
20
- = Benefits =
21
-
22
- * No more site-wide, generic sidebars. Each page (or section) can have its own widgets.
23
- * Complete control over the names of your custom sidebars.
24
- * Assign the same sidebar to multiple pages.
25
- * Modify a page's sidebar without creating an unnecessary revision.
26
-
27
- = Advanced Usage =
28
-
29
- 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:
30
-
31
- `function myprefix_init() {
32
- add_post_type_support( '{{post_type}}', 'simple-page-sidebars' );
33
- }
34
- add_action( 'init', 'myprefix_init' );`
35
-
36
- = Additional Resources =
37
-
38
- * [Write a review](https://wordpress.org/support/view/plugin-reviews/simple-page-sidebars#postform)
39
- * [Contribute on GitHub](https://github.com/cedaro/simple-page-sidebars)
40
- * [Follow @cedaroco](https://twitter.com/cedaroco)
41
- * [Visit Cedaro](http://www.cedaro.com/?utm_source=wordpress.org&utm_medium=link&utm_content=simple-page-sidebars-readme&utm_campaign=plugins)
42
-
43
- = Translation Credits =
44
-
45
- * Indonesian (id_ID) - Marga Satrya [v1.1.7]
46
- * Serbo-Croation (sr_RS) - Borisa Djuraskovic [v1.1.5]
47
- * Spanish (es_ES) - David Perez [Closemarketing](https://www.closemarketing.es/) [v1.1.7]
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
-
64
- We recommend that you set your blog to use the default sidebar and create custom sidebars for pages (including the front/homepage). That way your blog page and posts all have the same sidebar.
65
-
66
- However, if you defined a page for your posts in the Reading settings panel and assigned a custom sidebar to that page, that will work, too.
67
-
68
- = Can I hide the "Sidebar" column on the Pages screen in the admin panel? =
69
-
70
- Yes, just click the "Screen Options" tab in the upper right corner of your screen and uncheck the "Sidebar" option.
71
-
72
- == Screenshots ==
73
-
74
- 1. Simply create a new sidebar when editing a page.
75
- 2. The new sidebar shows up on the widget panel. Notice the new "Widget Area" widget for including other widget areas.
76
- 3. Bulk edit in action. Easily assign a sidebar to multiple pages. (Quick edit works, too!)
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.2.0 =
91
- * Transferred to Cedaro.
92
- * Updated the Widget Area class constructor to prevent deprecation notices in WP 4.3+.
93
-
94
- = 1.1.8 =
95
- * Added Spanish translation.
96
-
97
- = 1.1.7 =
98
- * Added Indonesian translation.
99
-
100
- = 1.1.6 =
101
- * Prevent quick edit nonces from being submitted when searching or filtering a post list table.
102
-
103
- = 1.1.5 =
104
- * Added Serbo-Croatian translation.
105
-
106
- = 1.1.4 =
107
- * Really fix the Quick Edit functionality.
108
- * Update text domain loading order to get ready for language packs.
109
- * Fix a strict PHP notice.
110
-
111
- = 1.1.3 =
112
- * Fixed Quick Edit functionality in WordPress 3.6.
113
-
114
- = 1.1.2 =
115
- * Changed the parent file of the "Edit Sidebar" screen to remove the small gap between submenu items.
116
-
117
- = 1.1.1 =
118
- * Worked around the slashing weirdness in WordPress API.
119
- * 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.
120
- * Added a filter to disable the edit link in the custom Sidebar column (`simple_page_sidebars_show_edit_link_in_column`).
121
-
122
- = 1.1 =
123
- * Added an Edit Sidebar screen for updating a sidebar name and associated pages.
124
- * Added an update message when a sidebar is saved on the Add/Edit Page screen.
125
- * Made the sidebar column sortable on the All Pages screen.
126
- * Refactored the codebase (formatting, improved comments, static classes, organization, etc).
127
- * Added better feedback throughout the dashboard when something goes wrong.
128
- * Saved spinner image to plugin folder due to updates coming in 3.5.
129
- * Removed deprecated filters.
130
-
131
- = 1.0.1 =
132
- * Fixed bug causing issues with other plugins that don't submit the sidebar nonce on the All Pages screen.
133
-
134
- = 1.0 =
135
- * Modified check for blog page.
136
-
137
- = 0.2.1 =
138
- * Now works for the blog page when it's set in the Reading Settings.
139
- * Bug fixes.
140
-
141
- = 0.2 =
142
- * Added an option to define the default sidebar on the Reading options panel.
143
- * Removed the template change requirement. It's no longer recommended.
144
- * Refactored code, including function/hook names.
145
- * Deprecated `simple_sidebar` function. Replaced by `simple_page_sidebar`.
146
- * Deprecated `simpsid_widget_areas` filter. Replaced by `simple_page_sidebars_widget_areas`.
147
- * Deprecated `simpsid_widget_area_defaults` filter. Replaced by `simple_page_sidebars_widget_area_defaults`.
148
- * Deprecated `simpsid_sidebar_name` filter. Replaced with `simple_page_sidebars_last_call`.
149
-
150
- = 0.1 =
151
- * Initial release.
1
+ # Simple Page Sidebars
2
+
3
+ Contributors: cedaro, bradyvercher
4
+ Tags: sidebars, custom sidebars, dynamic sidebar, simple, widget, widgets
5
+ Requires at least: 4.7
6
+ Tested up to: 4.9
7
+ Stable tag: 1.2.1
8
+ License: GPL-2.0+
9
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Easily assign custom, widget-enabled sidebars to any page.
12
+
13
+ ## Description
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](https://wordpress.org/support/view/plugin-reviews/simple-page-sidebars#postform)
40
+ * [Contribute on GitHub](https://github.com/cedaro/simple-page-sidebars)
41
+ * [Follow @cedaroco](https://twitter.com/cedaroco)
42
+ * [Visit Cedaro](https://www.cedaro.com/?utm_source=wordpress.org&utm_medium=link&utm_content=simple-page-sidebars-readme&utm_campaign=plugins)
43
+
44
+ ## Installation
45
+
46
+ Installing Simple Page Sidebars is just like installing most other plugins. [Check out the codex](https://codex.wordpress.org/Managing_Plugins#Installing_Plugins) if you have any questions.
47
+
48
+ ### Setup
49
+
50
+ After installation, go to the Reading options panel (the Reading link under Settings) and choose which of your registered sidebars is the default sidebar.
51
+
52
+ ## Frequently Asked Questions
53
+
54
+ #### Why is the default sidebar still showing after I've created a custom sidebar for a page?
55
+
56
+ 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.
57
+
58
+ #### How do I give my blog a different sidebar?
59
+
60
+ We recommend that you set your blog to use the default sidebar and create custom sidebars for pages (including the front/homepage). That way your blog page and posts all have the same sidebar.
61
+
62
+ However, if you defined a page for your posts in the Reading settings panel and assigned a custom sidebar to that page, that will work, too.
63
+
64
+ #### Can I hide the "Sidebar" column on the Pages screen in the admin panel?
65
+
66
+ Yes, just click the "Screen Options" tab in the upper right corner of your screen and uncheck the "Sidebar" option.
67
+
68
+ ## Screenshots
69
+
70
+ 1. Simply create a new sidebar when editing a page.
71
+ 2. The new sidebar shows up on the widget panel. Notice the new "Widget Area" widget for including other widget areas.
72
+ 3. Bulk edit in action. Easily assign a sidebar to multiple pages. (Quick edit works, too!)
73
+
74
+ ## Notes
75
+
76
+ ### Custom Loops
77
+
78
+ 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.
79
+
80
+ ### Theme Sidebars
81
+
82
+ 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.
83
+
84
+ ## Changelog
85
+
86
+ ### 1.2.1 - July 27, 2018
87
+ * Removed bundled language files in favor of WordPress.org language packs.
88
+
89
+ ### 1.2.0
90
+ * Transferred to Cedaro.
91
+ * Updated the Widget Area class constructor to prevent deprecation notices in WP 4.3+.
92
+
93
+ ### 1.1.8
94
+ * Added Spanish translation.
95
+
96
+ ### 1.1.7
97
+ * Added Indonesian translation.
98
+
99
+ ### 1.1.6
100
+ * Prevent quick edit nonces from being submitted when searching or filtering a post list table.
101
+
102
+ ### 1.1.5
103
+ * Added Serbo-Croatian translation.
104
+
105
+ ### 1.1.4
106
+ * Really fix the Quick Edit functionality.
107
+ * Update text domain loading order to get ready for language packs.
108
+ * Fix a strict PHP notice.
109
+
110
+ ### 1.1.3
111
+ * Fixed Quick Edit functionality in WordPress 3.6.
112
+
113
+ ### 1.1.2
114
+ * Changed the parent file of the "Edit Sidebar" screen to remove the small gap between submenu items.
115
+
116
+ ### 1.1.1
117
+ * Worked around the slashing weirdness in WordPress API.
118
+ * 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.
119
+ * Added a filter to disable the edit link in the custom Sidebar column (`simple_page_sidebars_show_edit_link_in_column`).
120
+
121
+ ### 1.1
122
+ * Added an Edit Sidebar screen for updating a sidebar name and associated pages.
123
+ * Added an update message when a sidebar is saved on the Add/Edit Page screen.
124
+ * Made the sidebar column sortable on the All Pages screen.
125
+ * Refactored the codebase (formatting, improved comments, static classes, organization, etc).
126
+ * Added better feedback throughout the dashboard when something goes wrong.
127
+ * Saved spinner image to plugin folder due to updates coming in 3.5.
128
+ * Removed deprecated filters.
129
+
130
+ ### 1.0.1
131
+ * Fixed bug causing issues with other plugins that don't submit the sidebar nonce on the All Pages screen.
132
+
133
+ ### 1.0
134
+ * Modified check for blog page.
135
+
136
+ ### 0.2.1
137
+ * Now works for the blog page when it's set in the Reading Settings.
138
+ * Bug fixes.
139
+
140
+ ### 0.2
141
+ * Added an option to define the default sidebar on the Reading options panel.
142
+ * Removed the template change requirement. It's no longer recommended.
143
+ * Refactored code, including function/hook names.
144
+ * Deprecated `simple_sidebar` function. Replaced by `simple_page_sidebar`.
145
+ * Deprecated `simpsid_widget_areas` filter. Replaced by `simple_page_sidebars_widget_areas`.
146
+ * Deprecated `simpsid_widget_area_defaults` filter. Replaced by `simple_page_sidebars_widget_area_defaults`.
147
+ * Deprecated `simpsid_sidebar_name` filter. Replaced with `simple_page_sidebars_last_call`.
148
+
149
+ ### 0.1
150
+ * Initial release.
 
simple-page-sidebars.php CHANGED
@@ -1,275 +1,272 @@
1
- <?php
2
- /**
3
- * Simple Page Sidebars
4
- *
5
- * @package SimplePageSidebars
6
- * @author Brady Vercher <brady@blazersix.com>
7
- * @copyright Copyright (c) 2015 Cedaro, LLC
8
- * @license GPL-2.0+
9
- *
10
- * Plugin Name: Simple Page Sidebars
11
- * Plugin URI: https://wordpress.org/plugins/simple-page-sidebars/
12
- * Description: Assign custom, widget-enabled sidebars to any page with ease.
13
- * Version: 1.2.0
14
- * Author: Cedaro
15
- * Author URI: http://www.cedaro.com/?utm_source=wordpress-plugin&utm_medium=link&utm_content=simple-page-sidebars-author-uri&utm_campaign=plugins
16
- * License: GPL-2.0+
17
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
18
- * Text Domain: simple-page-sidebars
19
- * Domain Path: /languages
20
- */
21
-
22
- /**
23
- * Set a constant path to the plugin's root directory.
24
- */
25
- if ( ! defined( 'SIMPLE_PAGE_SIDEBARS_DIR' ) )
26
- define( 'SIMPLE_PAGE_SIDEBARS_DIR', plugin_dir_path( __FILE__ ) );
27
-
28
- /**
29
- * Set a constant URL to the plugin's root directory.
30
- */
31
- if ( ! defined( 'SIMPLE_PAGE_SIDEBARS_URL' ) )
32
- define( 'SIMPLE_PAGE_SIDEBARS_URL', plugin_dir_url( __FILE__ ) );
33
-
34
- /**
35
- * Main plugin class.
36
- *
37
- * @since 0.2.0
38
- */
39
- class Simple_Page_Sidebars {
40
- /**
41
- * Setup the plugin.
42
- *
43
- * @since 0.2.0
44
- */
45
- public static function load() {
46
- self::load_textdomain();
47
-
48
- require_once( plugin_dir_path( __FILE__ ) . 'includes/widget-area.php' );
49
-
50
- // Load the admin functionality.
51
- if ( is_admin() ) {
52
- add_action( 'admin_init', array( __CLASS__, 'upgrade' ) );
53
-
54
- require_once( plugin_dir_path( __FILE__ ) . 'admin/admin.php' );
55
- Simple_Page_Sidebars_Admin::load();
56
- }
57
-
58
- // Lower priority registers sidebars below those typically added by themes.
59
- add_action( 'widgets_init', array( __CLASS__, 'register_sidebars' ), 20 );
60
- add_action( 'widgets_init', array( __CLASS__, 'register_widgets' ) );
61
-
62
- if ( ! is_admin() ) {
63
- add_filter( 'sidebars_widgets', array( __CLASS__, 'replace_sidebar' ) );
64
- }
65
- }
66
-
67
- /**
68
- * Plugin localization support.
69
- *
70
- * @since 1.1.4
71
- */
72
- public static function load_textdomain() {
73
- $locale = apply_filters( 'plugin_locale', get_locale(), 'simple-page-sidebars' );
74
- load_textdomain( 'simple-page-sidebars', WP_LANG_DIR . '/simple-page-sidebars/' . $locale . '.mo' );
75
- load_plugin_textdomain( 'simple-page-sidebars', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
76
- }
77
-
78
- /**
79
- * Register the Area widget.
80
- *
81
- * @since 1.1.0
82
- */
83
- public static function register_widgets() {
84
- register_widget( 'Simple_Page_Sidebars_Widget_Area' );
85
- }
86
-
87
- /**
88
- * Add custom widget areas and automatically register page sidebars.
89
- *
90
- * @todo Try to insert a link into the description of custom sidebars so
91
- * they can be edited. It'd be useful for when the Sidebar column is
92
- * disabled, since there isn't any other way to access the Edit
93
- * Sidebar screen.
94
- *
95
- * @since 0.2.0
96
- */
97
- public static function register_sidebars() {
98
- $widget_areas = array();
99
-
100
- // Add widget areas using this filter.
101
- $widget_areas = apply_filters( 'simple_page_sidebars_widget_areas', $widget_areas );
102
-
103
- // Verify id's exist, otherwise create them.
104
- // Help ensure widgets don't get mixed up if widget areas are added or removed.
105
- if ( ! empty( $widget_areas ) && is_array( $widget_areas ) ) {
106
- foreach ( $widget_areas as $key => $area ) {
107
- if ( is_numeric( $key ) ) {
108
- $widget_areas[ 'widget-area-' . sanitize_key( $area['name'] ) ] = $area;
109
- unset( $widget_areas[ $key ] );
110
- }
111
- }
112
- }
113
-
114
- // Override the default widget properties.
115
- $widget_area_defaults = array(
116
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
117
- 'after_widget' => '</div>',
118
- 'before_title' => '<h4 class="title">',
119
- 'after_title' => '</h4>'
120
- );
121
-
122
- $widget_area_defaults = apply_filters( 'simple_page_sidebars_widget_defaults', $widget_area_defaults );
123
-
124
- // If any custom sidebars have been assigned to pages, merge them with already defined widget areas.
125
- $sidebars = simple_page_sidebars_get_names();
126
- if ( ! empty( $sidebars ) ) {
127
- foreach ( $sidebars as $sidebar ) {
128
- $page_sidebars[ 'page-sidebar-' . sanitize_key( $sidebar ) ] = array(
129
- 'name' => $sidebar,
130
- 'description' => ''
131
- );
132
- }
133
-
134
- ksort( $page_sidebars );
135
- $widget_areas = array_merge_recursive( $widget_areas, $page_sidebars );
136
- }
137
-
138
- if ( ! empty( $widget_areas ) && is_array( $widget_areas ) ) {
139
- // Register the widget areas.
140
- foreach ( $widget_areas as $key => $area ) {
141
- register_sidebar(array(
142
- 'id' => $key,
143
- 'name' => $area['name'],
144
- 'description' => $area['description'],
145
- 'before_widget' => ( isset( $area['before_widget'] ) ) ? $area['before_widget'] : $widget_area_defaults['before_widget'],
146
- 'after_widget' => ( isset( $area['after_widget'] ) ) ? $area['after_widget'] : $widget_area_defaults['after_widget'],
147
- 'before_title' => ( isset( $area['before_title'] ) ) ? $area['before_title'] : $widget_area_defaults['before_title'],
148
- 'after_title' => ( isset( $area['after_title'] ) ) ? $area['after_title'] : $widget_area_defaults['after_title']
149
- ));
150
- }
151
- }
152
- }
153
-
154
- /**
155
- * Replaces the default sidebar with a custom defined page sidebar.
156
- *
157
- * @since 0.2.0
158
- * @param array $sidebars_widgets
159
- */
160
- public static function replace_sidebar( $sidebars_widgets ) {
161
- global $post;
162
-
163
- $supports = ( isset( $post->post_type ) && post_type_supports( $post->post_type, 'simple-page-sidebars' ) ) ? true : false;
164
-
165
- if ( is_page() || $supports || ( is_home() && $posts_page = get_option( 'page_for_posts' ) ) ) {
166
- $post_id = ( ! empty( $posts_page ) ) ? $posts_page : $post->ID;
167
-
168
- $custom_sidebar = get_post_meta( $post_id, '_sidebar_name', true );
169
- $default_sidebar_id = get_option( 'simple_page_sidebars_default_sidebar' );
170
-
171
- if ( $custom_sidebar && $default_sidebar_id ) {
172
- $custom_sidebar_id = 'page-sidebar-' . sanitize_key( $custom_sidebar );
173
-
174
- // Only replace the default sidebar if the custom sidebar has widgets.
175
- if ( ! empty( $sidebars_widgets[ $custom_sidebar_id ] ) ) {
176
- $sidebars_widgets[ $default_sidebar_id ] = $sidebars_widgets[ $custom_sidebar_id ];
177
- }
178
- }
179
- }
180
-
181
- return $sidebars_widgets;
182
- }
183
-
184
- /**
185
- * Save version information for future upgrades.
186
- *
187
- * @since 1.1.0
188
- */
189
- public static function upgrade() {
190
- $saved_version = get_option( 'simple_page_sidebars_version' );
191
-
192
- // If the plugin version setting isn't set or if it's less than or equal to 1.1.0, update the saved version.
193
- if ( ! $saved_version || version_compare( $saved_version, '1.1.0', '<=' ) ) {
194
- $plugin_data = get_plugin_data( __FILE__ );
195
-
196
- // Update saved version number.
197
- update_option( 'simple_page_sidebars_version', $plugin_data['Version'] );
198
- }
199
- }
200
- }
201
- add_action( 'plugins_loaded', array( 'Simple_Page_Sidebars', 'load' ) );
202
-
203
- /**
204
- * Get an array of custom sidebar names.
205
- *
206
- * @since 0.2.0
207
- * @return array Custom sidebar names.
208
- */
209
- function simple_page_sidebars_get_names() {
210
- global $wpdb;
211
-
212
- $sidebar_names = $wpdb->get_results( "SELECT DISTINCT meta_value
213
- FROM $wpdb->posts p, $wpdb->postmeta pm
214
- WHERE p.post_status!='auto-draft' AND p.ID=pm.post_id AND pm.meta_key='_sidebar_name'
215
- ORDER BY pm.meta_value ASC" );
216
-
217
- $sidebars = array();
218
- if ( ! empty( $sidebar_names ) ) {
219
- foreach ( $sidebar_names as $meta ) {
220
- $sidebars[] = $meta->meta_value;
221
- }
222
- }
223
-
224
- return $sidebars;
225
- }
226
-
227
- /**
228
- * Sidebar display template tag.
229
- *
230
- * This is no longer the recommended usage. No code changes to the theme are
231
- * are required for the plugin to work.
232
- *
233
- * Call this function in the template where custom sidebars should be
234
- * displayed. If a custom sidebar hasn't been defined, the sidebar name passed
235
- * as the parameter will be served as a fallback.
236
- *
237
- * @since 0.2.0
238
- * @param string $default_sidebar
239
- */
240
- function simple_page_sidebar( $default_sidebar ) {
241
- global $post, $wp_registered_sidebars;
242
-
243
- $sidebar_name = get_post_meta( $post->ID, '_sidebar_name', true );
244
-
245
- // Last chance to override which sidebar is displayed.
246
- $sidebar_name = apply_filters( 'simple_page_sidebars_last_call', $sidebar_name );
247
-
248
- if ( is_page() && ! empty( $sidebar_name ) ) {
249
- $sidebars_widgets = wp_get_sidebars_widgets();
250
- if ( count( $sidebars_widgets ) ) {
251
- foreach ( $wp_registered_sidebars as $id => $sidebar ) {
252
- if ( $sidebar['name'] == $sidebar_name ) {
253
- if ( count( $sidebars_widgets[ $id ] ) ) {
254
- dynamic_sidebar( $sidebar_name );
255
- } elseif ( ! empty( $default_sidebar ) ) {
256
- dynamic_sidebar( $default_sidebar );
257
- }
258
- }
259
- }
260
- }
261
- } elseif ( ! empty( $default_sidebar ) ) {
262
- dynamic_sidebar( $default_sidebar );
263
- }
264
- }
265
-
266
- /**
267
- * Deprecated.
268
- */
269
- if ( ! function_exists( 'simple_sidebar' ) ) :
270
- function simple_sidebar( $default_sidebar ) {
271
- _deprecated_function( __FUNCTION__, '0.1.1', 'simple_page_sidebar()' );
272
-
273
- simple_page_sidebar( $default_sidebar );
274
- }
275
- endif;
1
+ <?php
2
+ /**
3
+ * Simple Page Sidebars
4
+ *
5
+ * @package SimplePageSidebars
6
+ * @copyright Copyright (c) 2015 Cedaro, LLC
7
+ * @license GPL-2.0+
8
+ *
9
+ * @wordpress-plugin
10
+ * Plugin Name: Simple Page Sidebars
11
+ * Plugin URI: https://wordpress.org/plugins/simple-page-sidebars/
12
+ * Description: Assign custom, widget-enabled sidebars to any page with ease.
13
+ * Version: 1.2.1
14
+ * Author: Cedaro
15
+ * Author URI: https://www.cedaro.com/?utm_source=wordpress-plugin&utm_medium=link&utm_content=simple-page-sidebars-author-uri&utm_campaign=plugins
16
+ * License: GPL-2.0+
17
+ * License URI: https://www.gnu.org/licenses/gpl-2.0.html
18
+ * Text Domain: simple-page-sidebars
19
+ */
20
+
21
+ /**
22
+ * Set a constant path to the plugin's root directory.
23
+ */
24
+ if ( ! defined( 'SIMPLE_PAGE_SIDEBARS_DIR' ) )
25
+ define( 'SIMPLE_PAGE_SIDEBARS_DIR', plugin_dir_path( __FILE__ ) );
26
+
27
+ /**
28
+ * Set a constant URL to the plugin's root directory.
29
+ */
30
+ if ( ! defined( 'SIMPLE_PAGE_SIDEBARS_URL' ) )
31
+ define( 'SIMPLE_PAGE_SIDEBARS_URL', plugin_dir_url( __FILE__ ) );
32
+
33
+ /**
34
+ * Main plugin class.
35
+ *
36
+ * @since 0.2.0
37
+ */
38
+ class Simple_Page_Sidebars {
39
+ /**
40
+ * Setup the plugin.
41
+ *
42
+ * @since 0.2.0
43
+ */
44
+ public static function load() {
45
+ self::load_textdomain();
46
+
47
+ require_once( plugin_dir_path( __FILE__ ) . 'includes/widget-area.php' );
48
+
49
+ // Load the admin functionality.
50
+ if ( is_admin() ) {
51
+ add_action( 'admin_init', array( __CLASS__, 'upgrade' ) );
52
+
53
+ require_once( plugin_dir_path( __FILE__ ) . 'admin/admin.php' );
54
+ Simple_Page_Sidebars_Admin::load();
55
+ }
56
+
57
+ // Lower priority registers sidebars below those typically added by themes.
58
+ add_action( 'widgets_init', array( __CLASS__, 'register_sidebars' ), 20 );
59
+ add_action( 'widgets_init', array( __CLASS__, 'register_widgets' ) );
60
+
61
+ if ( ! is_admin() ) {
62
+ add_filter( 'sidebars_widgets', array( __CLASS__, 'replace_sidebar' ) );
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Plugin localization support.
68
+ *
69
+ * @since 1.1.4
70
+ */
71
+ public static function load_textdomain() {
72
+ load_plugin_textdomain( 'simple-page-sidebars' );
73
+ }
74
+
75
+ /**
76
+ * Register the Area widget.
77
+ *
78
+ * @since 1.1.0
79
+ */
80
+ public static function register_widgets() {
81
+ register_widget( 'Simple_Page_Sidebars_Widget_Area' );
82
+ }
83
+
84
+ /**
85
+ * Add custom widget areas and automatically register page sidebars.
86
+ *
87
+ * @todo Try to insert a link into the description of custom sidebars so
88
+ * they can be edited. It'd be useful for when the Sidebar column is
89
+ * disabled, since there isn't any other way to access the Edit
90
+ * Sidebar screen.
91
+ *
92
+ * @since 0.2.0
93
+ */
94
+ public static function register_sidebars() {
95
+ $widget_areas = array();
96
+
97
+ // Add widget areas using this filter.
98
+ $widget_areas = apply_filters( 'simple_page_sidebars_widget_areas', $widget_areas );
99
+
100
+ // Verify id's exist, otherwise create them.
101
+ // Help ensure widgets don't get mixed up if widget areas are added or removed.
102
+ if ( ! empty( $widget_areas ) && is_array( $widget_areas ) ) {
103
+ foreach ( $widget_areas as $key => $area ) {
104
+ if ( is_numeric( $key ) ) {
105
+ $widget_areas[ 'widget-area-' . sanitize_key( $area['name'] ) ] = $area;
106
+ unset( $widget_areas[ $key ] );
107
+ }
108
+ }
109
+ }
110
+
111
+ // Override the default widget properties.
112
+ $widget_area_defaults = array(
113
+ 'before_widget' => '<div id="%1$s" class="widget %2$s">',
114
+ 'after_widget' => '</div>',
115
+ 'before_title' => '<h4 class="title">',
116
+ 'after_title' => '</h4>'
117
+ );
118
+
119
+ $widget_area_defaults = apply_filters( 'simple_page_sidebars_widget_defaults', $widget_area_defaults );
120
+
121
+ // If any custom sidebars have been assigned to pages, merge them with already defined widget areas.
122
+ $sidebars = simple_page_sidebars_get_names();
123
+ if ( ! empty( $sidebars ) ) {
124
+ foreach ( $sidebars as $sidebar ) {
125
+ $page_sidebars[ 'page-sidebar-' . sanitize_key( $sidebar ) ] = array(
126
+ 'name' => $sidebar,
127
+ 'description' => ''
128
+ );
129
+ }
130
+
131
+ ksort( $page_sidebars );
132
+ $widget_areas = array_merge_recursive( $widget_areas, $page_sidebars );
133
+ }
134
+
135
+ if ( ! empty( $widget_areas ) && is_array( $widget_areas ) ) {
136
+ // Register the widget areas.
137
+ foreach ( $widget_areas as $key => $area ) {
138
+ register_sidebar(array(
139
+ 'id' => $key,
140
+ 'name' => $area['name'],
141
+ 'description' => $area['description'],
142
+ 'before_widget' => ( isset( $area['before_widget'] ) ) ? $area['before_widget'] : $widget_area_defaults['before_widget'],
143
+ 'after_widget' => ( isset( $area['after_widget'] ) ) ? $area['after_widget'] : $widget_area_defaults['after_widget'],
144
+ 'before_title' => ( isset( $area['before_title'] ) ) ? $area['before_title'] : $widget_area_defaults['before_title'],
145
+ 'after_title' => ( isset( $area['after_title'] ) ) ? $area['after_title'] : $widget_area_defaults['after_title']
146
+ ));
147
+ }
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Replaces the default sidebar with a custom defined page sidebar.
153
+ *
154
+ * @since 0.2.0
155
+ * @param array $sidebars_widgets
156
+ */
157
+ public static function replace_sidebar( $sidebars_widgets ) {
158
+ global $post;
159
+
160
+ $supports = ( isset( $post->post_type ) && post_type_supports( $post->post_type, 'simple-page-sidebars' ) ) ? true : false;
161
+
162
+ if ( is_page() || $supports || ( is_home() && $posts_page = get_option( 'page_for_posts' ) ) ) {
163
+ $post_id = ( ! empty( $posts_page ) ) ? $posts_page : $post->ID;
164
+
165
+ $custom_sidebar = get_post_meta( $post_id, '_sidebar_name', true );
166
+ $default_sidebar_id = get_option( 'simple_page_sidebars_default_sidebar' );
167
+
168
+ if ( $custom_sidebar && $default_sidebar_id ) {
169
+ $custom_sidebar_id = 'page-sidebar-' . sanitize_key( $custom_sidebar );
170
+
171
+ // Only replace the default sidebar if the custom sidebar has widgets.
172
+ if ( ! empty( $sidebars_widgets[ $custom_sidebar_id ] ) ) {
173
+ $sidebars_widgets[ $default_sidebar_id ] = $sidebars_widgets[ $custom_sidebar_id ];
174
+ }
175
+ }
176
+ }
177
+
178
+ return $sidebars_widgets;
179
+ }
180
+
181
+ /**
182
+ * Save version information for future upgrades.
183
+ *
184
+ * @since 1.1.0
185
+ */
186
+ public static function upgrade() {
187
+ $saved_version = get_option( 'simple_page_sidebars_version' );
188
+
189
+ // If the plugin version setting isn't set or if it's less than or equal to 1.1.0, update the saved version.
190
+ if ( ! $saved_version || version_compare( $saved_version, '1.1.0', '<=' ) ) {
191
+ $plugin_data = get_plugin_data( __FILE__ );
192
+
193
+ // Update saved version number.
194
+ update_option( 'simple_page_sidebars_version', $plugin_data['Version'] );
195
+ }
196
+ }
197
+ }
198
+ add_action( 'plugins_loaded', array( 'Simple_Page_Sidebars', 'load' ) );
199
+
200
+ /**
201
+ * Get an array of custom sidebar names.
202
+ *
203
+ * @since 0.2.0
204
+ * @return array Custom sidebar names.
205
+ */
206
+ function simple_page_sidebars_get_names() {
207
+ global $wpdb;
208
+
209
+ $sidebar_names = $wpdb->get_results( "SELECT DISTINCT meta_value
210
+ FROM $wpdb->posts p, $wpdb->postmeta pm
211
+ WHERE p.post_status!='auto-draft' AND p.ID=pm.post_id AND pm.meta_key='_sidebar_name'
212
+ ORDER BY pm.meta_value ASC" );
213
+
214
+ $sidebars = array();
215
+ if ( ! empty( $sidebar_names ) ) {
216
+ foreach ( $sidebar_names as $meta ) {
217
+ $sidebars[] = $meta->meta_value;
218
+ }
219
+ }
220
+
221
+ return $sidebars;
222
+ }
223
+
224
+ /**
225
+ * Sidebar display template tag.
226
+ *
227
+ * This is no longer the recommended usage. No code changes to the theme are
228
+ * are required for the plugin to work.
229
+ *
230
+ * Call this function in the template where custom sidebars should be
231
+ * displayed. If a custom sidebar hasn't been defined, the sidebar name passed
232
+ * as the parameter will be served as a fallback.
233
+ *
234
+ * @since 0.2.0
235
+ * @param string $default_sidebar
236
+ */
237
+ function simple_page_sidebar( $default_sidebar ) {
238
+ global $post, $wp_registered_sidebars;
239
+
240
+ $sidebar_name = get_post_meta( $post->ID, '_sidebar_name', true );
241
+
242
+ // Last chance to override which sidebar is displayed.
243
+ $sidebar_name = apply_filters( 'simple_page_sidebars_last_call', $sidebar_name );
244
+
245
+ if ( is_page() && ! empty( $sidebar_name ) ) {
246
+ $sidebars_widgets = wp_get_sidebars_widgets();
247
+ if ( count( $sidebars_widgets ) ) {
248
+ foreach ( $wp_registered_sidebars as $id => $sidebar ) {
249
+ if ( $sidebar['name'] == $sidebar_name ) {
250
+ if ( count( $sidebars_widgets[ $id ] ) ) {
251
+ dynamic_sidebar( $sidebar_name );
252
+ } elseif ( ! empty( $default_sidebar ) ) {
253
+ dynamic_sidebar( $default_sidebar );
254
+ }
255
+ }
256
+ }
257
+ }
258
+ } elseif ( ! empty( $default_sidebar ) ) {
259
+ dynamic_sidebar( $default_sidebar );
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Deprecated.
265
+ */
266
+ if ( ! function_exists( 'simple_sidebar' ) ) :
267
+ function simple_sidebar( $default_sidebar ) {
268
+ _deprecated_function( __FUNCTION__, '0.1.1', 'simple_page_sidebar()' );
269
+
270
+ simple_page_sidebar( $default_sidebar );
271
+ }
272
+ endif;
 
 
 
uninstall.php CHANGED
@@ -1,10 +1,10 @@
1
- <?php
2
- if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
3
- exit;
4
- }
5
-
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
- delete_option( 'simple_page_sidebars_version' );
1
+ <?php
2
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
3
+ exit;
4
+ }
5
+
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
+ delete_option( 'simple_page_sidebars_version' );