9 Commits

Author SHA1 Message Date
Nathan Rice f021c01b25 Tagging 2.0.1. 2013-08-26 15:04:07 -04:00
Nathan Rice eedd494ae5 Use proper key for Genesis 2.0.1 compatibility. 2013-08-26 15:02:02 -04:00
Nathan Rice d8e63f2ccd Merge pull request #2 from GaryJones/patch-1
Fix incorrect text domain
2013-08-26 11:58:40 -07:00
Nathan Rice dcae718c4a Merge pull request #1 from billerickson/develop
use sidebar name rather than hardcoded labels
2013-08-26 11:58:24 -07:00
Gary Jones b69d318af9 Fix incorrect text domain 2013-08-20 03:40:55 +01:00
Bill Erickson f84db05c75 use sidebar name rather than hardcoded labels 2013-08-09 18:44:30 -05:00
Nathan Rice c47dd22e92 Tagging 2.0.0. 2013-08-09 13:43:39 -04:00
Nathan Rice 39f21130f4 Better Genesis version detection. 2013-08-09 13:38:26 -04:00
Nathan Rice 718dfd9a55 Genesis 2.0 compatibility, standards. 2013-08-09 13:35:43 -04:00
7 changed files with 111 additions and 100 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(); $page_ops = array();
$settings_field = SS_SETTINGS_FIELD; $settings_field = SS_SETTINGS_FIELD;
$this->create( $page_id, $menu_ops, $page_ops, $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' ) ); add_action( 'admin_init', array( $this, 'actions' ) );
} }
@@ -201,10 +201,10 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
exit; exit;
} }
// nonce verification //* nonce verification
check_admin_referer( 'simple-sidebars-action_create-sidebar' ); 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'] ) ) if ( is_numeric( $args['id'] ) )
$args['id'] = sanitize_title_with_dashes( $args['name'] ); $args['id'] = sanitize_title_with_dashes( $args['name'] );
@@ -242,10 +242,10 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
exit; exit;
} }
// nonce verification //* nonce verification
check_admin_referer( 'simple-sidebars-action_edit-sidebar' ); 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'] ) ) if ( is_numeric( $args['id'] ) )
$args['id'] = sanitize_title_with_dashes( $args['name'] ); $args['id'] = sanitize_title_with_dashes( $args['name'] );
@@ -283,7 +283,7 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
exit; exit;
} }
// nonce verification //* nonce verification
check_admin_referer( 'simple-sidebars-action_delete-sidebar' ); check_admin_referer( 'simple-sidebars-action_delete-sidebar' );
$_sidebars = (array) get_option( SS_SETTINGS_FIELD ); $_sidebars = (array) get_option( SS_SETTINGS_FIELD );
+20 -15
View File
@@ -1,9 +1,9 @@
<?php <?php
add_action('admin_menu', 'ss_add_inpost_metabox');
/** /**
* This bit of code registers the meta box on posts/pages, * This bit of code registers the meta box on posts/pages,
* so that users can choose what sidebar to use. * so that users can choose what sidebar to use.
*/ */
add_action('admin_menu', 'ss_add_inpost_metabox');
function 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 ) {
@@ -19,13 +19,18 @@ function ss_add_inpost_metabox() {
function ss_inpost_metabox() { function ss_inpost_metabox() {
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) ); $_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
global $wp_registered_sidebars;
?> ?>
<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__ ) ); ?>" />
<?php
if( isset( $wp_registered_sidebars['sidebar'] ) ) {
?>
<p> <p>
<label class="howto" for="_ss_sidebar"><span><?php _e('Primary Sidebar', 'ss'); ?><span></label> <label class="howto" for="_ss_sidebar"><span><?php echo esc_attr( $wp_registered_sidebars['sidebar']['name'] ); ?><span></label>
<select name="_ss_sidebar" id="_ss_sidebar" style="width: 99%"> <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 <?php
@@ -36,12 +41,11 @@ function ss_inpost_metabox() {
</select> </select>
</p> </p>
<?php <?php
// don't show the option if there are no 3 column layouts registered }
if ( ! ss_has_3_column_layouts() ) if( isset( $wp_registered_sidebars['sidebar-alt'] ) ) {
return;
?> ?>
<p> <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 echo esc_attr( $wp_registered_sidebars['sidebar-alt']['name'] ); ?><span></label>
<select name="_ss_sidebar_alt" id="_ss_sidebar_alt" style="width: 99%"> <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 <?php
@@ -54,41 +58,42 @@ function ss_inpost_metabox() {
<?php <?php
} }
}
add_action( 'save_post', 'ss_inpost_metabox_save', 1, 2 );
/** /**
* This bit of code saves the sidebars chosen as post meta. * 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 ) { 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__) ) ) if ( !isset($_POST['ss_inpost_nonce']) || !wp_verify_nonce( $_POST['ss_inpost_nonce'], plugin_basename(__FILE__) ) )
return $post->ID; 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_AUTOSAVE') && DOING_AUTOSAVE ) return;
if ( defined('DOING_AJAX') && DOING_AJAX ) return; if ( defined('DOING_AJAX') && DOING_AJAX ) return;
if ( defined('DOING_CRON') && DOING_CRON ) return; if ( defined('DOING_CRON') && DOING_CRON ) return;
// is the user allowed to edit the post or page? //* 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 ) ) if ( ( 'page' == $_POST['post_type'] && ! current_user_can( 'edit_page', $post->ID ) ) || ! current_user_can( 'edit_post', $post->ID ) )
return $post->ID; return $post->ID;
$_sidebars = array( $_sidebars = array(
'_ss_sidebar' => $_POST['_ss_sidebar'], '_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 ) { 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 ) { if ( $value ) {
// save/update
update_post_meta($post->ID, $key, $value); update_post_meta($post->ID, $key, $value);
} else { } else {
// delete if blank
delete_post_meta($post->ID, $key); delete_post_meta($post->ID, $key);
} }
+4 -4
View File
@@ -31,9 +31,9 @@ function ss_term_sidebar($tag, $taxonomy) {
<table class="form-table"> <table class="form-table">
<tr class="form-field"> <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="genesis-meta[_ss_sidebar]"><?php _e( 'Primary Sidebar', 'ss' ); ?></label></th>
<td> <td>
<select name="meta[_ss_sidebar]" id="meta[_ss_sidebar]" style="padding-right: 10px;"> <select name="genesis-meta[_ss_sidebar]" id="genesis-meta[_ss_sidebar]" style="padding-right: 10px;">
<option value=""><?php _e( 'Default', 'ss' ); ?></option> <option value=""><?php _e( 'Default', 'ss' ); ?></option>
<?php <?php
foreach ( (array) $_sidebars as $id => $info ) { foreach ( (array) $_sidebars as $id => $info ) {
@@ -48,9 +48,9 @@ function ss_term_sidebar($tag, $taxonomy) {
if ( ss_has_3_column_layouts() ) { if ( ss_has_3_column_layouts() ) {
?> ?>
<tr class="form-field"> <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="genesis-meta[_ss_sidebar_alt]"><?php _e( 'Secondary Sidebar', 'ss' ); ?></label></th>
<td> <td>
<select name="meta[_ss_sidebar_alt]" id="meta[_ss_sidebar_alt]" style="padding-right: 10px;"> <select name="genesis-meta[_ss_sidebar_alt]" id="genesis-meta[_ss_sidebar_alt]" style="padding-right: 10px;">
<option value=""><?php _e( 'Default', 'ss' ); ?></option> <option value=""><?php _e( 'Default', 'ss' ); ?></option>
<?php <?php
foreach ( (array) $_sidebars as $id => $info ) { foreach ( (array) $_sidebars as $id => $info ) {
+13 -19
View File
@@ -9,7 +9,7 @@ Author URI: http://www.nathanrice.net/
Text Domain: ss Text Domain: ss
Domain Path: /languages/ Domain Path: /languages/
Version: 1.0.0 Version: 2.0.1
License: GNU General Public License v2.0 (or later) License: GNU General Public License v2.0 (or later)
License URI: http://www.opensource.org/licenses/gpl-license.php License URI: http://www.opensource.org/licenses/gpl-license.php
@@ -30,9 +30,8 @@ register_activation_hook( __FILE__, 'ss_activation_check' );
*/ */
function ss_activation_check() { function ss_activation_check() {
if ( 'genesis' != basename( TEMPLATEPATH ) ) { if ( ! defined( 'PARENT_THEME_VERSION' ) || ! version_compare( PARENT_THEME_VERSION, '2.0.0', '>=' ) )
ss_deactivate( '1.8.0', '3.3' ); ss_deactivate( '2.0.0', '3.6' );
}
} }
@@ -46,7 +45,7 @@ function ss_activation_check() {
function ss_deactivate( $genesis_version = '1.8.0', $wp_version = '3.3' ) { function ss_deactivate( $genesis_version = '1.8.0', $wp_version = '3.3' ) {
deactivate_plugins( plugin_basename( __FILE__ ) ); deactivate_plugins( plugin_basename( __FILE__ ) );
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 ) ); 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://my.studiopress.com/?download_id=91046d629e74d525b3f2978e404e7ffa', $genesis_version ) );
} }
@@ -60,27 +59,27 @@ add_action( 'genesis_init', 'ss_genesis_init', 12 );
*/ */
function ss_genesis_init() { 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' ) ) if ( ! class_exists( 'Genesis_Admin_Boxes' ) )
add_action( 'admin_init', 'ss_deactivate', 10, 0 ); add_action( 'admin_init', 'ss_deactivate', 10, 0 );
/** Load translations */ //* Load translations
load_plugin_textdomain( 'ss', false, 'genesis-simple-sidebars/languages' ); load_plugin_textdomain( 'ss', false, 'genesis-simple-sidebars/languages' );
/** required hooks */ //* required hooks
add_action( 'get_header', 'ss_sidebars_init' ); add_action( 'get_header', 'ss_sidebars_init' );
add_action( 'widgets_init', 'ss_register_sidebars' ); 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() ) if ( ! is_admin() )
return; return;
/** Include admin files */ //* Include admin files
require_once( SS_PLUGIN_DIR . '/includes/admin.php' ); require_once( SS_PLUGIN_DIR . '/includes/admin.php' );
require_once( SS_PLUGIN_DIR . '/includes/inpost.php' ); require_once( SS_PLUGIN_DIR . '/includes/inpost.php' );
require_once( SS_PLUGIN_DIR . '/includes/term.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' ); add_action( 'init', 'ss_term_edit_init' );
} }
@@ -95,23 +94,18 @@ function ss_register_sidebars() {
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) ); $_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 ) if ( ! $_sidebars )
return; 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 ) { foreach ( (array) $_sidebars as $id => $info ) {
register_sidebar( array( genesis_register_sidebar( array(
'name' => esc_html( $info['name'] ), 'name' => esc_html( $info['name'] ),
'id' => $id, 'id' => $id,
'description' => esc_html( $info['description'] ), 'description' => esc_html( $info['description'] ),
'editable' => 1, '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"
) ); ) );
} }
+17 -5
View File
@@ -2,15 +2,15 @@
Contributors: nathanrice, wpmuguru Contributors: nathanrice, wpmuguru
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118
Tags: hooks, genesis, genesiswp, studiopress Tags: hooks, genesis, genesiswp, studiopress
Requires at least: 3.0 Requires at least: 3.6
Tested up to: 3.3 Tested up to: 3.6
Stable tag: 0.9.2.1 Stable tag: 2.0.1
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 == == 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. 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.
@@ -59,3 +59,15 @@ Not in the way you're probably thinking. The markup surrounding the widget area
* Default custom taxonomy support to on for public taxonomies * Default custom taxonomy support to on for public taxonomies
* Remove secondary selection when no 3 column layouts are enabled * Remove secondary selection when no 3 column layouts are enabled
= 1.0.0 =
* Reorganize theme files
* Standards
= 2.0.0 =
* Compatibility with Genesis 2.0
* Standards
= 2.0.1 =
* Genesis 2.0.1 compatibility with term meta keys
* Use actual sidebar name, instead of hard coded names
* Fix incorrect textdomain