mirror of
https://github.com/10h30/genesis-simple-sidebars.git
synced 2026-06-05 15:08:34 +09:00
Tagging 0.9.2.
This commit is contained in:
+63
-36
@@ -3,20 +3,23 @@
|
||||
Plugin Name: Genesis Simple Sidebars
|
||||
Plugin URI: http://www.studiopress.com/plugins/simple-sidebars
|
||||
Description: Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.
|
||||
Version: 0.9.1
|
||||
Version: 0.9.2
|
||||
Author: Nathan Rice
|
||||
Author URI: http://www.nathanrice.net/
|
||||
Text Domain: ss
|
||||
Domain Path: /languages/
|
||||
*/
|
||||
|
||||
// require Genesis 1.2 upon activation
|
||||
register_activation_hook(__FILE__, 'ss_activation_check');
|
||||
function ss_activation_check() {
|
||||
|
||||
$latest = '1.2';
|
||||
$latest = '1.2';
|
||||
|
||||
$theme_info = get_theme_data(TEMPLATEPATH.'/style.css');
|
||||
$theme_info = get_theme_data(TEMPLATEPATH.'/style.css');
|
||||
|
||||
if( basename(TEMPLATEPATH) != 'genesis' ) {
|
||||
load_plugin_textdomain( 'ss', false, 'genesis-simple-sidebars/languages' );
|
||||
deactivate_plugins(plugin_basename(__FILE__)); // Deactivate ourself
|
||||
wp_die( sprintf( __('Sorry, you can\'t activate unless you have installed <a href="%s">Genesis</a>', 'ss'), 'http://www.studiopress.com/themes/genesis' ) );
|
||||
}
|
||||
@@ -28,20 +31,33 @@ function ss_activation_check() {
|
||||
|
||||
}
|
||||
|
||||
// Define our constants
|
||||
define('SS_SETTINGS_FIELD', 'ss-settings');
|
||||
define('SS_PLUGIN_DIR', dirname(__FILE__));
|
||||
/**
|
||||
* Hook into Genesis
|
||||
*/
|
||||
add_action( 'genesis_init', 'ss_genesis_init', 12 );
|
||||
function ss_genesis_init() {
|
||||
// Define our constants
|
||||
define( 'SS_SETTINGS_FIELD', 'ss-settings' );
|
||||
define( 'SS_PLUGIN_DIR', dirname( __FILE__ ) );
|
||||
|
||||
// Include files
|
||||
require_once(SS_PLUGIN_DIR . '/admin.php');
|
||||
require_once(SS_PLUGIN_DIR . '/functions.php');
|
||||
require_once(SS_PLUGIN_DIR . '/inpost.php');
|
||||
require_once(SS_PLUGIN_DIR . '/term.php');
|
||||
// required hooks
|
||||
add_action( 'get_header', 'ss_sidebars_init' );
|
||||
add_action( 'widgets_init', 'ss_register_sidebars' );
|
||||
if ( !is_admin() )
|
||||
return;
|
||||
|
||||
// Include admin files
|
||||
load_plugin_textdomain( 'ss', false, 'genesis-simple-sidebars/languages' );
|
||||
require_once( SS_PLUGIN_DIR . '/admin.php' );
|
||||
require_once( SS_PLUGIN_DIR . '/functions.php' );
|
||||
require_once( SS_PLUGIN_DIR . '/inpost.php' );
|
||||
require_once( SS_PLUGIN_DIR . '/term.php' );
|
||||
// let the child theme hook the genesis_simple_sidebars_taxonomies filter before hooking term edit
|
||||
add_action( 'init', 'ss_term_edit_init' );
|
||||
}
|
||||
/**
|
||||
* This function registers the created sidebars
|
||||
*/
|
||||
add_action('widgets_init', 'ss_register_sidebars');
|
||||
function ss_register_sidebars() {
|
||||
|
||||
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
||||
@@ -70,7 +86,6 @@ function ss_register_sidebars() {
|
||||
* Remove the default sidebars, run some conditional logic,
|
||||
* use alternate sidebars if necessary, else fallback on default sidebars.
|
||||
*/
|
||||
add_action('get_header', 'ss_sidebars_init');
|
||||
function ss_sidebars_init() {
|
||||
remove_action('genesis_sidebar', 'genesis_do_sidebar');
|
||||
remove_action('genesis_sidebar_alt', 'genesis_do_sidebar_alt');
|
||||
@@ -79,40 +94,52 @@ function ss_sidebars_init() {
|
||||
}
|
||||
|
||||
function ss_do_sidebar() {
|
||||
|
||||
if ( is_singular() && $_sidebar = genesis_get_custom_field('_ss_sidebar') ) {
|
||||
if ( dynamic_sidebar($_sidebar) ) return;
|
||||
}
|
||||
|
||||
if ( is_category() ) {
|
||||
$term = get_term( get_query_var('cat'), 'category' );
|
||||
if( isset( $term->meta['_ss_sidebar'] ) && dynamic_sidebar( $term->meta['_ss_sidebar'] ) ) return;
|
||||
}
|
||||
|
||||
if ( is_tag() ) {
|
||||
$term = get_term( get_query_var('tag_id'), 'post_tag' );
|
||||
if( isset( $term->meta['_ss_sidebar'] ) && dynamic_sidebar( $term->meta['_ss_sidebar'] ) ) return;
|
||||
}
|
||||
|
||||
genesis_do_sidebar();
|
||||
|
||||
|
||||
if ( ! ss_do_one_sidebar( '_ss_sidebar' ) )
|
||||
genesis_do_sidebar();
|
||||
|
||||
}
|
||||
function ss_do_sidebar_alt() {
|
||||
|
||||
if ( ! ss_do_one_sidebar( '_ss_sidebar_alt' ) )
|
||||
genesis_do_sidebar_alt();
|
||||
|
||||
}
|
||||
|
||||
function ss_do_one_sidebar( $bar = '_ss_sidebar' ) {
|
||||
static $taxonomies = null;
|
||||
|
||||
if ( is_singular() && $_sidebar_alt = genesis_get_custom_field('_ss_sidebar_alt') ) {
|
||||
if ( dynamic_sidebar($_sidebar_alt) ) return;
|
||||
if ( is_singular() && $_bar = genesis_get_custom_field( $bar ) ) {
|
||||
if ( dynamic_sidebar( $_bar ) ) return true;
|
||||
}
|
||||
|
||||
if ( is_category() ) {
|
||||
$term = get_term( get_query_var('cat'), 'category' );
|
||||
if( isset( $term->meta['_ss_sidebar_alt'] ) && dynamic_sidebar( $term->meta['_ss_sidebar_alt'] ) ) return;
|
||||
if( isset( $term->meta[$bar] ) && dynamic_sidebar( $term->meta[$bar] ) ) return true;
|
||||
}
|
||||
|
||||
if ( is_tag() ) {
|
||||
$term = get_term( get_query_var('tag_id'), 'post_tag' );
|
||||
if( isset( $term->meta['_ss_sidebar_alt'] ) && dynamic_sidebar( $term->meta['_ss_sidebar_alt'] ) ) return;
|
||||
if( isset( $term->meta[$bar] ) && dynamic_sidebar( $term->meta[$bar] ) ) return true;
|
||||
}
|
||||
|
||||
genesis_do_sidebar_alt();
|
||||
if ( is_tax() ) {
|
||||
if( $taxonomies === null )
|
||||
$taxonomies = (array)apply_filters( 'genesis_simple_sidebars_taxonomies', array() );
|
||||
|
||||
foreach( $taxonomies as $tax ) {
|
||||
if( $tax == 'post_tag' || $tax == 'category' )
|
||||
continue;
|
||||
|
||||
if( is_tax( $tax ) ) {
|
||||
$obj = get_queried_object();
|
||||
$term = get_term( $obj->term_id, $tax );
|
||||
if( isset( $term->meta[$bar] ) && dynamic_sidebar( $term->meta[$bar] ) ) return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user