Version Description
Initial release.
Download this release
Release Info
Developer | blazersix |
Plugin | Simple Page Sidebars |
Version | 0.1 |
Comparing to | |
See all releases |
Version 0.1
- admin/admin.php +256 -0
- includes/widget-area.php +61 -0
- languages/simple-page-sidebars.mo +0 -0
- languages/simple-page-sidebars.pot +67 -0
- readme.txt +36 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- simple-page-sidebars.php +143 -0
- uninstall.php +9 -0
admin/admin.php
ADDED
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Super function for saving page sidebars
|
4 |
+
*/
|
5 |
+
add_action( 'save_post', 'simpsid_update_page_sidebar' );
|
6 |
+
add_action( 'wp_ajax_simpsid_update_page_sidebar', 'simpsid_update_page_sidebar' );
|
7 |
+
function simpsid_update_page_sidebar( $post_id = 0 ) {
|
8 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
9 |
+
return $post_id;
|
10 |
+
|
11 |
+
if ( $post_id == 0 ) {
|
12 |
+
$post_id = $_POST['post_id'];
|
13 |
+
}
|
14 |
+
|
15 |
+
// verify either an individual post nonce or the bulk edit nonce
|
16 |
+
// requests can come from a page update, ajax from the sidebar meta box, quick edit, or bulk edit
|
17 |
+
if ( ! wp_verify_nonce( $_REQUEST['sidebar_name_nonce'], 'update-page-sidebar-name-' . $post_id ) && ! wp_verify_nonce( $_REQUEST['bulk_sidebar_name_nonce'], 'bulk-update-page-sidebar-name' ) ) {
|
18 |
+
if ( defined( 'DOING AJAX' ) && DOING_AJAX ) {
|
19 |
+
exit;
|
20 |
+
} else {
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( ! wp_is_post_revision( $post_id ) && 'page' == get_post_type( $post_id ) ) {
|
26 |
+
// if 'new_sidebar_name' is set and not empty, it supercedes any 'sidebar_name' setting
|
27 |
+
// if 'sidebar_name' is blank or it equals 'default', delete meta
|
28 |
+
// if 'sidebar_name' is set and not empty, update to new name
|
29 |
+
// if 'sidebar_name' is -1, skip
|
30 |
+
|
31 |
+
// bulk edit uses $_GET for some reason, so we use the $_REQUEST global
|
32 |
+
if ( isset( $_REQUEST['new_sidebar_name' ] ) && ! empty( $_REQUEST['new_sidebar_name'] ) ) {
|
33 |
+
update_post_meta( $post_id, '_sidebar_name', $_REQUEST['new_sidebar_name'] );
|
34 |
+
} else {
|
35 |
+
// if $_REQUEST['sidebar_name'] isn't set, we don't want to update the sidebar meta value
|
36 |
+
$sidebar = ( isset( $_REQUEST['sidebar_name'] ) ) ? $_REQUEST['sidebar_name'] : -1;
|
37 |
+
|
38 |
+
if ( empty( $sidebar ) || 'default' == $sidebar ) {
|
39 |
+
delete_post_meta( $post_id, '_sidebar_name' );
|
40 |
+
} elseif ( -1 != intval( $sidebar ) ) {
|
41 |
+
update_post_meta( $post_id, '_sidebar_name', $_REQUEST['sidebar_name'] );
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
if ( defined( 'DOING AJAX' ) && DOING_AJAX )
|
47 |
+
exit;
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
add_action( 'admin_menu', 'simpsid_admin_menu' );
|
52 |
+
function simpsid_admin_menu() {
|
53 |
+
add_action( 'admin_footer-post.php', 'simpsid_page_sidebar_script' );
|
54 |
+
|
55 |
+
// wish the Page Attributes meta box had a hook. oh well.
|
56 |
+
add_meta_box( 'simplepagesidebarsdiv', 'Sidebar', 'simpsid_page_sidebar_meta_box', 'page', 'side', 'core' );
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
function simpsid_page_sidebar_meta_box( $page ) {
|
61 |
+
global $wpdb;
|
62 |
+
|
63 |
+
$sidebar = get_post_meta( $page->ID, '_sidebar_name', true );
|
64 |
+
$current_sidebars = simpsid_get_page_sidebars();
|
65 |
+
|
66 |
+
wp_nonce_field( 'update-page-sidebar-name-' . $page->ID, 'sidebar_name_nonce', false );
|
67 |
+
?>
|
68 |
+
<p>
|
69 |
+
<label for="sidebar-name" class="screen-reader-text"><?php _e( 'Choose an existing sidebar:', 'simple-page-sidebars' ); ?></label>
|
70 |
+
<select name="sidebar_name" id="sidebar-name" class="widefat">
|
71 |
+
<option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
|
72 |
+
<?php
|
73 |
+
foreach ( $current_sidebars as $sb ) {
|
74 |
+
echo '<option value="' . esc_attr( $sb ) . '"';
|
75 |
+
selected( $sb, $sidebar );
|
76 |
+
echo '>' . esc_html( $sb ) . '</option>';
|
77 |
+
}
|
78 |
+
?>
|
79 |
+
</select>
|
80 |
+
<label for="new-sidebar-name" class="screen-reader-text"><?php _e( 'Or create a new sidebar:', 'simple-page-sidebars' ); ?></label>
|
81 |
+
<input type="text" name="new_sidebar_name" id="new-sidebar-name" class="widefat hide-if-js" value="" />
|
82 |
+
<span id="sidebarnew" class="hide-if-no-js"><?php _e( 'Enter New', 'simple-page-sidebars' ); ?></span>
|
83 |
+
<span id="sidebarcancel" class="hidden"><?php _e( 'Cancel', 'simple-page-sidebars' ); ?></span>
|
84 |
+
</p>
|
85 |
+
|
86 |
+
<p style="margin-top: 10px; margin-bottom: 0; text-align: right">
|
87 |
+
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" id="sidebar-update-feedback" style="display: none" />
|
88 |
+
<button class="button"><?php _e( 'Update', 'simple-page-sidebars' ); ?></button>
|
89 |
+
</p>
|
90 |
+
|
91 |
+
<style type="text/css">
|
92 |
+
#sidebar-update-feedback { display: none; margin: 0 5px 0 0; vertical-align: middle;}
|
93 |
+
#sidebarcancel, #sidebarnew { cursor: pointer; float: left; margin: 3px 0 0 3px; color: #21759b; font-size: 12px;}
|
94 |
+
#sidebarcancel, #sidebarnew:hover { color: #d54e21;}
|
95 |
+
</style>
|
96 |
+
|
97 |
+
<script type="text/javascript">
|
98 |
+
jQuery(function($) {
|
99 |
+
$('#sidebarcancel, #sidebarnew').click(function() {
|
100 |
+
$('#new-sidebar-name, #sidebar-name, #sidebarcancel, #sidebarnew').toggle();
|
101 |
+
|
102 |
+
// clear the new sidebar name field when cancel is clicked
|
103 |
+
if ( 'sidebarcancel' == $(this).attr('id') ) {
|
104 |
+
$('#new-sidebar-name').val('');
|
105 |
+
}
|
106 |
+
});
|
107 |
+
|
108 |
+
$('#simplepagesidebarsdiv').find('button').click(function(e) {
|
109 |
+
e.preventDefault();
|
110 |
+
|
111 |
+
$('#sidebar-update-feedback').show();
|
112 |
+
$.post(ajaxurl, {
|
113 |
+
action : 'simpsid_update_page_sidebar',
|
114 |
+
post_id : $('#post_ID').val(),
|
115 |
+
sidebar_name : $('select[name="sidebar_name"]').val(),
|
116 |
+
new_sidebar_name : $('input[name="new_sidebar_name"]').val(),
|
117 |
+
sidebar_name_nonce : $('input[name="sidebar_name_nonce"]').val()
|
118 |
+
},
|
119 |
+
function(data){
|
120 |
+
new_sidebar_name = $('#new-sidebar-name').val();
|
121 |
+
|
122 |
+
if ( '' != new_sidebar_name ) {
|
123 |
+
if ( $('#simplepagesidebarsdiv select option[value="' + new_sidebar_name + '"]').length < 1 ) {
|
124 |
+
$('#simplepagesidebarsdiv select').append('<option selected="selected">' + new_sidebar_name + '</option>').val(new_sidebar_name);
|
125 |
+
} else {
|
126 |
+
$('#simplepagesidebarsdiv select option[value="' + new_sidebar_name + '"]').attr('selected','selected');
|
127 |
+
}
|
128 |
+
|
129 |
+
$('#new-sidebar-name, #sidebar-name, #sidebarcancel, #sidebarnew').toggle().filter('input').val('');
|
130 |
+
}
|
131 |
+
|
132 |
+
$('#sidebar-update-feedback').hide();
|
133 |
+
}
|
134 |
+
);
|
135 |
+
});
|
136 |
+
});
|
137 |
+
</script>
|
138 |
+
|
139 |
+
<br class="clear" />
|
140 |
+
<?php
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
function simpsid_page_sidebar_script() {
|
145 |
+
global $current_screen;
|
146 |
+
if ( 'page' != $current_screen->id || 'page' != $current_screen->post_type ) { return; }
|
147 |
+
?>
|
148 |
+
|
149 |
+
<?php
|
150 |
+
}
|
151 |
+
|
152 |
+
|
153 |
+
// quick edit ain't so quick to implement
|
154 |
+
add_filter('manage_pages_columns', 'simpsid_manage_pages_columns');
|
155 |
+
function simpsid_manage_pages_columns( $columns ) {
|
156 |
+
$columns['sidebar'] = __( 'Sidebar', 'simple-page-sidebars' );
|
157 |
+
return $columns;
|
158 |
+
}
|
159 |
+
|
160 |
+
|
161 |
+
add_action( 'manage_pages_custom_column', 'simpsid_manage_pages_custom_column', 10, 2 );
|
162 |
+
function simpsid_manage_pages_custom_column( $column, $page_id ) {
|
163 |
+
if ( 'sidebar' == $column ) {
|
164 |
+
$sidebar = get_post_meta( $page_id, '_sidebar_name', true );
|
165 |
+
echo ( $sidebar ) ? esc_html( $sidebar ) : '';
|
166 |
+
|
167 |
+
// add the nonce here and copy it to the inline editor with javascript
|
168 |
+
wp_nonce_field( 'update-page-sidebar-name-' . $page_id, 'sidebar_name_nonce', false );
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
|
173 |
+
add_action( 'quick_edit_custom_box', 'simpsid_quick_edit_custom_box', 10, 2 );
|
174 |
+
function simpsid_quick_edit_custom_box( $column, $post_type ) {
|
175 |
+
if ( 'page' != $post_type || 'sidebar' != $column ) { return; }
|
176 |
+
|
177 |
+
$sidebars = simpsid_get_page_sidebars();
|
178 |
+
?>
|
179 |
+
<fieldset class="inline-edit-col-left">
|
180 |
+
<div class="inline-edit-col">
|
181 |
+
<div class="inline-edit-group" id="sidebar-edit-group">
|
182 |
+
<label>
|
183 |
+
<span class="title"><?php _e( 'Sidebar', 'simple-page-sidebars' ); ?></span>
|
184 |
+
<select name="sidebar_name" id="sidebar-name">
|
185 |
+
<option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
|
186 |
+
<?php
|
187 |
+
foreach ( $sidebars as $sb ) {
|
188 |
+
echo '<option value="' . $sb . '">' . $sb . '</option>';
|
189 |
+
}
|
190 |
+
?>
|
191 |
+
</select>
|
192 |
+
</label>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
</fieldset>
|
196 |
+
<?php
|
197 |
+
}
|
198 |
+
|
199 |
+
|
200 |
+
add_action( 'admin_footer-edit.php', 'simpsid_quick_edit_js' );
|
201 |
+
function simpsid_quick_edit_js() {
|
202 |
+
global $current_screen;
|
203 |
+
if ( 'edit-page' != $current_screen->id || 'page' != $current_screen->post_type ) { return; }
|
204 |
+
?>
|
205 |
+
<script type="text/javascript">
|
206 |
+
jQuery(function($) {
|
207 |
+
$('table.pages').delegate('a.editinline', 'click', function(e) {
|
208 |
+
inlineEditPost.revert();
|
209 |
+
|
210 |
+
var id = inlineEditPost.getId(this);
|
211 |
+
var currentSidebar = $('#post-' + id + ' .sidebar').text();
|
212 |
+
|
213 |
+
// select the current sidebar option
|
214 |
+
$('select#sidebar-name option').attr('selected', false);
|
215 |
+
if ( '' != currentSidebar ) {
|
216 |
+
$('select#sidebar-name option:contains(' + currentSidebar + ')').attr('selected', true);
|
217 |
+
}
|
218 |
+
|
219 |
+
// copy the sidebar name nonce
|
220 |
+
$('#sidebar-edit-group').find('input[name="sidebar_name_nonce"]').remove().end().append( $('#post-' + id + ' input[name="sidebar_name_nonce"]').clone() );
|
221 |
+
});
|
222 |
+
});
|
223 |
+
</script>
|
224 |
+
<style type="text/css">
|
225 |
+
.widefat .column-sidebar { width: 15%;}
|
226 |
+
</style>
|
227 |
+
<?php
|
228 |
+
}
|
229 |
+
|
230 |
+
|
231 |
+
add_action( 'bulk_edit_custom_box', 'simpsid_bulk_edit_custom_box', 10, 2 );
|
232 |
+
function simpsid_bulk_edit_custom_box( $column, $post_type ) {
|
233 |
+
if ( 'page' != $post_type || 'sidebar' != $column ) { return; }
|
234 |
+
|
235 |
+
$sidebars = simpsid_get_page_sidebars();
|
236 |
+
?>
|
237 |
+
<fieldset class="inline-edit-col-right" style="margin-top: 0">
|
238 |
+
<div class="inline-edit-col">
|
239 |
+
<label>
|
240 |
+
<span class="title"><?php _e( 'Sidebar', 'simple-page-sidebars' ); ?></span>
|
241 |
+
<select name="sidebar_name" id="sidebar-name">
|
242 |
+
<option value="-1"><?php _e( '— No Change —', 'simple-page-sidebars' ); ?></option>
|
243 |
+
<option value="default"><?php _e( 'Default Sidebar', 'simple-page-sidebars' ); ?></option>
|
244 |
+
<?php
|
245 |
+
foreach ( $sidebars as $sb ) {
|
246 |
+
echo '<option value="' . $sb . '">' . $sb . '</option>';
|
247 |
+
}
|
248 |
+
?>
|
249 |
+
</select>
|
250 |
+
</label>
|
251 |
+
<?php wp_nonce_field( 'bulk-update-page-sidebar-name', 'bulk_sidebar_name_nonce', false ); ?>
|
252 |
+
</div>
|
253 |
+
</fieldset>
|
254 |
+
<?php
|
255 |
+
}
|
256 |
+
?>
|
includes/widget-area.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Simple_Page_Sidebars_Widget_Area extends WP_Widget {
|
3 |
+
function Simple_Page_Sidebars_Widget_Area() {
|
4 |
+
$widget_ops = array(
|
5 |
+
'classname' => 'widget_area',
|
6 |
+
'description' => __( 'Include all widgets from another widget area', 'simple-page-sidebars' )
|
7 |
+
);
|
8 |
+
|
9 |
+
$this->WP_Widget( 'area', __( 'Widget Area', 'simple-page-sidebars' ), $widget_ops );
|
10 |
+
}
|
11 |
+
|
12 |
+
function widget( $args, $instance ) {
|
13 |
+
extract( $args );
|
14 |
+
|
15 |
+
// don't want to create a never ending loop!
|
16 |
+
if ( $id != $instance['area_id'] ) {
|
17 |
+
echo $before_widget;
|
18 |
+
|
19 |
+
echo ( ! empty( $instance['title'] ) ) ? $before_title . esc_html( $instance['title'] ) . $after_title : '';
|
20 |
+
|
21 |
+
echo '<div class="widget-area-inside">';
|
22 |
+
dynamic_sidebar( $instance['area_id'] );
|
23 |
+
echo '</div>';
|
24 |
+
|
25 |
+
echo $after_widget;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
function update($new_instance, $old_instance) {
|
30 |
+
$instance = $old_instance;
|
31 |
+
$instance['title'] = esc_html( $new_instance['title'] );
|
32 |
+
$instance['area_id'] = $new_instance['area_id'];
|
33 |
+
|
34 |
+
return $instance;
|
35 |
+
}
|
36 |
+
|
37 |
+
function form($instance) {
|
38 |
+
$instance = wp_parse_args( (array) $instance, array( 'area_id' => '', 'title' => '' ) );
|
39 |
+
?>
|
40 |
+
<p>
|
41 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'simple-page-sidebars' ); ?></label>
|
42 |
+
<input type="text" name="<?php echo $this->get_field_name( 'title' ); ?>" id="<?php echo $this->get_field_id('title'); ?>" value="<?php esc_attr( $instance['title'] ); ?>" class="widefat" />
|
43 |
+
</p>
|
44 |
+
<p>
|
45 |
+
<label for="<?php echo $this->get_field_id( 'area_id' ); ?>"><?php _e( 'Area Name:', 'simple-page-sidebars' ); ?></label>
|
46 |
+
<select name="<?php echo $this->get_field_name( 'area_id' ); ?>" id="<?php echo $this->get_field_id( 'area_id' ); ?>" class="widefat">
|
47 |
+
<option value=""></option>';
|
48 |
+
<?php
|
49 |
+
global $wp_registered_sidebars;
|
50 |
+
|
51 |
+
foreach ( $wp_registered_sidebars as $id => $area ) {
|
52 |
+
echo '<option value="' . $id . '"' . selected( $id, $instance['area_id'], false ) . '>' . esc_html( $area['name'] ) . '</option>';
|
53 |
+
}
|
54 |
+
?>
|
55 |
+
</select>
|
56 |
+
</p>
|
57 |
+
<?php
|
58 |
+
}
|
59 |
+
}
|
60 |
+
add_action( 'widgets_init', create_function( '', 'return register_widget("Simple_Page_Sidebars_Widget_Area");' ) );
|
61 |
+
?>
|
languages/simple-page-sidebars.mo
ADDED
Binary file
|
languages/simple-page-sidebars.pot
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Simple Page Sidebars\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2011-11-09 09:41-0800\n"
|
6 |
+
"PO-Revision-Date: 2011-11-09 09:42-0800\n"
|
7 |
+
"Last-Translator: Brady Vercher <brady@blazersix.com>\n"
|
8 |
+
"Language-Team: \n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Poedit-KeywordsList: _e;__;esc_attr_e;esc_attr__;esc_html_e;esc_html__\n"
|
13 |
+
"X-Poedit-Basepath: ../\n"
|
14 |
+
"X-Poedit-SearchPath-0: .\n"
|
15 |
+
|
16 |
+
#: admin/admin.php:67
|
17 |
+
msgid "Choose an existing sidebar:"
|
18 |
+
msgstr ""
|
19 |
+
|
20 |
+
#: admin/admin.php:69
|
21 |
+
#: admin/admin.php:183
|
22 |
+
#: admin/admin.php:241
|
23 |
+
msgid "Default Sidebar"
|
24 |
+
msgstr ""
|
25 |
+
|
26 |
+
#: admin/admin.php:78
|
27 |
+
msgid "Or create a new sidebar:"
|
28 |
+
msgstr ""
|
29 |
+
|
30 |
+
#: admin/admin.php:80
|
31 |
+
msgid "Enter New"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#: admin/admin.php:81
|
35 |
+
msgid "Cancel"
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#: admin/admin.php:86
|
39 |
+
msgid "Update"
|
40 |
+
msgstr ""
|
41 |
+
|
42 |
+
#: admin/admin.php:154
|
43 |
+
#: admin/admin.php:181
|
44 |
+
#: admin/admin.php:238
|
45 |
+
msgid "Sidebar"
|
46 |
+
msgstr ""
|
47 |
+
|
48 |
+
#: admin/admin.php:240
|
49 |
+
msgid "— No Change —"
|
50 |
+
msgstr ""
|
51 |
+
|
52 |
+
#: includes/widget-area.php:6
|
53 |
+
msgid "Include all widgets from another widget area"
|
54 |
+
msgstr ""
|
55 |
+
|
56 |
+
#: includes/widget-area.php:9
|
57 |
+
msgid "Widget Area"
|
58 |
+
msgstr ""
|
59 |
+
|
60 |
+
#: includes/widget-area.php:41
|
61 |
+
msgid "Title:"
|
62 |
+
msgstr ""
|
63 |
+
|
64 |
+
#: includes/widget-area.php:45
|
65 |
+
msgid "Area Name:"
|
66 |
+
msgstr ""
|
67 |
+
|
readme.txt
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Simple Page Sidebars ===
|
2 |
+
Contributors: blazersix
|
3 |
+
Donate link: http://bit.ly/s2zcgD
|
4 |
+
Tags: sidebars, custom sidebars, dynamic sidebar, simple, widget, widgets
|
5 |
+
Requires at least: 3.2.1
|
6 |
+
Tested up to: 3.2.1
|
7 |
+
Stable tag: 0.1
|
8 |
+
|
9 |
+
Assign custom, widget-enabled sidebars to any page with ease.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Designed for simplicity and flexibility, Simple Page Sidebars gives WordPress users and theme authors the ability to assign custom sidebars to individual pages. Existing sidebars can be assigned in quick edit and bulk edit modes, helping save you time.
|
14 |
+
|
15 |
+
Also included is a widget to allow a sidebar to include all the widgets from any other widget area. Don't worry if that didn't make sense, because without a sanity check, a Widget Area widget including it's parent widget area would create an infinite loop.
|
16 |
+
|
17 |
+
== Installation ==
|
18 |
+
|
19 |
+
Installing Simple Page Sidebars is just like installing most other plugins. [Check out the codex](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins) if you have any questions.
|
20 |
+
|
21 |
+
#### Setup
|
22 |
+
You'll need to include the following function call within your sidebar template in order for the plugin to know which sidebar to replace.
|
23 |
+
|
24 |
+
`if ( function_exists( 'simple_sidebar' )
|
25 |
+
simple_sidebar( 'Default Sidebar Name' );`
|
26 |
+
|
27 |
+
== Screenshots ==
|
28 |
+
|
29 |
+
1. Simply create a new sidebar when editing a page.
|
30 |
+
2. The new sidebar shows up on the widget panel. Notice the new "Widget Area" widget for including other widget areas.
|
31 |
+
3. Bulk edit in action. Easily assign a sidebar to multiple pages. (Quick edit works, too!)
|
32 |
+
|
33 |
+
== Changelog ==
|
34 |
+
|
35 |
+
= 0.1 =
|
36 |
+
Initial release.
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
screenshot-3.png
ADDED
Binary file
|
simple-page-sidebars.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Simple Page Sidebars
|
4 |
+
Version: 0.1
|
5 |
+
Plugin URI: http://wordpress.org/extend/plugins/simple-page-sidebars/
|
6 |
+
Description: Assign custom, widget-enabled sidebars to any page with ease.
|
7 |
+
Author: Blazer Six, Inc.
|
8 |
+
Author URI: http://www.blazersix.com/
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
load_plugin_textdomain( 'simple-page-sidebars', false, 'simple-page-sidebars/languages' );
|
13 |
+
|
14 |
+
require_once( plugin_dir_path( __FILE__ ) .'/includes/widget-area.php' );
|
15 |
+
|
16 |
+
// Lower priority registers sidebars below those typically added in themes
|
17 |
+
add_action( 'widgets_init', 'simpsid_register_sidebars', 20 );
|
18 |
+
|
19 |
+
if ( is_admin() ) {
|
20 |
+
require_once( plugin_dir_path( __FILE__ ) .'/admin/admin.php' );
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
function simpsid_get_page_sidebars() {
|
25 |
+
global $wpdb;
|
26 |
+
|
27 |
+
$sql = "SELECT meta_value
|
28 |
+
FROM $wpdb->posts p, $wpdb->postmeta pm
|
29 |
+
WHERE p.post_type='page' AND p.post_status!='auto-draft' AND p.ID=pm.post_id
|
30 |
+
AND pm.meta_key='_sidebar_name'
|
31 |
+
GROUP BY pm.meta_value
|
32 |
+
ORDER BY pm.meta_value ASC";
|
33 |
+
|
34 |
+
$sidebars = array();
|
35 |
+
$sidebar_names = $wpdb->get_results($sql);
|
36 |
+
if ( count( $sidebar_names ) ) {
|
37 |
+
foreach ( $sidebar_names as $meta ) {
|
38 |
+
$sidebars[] = $meta->meta_value;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
return $sidebars;
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Add widget areas and automatically register page sidebars
|
48 |
+
*/
|
49 |
+
function simpsid_register_sidebars() {
|
50 |
+
global $wpdb;
|
51 |
+
|
52 |
+
$widget_areas = array();
|
53 |
+
|
54 |
+
// Add widget areas using this filter
|
55 |
+
$widget_areas = apply_filters( 'simpsid_widget_areas', $widget_areas );
|
56 |
+
|
57 |
+
// Verify id's exist, otherwise create them
|
58 |
+
// Helps ensure widgets don't get mixed up if widget areas are added or removed
|
59 |
+
if ( is_array( $widget_areas ) ) {
|
60 |
+
foreach ( $widget_areas as $key => $area ) {
|
61 |
+
if ( is_numeric( $key ) ) {
|
62 |
+
$widget_areas[ 'widget-area-' . sanitize_key( $area['name'] ) ] = $area;
|
63 |
+
unset( $widget_areas[ $key ] );
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
// Override the default widget properties
|
69 |
+
$widget_area_defaults = array(
|
70 |
+
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
71 |
+
'after_widget' => '</div>',
|
72 |
+
'before_title' => '<h4 class="title">',
|
73 |
+
'after_title' => '</h4>'
|
74 |
+
);
|
75 |
+
$widget_area_defaults = apply_filters( 'simpsid_widget_area_defaults', $widget_area_defaults );
|
76 |
+
|
77 |
+
// If any custom sidebars have been assigned to pages, merge them with widget areas defined above
|
78 |
+
$sidebars = simpsid_get_page_sidebars();
|
79 |
+
if ( count( $sidebars ) ) {
|
80 |
+
foreach ( $sidebars as $sidebar ) {
|
81 |
+
$page_sidebars[ 'page-sidebar-' . sanitize_key( $sidebar ) ] = array(
|
82 |
+
'name' => $sidebar,
|
83 |
+
'description' => NULL
|
84 |
+
);
|
85 |
+
}
|
86 |
+
|
87 |
+
ksort($page_sidebars);
|
88 |
+
$widget_areas = array_merge_recursive($widget_areas, $page_sidebars);
|
89 |
+
}
|
90 |
+
|
91 |
+
if ( is_array( $widget_areas ) ) {
|
92 |
+
// Register the widget areas
|
93 |
+
foreach ( $widget_areas as $key => $area ) {
|
94 |
+
register_sidebar(array(
|
95 |
+
'id' => $key,
|
96 |
+
'name' => $area['name'],
|
97 |
+
'description' => $area['description'],
|
98 |
+
'before_widget' => ( ! isset( $area['before_widget'] ) ) ? $widget_area_defaults['before_widget'] : $area['before_widget'],
|
99 |
+
'after_widget' => ( ! isset( $area['after_widget'] ) ) ? $widget_area_defaults['after_widget'] : $area['after_widget'],
|
100 |
+
'before_title' => ( ! isset( $area['before_title'] ) ) ? $widget_area_defaults['before_title'] : $area['before_title'],
|
101 |
+
'after_title' => ( ! isset( $area['after_title'] ) ) ? $widget_area_defaults['after_title'] : $area['after_title']
|
102 |
+
));
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
|
108 |
+
|
109 |
+
/*
|
110 |
+
* Sidebar display template tag
|
111 |
+
*
|
112 |
+
* Call this function in the template where custom sidebars should be displayed.
|
113 |
+
* If a custom sidebar hasn't been defined, the sidebar name passed as the parameter
|
114 |
+
* will be served as a fallback.
|
115 |
+
*
|
116 |
+
* @param string $default_sidebar
|
117 |
+
*/
|
118 |
+
function simple_sidebar( $default_sidebar ) {
|
119 |
+
global $post, $wp_registered_sidebars;
|
120 |
+
|
121 |
+
$sidebar_name = get_post_meta( $post->ID, '_sidebar_name', true );
|
122 |
+
|
123 |
+
// Last chance to override which sidebar is displayed
|
124 |
+
$sidebar_name = apply_filters( 'simpsid_sidebar_name', $sidebar_name );
|
125 |
+
|
126 |
+
if ( is_page() && ! empty( $sidebar_name ) ) {
|
127 |
+
$sidebars_widgets = wp_get_sidebars_widgets();
|
128 |
+
if ( count( $sidebars_widgets ) ) {
|
129 |
+
foreach ( $wp_registered_sidebars as $id => $sidebar ) {
|
130 |
+
if ( $sidebar['name'] == $sidebar_name ) {
|
131 |
+
if ( count( $sidebars_widgets[$id] ) ) {
|
132 |
+
dynamic_sidebar( $sidebar_name );
|
133 |
+
} elseif ( ! empty( $default_sidebar ) ) {
|
134 |
+
dynamic_sidebar( $default_sidebar );
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
} elseif ( ! empty( $default_sidebar ) ) {
|
140 |
+
dynamic_sidebar( $default_sidebar );
|
141 |
+
}
|
142 |
+
}
|
143 |
+
?>
|
uninstall.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
?>
|