Genesis 2.0 compatibility, standards.

This commit is contained in:
Nathan Rice
2013-08-09 13:35:43 -04:00
parent cf767d3206
commit 718dfd9a55
7 changed files with 85 additions and 90 deletions
+7 -7
View File
@@ -34,14 +34,14 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
)
);
/** Empty, as we'll be building the page manually */
//* Empty, as we'll be building the page manually
$page_ops = array();
$settings_field = SS_SETTINGS_FIELD;
$this->create( $page_id, $menu_ops, $page_ops, $settings_field );
/** Simpe Sidebar actions (create, edit, or delete) */
//* Simpe Sidebar actions (create, edit, or delete)
add_action( 'admin_init', array( $this, 'actions' ) );
}
@@ -201,10 +201,10 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
exit;
}
// nonce verification
//* nonce verification
check_admin_referer( 'simple-sidebars-action_create-sidebar' );
// WP changes a numeric sidebar id to sidebar-id which makes it inaccessible to the user
//* WP changes a numeric sidebar id to sidebar-id which makes it inaccessible to the user
if ( is_numeric( $args['id'] ) )
$args['id'] = sanitize_title_with_dashes( $args['name'] );
@@ -242,10 +242,10 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
exit;
}
// nonce verification
//* nonce verification
check_admin_referer( 'simple-sidebars-action_edit-sidebar' );
// WP changes a numeric sidebar id to sidebar-id which makes it inaccessible to the user
//* WP changes a numeric sidebar id to sidebar-id which makes it inaccessible to the user
if ( is_numeric( $args['id'] ) )
$args['id'] = sanitize_title_with_dashes( $args['name'] );
@@ -283,7 +283,7 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
exit;
}
// nonce verification
//* nonce verification
check_admin_referer( 'simple-sidebars-action_delete-sidebar' );
$_sidebars = (array) get_option( SS_SETTINGS_FIELD );
+23 -23
View File
@@ -1,15 +1,15 @@
<?php
add_action('admin_menu', 'ss_add_inpost_metabox');
/**
* This bit of code registers the meta box on posts/pages,
* so that users can choose what sidebar to use.
*/
add_action('admin_menu', 'ss_add_inpost_metabox');
function ss_add_inpost_metabox() {
foreach ( (array)get_post_types( array( 'public' => true ) ) as $type ) {
foreach ( (array) get_post_types( array( 'public' => true ) ) as $type ) {
if ( post_type_supports( $type, 'genesis-simple-sidebars' ) || $type == 'post' || $type == 'page' ) {
add_meta_box('ss_inpost_metabox', __('Sidebar Selection', 'ss'), 'ss_inpost_metabox', $type, 'side', 'low');
add_meta_box( 'ss_inpost_metabox', __( 'Sidebar Selection', 'ss' ), 'ss_inpost_metabox', $type, 'side', 'low' );
}
}
@@ -22,31 +22,31 @@ function ss_inpost_metabox() {
?>
<input type="hidden" name="ss_inpost_nonce" value="<?php echo wp_create_nonce(plugin_basename(__FILE__)); ?>" />
<input type="hidden" name="ss_inpost_nonce" value="<?php echo wp_create_nonce( plugin_basename( __FILE__ ) ); ?>" />
<p>
<label class="howto" for="_ss_sidebar"><span><?php _e('Primary Sidebar', 'ss'); ?><span></label>
<label class="howto" for="_ss_sidebar"><span><?php _e( 'Primary Sidebar', 'ss' ); ?><span></label>
<select name="_ss_sidebar" id="_ss_sidebar" style="width: 99%">
<option value=""><?php _e('Default', 'ss'); ?></option>
<option value=""><?php _e( 'Default', 'ss' ); ?></option>
<?php
foreach ( (array)$_sidebars as $id => $info ) {
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field('_ss_sidebar'), false), esc_html( $info['name'] ) );
foreach ( (array) $_sidebars as $id => $info ) {
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field( '_ss_sidebar' ), false), esc_html( $info['name'] ) );
}
?>
</select>
</p>
<?php
// don't show the option if there are no 3 column layouts registered
//* don't show the option if there are no 3 column layouts registered
if ( ! ss_has_3_column_layouts() )
return;
?>
<p>
<label class="howto" for="_ss_sidebar_alt"><span><?php _e('Secondary Sidebar', 'ss'); ?><span></label>
<label class="howto" for="_ss_sidebar_alt"><span><?php _e( 'Secondary Sidebar', 'ss' ); ?><span></label>
<select name="_ss_sidebar_alt" id="_ss_sidebar_alt" style="width: 99%">
<option value=""><?php _e('Default', 'ss'); ?></option>
<option value=""><?php _e( 'Default', 'ss' ); ?></option>
<?php
foreach ( (array)$_sidebars as $id => $info ) {
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field('_ss_sidebar_alt'), false), esc_html( $info['name'] ) );
foreach ( (array) $_sidebars as $id => $info ) {
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field( '_ss_sidebar_alt' ), false ), esc_html( $info['name'] ) );
}
?>
</select>
@@ -55,40 +55,40 @@ function ss_inpost_metabox() {
<?php
}
add_action( 'save_post', 'ss_inpost_metabox_save', 1, 2 );
/**
* This bit of code saves the sidebars chosen as post meta.
*/
add_action('save_post', 'ss_inpost_metabox_save', 1, 2);
function ss_inpost_metabox_save( $post_id, $post ) {
// verify the nonce
//* verify the nonce
if ( !isset($_POST['ss_inpost_nonce']) || !wp_verify_nonce( $_POST['ss_inpost_nonce'], plugin_basename(__FILE__) ) )
return $post->ID;
// don't try to save the data under autosave, ajax, or future post.
//* don't try to save the data under autosave, ajax, or future post.
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
if ( defined('DOING_AJAX') && DOING_AJAX ) return;
if ( defined('DOING_CRON') && DOING_CRON ) return;
// is the user allowed to edit the post or page?
if ( ( 'page' == $_POST['post_type'] && !current_user_can('edit_page', $post->ID) ) || !current_user_can('edit_post', $post->ID ) )
//* is the user allowed to edit the post or page?
if ( ( 'page' == $_POST['post_type'] && ! current_user_can( 'edit_page', $post->ID ) ) || ! current_user_can( 'edit_post', $post->ID ) )
return $post->ID;
$_sidebars = array(
'_ss_sidebar' => $_POST['_ss_sidebar'],
'_ss_sidebar_alt' => $_POST['_ss_sidebar_alt']
'_ss_sidebar_alt' => $_POST['_ss_sidebar_alt'],
);
// store the custom fields
//* store the custom fields
foreach ( $_sidebars as $key => $value ) {
if ( $post->post_type == 'revision' ) return; // don't try to store data during revision save
//* don't try to store data during revision save
if ( 'revision' === $post->post_type )
return;
if ( $value ) {
// save/update
update_post_meta($post->ID, $key, $value);
} else {
// delete if blank
delete_post_meta($post->ID, $key);
}
+7 -7
View File
@@ -27,16 +27,16 @@ function ss_term_sidebar($tag, $taxonomy) {
?>
<h3><?php _e('Sidebar Options', 'ss'); ?></h3>
<h3><?php _e( 'Sidebar Options', 'ss' ); ?></h3>
<table class="form-table">
<tr class="form-field">
<th scope="row" valign="top"><label for="meta[_ss_sidebar]"><?php _e('Primary Sidebar', 'ss'); ?></label></th>
<th scope="row" valign="top"><label for="meta[_ss_sidebar]"><?php _e( 'Primary Sidebar', 'ss' ); ?></label></th>
<td>
<select name="meta[_ss_sidebar]" id="meta[_ss_sidebar]" style="padding-right: 10px;">
<option value=""><?php _e('Default', 'ss'); ?></option>
<option value=""><?php _e( 'Default', 'ss' ); ?></option>
<?php
foreach ( (array)$_sidebars as $id => $info ) {
foreach ( (array) $_sidebars as $id => $info ) {
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, $tag->meta['_ss_sidebar'] , false), esc_html( $info['name'] ) );
}
?>
@@ -48,12 +48,12 @@ function ss_term_sidebar($tag, $taxonomy) {
if ( ss_has_3_column_layouts() ) {
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="meta[_ss_sidebar_alt]"><?php _e('Secondary Sidebar', 'ss'); ?></label></th>
<th scope="row" valign="top"><label for="meta[_ss_sidebar_alt]"><?php _e( 'Secondary Sidebar', 'ss' ); ?></label></th>
<td>
<select name="meta[_ss_sidebar_alt]" id="meta[_ss_sidebar_alt]" style="padding-right: 10px;">
<option value=""><?php _e('Default', 'ss'); ?></option>
<option value=""><?php _e( 'Default', 'ss' ); ?></option>
<?php
foreach ( (array)$_sidebars as $id => $info ) {
foreach ( (array) $_sidebars as $id => $info ) {
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, $tag->meta['_ss_sidebar_alt'] , false), esc_html( $info['name'] ) );
}
?>
+9 -9
View File
@@ -5,35 +5,35 @@ if ( array_key_exists( $_REQUEST['id'], (array) $_sidebars ) ) {
wp_die( __( 'Nice try, partner. But that sidebar doesn\'t exist. Click back and try again.', 'ss' ) );
}
screen_icon('themes'); ?>
<h2><?php _e('Edit Sidebar', 'ss'); ?></h2>
screen_icon( 'themes' ); ?>
<h2><?php _e( 'Edit Sidebar', 'ss' ); ?></h2>
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&amp;action=edit' ); ?>">
<?php wp_nonce_field('simple-sidebars-action_edit-sidebar'); ?>
<?php wp_nonce_field( 'simple-sidebars-action_edit-sidebar' ); ?>
<table class="form-table">
<tr class="form-field">
<th scope="row" valign="top"><label for="edit_sidebar[name]"><?php _e('Name', 'ss'); ?></label></th>
<th scope="row" valign="top"><label for="edit_sidebar[name]"><?php _e( 'Name', 'ss' ); ?></label></th>
<td><input name="edit_sidebar[name]" id="edit_sidebar[name]" type="text" value="<?php echo esc_html( $_sidebar['name'] ); ?>" size="40" />
<p class="description"><?php _e('A recognizable name for your new sidebar widget area', 'ss'); ?></p></td>
<p class="description"><?php _e( 'A recognizable name for your new sidebar widget area', 'ss' ); ?></p></td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="edit_sidebar[id]"><?php _e('ID', 'ss'); ?></label></th>
<th scope="row" valign="top"><label for="edit_sidebar[id]"><?php _e( 'ID', 'ss' ); ?></label></th>
<td>
<input type="text" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" disabled="disabled" />
<input name="edit_sidebar[id]" id="edit_sidebar[id]" type="hidden" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" />
<p class="description"><?php _e('The unique ID is used to register the sidebar widget area (cannot be changed)', 'ss'); ?></p></td>
<p class="description"><?php _e( 'The unique ID is used to register the sidebar widget area (cannot be changed)', 'ss' ); ?></p></td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="edit_sidebar[description]"><?php _e('Description', 'ss'); ?></label></th>
<th scope="row" valign="top"><label for="edit_sidebar[description]"><?php _e( 'Description', 'ss' ); ?></label></th>
<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>
</tr>
</table>
<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php _e('Update', 'ss'); ?>" /></p>
<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php _e( 'Update', 'ss' ); ?>" /></p>
</form>
+17 -17
View File
@@ -1,26 +1,26 @@
<?php screen_icon('themes'); ?>
<h2><?php _e('Genesis - Simple Sidebars', 'ss'); ?></h2>
<?php screen_icon( 'themes' ); ?>
<h2><?php _e( 'Genesis - Simple Sidebars', 'ss' ); ?></h2>
<div id="col-container">
<div id="col-right">
<div class="col-wrap">
<h3><?php _e('Current Sidebars', 'ss'); ?></h3>
<h3><?php _e( 'Current Sidebars', 'ss' ); ?></h3>
<table class="widefat tag fixed" cellspacing="0">
<thead>
<tr>
<th scope="col" id="name" class="manage-column column-name"><?php _e('Name', 'ss'); ?></th>
<th scope="col" class="manage-column column-slug"><?php _e('ID', 'ss'); ?></th>
<th scope="col" id="description" class="manage-column column-description"><?php _e('Description', 'ss'); ?></th>
<th scope="col" id="name" class="manage-column column-name"><?php _e( 'Name', 'ss' ); ?></th>
<th scope="col" class="manage-column column-slug"><?php _e( 'ID', 'ss' ); ?></th>
<th scope="col" id="description" class="manage-column column-description"><?php _e( 'Description', 'ss' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col" class="manage-column column-name"><?php _e('Name', 'ss'); ?></th>
<th scope="col" class="manage-column column-slug"><?php _e('ID', 'ss'); ?></th>
<th scope="col" class="manage-column column-description"><?php _e('Description', 'ss'); ?></th>
<th scope="col" class="manage-column column-name"><?php _e( 'Name', 'ss' ); ?></th>
<th scope="col" class="manage-column column-slug"><?php _e( 'ID', 'ss' ); ?></th>
<th scope="col" class="manage-column column-description"><?php _e( 'Description', 'ss' ); ?></th>
</tr>
</tfoot>
@@ -39,29 +39,29 @@
<div class="form-wrap">
<h3><?php _e('Add New Sidebar', 'ss'); ?></h3>
<h3><?php _e( 'Add New Sidebar', 'ss' ); ?></h3>
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&amp;action=create' ); ?>">
<?php wp_nonce_field('simple-sidebars-action_create-sidebar'); ?>
<?php wp_nonce_field( 'simple-sidebars-action_create-sidebar' ); ?>
<div class="form-field form-required">
<label for="sidebar-name"><?php _e('Name', 'ss'); ?></label>
<label for="sidebar-name"><?php _e( 'Name', 'ss' ); ?></label>
<input name="new_sidebar[name]" id="sidebar-name" type="text" value="" size="40" aria-required="true" />
<p><?php _e('A recognizable name for your new sidebar widget area', 'ss'); ?></p>
<p><?php _e( 'A recognizable name for your new sidebar widget area', 'ss' ); ?></p>
</div>
<div class="form-field">
<label for="sidebar-id"><?php _e('ID', 'ss'); ?></label>
<label for="sidebar-id"><?php _e( 'ID', 'ss' ); ?></label>
<input name="new_sidebar[id]" id="sidebar-id" type="text" value="" size="40" />
<p><?php _e('The unique ID is used to register the sidebar widget area', 'ss'); ?></p>
<p><?php _e( 'The unique ID is used to register the sidebar widget area', 'ss' ); ?></p>
</div>
<div class="form-field">
<label for="sidebar-description"><?php _e('Description', 'ss'); ?></label>
<label for="sidebar-description"><?php _e( 'Description', 'ss' ); ?></label>
<textarea name="new_sidebar[description]" id="sidebar-description" rows="5" cols="40"></textarea>
</div>
<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php _e('Add New Sidebar', 'ss'); ?>" /></p>
<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php _e( 'Add New Sidebar', 'ss' ); ?>" /></p>
</form></div>
</div>
+10 -15
View File
@@ -9,7 +9,7 @@ Author URI: http://www.nathanrice.net/
Text Domain: ss
Domain Path: /languages/
Version: 1.0.0
Version: 2.0.0-dev
License: GNU General Public License v2.0 (or later)
License URI: http://www.opensource.org/licenses/gpl-license.php
@@ -60,27 +60,27 @@ add_action( 'genesis_init', 'ss_genesis_init', 12 );
*/
function ss_genesis_init() {
/** Deactivate if not running Genesis 1.8.0 or greater */
//* Deactivate if not running Genesis 1.8.0 or greater
if ( ! class_exists( 'Genesis_Admin_Boxes' ) )
add_action( 'admin_init', 'ss_deactivate', 10, 0 );
/** Load translations */
//* Load translations
load_plugin_textdomain( 'ss', false, 'genesis-simple-sidebars/languages' );
/** required hooks */
//* required hooks
add_action( 'get_header', 'ss_sidebars_init' );
add_action( 'widgets_init', 'ss_register_sidebars' );
/** The rest is admin stuff, so load only if we're in the admin area */
//* The rest is admin stuff, so load only if we're in the admin area
if ( ! is_admin() )
return;
/** Include admin files */
//* Include admin files
require_once( SS_PLUGIN_DIR . '/includes/admin.php' );
require_once( SS_PLUGIN_DIR . '/includes/inpost.php' );
require_once( SS_PLUGIN_DIR . '/includes/term.php' );
/** let the child theme hook the genesis_simple_sidebars_taxonomies filter before hooking term edit */
//* let the child theme hook the genesis_simple_sidebars_taxonomies filter before hooking term edit
add_action( 'init', 'ss_term_edit_init' );
}
@@ -95,23 +95,18 @@ function ss_register_sidebars() {
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
/** If no sidebars have been created, do nothing */
//* If no sidebars have been created, do nothing
if ( ! $_sidebars )
return;
/** Cycle through created sidebars, register them as widget areas */
//* Cycle through created sidebars, register them as widget areas
foreach ( (array) $_sidebars as $id => $info ) {
register_sidebar( array(
genesis_register_sidebar( array(
'name' => esc_html( $info['name'] ),
'id' => $id,
'description' => esc_html( $info['description'] ),
'editable' => 1,
'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-wrap">',
'after_widget' => "</div></div>\n",
'before_title' => '<h4 class="widgettitle">',
'after_title' => "</h4>\n"
) );
}
+3 -3
View File
@@ -4,13 +4,13 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: hooks, genesis, genesiswp, studiopress
Requires at least: 3.0
Tested up to: 3.3
Stable tag: 0.9.2.1
Stable tag: 1.0.0
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.
This plugin allows you to create multiple, dynamic widget areas, and assign those widget areas to sidebar locations within the Genesis Framework on a per post, per page, or per tag/category archive basis.
== Description ==
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.
This plugin allows you to create multiple, dynamic widget areas, and assign those widget areas to sidebar locations within the Genesis Framework on a per post, per page, or per tag/category archive basis.
Creating widget areas programmatically, then using conditional logic to properly assign them to sidebar locations can be a complex task for a beginner. This plugin allows you to do all this from a simple administration menu, and assign widget areas to sidebar locations with simple drop-down menus within the post/page edit screens, or when editing a tag or category.