Version Description
- Increase requirement to WordPress 3.3 and Genesis 1.8.0
- Switch to Genesis Admin class to build admin menu.
Download this release
Release Info
Developer | wpmuguru |
Plugin | Genesis Simple Sidebars |
Version | 1.0.0 |
Comparing to | |
See all releases |
Code changes from version 0.9.2.1 to 1.0.0
- admin.php +0 -181
- functions.php +0 -189
- includes/admin.php +349 -0
- inpost.php → includes/inpost.php +21 -15
- term.php → includes/term.php +11 -6
- includes/views/edit.php +39 -0
- includes/views/main.php +70 -0
- languages/ss-fr_FR.mo +0 -0
- languages/ss-fr_FR.po +173 -0
- plugin.php +150 -66
- readme.txt +6 -3
admin.php
DELETED
@@ -1,181 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* This registers the settings field and adds empty array to the options table
|
4 |
-
*/
|
5 |
-
add_action('admin_init', 'register_ss_settings');
|
6 |
-
function register_ss_settings() {
|
7 |
-
register_setting(SS_SETTINGS_FIELD, SS_SETTINGS_FIELD);
|
8 |
-
add_option(SS_SETTINGS_FIELD, array(), '', 'yes');
|
9 |
-
}
|
10 |
-
|
11 |
-
/**
|
12 |
-
* This function adds our "Simple Sidebars" submenu item
|
13 |
-
*/
|
14 |
-
add_action('admin_menu', 'ss_settings_init', 15);
|
15 |
-
function ss_settings_init() {
|
16 |
-
|
17 |
-
add_submenu_page('genesis', __('Simple Sidebars','ss'), __('Simple Sidebars','ss'), 'manage_options', 'simple-sidebars', 'ss_settings_admin');
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
-
add_action('admin_init', 'ss_action_functions');
|
22 |
-
function ss_action_functions() {
|
23 |
-
|
24 |
-
if ( !isset( $_REQUEST['page'] ) || $_REQUEST['page'] != 'simple-sidebars' ) {
|
25 |
-
return;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* This section handles the data if a new sidebar is created
|
30 |
-
*/
|
31 |
-
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'create' ) {
|
32 |
-
ss_create_sidebar( $_POST['new_sidebar'] );
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* This section will handle the data if a sidebar is deleted
|
37 |
-
*/
|
38 |
-
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'delete' && isset( $_REQUEST['id'] ) ) {
|
39 |
-
ss_delete_sidebar( $_REQUEST['id'] );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* This section will handle the data if a sidebar is to be modified
|
44 |
-
*/
|
45 |
-
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' && !isset( $_REQUEST['id'] ) ) {
|
46 |
-
ss_edit_sidebar( $_POST['edit_sidebar'] );
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* This function is what actually gets output to the page.
|
52 |
-
* It handles the markup, builds the form, etc.
|
53 |
-
*/
|
54 |
-
function ss_settings_admin() { ?>
|
55 |
-
|
56 |
-
<div class="wrap">
|
57 |
-
|
58 |
-
<?php
|
59 |
-
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' ) :
|
60 |
-
|
61 |
-
$_sidebars = get_option( SS_SETTINGS_FIELD );
|
62 |
-
|
63 |
-
if ( array_key_exists( $_REQUEST['id'], (array)$_sidebars ) ) {
|
64 |
-
$_sidebar = stripslashes_deep( $_sidebars[$_REQUEST['id']] );
|
65 |
-
} else {
|
66 |
-
wp_die( __('Nice try, partner. But that sidebar doesn\'t exist. Click back and try again.', 'ss') );
|
67 |
-
}
|
68 |
-
|
69 |
-
?>
|
70 |
-
|
71 |
-
<?php screen_icon('themes'); ?>
|
72 |
-
<h2><?php _e('Edit Sidebar', 'ss'); ?></h2>
|
73 |
-
|
74 |
-
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&action=edit' ); ?>">
|
75 |
-
<?php wp_nonce_field('simple-sidebars-action_edit-sidebar'); ?>
|
76 |
-
<table class="form-table">
|
77 |
-
|
78 |
-
<tr class="form-field">
|
79 |
-
<th scope="row" valign="top"><label for="edit_sidebar[name]"><?php _e('Name', 'ss'); ?></label></th>
|
80 |
-
<td><input name="edit_sidebar[name]" id="edit_sidebar[name]" type="text" value="<?php echo esc_html( $_sidebar['name'] ); ?>" size="40" />
|
81 |
-
<p class="description"><?php _e('A recognizable name for your new sidebar widget area', 'ss'); ?></p></td>
|
82 |
-
</tr>
|
83 |
-
|
84 |
-
<tr class="form-field">
|
85 |
-
<th scope="row" valign="top"><label for="edit_sidebar[id]"><?php _e('ID', 'ss'); ?></label></th>
|
86 |
-
<td>
|
87 |
-
<input type="text" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" disabled="disabled" />
|
88 |
-
<input name="edit_sidebar[id]" id="edit_sidebar[id]" type="hidden" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" />
|
89 |
-
<p class="description"><?php _e('The unique ID is used to register the sidebar widget area (cannot be changed)', 'ss'); ?></p></td>
|
90 |
-
</tr>
|
91 |
-
|
92 |
-
<tr class="form-field">
|
93 |
-
<th scope="row" valign="top"><label for="edit_sidebar[description]"><?php _e('Description', 'ss'); ?></label></th>
|
94 |
-
<td><textarea name="edit_sidebar[description]" id="edit_sidebar[description]" rows="3" cols="50" style="width: 97%;"><?php echo esc_html( $_sidebar['description'] ); ?></textarea></td>
|
95 |
-
</tr>
|
96 |
-
|
97 |
-
</table>
|
98 |
-
|
99 |
-
<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php _e('Update', 'ss'); ?>" /></p>
|
100 |
-
|
101 |
-
</form>
|
102 |
-
|
103 |
-
<?php else : ?>
|
104 |
-
|
105 |
-
<?php screen_icon('themes'); ?>
|
106 |
-
<h2><?php _e('Genesis - Simple Sidebars', 'ss'); ?></h2>
|
107 |
-
|
108 |
-
<div id="col-container">
|
109 |
-
|
110 |
-
<div id="col-right">
|
111 |
-
<div class="col-wrap">
|
112 |
-
|
113 |
-
<h3><?php _e('Current Sidebars', 'ss'); ?></h3>
|
114 |
-
<table class="widefat tag fixed" cellspacing="0">
|
115 |
-
<thead>
|
116 |
-
<tr>
|
117 |
-
<th scope="col" id="name" class="manage-column column-name"><?php _e('Name', 'ss'); ?></th>
|
118 |
-
<th scope="col" class="manage-column column-slug"><?php _e('ID', 'ss'); ?></th>
|
119 |
-
<th scope="col" id="description" class="manage-column column-description"><?php _e('Description', 'ss'); ?></th>
|
120 |
-
</tr>
|
121 |
-
</thead>
|
122 |
-
|
123 |
-
<tfoot>
|
124 |
-
<tr>
|
125 |
-
<th scope="col" class="manage-column column-name"><?php _e('Name', 'ss'); ?></th>
|
126 |
-
<th scope="col" class="manage-column column-slug"><?php _e('ID', 'ss'); ?></th>
|
127 |
-
<th scope="col" class="manage-column column-description"><?php _e('Description', 'ss'); ?></th>
|
128 |
-
</tr>
|
129 |
-
</tfoot>
|
130 |
-
|
131 |
-
<tbody id="the-list" class="list:tag">
|
132 |
-
|
133 |
-
<?php ss_sidebar_table_rows(); ?>
|
134 |
-
|
135 |
-
</tbody>
|
136 |
-
</table>
|
137 |
-
|
138 |
-
</div>
|
139 |
-
</div><!-- /col-right -->
|
140 |
-
|
141 |
-
<div id="col-left">
|
142 |
-
<div class="col-wrap">
|
143 |
-
|
144 |
-
|
145 |
-
<div class="form-wrap">
|
146 |
-
<h3><?php _e('Add New Sidebar', 'ss'); ?></h3>
|
147 |
-
|
148 |
-
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&action=create' ); ?>">
|
149 |
-
<?php wp_nonce_field('simple-sidebars-action_create-sidebar'); ?>
|
150 |
-
|
151 |
-
<div class="form-field form-required">
|
152 |
-
<label for="sidebar-name"><?php _e('Name', 'ss'); ?></label>
|
153 |
-
<input name="new_sidebar[name]" id="sidebar-name" type="text" value="" size="40" aria-required="true" />
|
154 |
-
<p><?php _e('A recognizable name for your new sidebar widget area', 'ss'); ?></p>
|
155 |
-
</div>
|
156 |
-
|
157 |
-
<div class="form-field">
|
158 |
-
<label for="sidebar-id"><?php _e('ID', 'ss'); ?></label>
|
159 |
-
<input name="new_sidebar[id]" id="sidebar-id" type="text" value="" size="40" />
|
160 |
-
<p><?php _e('The unique ID is used to register the sidebar widget area', 'ss'); ?></p>
|
161 |
-
</div>
|
162 |
-
|
163 |
-
<div class="form-field">
|
164 |
-
<label for="sidebar-description"><?php _e('Description', 'ss'); ?></label>
|
165 |
-
<textarea name="new_sidebar[description]" id="sidebar-description" rows="5" cols="40"></textarea>
|
166 |
-
</div>
|
167 |
-
|
168 |
-
<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php _e('Add New Sidebar', 'ss'); ?>" /></p>
|
169 |
-
</form></div>
|
170 |
-
|
171 |
-
</div>
|
172 |
-
</div><!-- /col-left -->
|
173 |
-
|
174 |
-
</div><!-- /col-container -->
|
175 |
-
|
176 |
-
<?php endif; ?>
|
177 |
-
|
178 |
-
</div><!-- /wrap -->
|
179 |
-
|
180 |
-
<?php
|
181 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
functions.php
DELETED
@@ -1,189 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
function ss_sidebar_table_rows() {
|
3 |
-
global $wp_registered_sidebars;
|
4 |
-
|
5 |
-
$_sidebars = $wp_registered_sidebars;
|
6 |
-
|
7 |
-
$alt = true;
|
8 |
-
|
9 |
-
foreach ( (array)$_sidebars as $id => $info ) { ?>
|
10 |
-
|
11 |
-
<?php
|
12 |
-
$is_editable = isset( $info['editable'] ) && $info['editable'] ? true : false;
|
13 |
-
?>
|
14 |
-
|
15 |
-
<tr <?php if ( $alt ) { echo 'class="alternate"'; $alt = false; } else { $alt = true; } ?>>
|
16 |
-
<td class="name column-name">
|
17 |
-
<?php
|
18 |
-
if ( $is_editable ) {
|
19 |
-
printf( '<a class="row-title" href="%s" title="Edit %s">%s</a>', admin_url('admin.php?page=simple-sidebars&action=edit&id=' . esc_html( $id ) ), esc_html( $info['name'] ), esc_html( $info['name'] ) );
|
20 |
-
} else {
|
21 |
-
printf( '<strong class="row-title">%s</strong>', esc_html( $info['name'] ) );
|
22 |
-
}
|
23 |
-
?>
|
24 |
-
|
25 |
-
<?php if ( $is_editable ) : ?>
|
26 |
-
<br />
|
27 |
-
<div class="row-actions">
|
28 |
-
<span class="edit"><a href="<?php echo admin_url('admin.php?page=simple-sidebars&action=edit&id=' . esc_html( $id ) ); ?>"><?php _e('Edit', 'ss'); ?></a> | </span>
|
29 |
-
<span class="delete"><a class="delete-tag" href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=simple-sidebars&action=delete&id=' . esc_html( $id ) ), 'simple-sidebars-action_delete-sidebar' ); ?>"><?php _e('Delete', 'ss'); ?></a></span>
|
30 |
-
</div>
|
31 |
-
<?php endif; ?>
|
32 |
-
|
33 |
-
</td>
|
34 |
-
<td class="slug column-slug"><?php echo esc_html( $id ); ?></td>
|
35 |
-
<td class="description column-description"><?php echo esc_html( $info['description'] )?></td>
|
36 |
-
</tr>
|
37 |
-
|
38 |
-
<?php
|
39 |
-
}
|
40 |
-
|
41 |
-
}
|
42 |
-
|
43 |
-
function ss_create_sidebar( $args = array() ) {
|
44 |
-
|
45 |
-
if ( empty( $args['name'] ) || empty( $args['id'] ) ) {
|
46 |
-
wp_die( ss_error_message(1) );
|
47 |
-
exit;
|
48 |
-
}
|
49 |
-
|
50 |
-
// nonce verification
|
51 |
-
check_admin_referer('simple-sidebars-action_create-sidebar');
|
52 |
-
|
53 |
-
// WP changes a numeric sidebar id to sidebar-id which makes it inaccessible to the user
|
54 |
-
if ( is_numeric( $args['id'] ) )
|
55 |
-
$args['id'] = sanitize_title_with_dashes( $args['name'] );
|
56 |
-
|
57 |
-
$db = (array)get_option(SS_SETTINGS_FIELD);
|
58 |
-
$new = array(
|
59 |
-
sanitize_title_with_dashes( $args['id'] ) => array(
|
60 |
-
'name' => esc_html( $args['name'] ),
|
61 |
-
'description' => esc_html( $args['description'] )
|
62 |
-
)
|
63 |
-
);
|
64 |
-
|
65 |
-
if ( array_key_exists( $args['id'], $db ) ) {
|
66 |
-
wp_die( ss_error_message(2) );
|
67 |
-
exit;
|
68 |
-
}
|
69 |
-
|
70 |
-
$_sidebars = wp_parse_args( $new, $db );
|
71 |
-
|
72 |
-
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
73 |
-
wp_redirect( admin_url('admin.php?page=simple-sidebars&created=true') );
|
74 |
-
exit;
|
75 |
-
|
76 |
-
}
|
77 |
-
|
78 |
-
function ss_edit_sidebar( $args = array() ) {
|
79 |
-
|
80 |
-
if ( empty( $args['name'] ) || empty( $args['id'] ) ) {
|
81 |
-
wp_die( ss_error_message(3) );
|
82 |
-
exit;
|
83 |
-
}
|
84 |
-
|
85 |
-
// nonce verification
|
86 |
-
check_admin_referer('simple-sidebars-action_edit-sidebar');
|
87 |
-
|
88 |
-
// WP changes a numeric sidebar id to sidebar-id which makes it inaccessible to the user
|
89 |
-
if ( is_numeric( $args['id'] ) )
|
90 |
-
$args['id'] = sanitize_title_with_dashes( $args['name'] );
|
91 |
-
|
92 |
-
$db = (array)get_option(SS_SETTINGS_FIELD);
|
93 |
-
$new = array(
|
94 |
-
sanitize_title_with_dashes( $args['id'] ) => array(
|
95 |
-
'name' => esc_html( $args['name'] ),
|
96 |
-
'description' => esc_html( $args['description'] )
|
97 |
-
)
|
98 |
-
);
|
99 |
-
|
100 |
-
if ( !array_key_exists( $args['id'], $db ) ) {
|
101 |
-
wp_die( ss_error_message(3) );
|
102 |
-
exit;
|
103 |
-
}
|
104 |
-
|
105 |
-
$_sidebars = wp_parse_args( $new, $db );
|
106 |
-
|
107 |
-
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
108 |
-
wp_redirect( admin_url('admin.php?page=simple-sidebars&edited=true') );
|
109 |
-
exit;
|
110 |
-
|
111 |
-
}
|
112 |
-
|
113 |
-
function ss_delete_sidebar( $id = '' ) {
|
114 |
-
|
115 |
-
if ( empty( $id ) ) {
|
116 |
-
wp_die( ss_error_message(4) );
|
117 |
-
exit;
|
118 |
-
}
|
119 |
-
|
120 |
-
// nonce verification
|
121 |
-
check_admin_referer('simple-sidebars-action_delete-sidebar');
|
122 |
-
|
123 |
-
$_sidebars = (array)get_option( SS_SETTINGS_FIELD );
|
124 |
-
|
125 |
-
if ( !isset( $_sidebars[$id] ) ) {
|
126 |
-
wp_die( ss_error_message(4) );
|
127 |
-
exit;
|
128 |
-
}
|
129 |
-
|
130 |
-
unset( $_sidebars[$id] );
|
131 |
-
|
132 |
-
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
133 |
-
wp_redirect( admin_url('admin.php?page=simple-sidebars&deleted=true') );
|
134 |
-
exit;
|
135 |
-
|
136 |
-
}
|
137 |
-
|
138 |
-
function ss_error_message( $error = false ) {
|
139 |
-
|
140 |
-
if ( !$error ) return false;
|
141 |
-
|
142 |
-
switch( (int)$error ) {
|
143 |
-
|
144 |
-
case 1:
|
145 |
-
return __('Oops! Please choose a valid Name and ID for this sidebar', 'ss');
|
146 |
-
break;
|
147 |
-
case 2:
|
148 |
-
return __('Oops! That sidebar ID already exists', 'ss');
|
149 |
-
break;
|
150 |
-
case 3:
|
151 |
-
return __('Oops! You are trying to edit a sidebar that does not exist, or is not editable', 'ss');
|
152 |
-
break;
|
153 |
-
case 4:
|
154 |
-
return __('Oops! You are trying to delete a sidebar that does not exist, or cannot be deleted', 'ss');
|
155 |
-
break;
|
156 |
-
default:
|
157 |
-
return __('Oops! Something went wrong. Try again.', 'ss');
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
add_action('admin_notices', 'ss_success_message');
|
164 |
-
function ss_success_message() {
|
165 |
-
|
166 |
-
if ( !isset( $_REQUEST['page'] ) || $_REQUEST['page'] != 'simple-sidebars' ) {
|
167 |
-
return;
|
168 |
-
}
|
169 |
-
|
170 |
-
$format = '<div id="message" class="updated"><p><strong>%s</strong></p></div>';
|
171 |
-
|
172 |
-
if ( isset( $_REQUEST['created'] ) && $_REQUEST['created'] === 'true' ) {
|
173 |
-
printf( $format, __('New sidebar successfully created!', 'ss') );
|
174 |
-
return;
|
175 |
-
}
|
176 |
-
|
177 |
-
if ( isset( $_REQUEST['edited'] ) && $_REQUEST['edited'] === 'true' ) {
|
178 |
-
printf( $format, __('Sidebar successfully edited!', 'ss') );
|
179 |
-
return;
|
180 |
-
}
|
181 |
-
|
182 |
-
if ( isset( $_REQUEST['deleted'] ) && $_REQUEST['deleted'] === 'true' ) {
|
183 |
-
printf( $format, __('Sidebar successfully deleted.', 'ss') );
|
184 |
-
return;
|
185 |
-
}
|
186 |
-
|
187 |
-
return;
|
188 |
-
|
189 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/admin.php
ADDED
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Controls the creation, deletion, and editing of Simple Sidebar.
|
4 |
+
*
|
5 |
+
* @author StudioPress
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Registers a new admin page, providing content and corresponding menu item
|
10 |
+
* for the Genesis Simple Sidebars plugin.
|
11 |
+
*
|
12 |
+
* @since 1.0.0
|
13 |
+
*/
|
14 |
+
class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Create an admin menu item and settings page.
|
18 |
+
*
|
19 |
+
* @since 1.0.0
|
20 |
+
*
|
21 |
+
* @uses Genesis_Admin::create() Register the admin page
|
22 |
+
*
|
23 |
+
* @see Genesis_Admin_Import_Export::actions() Handle creating, editing, and deleting sidebars.
|
24 |
+
*/
|
25 |
+
public function __construct() {
|
26 |
+
|
27 |
+
$page_id = 'simple-sidebars';
|
28 |
+
|
29 |
+
$menu_ops = array(
|
30 |
+
'submenu' => array(
|
31 |
+
'parent_slug' => 'genesis',
|
32 |
+
'page_title' => __( 'Genesis - Simple Sidebars', 'ss' ),
|
33 |
+
'menu_title' => __( 'Simple Sidebars', 'ss' )
|
34 |
+
)
|
35 |
+
);
|
36 |
+
|
37 |
+
/** Empty, as we'll be building the page manually */
|
38 |
+
$page_ops = array();
|
39 |
+
|
40 |
+
$settings_field = SS_SETTINGS_FIELD;
|
41 |
+
|
42 |
+
$this->create( $page_id, $menu_ops, $page_ops, $settings_field );
|
43 |
+
|
44 |
+
/** Simpe Sidebar actions (create, edit, or delete) */
|
45 |
+
add_action( 'admin_init', array( $this, 'actions' ) );
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Callback for displaying the Simple Sidebars admin page.
|
51 |
+
*
|
52 |
+
* Echoes out HTML.
|
53 |
+
*
|
54 |
+
* @since 1.0.0
|
55 |
+
*
|
56 |
+
*/
|
57 |
+
public function admin() {
|
58 |
+
|
59 |
+
$_sidebars = get_option( $this->settings_field );
|
60 |
+
|
61 |
+
echo '<div class="wrap">';
|
62 |
+
|
63 |
+
if ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] )
|
64 |
+
require_once( SS_PLUGIN_DIR . '/includes/views/edit.php' );
|
65 |
+
else
|
66 |
+
require_once( SS_PLUGIN_DIR . '/includes/views/main.php' );
|
67 |
+
|
68 |
+
echo '</div>';
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Display sidebar table rows.
|
74 |
+
*
|
75 |
+
* Displays table rows of sidebars for viewing and editing on the main admin page.
|
76 |
+
*
|
77 |
+
* @since 1.0.0
|
78 |
+
*
|
79 |
+
*/
|
80 |
+
public function table_rows() {
|
81 |
+
|
82 |
+
global $wp_registered_sidebars;
|
83 |
+
|
84 |
+
$_sidebars = $wp_registered_sidebars;
|
85 |
+
|
86 |
+
$alt = true;
|
87 |
+
|
88 |
+
foreach ( (array) $_sidebars as $id => $info ) :
|
89 |
+
|
90 |
+
$is_editable = isset( $info['editable'] ) && $info['editable'] ? true : false;
|
91 |
+
|
92 |
+
?>
|
93 |
+
|
94 |
+
<tr <?php if ( $alt ) { echo 'class="alternate"'; $alt = false; } else { $alt = true; } ?>>
|
95 |
+
<td class="name column-name">
|
96 |
+
<?php
|
97 |
+
if ( $is_editable ) {
|
98 |
+
printf( '<a class="row-title" href="%s" title="Edit %s">%s</a>', admin_url('admin.php?page=simple-sidebars&action=edit&id=' . esc_html( $id ) ), esc_html( $info['name'] ), esc_html( $info['name'] ) );
|
99 |
+
} else {
|
100 |
+
printf( '<strong class="row-title">%s</strong>', esc_html( $info['name'] ) );
|
101 |
+
}
|
102 |
+
?>
|
103 |
+
|
104 |
+
<?php if ( $is_editable ) : ?>
|
105 |
+
<br />
|
106 |
+
<div class="row-actions">
|
107 |
+
<span class="edit"><a href="<?php echo admin_url('admin.php?page=simple-sidebars&action=edit&id=' . esc_html( $id ) ); ?>"><?php _e('Edit', 'ss'); ?></a> | </span>
|
108 |
+
<span class="delete"><a class="delete-tag" href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=simple-sidebars&action=delete&id=' . esc_html( $id ) ), 'simple-sidebars-action_delete-sidebar' ); ?>"><?php _e('Delete', 'ss'); ?></a></span>
|
109 |
+
</div>
|
110 |
+
<?php endif; ?>
|
111 |
+
|
112 |
+
</td>
|
113 |
+
<td class="slug column-slug"><?php echo esc_html( $id ); ?></td>
|
114 |
+
<td class="description column-description"><?php echo esc_html( $info['description'] )?></td>
|
115 |
+
</tr>
|
116 |
+
|
117 |
+
<?php
|
118 |
+
endforeach;
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Action handler.
|
124 |
+
*
|
125 |
+
* Depending on what action was intended by the user, this method calls the appropriate action method.
|
126 |
+
*
|
127 |
+
* @since 1.0.0
|
128 |
+
*
|
129 |
+
*/
|
130 |
+
public function actions() {
|
131 |
+
|
132 |
+
if ( ! genesis_is_menu_page( 'simple-sidebars' ) )
|
133 |
+
return;
|
134 |
+
|
135 |
+
/**
|
136 |
+
* This section handles the data if a new sidebar is created
|
137 |
+
*/
|
138 |
+
if ( isset( $_REQUEST['action'] ) && 'create' == $_REQUEST['action'] ) {
|
139 |
+
$this->create_sidebar( $_POST['new_sidebar'] );
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* This section will handle the data if a sidebar is deleted
|
144 |
+
*/
|
145 |
+
if ( isset( $_REQUEST['action'] ) && 'delete' == $_REQUEST['action'] && isset( $_REQUEST['id'] ) ) {
|
146 |
+
$this->delete_sidebar( $_REQUEST['id'] );
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* This section will handle the data if a sidebar is to be modified
|
151 |
+
*/
|
152 |
+
if ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] && ! isset( $_REQUEST['id'] ) ) {
|
153 |
+
$this->edit_sidebar( $_POST['edit_sidebar'] );
|
154 |
+
}
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Add custom notices that display when you successfully create, edit, or delete a sidebar.
|
160 |
+
*
|
161 |
+
* @since 1.0.0
|
162 |
+
*
|
163 |
+
* @return null Returns null if not on the correct admin page.
|
164 |
+
*/
|
165 |
+
public function notices() {
|
166 |
+
|
167 |
+
if ( ! genesis_is_menu_page( 'simple-sidebars' ) )
|
168 |
+
return;
|
169 |
+
|
170 |
+
$pattern = '<div id="message" class="updated"><p><strong>%s</strong></p></div>';
|
171 |
+
|
172 |
+
if ( isset( $_REQUEST['created'] ) && 'true' === $_REQUEST['created'] ) {
|
173 |
+
printf( $pattern, __( 'New sidebar successfully created!', 'ss' ) );
|
174 |
+
return;
|
175 |
+
}
|
176 |
+
|
177 |
+
if ( isset( $_REQUEST['edited'] ) && 'true' === $_REQUEST['edited'] ) {
|
178 |
+
printf( $pattern, __( 'Sidebar successfully edited!', 'ss' ) );
|
179 |
+
return;
|
180 |
+
}
|
181 |
+
|
182 |
+
if ( isset( $_REQUEST['deleted'] ) && 'true' === $_REQUEST['deleted'] ) {
|
183 |
+
printf( $pattern, __( 'Sidebar successfully deleted.', 'ss' ) );
|
184 |
+
return;
|
185 |
+
}
|
186 |
+
|
187 |
+
return;
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Create a sidebar.
|
193 |
+
*
|
194 |
+
* @since 1.0.0
|
195 |
+
*
|
196 |
+
*/
|
197 |
+
protected function create_sidebar( $args = array() ) {
|
198 |
+
|
199 |
+
if ( empty( $args['name'] ) || empty( $args['id'] ) ) {
|
200 |
+
wp_die( $this->error( 1 ) );
|
201 |
+
exit;
|
202 |
+
}
|
203 |
+
|
204 |
+
// nonce verification
|
205 |
+
check_admin_referer( 'simple-sidebars-action_create-sidebar' );
|
206 |
+
|
207 |
+
// WP changes a numeric sidebar id to sidebar-id which makes it inaccessible to the user
|
208 |
+
if ( is_numeric( $args['id'] ) )
|
209 |
+
$args['id'] = sanitize_title_with_dashes( $args['name'] );
|
210 |
+
|
211 |
+
$db = (array) get_option( SS_SETTINGS_FIELD );
|
212 |
+
$new = array(
|
213 |
+
sanitize_title_with_dashes( $args['id'] ) => array(
|
214 |
+
'name' => esc_html( $args['name'] ),
|
215 |
+
'description' => esc_html( $args['description'] )
|
216 |
+
)
|
217 |
+
);
|
218 |
+
|
219 |
+
if ( array_key_exists( $args['id'], $db ) ) {
|
220 |
+
wp_die( $this->error( 2 ) );
|
221 |
+
exit;
|
222 |
+
}
|
223 |
+
|
224 |
+
$_sidebars = wp_parse_args( $new, $db );
|
225 |
+
|
226 |
+
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
227 |
+
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&created=true' ) );
|
228 |
+
exit;
|
229 |
+
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Edit a sidebar.
|
234 |
+
*
|
235 |
+
* @since 1.0.0
|
236 |
+
*
|
237 |
+
*/
|
238 |
+
protected function edit_sidebar( $args = array() ) {
|
239 |
+
|
240 |
+
if ( empty( $args['name'] ) || empty( $args['id'] ) ) {
|
241 |
+
wp_die( $this->error( 3 ) );
|
242 |
+
exit;
|
243 |
+
}
|
244 |
+
|
245 |
+
// nonce verification
|
246 |
+
check_admin_referer( 'simple-sidebars-action_edit-sidebar' );
|
247 |
+
|
248 |
+
// WP changes a numeric sidebar id to sidebar-id which makes it inaccessible to the user
|
249 |
+
if ( is_numeric( $args['id'] ) )
|
250 |
+
$args['id'] = sanitize_title_with_dashes( $args['name'] );
|
251 |
+
|
252 |
+
$db = (array) get_option( SS_SETTINGS_FIELD );
|
253 |
+
$new = array(
|
254 |
+
sanitize_title_with_dashes( $args['id'] ) => array(
|
255 |
+
'name' => esc_html( $args['name'] ),
|
256 |
+
'description' => esc_html( $args['description'] )
|
257 |
+
)
|
258 |
+
);
|
259 |
+
|
260 |
+
if ( ! array_key_exists( $args['id'], $db ) ) {
|
261 |
+
wp_die( $this->error( 3 ) );
|
262 |
+
exit;
|
263 |
+
}
|
264 |
+
|
265 |
+
$_sidebars = wp_parse_args( $new, $db );
|
266 |
+
|
267 |
+
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
268 |
+
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&edited=true' ) );
|
269 |
+
exit;
|
270 |
+
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Delete a sidebar.
|
275 |
+
*
|
276 |
+
* @since 1.0.0
|
277 |
+
*
|
278 |
+
*/
|
279 |
+
protected function delete_sidebar( $id = '' ) {
|
280 |
+
|
281 |
+
if ( empty( $id ) ) {
|
282 |
+
wp_die( $this->error( 4 ) );
|
283 |
+
exit;
|
284 |
+
}
|
285 |
+
|
286 |
+
// nonce verification
|
287 |
+
check_admin_referer( 'simple-sidebars-action_delete-sidebar' );
|
288 |
+
|
289 |
+
$_sidebars = (array) get_option( SS_SETTINGS_FIELD );
|
290 |
+
|
291 |
+
if ( ! isset( $_sidebars[$id] ) ) {
|
292 |
+
wp_die( $this->error( 4 ) );
|
293 |
+
exit;
|
294 |
+
}
|
295 |
+
|
296 |
+
unset( $_sidebars[$id] );
|
297 |
+
|
298 |
+
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
299 |
+
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&deleted=true' ) );
|
300 |
+
exit;
|
301 |
+
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Returns an error message by ID.
|
306 |
+
*
|
307 |
+
* @since 1.0.0
|
308 |
+
*
|
309 |
+
* @return string Returns an error string based on an error ID.
|
310 |
+
*/
|
311 |
+
protected function error( $error = false ) {
|
312 |
+
|
313 |
+
if ( ! $error )
|
314 |
+
return false;
|
315 |
+
|
316 |
+
switch( (int) $error ) {
|
317 |
+
|
318 |
+
case 1:
|
319 |
+
return __( 'Oops! Please choose a valid Name and ID for this sidebar', 'ss' );
|
320 |
+
break;
|
321 |
+
case 2:
|
322 |
+
return __( 'Oops! That sidebar ID already exists', 'ss' );
|
323 |
+
break;
|
324 |
+
case 3:
|
325 |
+
return __( 'Oops! You are trying to edit a sidebar that does not exist, or is not editable', 'ss' );
|
326 |
+
break;
|
327 |
+
case 4:
|
328 |
+
return __( 'Oops! You are trying to delete a sidebar that does not exist, or cannot be deleted', 'ss' );
|
329 |
+
break;
|
330 |
+
default:
|
331 |
+
return __( 'Oops! Something went wrong. Try again.', 'ss' );
|
332 |
+
|
333 |
+
}
|
334 |
+
|
335 |
+
}
|
336 |
+
|
337 |
+
}
|
338 |
+
|
339 |
+
add_action( 'genesis_admin_menu', 'simplesidebars_settings_menu' );
|
340 |
+
/**
|
341 |
+
* Instantiate the class to create the menu.
|
342 |
+
*
|
343 |
+
* @since 1.0.0
|
344 |
+
*/
|
345 |
+
function simplesidebars_settings_menu() {
|
346 |
+
|
347 |
+
new Genesis_Simple_Sidebars_Admin;
|
348 |
+
|
349 |
+
}
|
inpost.php → includes/inpost.php
RENAMED
@@ -4,20 +4,26 @@
|
|
4 |
* so that users can choose what sidebar to use.
|
5 |
*/
|
6 |
add_action('admin_menu', 'ss_add_inpost_metabox');
|
7 |
-
function ss_add_inpost_metabox() {
|
|
|
8 |
foreach ( (array)get_post_types( array( 'public' => true ) ) as $type ) {
|
|
|
9 |
if ( post_type_supports( $type, 'genesis-simple-sidebars' ) || $type == 'post' || $type == 'page' ) {
|
10 |
add_meta_box('ss_inpost_metabox', __('Sidebar Selection', 'ss'), 'ss_inpost_metabox', $type, 'side', 'low');
|
11 |
-
}
|
|
|
12 |
}
|
|
|
13 |
}
|
14 |
|
15 |
-
function ss_inpost_metabox() {
|
|
|
16 |
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
|
|
17 |
?>
|
18 |
-
|
19 |
<input type="hidden" name="ss_inpost_nonce" value="<?php echo wp_create_nonce(plugin_basename(__FILE__)); ?>" />
|
20 |
-
|
21 |
<p>
|
22 |
<label class="howto" for="_ss_sidebar"><span><?php _e('Primary Sidebar', 'ss'); ?><span></label>
|
23 |
<select name="_ss_sidebar" id="_ss_sidebar" style="width: 99%">
|
@@ -31,7 +37,7 @@ function ss_inpost_metabox() {
|
|
31 |
</p>
|
32 |
<?php
|
33 |
// don't show the option if there are no 3 column layouts registered
|
34 |
-
if ( !ss_has_3_column_layouts() )
|
35 |
return;
|
36 |
?>
|
37 |
<p>
|
@@ -45,8 +51,8 @@ function ss_inpost_metabox() {
|
|
45 |
?>
|
46 |
</select>
|
47 |
</p>
|
48 |
-
|
49 |
-
<?php
|
50 |
}
|
51 |
|
52 |
/**
|
@@ -54,11 +60,11 @@ function ss_inpost_metabox() {
|
|
54 |
*/
|
55 |
add_action('save_post', 'ss_inpost_metabox_save', 1, 2);
|
56 |
function ss_inpost_metabox_save( $post_id, $post ) {
|
57 |
-
|
58 |
// verify the nonce
|
59 |
if ( !isset($_POST['ss_inpost_nonce']) || !wp_verify_nonce( $_POST['ss_inpost_nonce'], plugin_basename(__FILE__) ) )
|
60 |
return $post->ID;
|
61 |
-
|
62 |
// don't try to save the data under autosave, ajax, or future post.
|
63 |
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
|
64 |
if ( defined('DOING_AJAX') && DOING_AJAX ) return;
|
@@ -67,17 +73,17 @@ function ss_inpost_metabox_save( $post_id, $post ) {
|
|
67 |
// is the user allowed to edit the post or page?
|
68 |
if ( ( 'page' == $_POST['post_type'] && !current_user_can('edit_page', $post->ID) ) || !current_user_can('edit_post', $post->ID ) )
|
69 |
return $post->ID;
|
70 |
-
|
71 |
$_sidebars = array(
|
72 |
'_ss_sidebar' => $_POST['_ss_sidebar'],
|
73 |
'_ss_sidebar_alt' => $_POST['_ss_sidebar_alt']
|
74 |
);
|
75 |
-
|
76 |
// store the custom fields
|
77 |
foreach ( $_sidebars as $key => $value ) {
|
78 |
-
|
79 |
if ( $post->post_type == 'revision' ) return; // don't try to store data during revision save
|
80 |
-
|
81 |
if ( $value ) {
|
82 |
// save/update
|
83 |
update_post_meta($post->ID, $key, $value);
|
@@ -87,5 +93,5 @@ function ss_inpost_metabox_save( $post_id, $post ) {
|
|
87 |
}
|
88 |
|
89 |
}
|
90 |
-
|
91 |
}
|
4 |
* so that users can choose what sidebar to use.
|
5 |
*/
|
6 |
add_action('admin_menu', 'ss_add_inpost_metabox');
|
7 |
+
function ss_add_inpost_metabox() {
|
8 |
+
|
9 |
foreach ( (array)get_post_types( array( 'public' => true ) ) as $type ) {
|
10 |
+
|
11 |
if ( post_type_supports( $type, 'genesis-simple-sidebars' ) || $type == 'post' || $type == 'page' ) {
|
12 |
add_meta_box('ss_inpost_metabox', __('Sidebar Selection', 'ss'), 'ss_inpost_metabox', $type, 'side', 'low');
|
13 |
+
}
|
14 |
+
|
15 |
}
|
16 |
+
|
17 |
}
|
18 |
|
19 |
+
function ss_inpost_metabox() {
|
20 |
+
|
21 |
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
22 |
+
|
23 |
?>
|
24 |
+
|
25 |
<input type="hidden" name="ss_inpost_nonce" value="<?php echo wp_create_nonce(plugin_basename(__FILE__)); ?>" />
|
26 |
+
|
27 |
<p>
|
28 |
<label class="howto" for="_ss_sidebar"><span><?php _e('Primary Sidebar', 'ss'); ?><span></label>
|
29 |
<select name="_ss_sidebar" id="_ss_sidebar" style="width: 99%">
|
37 |
</p>
|
38 |
<?php
|
39 |
// don't show the option if there are no 3 column layouts registered
|
40 |
+
if ( ! ss_has_3_column_layouts() )
|
41 |
return;
|
42 |
?>
|
43 |
<p>
|
51 |
?>
|
52 |
</select>
|
53 |
</p>
|
54 |
+
|
55 |
+
<?php
|
56 |
}
|
57 |
|
58 |
/**
|
60 |
*/
|
61 |
add_action('save_post', 'ss_inpost_metabox_save', 1, 2);
|
62 |
function ss_inpost_metabox_save( $post_id, $post ) {
|
63 |
+
|
64 |
// verify the nonce
|
65 |
if ( !isset($_POST['ss_inpost_nonce']) || !wp_verify_nonce( $_POST['ss_inpost_nonce'], plugin_basename(__FILE__) ) )
|
66 |
return $post->ID;
|
67 |
+
|
68 |
// don't try to save the data under autosave, ajax, or future post.
|
69 |
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
|
70 |
if ( defined('DOING_AJAX') && DOING_AJAX ) return;
|
73 |
// is the user allowed to edit the post or page?
|
74 |
if ( ( 'page' == $_POST['post_type'] && !current_user_can('edit_page', $post->ID) ) || !current_user_can('edit_post', $post->ID ) )
|
75 |
return $post->ID;
|
76 |
+
|
77 |
$_sidebars = array(
|
78 |
'_ss_sidebar' => $_POST['_ss_sidebar'],
|
79 |
'_ss_sidebar_alt' => $_POST['_ss_sidebar_alt']
|
80 |
);
|
81 |
+
|
82 |
// store the custom fields
|
83 |
foreach ( $_sidebars as $key => $value ) {
|
84 |
+
|
85 |
if ( $post->post_type == 'revision' ) return; // don't try to store data during revision save
|
86 |
+
|
87 |
if ( $value ) {
|
88 |
// save/update
|
89 |
update_post_meta($post->ID, $key, $value);
|
93 |
}
|
94 |
|
95 |
}
|
96 |
+
|
97 |
}
|
term.php → includes/term.php
RENAMED
@@ -5,26 +5,31 @@
|
|
5 |
* are passed via the hook so that we can use them.
|
6 |
*/
|
7 |
function ss_term_edit_init() {
|
|
|
8 |
$taxonomies = ss_get_taxonomies();
|
9 |
-
|
|
|
|
|
10 |
foreach( $taxonomies as $tax )
|
11 |
add_action( "{$tax}_edit_form", 'ss_term_sidebar', 9, 2 );
|
|
|
12 |
}
|
|
|
13 |
}
|
14 |
|
15 |
function ss_term_sidebar($tag, $taxonomy) {
|
16 |
-
|
17 |
// Merge Defaults to prevent notices
|
18 |
$tag->meta = wp_parse_args( $tag->meta, array( '_ss_sidebar' => '', '_ss_sidebar_alt' => '' ) );
|
19 |
|
20 |
// Pull custom sidebars
|
21 |
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
22 |
-
|
23 |
?>
|
24 |
|
25 |
<h3><?php _e('Sidebar Options', 'ss'); ?></h3>
|
26 |
<table class="form-table">
|
27 |
-
|
28 |
<tr class="form-field">
|
29 |
<th scope="row" valign="top"><label for="meta[_ss_sidebar]"><?php _e('Primary Sidebar', 'ss'); ?></label></th>
|
30 |
<td>
|
@@ -41,7 +46,7 @@ function ss_term_sidebar($tag, $taxonomy) {
|
|
41 |
<?php
|
42 |
// don't show the option if there are no 3 column layouts registered
|
43 |
if ( ss_has_3_column_layouts() ) {
|
44 |
-
?>
|
45 |
<tr class="form-field">
|
46 |
<th scope="row" valign="top"><label for="meta[_ss_sidebar_alt]"><?php _e('Secondary Sidebar', 'ss'); ?></label></th>
|
47 |
<td>
|
@@ -59,6 +64,6 @@ function ss_term_sidebar($tag, $taxonomy) {
|
|
59 |
}
|
60 |
?>
|
61 |
</table>
|
62 |
-
|
63 |
<?php
|
64 |
}
|
5 |
* are passed via the hook so that we can use them.
|
6 |
*/
|
7 |
function ss_term_edit_init() {
|
8 |
+
|
9 |
$taxonomies = ss_get_taxonomies();
|
10 |
+
|
11 |
+
if ( ! empty( $taxonomies ) && is_admin() && is_array( $taxonomies ) ) {
|
12 |
+
|
13 |
foreach( $taxonomies as $tax )
|
14 |
add_action( "{$tax}_edit_form", 'ss_term_sidebar', 9, 2 );
|
15 |
+
|
16 |
}
|
17 |
+
|
18 |
}
|
19 |
|
20 |
function ss_term_sidebar($tag, $taxonomy) {
|
21 |
+
|
22 |
// Merge Defaults to prevent notices
|
23 |
$tag->meta = wp_parse_args( $tag->meta, array( '_ss_sidebar' => '', '_ss_sidebar_alt' => '' ) );
|
24 |
|
25 |
// Pull custom sidebars
|
26 |
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
27 |
+
|
28 |
?>
|
29 |
|
30 |
<h3><?php _e('Sidebar Options', 'ss'); ?></h3>
|
31 |
<table class="form-table">
|
32 |
+
|
33 |
<tr class="form-field">
|
34 |
<th scope="row" valign="top"><label for="meta[_ss_sidebar]"><?php _e('Primary Sidebar', 'ss'); ?></label></th>
|
35 |
<td>
|
46 |
<?php
|
47 |
// don't show the option if there are no 3 column layouts registered
|
48 |
if ( ss_has_3_column_layouts() ) {
|
49 |
+
?>
|
50 |
<tr class="form-field">
|
51 |
<th scope="row" valign="top"><label for="meta[_ss_sidebar_alt]"><?php _e('Secondary Sidebar', 'ss'); ?></label></th>
|
52 |
<td>
|
64 |
}
|
65 |
?>
|
66 |
</table>
|
67 |
+
|
68 |
<?php
|
69 |
}
|
includes/views/edit.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( array_key_exists( $_REQUEST['id'], (array) $_sidebars ) ) {
|
3 |
+
$_sidebar = stripslashes_deep( $_sidebars[$_REQUEST['id']] );
|
4 |
+
} else {
|
5 |
+
wp_die( __( 'Nice try, partner. But that sidebar doesn\'t exist. Click back and try again.', 'ss' ) );
|
6 |
+
}
|
7 |
+
|
8 |
+
screen_icon('themes'); ?>
|
9 |
+
<h2><?php _e('Edit Sidebar', 'ss'); ?></h2>
|
10 |
+
|
11 |
+
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&action=edit' ); ?>">
|
12 |
+
<?php wp_nonce_field('simple-sidebars-action_edit-sidebar'); ?>
|
13 |
+
|
14 |
+
<table class="form-table">
|
15 |
+
|
16 |
+
<tr class="form-field">
|
17 |
+
<th scope="row" valign="top"><label for="edit_sidebar[name]"><?php _e('Name', 'ss'); ?></label></th>
|
18 |
+
<td><input name="edit_sidebar[name]" id="edit_sidebar[name]" type="text" value="<?php echo esc_html( $_sidebar['name'] ); ?>" size="40" />
|
19 |
+
<p class="description"><?php _e('A recognizable name for your new sidebar widget area', 'ss'); ?></p></td>
|
20 |
+
</tr>
|
21 |
+
|
22 |
+
<tr class="form-field">
|
23 |
+
<th scope="row" valign="top"><label for="edit_sidebar[id]"><?php _e('ID', 'ss'); ?></label></th>
|
24 |
+
<td>
|
25 |
+
<input type="text" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" disabled="disabled" />
|
26 |
+
<input name="edit_sidebar[id]" id="edit_sidebar[id]" type="hidden" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" />
|
27 |
+
<p class="description"><?php _e('The unique ID is used to register the sidebar widget area (cannot be changed)', 'ss'); ?></p></td>
|
28 |
+
</tr>
|
29 |
+
|
30 |
+
<tr class="form-field">
|
31 |
+
<th scope="row" valign="top"><label for="edit_sidebar[description]"><?php _e('Description', 'ss'); ?></label></th>
|
32 |
+
<td><textarea name="edit_sidebar[description]" id="edit_sidebar[description]" rows="3" cols="50" style="width: 97%;"><?php echo esc_html( $_sidebar['description'] ); ?></textarea></td>
|
33 |
+
</tr>
|
34 |
+
|
35 |
+
</table>
|
36 |
+
|
37 |
+
<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php _e('Update', 'ss'); ?>" /></p>
|
38 |
+
|
39 |
+
</form>
|
includes/views/main.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php screen_icon('themes'); ?>
|
2 |
+
<h2><?php _e('Genesis - Simple Sidebars', 'ss'); ?></h2>
|
3 |
+
|
4 |
+
<div id="col-container">
|
5 |
+
|
6 |
+
<div id="col-right">
|
7 |
+
<div class="col-wrap">
|
8 |
+
|
9 |
+
<h3><?php _e('Current Sidebars', 'ss'); ?></h3>
|
10 |
+
<table class="widefat tag fixed" cellspacing="0">
|
11 |
+
<thead>
|
12 |
+
<tr>
|
13 |
+
<th scope="col" id="name" class="manage-column column-name"><?php _e('Name', 'ss'); ?></th>
|
14 |
+
<th scope="col" class="manage-column column-slug"><?php _e('ID', 'ss'); ?></th>
|
15 |
+
<th scope="col" id="description" class="manage-column column-description"><?php _e('Description', 'ss'); ?></th>
|
16 |
+
</tr>
|
17 |
+
</thead>
|
18 |
+
|
19 |
+
<tfoot>
|
20 |
+
<tr>
|
21 |
+
<th scope="col" class="manage-column column-name"><?php _e('Name', 'ss'); ?></th>
|
22 |
+
<th scope="col" class="manage-column column-slug"><?php _e('ID', 'ss'); ?></th>
|
23 |
+
<th scope="col" class="manage-column column-description"><?php _e('Description', 'ss'); ?></th>
|
24 |
+
</tr>
|
25 |
+
</tfoot>
|
26 |
+
|
27 |
+
<tbody id="the-list" class="list:tag">
|
28 |
+
|
29 |
+
<?php $this->table_rows(); ?>
|
30 |
+
|
31 |
+
</tbody>
|
32 |
+
</table>
|
33 |
+
|
34 |
+
</div>
|
35 |
+
</div><!-- /col-right -->
|
36 |
+
|
37 |
+
<div id="col-left">
|
38 |
+
<div class="col-wrap">
|
39 |
+
|
40 |
+
|
41 |
+
<div class="form-wrap">
|
42 |
+
<h3><?php _e('Add New Sidebar', 'ss'); ?></h3>
|
43 |
+
|
44 |
+
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&action=create' ); ?>">
|
45 |
+
<?php wp_nonce_field('simple-sidebars-action_create-sidebar'); ?>
|
46 |
+
|
47 |
+
<div class="form-field form-required">
|
48 |
+
<label for="sidebar-name"><?php _e('Name', 'ss'); ?></label>
|
49 |
+
<input name="new_sidebar[name]" id="sidebar-name" type="text" value="" size="40" aria-required="true" />
|
50 |
+
<p><?php _e('A recognizable name for your new sidebar widget area', 'ss'); ?></p>
|
51 |
+
</div>
|
52 |
+
|
53 |
+
<div class="form-field">
|
54 |
+
<label for="sidebar-id"><?php _e('ID', 'ss'); ?></label>
|
55 |
+
<input name="new_sidebar[id]" id="sidebar-id" type="text" value="" size="40" />
|
56 |
+
<p><?php _e('The unique ID is used to register the sidebar widget area', 'ss'); ?></p>
|
57 |
+
</div>
|
58 |
+
|
59 |
+
<div class="form-field">
|
60 |
+
<label for="sidebar-description"><?php _e('Description', 'ss'); ?></label>
|
61 |
+
<textarea name="new_sidebar[description]" id="sidebar-description" rows="5" cols="40"></textarea>
|
62 |
+
</div>
|
63 |
+
|
64 |
+
<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php _e('Add New Sidebar', 'ss'); ?>" /></p>
|
65 |
+
</form></div>
|
66 |
+
|
67 |
+
</div>
|
68 |
+
</div><!-- /col-left -->
|
69 |
+
|
70 |
+
</div><!-- /col-container -->
|
languages/ss-fr_FR.mo
ADDED
Binary file
|
languages/ss-fr_FR.po
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# SOME DESCRIPTIVE TITLE.
|
2 |
+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
3 |
+
# This file is distributed under the same license as the PACKAGE package.
|
4 |
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
5 |
+
#
|
6 |
+
msgid ""
|
7 |
+
msgstr ""
|
8 |
+
"Project-Id-Version: Simple Sidebar\n"
|
9 |
+
"Report-Msgid-Bugs-To: \n"
|
10 |
+
"POT-Creation-Date: 2011-08-06 21:23-0300\n"
|
11 |
+
"PO-Revision-Date: 2012-12-03 08:27+0100\n"
|
12 |
+
"Last-Translator: gregoire noyelle <hello@gregoirenoyelle.com>\n"
|
13 |
+
"Language-Team: Grégoire Noyelle <hello@gregoirenoyelle.com>\n"
|
14 |
+
"MIME-Version: 1.0\n"
|
15 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
16 |
+
"Content-Transfer-Encoding: 8bit\n"
|
17 |
+
"Plural-Forms: nplurals=2;plural=n>1;\n"
|
18 |
+
"Language: French\n"
|
19 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
20 |
+
"X-Generator: Poedit 1.5.4\n"
|
21 |
+
|
22 |
+
#: admin.php:17
|
23 |
+
msgid "Simple Sidebars"
|
24 |
+
msgstr "Barre latérale"
|
25 |
+
|
26 |
+
#: admin.php:66
|
27 |
+
msgid ""
|
28 |
+
"Nice try, partner. But that sidebar doesn't exist. Click back and try again."
|
29 |
+
msgstr ""
|
30 |
+
"Chouette essai. Mais cette barre latérale n'existe pas. Merci de revenir en "
|
31 |
+
"arrière et d'essayer à nouveau"
|
32 |
+
|
33 |
+
#: admin.php:72
|
34 |
+
msgid "Edit Sidebar"
|
35 |
+
msgstr "Editer la Barre Latérale"
|
36 |
+
|
37 |
+
#: admin.php:79 admin.php:117 admin.php:125 admin.php:152
|
38 |
+
msgid "Name"
|
39 |
+
msgstr "Nom"
|
40 |
+
|
41 |
+
#: admin.php:81 admin.php:154
|
42 |
+
msgid "A recognizable name for your new sidebar widget area"
|
43 |
+
msgstr "Un nom reconnaissable qui apparaîtra dans vos réglages"
|
44 |
+
|
45 |
+
#: admin.php:85 admin.php:118 admin.php:126 admin.php:158
|
46 |
+
msgid "ID"
|
47 |
+
msgstr "ID (identifiant) ATTENTION VOIR NOTE"
|
48 |
+
|
49 |
+
#: admin.php:89
|
50 |
+
msgid ""
|
51 |
+
"The unique ID is used to register the sidebar widget area (cannot be changed)"
|
52 |
+
msgstr ""
|
53 |
+
"Le ID unique est utilisé pour enregistrer la nouvelle zone de widget pour la "
|
54 |
+
"Barre Latérale (ne peux pas être changé). <b>ATTENTION</b> à ne pas mettre "
|
55 |
+
"de lettre accentuées, pas d'espace ou autre signes que des lettres. Le plus "
|
56 |
+
"simple est de prendre des minuscules et des tirets à la place des espaces. "
|
57 |
+
|
58 |
+
#: admin.php:93 admin.php:119 admin.php:127 admin.php:164
|
59 |
+
msgid "Description"
|
60 |
+
msgstr "Description"
|
61 |
+
|
62 |
+
#: admin.php:99
|
63 |
+
msgid "Update"
|
64 |
+
msgstr "Mise à jour"
|
65 |
+
|
66 |
+
#: admin.php:106
|
67 |
+
msgid "Genesis - Simple Sidebars"
|
68 |
+
msgstr "Genesis - Barre latérale"
|
69 |
+
|
70 |
+
#: admin.php:113
|
71 |
+
msgid "Current Sidebars"
|
72 |
+
msgstr "Zones de Widgets activées"
|
73 |
+
|
74 |
+
#: admin.php:146 admin.php:168
|
75 |
+
msgid "Add New Sidebar"
|
76 |
+
msgstr "Ajouter une nouvelle Barre Latérale"
|
77 |
+
|
78 |
+
#: admin.php:160
|
79 |
+
msgid "The unique ID is used to register the sidebar widget area"
|
80 |
+
msgstr ""
|
81 |
+
"Le ID unique est utilisé pour enregistrer la barre nouvelle zone de widget "
|
82 |
+
"pour la Barre Latérale. <b>ATTENTION</b> à ne pas mettre de lettre "
|
83 |
+
"accentuées, pas d'espace ou autre signes que des lettres. Le plus simple est "
|
84 |
+
"de prendre des minuscules et des tirets à la place des espaces."
|
85 |
+
|
86 |
+
#: functions.php:28
|
87 |
+
msgid "Edit"
|
88 |
+
msgstr "Editer"
|
89 |
+
|
90 |
+
#: functions.php:29
|
91 |
+
msgid "Delete"
|
92 |
+
msgstr "Suprimer"
|
93 |
+
|
94 |
+
#: functions.php:137
|
95 |
+
msgid "Oops! Please choose a valid Name and ID for this sidebar"
|
96 |
+
msgstr ""
|
97 |
+
"Oups ! Merci de choisir un Nom valide et un ID pour cette Barre Latérale. "
|
98 |
+
"<b>ATTENTION</b> à ne pas mettre de lettre accentuées, pas d'espace ou autre "
|
99 |
+
"signes que des lettres. Le plus simple est de prendre des minuscules et des "
|
100 |
+
"tirets à la place des espaces."
|
101 |
+
|
102 |
+
#: functions.php:140
|
103 |
+
msgid "Oops! That sidebar ID already exists"
|
104 |
+
msgstr "Oups ! Ce ID de Barre Latérale existe déjà."
|
105 |
+
|
106 |
+
#: functions.php:143
|
107 |
+
msgid ""
|
108 |
+
"Oops! You are trying to edit a sidebar that does not exist, or is not "
|
109 |
+
"editable"
|
110 |
+
msgstr ""
|
111 |
+
"Oups ! Vous essayez d'éditer une Barre Latérale qui n'existe pas, ou qui "
|
112 |
+
"n'est pas évitable."
|
113 |
+
|
114 |
+
#: functions.php:146
|
115 |
+
msgid ""
|
116 |
+
"Oops! You are trying to delete a sidebar that does not exist, or cannot be "
|
117 |
+
"deleted"
|
118 |
+
msgstr ""
|
119 |
+
"Oups ! Vous essayez de supprimer une Barre Latérale qui n'existe pas, ou qui "
|
120 |
+
"ne peux pas être supprimée."
|
121 |
+
|
122 |
+
#: functions.php:149
|
123 |
+
msgid "Oops! Something went wrong. Try again."
|
124 |
+
msgstr "Oups ! Quelque-chose va de travers. Essayez à nouveau"
|
125 |
+
|
126 |
+
#: functions.php:165
|
127 |
+
msgid "New sidebar successfully created!"
|
128 |
+
msgstr "La nouvelle Barre Latérale a été créé avec succès!"
|
129 |
+
|
130 |
+
#: functions.php:170
|
131 |
+
msgid "Sidebar successfully edited!"
|
132 |
+
msgstr "La Barre Latérale a été édité avec succès!"
|
133 |
+
|
134 |
+
#: functions.php:175
|
135 |
+
msgid "Sidebar successfully deleted."
|
136 |
+
msgstr "La Barre Latérale a été supprimé avec succès!"
|
137 |
+
|
138 |
+
#: inpost.php:10
|
139 |
+
msgid "Sidebar Selection"
|
140 |
+
msgstr "Sélection des Barres Latérales"
|
141 |
+
|
142 |
+
#: inpost.php:22 term.php:29
|
143 |
+
msgid "Primary Sidebar"
|
144 |
+
msgstr "Barre Latérale 1"
|
145 |
+
|
146 |
+
#: inpost.php:24 inpost.php:36 term.php:32 term.php:46
|
147 |
+
msgid "Default"
|
148 |
+
msgstr "Par défaut"
|
149 |
+
|
150 |
+
#: inpost.php:34 term.php:43
|
151 |
+
msgid "Secondary Sidebar"
|
152 |
+
msgstr "Barre Latérale 2"
|
153 |
+
|
154 |
+
#: plugin.php:21
|
155 |
+
#, php-format
|
156 |
+
msgid ""
|
157 |
+
"Sorry, you can't activate unless you have installed <a href=\"%s\">Genesis</"
|
158 |
+
"a>"
|
159 |
+
msgstr ""
|
160 |
+
"Désolé, vous ne pouvez pas activer ce plugin tant que vous n'avez pas "
|
161 |
+
"installé <a href=\"%s\">Genesis</a>."
|
162 |
+
|
163 |
+
#: plugin.php:26
|
164 |
+
#, php-format
|
165 |
+
msgid ""
|
166 |
+
"Sorry, you cannot activate without <a href=\"%s\">Genesis %s</a> or greater"
|
167 |
+
msgstr ""
|
168 |
+
"Désolé, vous ne pouvez activer ce plugin sans <a href=\"%s\">Genesis %s</a> "
|
169 |
+
"ou supérieur."
|
170 |
+
|
171 |
+
#: term.php:25
|
172 |
+
msgid "Sidebar Options"
|
173 |
+
msgstr "Options des Barres Latérales"
|
plugin.php
CHANGED
@@ -3,102 +3,159 @@
|
|
3 |
Plugin Name: Genesis Simple Sidebars
|
4 |
Plugin URI: http://www.studiopress.com/plugins/simple-sidebars
|
5 |
Description: Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.
|
6 |
-
Version: 0.9.2.1
|
7 |
Author: Nathan Rice
|
8 |
Author URI: http://www.nathanrice.net/
|
|
|
9 |
Text Domain: ss
|
10 |
Domain Path: /languages/
|
|
|
|
|
|
|
|
|
|
|
11 |
*/
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
}
|
31 |
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
*
|
|
|
|
|
|
|
|
|
36 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
add_action( 'genesis_init', 'ss_genesis_init', 12 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
function ss_genesis_init() {
|
39 |
-
// Define our constants
|
40 |
-
define( 'SS_SETTINGS_FIELD', 'ss-settings' );
|
41 |
-
define( 'SS_PLUGIN_DIR', dirname( __FILE__ ) );
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
add_action( 'get_header', 'ss_sidebars_init' );
|
45 |
add_action( 'widgets_init', 'ss_register_sidebars' );
|
46 |
-
|
|
|
|
|
47 |
return;
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
require_once( SS_PLUGIN_DIR . '/
|
52 |
-
require_once( SS_PLUGIN_DIR . '/
|
53 |
-
|
54 |
-
|
55 |
-
// let the child theme hook the genesis_simple_sidebars_taxonomies filter before hooking term edit
|
56 |
add_action( 'init', 'ss_term_edit_init' );
|
|
|
57 |
}
|
58 |
/**
|
59 |
-
*
|
|
|
|
|
|
|
|
|
60 |
*/
|
61 |
function ss_register_sidebars() {
|
62 |
-
|
63 |
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
69 |
'name' => esc_html( $info['name'] ),
|
70 |
'id' => $id,
|
71 |
'description' => esc_html( $info['description'] ),
|
72 |
'editable' => 1,
|
73 |
-
|
74 |
'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-wrap">',
|
75 |
'after_widget' => "</div></div>\n",
|
76 |
'before_title' => '<h4 class="widgettitle">',
|
77 |
'after_title' => "</h4>\n"
|
78 |
-
));
|
79 |
-
|
80 |
}
|
81 |
-
|
82 |
-
}
|
83 |
|
|
|
84 |
|
85 |
/**
|
|
|
|
|
86 |
* Remove the default sidebars, run some conditional logic,
|
87 |
* use alternate sidebars if necessary, else fallback on default sidebars.
|
|
|
|
|
88 |
*/
|
89 |
function ss_sidebars_init() {
|
90 |
-
|
91 |
-
remove_action('
|
92 |
-
|
93 |
-
add_action('
|
|
|
|
|
94 |
}
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
function ss_do_sidebar() {
|
97 |
|
98 |
if ( ! ss_do_one_sidebar( '_ss_sidebar' ) )
|
99 |
genesis_do_sidebar();
|
100 |
|
101 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
function ss_do_sidebar_alt() {
|
103 |
|
104 |
if ( ! ss_do_one_sidebar( '_ss_sidebar_alt' ) )
|
@@ -106,44 +163,62 @@ function ss_do_sidebar_alt() {
|
|
106 |
|
107 |
}
|
108 |
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
static $taxonomies = null;
|
111 |
-
|
112 |
-
if ( is_singular() && $
|
113 |
-
if ( dynamic_sidebar( $
|
114 |
}
|
115 |
-
|
116 |
if ( is_category() ) {
|
117 |
-
$term = get_term( get_query_var('cat'), 'category' );
|
118 |
-
if( isset( $term->meta[$
|
119 |
}
|
120 |
-
|
121 |
if ( is_tag() ) {
|
122 |
-
$term = get_term( get_query_var('tag_id'), 'post_tag' );
|
123 |
-
if( isset( $term->meta[$
|
124 |
}
|
125 |
-
|
126 |
if ( is_tax() ) {
|
127 |
-
if(
|
128 |
$taxonomies = ss_get_taxonomies();
|
129 |
-
|
130 |
-
foreach( $taxonomies as $tax ) {
|
131 |
-
if(
|
132 |
continue;
|
133 |
-
|
134 |
-
if( is_tax( $tax ) ) {
|
135 |
$obj = get_queried_object();
|
136 |
$term = get_term( $obj->term_id, $tax );
|
137 |
-
if( isset( $term->meta[$
|
138 |
break;
|
139 |
}
|
140 |
}
|
141 |
}
|
142 |
-
|
143 |
return false;
|
144 |
-
|
145 |
}
|
146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
function ss_get_taxonomies() {
|
148 |
|
149 |
$taxonomies = get_taxonomies( array( 'show_ui' => true, 'public' => true ) );
|
@@ -151,11 +226,20 @@ function ss_get_taxonomies() {
|
|
151 |
|
152 |
}
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
function ss_has_3_column_layouts() {
|
155 |
|
156 |
$_layouts = (array) genesis_get_layouts();
|
157 |
$_layouts = array_keys( $_layouts );
|
158 |
$_3_column = array_intersect( $_layouts, array( 'content-sidebar-sidebar', 'sidebar-content-sidebar', 'sidebar-sidebar-content' ) );
|
|
|
159 |
return ! empty( $_3_column );
|
160 |
|
161 |
}
|
3 |
Plugin Name: Genesis Simple Sidebars
|
4 |
Plugin URI: http://www.studiopress.com/plugins/simple-sidebars
|
5 |
Description: Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.
|
|
|
6 |
Author: Nathan Rice
|
7 |
Author URI: http://www.nathanrice.net/
|
8 |
+
|
9 |
Text Domain: ss
|
10 |
Domain Path: /languages/
|
11 |
+
|
12 |
+
Version: 1.0.0
|
13 |
+
|
14 |
+
License: GNU General Public License v2.0 (or later)
|
15 |
+
License URI: http://www.opensource.org/licenses/gpl-license.php
|
16 |
*/
|
17 |
|
18 |
+
/** Define our constants */
|
19 |
+
define( 'SS_SETTINGS_FIELD', 'ss-settings' );
|
20 |
+
define( 'SS_PLUGIN_DIR', dirname( __FILE__ ) );
|
21 |
|
22 |
+
register_activation_hook( __FILE__, 'ss_activation_check' );
|
23 |
+
/**
|
24 |
+
* Activation hook callback.
|
25 |
+
*
|
26 |
+
* This functions runs when the plugin is activated. It checks to make sure the user is running
|
27 |
+
* a minimum Genesis version, so there are no conflicts or fatal errors.
|
28 |
+
*
|
29 |
+
* @since 0.9.0
|
30 |
+
*/
|
31 |
+
function ss_activation_check() {
|
32 |
|
33 |
+
if ( 'genesis' != basename( TEMPLATEPATH ) ) {
|
34 |
+
ss_deactivate( '1.8.0', '3.3' );
|
35 |
+
}
|
|
|
36 |
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
+
* Deactivate Simple Sidebars.
|
41 |
+
*
|
42 |
+
* This function deactivates Simple Sidebars.
|
43 |
+
*
|
44 |
+
* @since 1.0.0
|
45 |
*/
|
46 |
+
function ss_deactivate( $genesis_version = '1.8.0', $wp_version = '3.3' ) {
|
47 |
+
|
48 |
+
deactivate_plugins( plugin_basename( __FILE__ ) );
|
49 |
+
wp_die( sprintf( __( 'Sorry, you cannot run Simple Sidebars without WordPress %s and <a href="%s">Genesis %s</a>, or greater.', 'ss' ), $wp_version, 'http://www.studiopress.com/support/showthread.php?t=19576', $genesis_version ) );
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
add_action( 'genesis_init', 'ss_genesis_init', 12 );
|
54 |
+
/**
|
55 |
+
* Plugin initialization.
|
56 |
+
*
|
57 |
+
* Initialize the plugin, set the constants, hook callbacks to actions, and include the plugin library.
|
58 |
+
*
|
59 |
+
* @since 0.9.0
|
60 |
+
*/
|
61 |
function ss_genesis_init() {
|
|
|
|
|
|
|
62 |
|
63 |
+
/** Deactivate if not running Genesis 1.8.0 or greater */
|
64 |
+
if ( ! class_exists( 'Genesis_Admin_Boxes' ) )
|
65 |
+
add_action( 'admin_init', 'ss_deactivate', 10, 0 );
|
66 |
+
|
67 |
+
/** Load translations */
|
68 |
+
load_plugin_textdomain( 'ss', false, 'genesis-simple-sidebars/languages' );
|
69 |
+
|
70 |
+
/** required hooks */
|
71 |
add_action( 'get_header', 'ss_sidebars_init' );
|
72 |
add_action( 'widgets_init', 'ss_register_sidebars' );
|
73 |
+
|
74 |
+
/** The rest is admin stuff, so load only if we're in the admin area */
|
75 |
+
if ( ! is_admin() )
|
76 |
return;
|
77 |
|
78 |
+
/** Include admin files */
|
79 |
+
require_once( SS_PLUGIN_DIR . '/includes/admin.php' );
|
80 |
+
require_once( SS_PLUGIN_DIR . '/includes/inpost.php' );
|
81 |
+
require_once( SS_PLUGIN_DIR . '/includes/term.php' );
|
82 |
+
|
83 |
+
/** let the child theme hook the genesis_simple_sidebars_taxonomies filter before hooking term edit */
|
|
|
84 |
add_action( 'init', 'ss_term_edit_init' );
|
85 |
+
|
86 |
}
|
87 |
/**
|
88 |
+
* Register widget areas.
|
89 |
+
*
|
90 |
+
* This function registers the created sidebars as widget areas
|
91 |
+
*
|
92 |
+
* @since 0.9.0
|
93 |
*/
|
94 |
function ss_register_sidebars() {
|
95 |
+
|
96 |
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
97 |
+
|
98 |
+
/** If no sidebars have been created, do nothing */
|
99 |
+
if ( ! $_sidebars )
|
100 |
+
return;
|
101 |
+
|
102 |
+
/** Cycle through created sidebars, register them as widget areas */
|
103 |
+
foreach ( (array) $_sidebars as $id => $info ) {
|
104 |
+
|
105 |
+
register_sidebar( array(
|
106 |
'name' => esc_html( $info['name'] ),
|
107 |
'id' => $id,
|
108 |
'description' => esc_html( $info['description'] ),
|
109 |
'editable' => 1,
|
110 |
+
|
111 |
'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-wrap">',
|
112 |
'after_widget' => "</div></div>\n",
|
113 |
'before_title' => '<h4 class="widgettitle">',
|
114 |
'after_title' => "</h4>\n"
|
115 |
+
) );
|
116 |
+
|
117 |
}
|
|
|
|
|
118 |
|
119 |
+
}
|
120 |
|
121 |
/**
|
122 |
+
* Use custom sidebars.
|
123 |
+
*
|
124 |
* Remove the default sidebars, run some conditional logic,
|
125 |
* use alternate sidebars if necessary, else fallback on default sidebars.
|
126 |
+
*
|
127 |
+
* @since 0.9.0
|
128 |
*/
|
129 |
function ss_sidebars_init() {
|
130 |
+
|
131 |
+
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
|
132 |
+
remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
|
133 |
+
add_action( 'genesis_sidebar', 'ss_do_sidebar' );
|
134 |
+
add_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
|
135 |
+
|
136 |
}
|
137 |
|
138 |
+
/**
|
139 |
+
* Display primary sidebar.
|
140 |
+
*
|
141 |
+
* Display custom sidebar if one exists, else display default primary sidebar.
|
142 |
+
*
|
143 |
+
* @since 0.9.0
|
144 |
+
*/
|
145 |
function ss_do_sidebar() {
|
146 |
|
147 |
if ( ! ss_do_one_sidebar( '_ss_sidebar' ) )
|
148 |
genesis_do_sidebar();
|
149 |
|
150 |
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Display secondary sidebar.
|
154 |
+
*
|
155 |
+
* Display custom sidebar if one exists, else display default secondary sidebar.
|
156 |
+
*
|
157 |
+
* @since 0.9.0
|
158 |
+
*/
|
159 |
function ss_do_sidebar_alt() {
|
160 |
|
161 |
if ( ! ss_do_one_sidebar( '_ss_sidebar_alt' ) )
|
163 |
|
164 |
}
|
165 |
|
166 |
+
/**
|
167 |
+
* Sidebar widget area output.
|
168 |
+
*
|
169 |
+
* Helper function to show widgets in a particular sidebar.
|
170 |
+
*
|
171 |
+
* @param string $sidebar_key sidebar id you wish to output.
|
172 |
+
*
|
173 |
+
* @since 0.9.0
|
174 |
+
*
|
175 |
+
*/
|
176 |
+
function ss_do_one_sidebar( $sidebar_key = '_ss_sidebar' ) {
|
177 |
+
|
178 |
static $taxonomies = null;
|
179 |
+
|
180 |
+
if ( is_singular() && $sidebar_key = genesis_get_custom_field( $sidebar_key ) ) {
|
181 |
+
if ( dynamic_sidebar( $sidebar_key ) ) return true;
|
182 |
}
|
183 |
+
|
184 |
if ( is_category() ) {
|
185 |
+
$term = get_term( get_query_var( 'cat' ), 'category' );
|
186 |
+
if ( isset( $term->meta[$sidebar_key] ) && dynamic_sidebar( $term->meta[$sidebar_key] ) ) return true;
|
187 |
}
|
188 |
+
|
189 |
if ( is_tag() ) {
|
190 |
+
$term = get_term( get_query_var( 'tag_id' ), 'post_tag' );
|
191 |
+
if ( isset( $term->meta[$sidebar_key] ) && dynamic_sidebar( $term->meta[$sidebar_key] ) ) return true;
|
192 |
}
|
193 |
+
|
194 |
if ( is_tax() ) {
|
195 |
+
if ( null === $taxonomies )
|
196 |
$taxonomies = ss_get_taxonomies();
|
197 |
+
|
198 |
+
foreach ( $taxonomies as $tax ) {
|
199 |
+
if ( 'post_tag' == $tax || 'category' == $tax )
|
200 |
continue;
|
201 |
+
|
202 |
+
if ( is_tax( $tax ) ) {
|
203 |
$obj = get_queried_object();
|
204 |
$term = get_term( $obj->term_id, $tax );
|
205 |
+
if ( isset( $term->meta[$sidebar_key] ) && dynamic_sidebar( $term->meta[$sidebar_key] ) ) return true;
|
206 |
break;
|
207 |
}
|
208 |
}
|
209 |
}
|
210 |
+
|
211 |
return false;
|
212 |
+
|
213 |
}
|
214 |
|
215 |
+
/**
|
216 |
+
* Return taxonomy ids.
|
217 |
+
*
|
218 |
+
* Helper function to return the array keys from a taxonomy query.
|
219 |
+
*
|
220 |
+
* @since 0.9.0
|
221 |
+
*/
|
222 |
function ss_get_taxonomies() {
|
223 |
|
224 |
$taxonomies = get_taxonomies( array( 'show_ui' => true, 'public' => true ) );
|
226 |
|
227 |
}
|
228 |
|
229 |
+
/**
|
230 |
+
* Does this Genesis install have the 3 column layouts deactivated?
|
231 |
+
*
|
232 |
+
* This function checks to see if the Genesis install still has active 3 column layouts. Since
|
233 |
+
* child themes and plugins can deregister layouts, we need to know if they have deregistered the 3 column layouts.
|
234 |
+
*
|
235 |
+
* @since 0.9.2
|
236 |
+
*/
|
237 |
function ss_has_3_column_layouts() {
|
238 |
|
239 |
$_layouts = (array) genesis_get_layouts();
|
240 |
$_layouts = array_keys( $_layouts );
|
241 |
$_3_column = array_intersect( $_layouts, array( 'content-sidebar-sidebar', 'sidebar-content-sidebar', 'sidebar-sidebar-content' ) );
|
242 |
+
|
243 |
return ! empty( $_3_column );
|
244 |
|
245 |
}
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: nathanrice, wpmuguru
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118
|
4 |
Tags: hooks, genesis, genesiswp, studiopress
|
5 |
-
Requires at least: 3.
|
6 |
-
Tested up to: 3.3
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
This plugin allows you to create multiple, dynamic widget areas, and assign those widget areas to sidebar locations within the Genesis Theme Framework on a per post, per page, or per tag/category archive basis.
|
10 |
|
@@ -59,3 +59,6 @@ Not in the way you're probably thinking. The markup surrounding the widget area
|
|
59 |
* Default custom taxonomy support to on for public taxonomies
|
60 |
* Remove secondary selection when no 3 column layouts are enabled
|
61 |
|
|
|
|
|
|
2 |
Contributors: nathanrice, wpmuguru
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118
|
4 |
Tags: hooks, genesis, genesiswp, studiopress
|
5 |
+
Requires at least: 3.3
|
6 |
+
Tested up to: 3.3.1
|
7 |
+
Stable tag: 1.0.0
|
8 |
|
9 |
This plugin allows you to create multiple, dynamic widget areas, and assign those widget areas to sidebar locations within the Genesis Theme Framework on a per post, per page, or per tag/category archive basis.
|
10 |
|
59 |
* Default custom taxonomy support to on for public taxonomies
|
60 |
* Remove secondary selection when no 3 column layouts are enabled
|
61 |
|
62 |
+
= 1.0.0 =
|
63 |
+
* Increase requirement to WordPress 3.3 and Genesis 1.8.0
|
64 |
+
* Switch to Genesis Admin class to build admin menu.
|