mirror of
https://github.com/10h30/genesis-simple-sidebars.git
synced 2026-07-12 02:56:12 +09:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 357bc65a70 | |||
| 4e5bfa7caf | |||
| f96e67d4df | |||
| fde95b0dd7 | |||
| 76e5f73e28 | |||
| 5a1b4bec6e | |||
| 2f6eb81ed6 | |||
| 13505bdc2b | |||
| ed788e7432 | |||
| 7395bd6db3 | |||
| ee29d99335 | |||
| 5300ec9601 | |||
| ff6077078d |
@@ -0,0 +1,187 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Genesis_Simple_Sidebars {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin version
|
||||||
|
*/
|
||||||
|
public $plugin_version = '2.1.0';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum WordPress version.
|
||||||
|
*/
|
||||||
|
public $min_wp_version = '4.7.2';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum Genesis version.
|
||||||
|
*/
|
||||||
|
public $min_genesis_version = '2.4.2';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The plugin textdomain, for translations.
|
||||||
|
*/
|
||||||
|
public $plugin_textdomain = 'genesis-simple-sidebars';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The url to the plugin directory.
|
||||||
|
*/
|
||||||
|
public $plugin_dir_url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path to the plugin directory.
|
||||||
|
*/
|
||||||
|
public $plugin_dir_path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main settings field for this plugin.
|
||||||
|
*/
|
||||||
|
public $settings_field = 'ss-settings';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Core functions of sidebar registration and output.
|
||||||
|
*/
|
||||||
|
public $core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Admin menu and settings page.
|
||||||
|
*/
|
||||||
|
public $admin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry settings and metadata.
|
||||||
|
*/
|
||||||
|
public $entry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
|
||||||
|
$this->plugin_dir_url = plugin_dir_url( __FILE__ );
|
||||||
|
$this->plugin_dir_path = plugin_dir_path( __FILE__ );
|
||||||
|
|
||||||
|
// For backward compatibility
|
||||||
|
define( 'SS_PLUGIN_DIR', $this->plugin_dir_path );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function init() {
|
||||||
|
|
||||||
|
register_activation_hook( __FILE__, array( $this, 'activation' ) );
|
||||||
|
|
||||||
|
$this->load_plugin_textdomain();
|
||||||
|
$this->includes();
|
||||||
|
$this->instantiate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin activation hook. Runs when plugin is activated.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function activation() {
|
||||||
|
|
||||||
|
if ( ! defined( 'PARENT_THEME_VERSION' ) || ! version_compare( PARENT_THEME_VERSION, $this->min_genesis_version, '>=' ) ) {
|
||||||
|
|
||||||
|
deactivate_plugins( plugin_basename( __FILE__ ) );
|
||||||
|
wp_die( sprintf( __( 'Sorry, you cannot run Genesis Simple Sidebars without WordPress %s and <a href="%s">Genesis %s</a>, or greater.', 'genesis-simple-sidebars' ), $this->min_wp_version, 'http://my.studiopress.com/?download_id=91046d629e74d525b3f2978e404e7ffa', $this->min_genesis_version ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the plugin textdomain, for translation.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function load_plugin_textdomain() {
|
||||||
|
load_plugin_textdomain( $this->plugin_textdomain, false, $this->plugin_dir_path . 'languages/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All general includes.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function includes() {
|
||||||
|
|
||||||
|
//require_once( $this->plugin_dir_path . 'includes/functions.php' );
|
||||||
|
//require_once( $this->plugin_dir_path . 'includes/deprecated.php' );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include the class file, instantiate the classes, create objects.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function instantiate() {
|
||||||
|
|
||||||
|
add_action( 'genesis_setup', array( $this, 'genesis_dependencies' ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load and instantiate any Genesis dependencies.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function genesis_dependencies() {
|
||||||
|
|
||||||
|
require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-core.php' );
|
||||||
|
$this->core = new Genesis_Simple_Sidebars_Core;
|
||||||
|
$this->core->init();
|
||||||
|
|
||||||
|
// Anything beyond this point should only be loaded if in the admin.
|
||||||
|
if ( ! is_admin() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-entry.php' );
|
||||||
|
$this->entry = new Genesis_Simple_Sidebars_Entry;
|
||||||
|
$this->entry->init();
|
||||||
|
|
||||||
|
require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-term.php' );
|
||||||
|
$this->term = new Genesis_Simple_Sidebars_Term;
|
||||||
|
$this->term->init();
|
||||||
|
|
||||||
|
require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-admin.php' );
|
||||||
|
$this->admin = new Genesis_Simple_Sidebars_Admin;
|
||||||
|
$this->admin->admin_menu();
|
||||||
|
|
||||||
|
// For backward compatibility
|
||||||
|
global $_genesis_simple_sidebars;
|
||||||
|
$_genesis_simple_sidebars = $this->admin;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to retrieve the static object without using globals.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
function Genesis_Simple_Sidebars() {
|
||||||
|
|
||||||
|
static $object;
|
||||||
|
|
||||||
|
if ( null == $object ) {
|
||||||
|
$object = new Genesis_Simple_Sidebars;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Initialize the object on `plugins_loaded`.
|
||||||
|
*/
|
||||||
|
add_action( 'plugins_loaded', array( Genesis_Simple_Sidebars(), 'init' ) );
|
||||||
@@ -13,6 +13,25 @@
|
|||||||
*/
|
*/
|
||||||
class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings field.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public $settings_field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
|
||||||
|
$this->settings_field = Genesis_Simple_Sidebars()->settings_field;
|
||||||
|
|
||||||
|
// For backward compatibility
|
||||||
|
define( 'SS_SETTINGS_FIELD', $this->settings_field );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an admin menu item and settings page.
|
* Create an admin menu item and settings page.
|
||||||
*
|
*
|
||||||
@@ -22,7 +41,7 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
|||||||
*
|
*
|
||||||
* @see Genesis_Admin_Import_Export::actions() Handle creating, editing, and deleting sidebars.
|
* @see Genesis_Admin_Import_Export::actions() Handle creating, editing, and deleting sidebars.
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function admin_menu() {
|
||||||
|
|
||||||
$page_id = 'simple-sidebars';
|
$page_id = 'simple-sidebars';
|
||||||
|
|
||||||
@@ -34,14 +53,12 @@ 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;
|
$this->create( $page_id, $menu_ops, $page_ops, $this->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' ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -56,14 +73,14 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
|||||||
*/
|
*/
|
||||||
public function admin() {
|
public function admin() {
|
||||||
|
|
||||||
$_sidebars = get_option( $this->settings_field );
|
|
||||||
|
|
||||||
echo '<div class="wrap">';
|
echo '<div class="wrap">';
|
||||||
|
|
||||||
if ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] )
|
if ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] ) {
|
||||||
require_once( SS_PLUGIN_DIR . '/includes/views/edit.php' );
|
require_once( Genesis_Simple_Sidebars()->plugin_dir_path . '/includes/views/admin-edit.php' );
|
||||||
else
|
}
|
||||||
require_once( SS_PLUGIN_DIR . '/includes/views/main.php' );
|
else {
|
||||||
|
require_once( Genesis_Simple_Sidebars()->plugin_dir_path . '/includes/views/admin-main.php' );
|
||||||
|
}
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
@@ -129,8 +146,9 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
|||||||
*/
|
*/
|
||||||
public function actions() {
|
public function actions() {
|
||||||
|
|
||||||
if ( ! genesis_is_menu_page( 'simple-sidebars' ) )
|
if ( ! genesis_is_menu_page( 'simple-sidebars' ) ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This section handles the data if a new sidebar is created
|
* This section handles the data if a new sidebar is created
|
||||||
@@ -164,8 +182,9 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
|||||||
*/
|
*/
|
||||||
public function notices() {
|
public function notices() {
|
||||||
|
|
||||||
if ( ! genesis_is_menu_page( 'simple-sidebars' ) )
|
if ( ! genesis_is_menu_page( 'simple-sidebars' ) ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$pattern = '<div id="message" class="updated"><p><strong>%s</strong></p></div>';
|
$pattern = '<div id="message" class="updated"><p><strong>%s</strong></p></div>';
|
||||||
|
|
||||||
@@ -196,34 +215,39 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
|||||||
*/
|
*/
|
||||||
protected function create_sidebar( $args = array() ) {
|
protected function create_sidebar( $args = array() ) {
|
||||||
|
|
||||||
if ( empty( $args['name'] ) || empty( $args['id'] ) ) {
|
if ( empty( $args['name'] ) ) {
|
||||||
wp_die( $this->error( 1 ) );
|
wp_die( $this->error( 1 ) );
|
||||||
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
|
// Change empty or numeric IDs to the name, lowercased and separated by dashes.
|
||||||
if ( is_numeric( $args['id'] ) )
|
if ( empty( $args['id'] ) || is_numeric( $args['id'] ) ) {
|
||||||
$args['id'] = sanitize_title_with_dashes( $args['name'] );
|
$args['id'] = $args['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strip all but alphanumeric, sanitize with dashes.
|
||||||
|
$id = preg_replace( "/[^a-zA-Z0-9 -]+/", "", sanitize_title_with_dashes( $args['id'] ) );
|
||||||
|
|
||||||
|
$db = (array) get_option( $this->settings_field );
|
||||||
|
|
||||||
$db = (array) get_option( SS_SETTINGS_FIELD );
|
|
||||||
$new = array(
|
$new = array(
|
||||||
sanitize_title_with_dashes( $args['id'] ) => array(
|
$id => array(
|
||||||
'name' => esc_html( $args['name'] ),
|
'name' => esc_html( $args['name'] ),
|
||||||
'description' => esc_html( $args['description'] )
|
'description' => esc_html( $args['description'] )
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( array_key_exists( $args['id'], $db ) ) {
|
if ( array_key_exists( $id, $db ) ) {
|
||||||
wp_die( $this->error( 2 ) );
|
wp_die( $this->error( 2 ) );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$_sidebars = wp_parse_args( $new, $db );
|
$_sidebars = wp_parse_args( $new, $db );
|
||||||
|
|
||||||
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
update_option( $this->settings_field, $_sidebars );
|
||||||
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&created=true' ) );
|
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&created=true' ) );
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
@@ -242,16 +266,12 @@ 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
|
$db = (array) get_option( $this->settings_field );
|
||||||
if ( is_numeric( $args['id'] ) )
|
|
||||||
$args['id'] = sanitize_title_with_dashes( $args['name'] );
|
|
||||||
|
|
||||||
$db = (array) get_option( SS_SETTINGS_FIELD );
|
|
||||||
$new = array(
|
$new = array(
|
||||||
sanitize_title_with_dashes( $args['id'] ) => array(
|
$args['id'] => array(
|
||||||
'name' => esc_html( $args['name'] ),
|
'name' => esc_html( $args['name'] ),
|
||||||
'description' => esc_html( $args['description'] )
|
'description' => esc_html( $args['description'] )
|
||||||
)
|
)
|
||||||
@@ -264,7 +284,7 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
|||||||
|
|
||||||
$_sidebars = wp_parse_args( $new, $db );
|
$_sidebars = wp_parse_args( $new, $db );
|
||||||
|
|
||||||
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
update_option( $this->settings_field, $_sidebars );
|
||||||
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&edited=true' ) );
|
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&edited=true' ) );
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
@@ -283,10 +303,10 @@ 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( $this->settings_field );
|
||||||
|
|
||||||
if ( ! isset( $_sidebars[$id] ) ) {
|
if ( ! isset( $_sidebars[$id] ) ) {
|
||||||
wp_die( $this->error( 4 ) );
|
wp_die( $this->error( 4 ) );
|
||||||
@@ -295,7 +315,7 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
|||||||
|
|
||||||
unset( $_sidebars[$id] );
|
unset( $_sidebars[$id] );
|
||||||
|
|
||||||
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
update_option( $this->settings_field, $_sidebars );
|
||||||
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&deleted=true' ) );
|
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&deleted=true' ) );
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
@@ -316,7 +336,7 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
|||||||
switch( (int) $error ) {
|
switch( (int) $error ) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
return __( 'Oops! Please choose a valid Name and ID for this sidebar', 'genesis-simple-sidebars' );
|
return __( 'Oops! Please choose a valid Name for this sidebar', 'genesis-simple-sidebars' );
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
return __( 'Oops! That sidebar ID already exists', 'genesis-simple-sidebars' );
|
return __( 'Oops! That sidebar ID already exists', 'genesis-simple-sidebars' );
|
||||||
@@ -335,17 +355,3 @@ class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'genesis_admin_menu', 'simplesidebars_settings_menu' );
|
|
||||||
/**
|
|
||||||
* Instantiate the class to create the menu.
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
function simplesidebars_settings_menu() {
|
|
||||||
|
|
||||||
global $_genesis_simple_sidebars_admin;
|
|
||||||
|
|
||||||
$_genesis_simple_sidebars_admin = new Genesis_Simple_Sidebars_Admin;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls the core functions of registration and output of Sidebars
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
class Genesis_Simple_Sidebars_Core {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The created sidebars.
|
||||||
|
*/
|
||||||
|
private $sidebars;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public taxonomies.
|
||||||
|
*/
|
||||||
|
private $public_taxonomies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the class.
|
||||||
|
*/
|
||||||
|
public function init() {
|
||||||
|
|
||||||
|
add_action( 'widgets_init', array( $this, 'register_sidebars' ) );
|
||||||
|
add_action( 'get_header', array( $this, 'swap_sidebars' ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take created sidebars and register them with WordPress.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function register_sidebars() {
|
||||||
|
|
||||||
|
$sidebars = Genesis_Simple_Sidebars()->core->get_sidebars();
|
||||||
|
|
||||||
|
if ( ! $sidebars ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cycle through created sidebars, register them as widget areas
|
||||||
|
foreach ( (array) $sidebars as $id => $info ) {
|
||||||
|
|
||||||
|
if ( ! isset( $info['name'] ) || ! isset( $info['description'] ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
genesis_register_sidebar( array(
|
||||||
|
'name' => esc_html( $info['name'] ),
|
||||||
|
'id' => $id,
|
||||||
|
'description' => esc_html( $info['description'] ),
|
||||||
|
'editable' => 1,
|
||||||
|
) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove default sidebars and inject custom sidebars.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function swap_sidebars() {
|
||||||
|
|
||||||
|
// Header
|
||||||
|
if ( is_registered_sidebar( 'header-right' ) ) {
|
||||||
|
global $wp_registered_sidebars;
|
||||||
|
$wp_registered_sidebars['ss-header-right-temp'] = $wp_registered_sidebars['header-right'];
|
||||||
|
unset( $wp_registered_sidebars['header-right'] );
|
||||||
|
add_action( 'genesis_header_right', array( $this, 'do_header_right' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sidebars
|
||||||
|
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
|
||||||
|
remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
|
||||||
|
add_action( 'genesis_sidebar', array( $this, 'do_primary_sidebar' ) );
|
||||||
|
add_action( 'genesis_sidebar_alt', array( $this, 'do_secondary_sidebar' ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output custom header widget area, if one is set. Otherwise output default.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function do_header_right() {
|
||||||
|
|
||||||
|
global $wp_registered_sidebars;
|
||||||
|
|
||||||
|
if ( ! $this->do_sidebar( '_ss_header' ) ) {
|
||||||
|
$wp_registered_sidebars['header-right'] = $wp_registered_sidebars['ss-header-right-temp'];
|
||||||
|
}
|
||||||
|
|
||||||
|
unset( $wp_registered_sidebars['ss-header-right-temp'] );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output custom primary sidebar, if one is set. Otherwise output default.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function do_primary_sidebar() {
|
||||||
|
|
||||||
|
if ( ! $this->do_sidebar( '_ss_sidebar' ) ) {
|
||||||
|
genesis_do_sidebar();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output custom secondary sidebar, if one is set. Otherwise output default.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function do_secondary_sidebar() {
|
||||||
|
|
||||||
|
if ( ! $this->do_sidebar( '_ss_sidebar_alt' ) ) {
|
||||||
|
genesis_do_sidebar_alt();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show widgets in a particular sidebar.
|
||||||
|
*
|
||||||
|
* @param string $key sidebar id you wish to output.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function do_sidebar( $key ) {
|
||||||
|
|
||||||
|
if ( is_singular() && $key = genesis_get_custom_field( $key ) ) {
|
||||||
|
|
||||||
|
if ( dynamic_sidebar( $key ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_tax() || is_category() || is_tag() ) {
|
||||||
|
|
||||||
|
if ( $key = get_term_meta( get_queried_object()->term_id, $key, true ) ) {
|
||||||
|
dynamic_sidebar( $key );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all custom registered sidebars.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function get_sidebars( $cache = true ) {
|
||||||
|
|
||||||
|
if ( ! $cache ) {
|
||||||
|
return stripslashes_deep( get_option( Genesis_Simple_Sidebars()->settings_field ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_null( $this->sidebars ) ) {
|
||||||
|
$this->sidebars = stripslashes_deep( get_option( Genesis_Simple_Sidebars()->settings_field ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->sidebars;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return taxonomy ids.
|
||||||
|
*
|
||||||
|
* Helper function to return the array keys from a taxonomy query.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function get_public_taxonomies() {
|
||||||
|
|
||||||
|
if ( is_null( $this->public_taxonomies ) ) {
|
||||||
|
$this->public_taxonomies = get_taxonomies( array(
|
||||||
|
'show_ui' => true,
|
||||||
|
'public' => true,
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->public_taxonomies = apply_filters( 'genesis_simple_sidebars_taxonomies', array_keys( $this->public_taxonomies ) );
|
||||||
|
|
||||||
|
return $this->public_taxonomies;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if this site has disabled 3 column layouts or not.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function has_3_column_layout() {
|
||||||
|
|
||||||
|
$layouts = genesis_get_layouts();
|
||||||
|
|
||||||
|
$three_column_layouts = array(
|
||||||
|
'content-sidebar-sidebar',
|
||||||
|
'sidebar-content-sidebar',
|
||||||
|
'sidebar-sidebar-content',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $three_column_layouts as $layout ) {
|
||||||
|
if ( array_key_exists( $layout, $layouts ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Genesis_Simple_Sidebars_Entry {
|
||||||
|
|
||||||
|
public function init() {
|
||||||
|
|
||||||
|
add_action( 'admin_menu', array( $this, 'add_metaboxes' ) );
|
||||||
|
add_action( 'save_post', array( $this, 'metabox_save' ), 1, 2 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cycle through supported post types and add metaboxes.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function add_metaboxes() {
|
||||||
|
|
||||||
|
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', 'genesis-simple-sidebars' ), array( $this, 'metabox_content' ), $type, 'side', 'low' );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include the metabox content.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function metabox_content() {
|
||||||
|
|
||||||
|
require_once( Genesis_Simple_Sidebars()->plugin_dir_path . 'includes/views/entry-metabox-content.php' );
|
||||||
|
|
||||||
|
print_r( get_post_meta( get_the_ID() ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the metabox fields when the entry is saved.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
public function metabox_save( $post_id, $post ) {
|
||||||
|
|
||||||
|
if ( ! isset( $_POST['genesis_simple_sidebars'] ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = wp_parse_args( $_POST['genesis_simple_sidebars'], array(
|
||||||
|
'_ss_header' => '',
|
||||||
|
'_ss_sidebar' => '',
|
||||||
|
'_ss_sidebar_alt' => '',
|
||||||
|
) );
|
||||||
|
|
||||||
|
genesis_save_custom_fields( $data, 'genesis-simple-sidebars-save-entry', 'genesis-simple-sidebars-save-entry-nonce', $post );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Genesis_Simple_Sidebars_Term {
|
||||||
|
|
||||||
|
public function init() {
|
||||||
|
|
||||||
|
add_action( 'init', array( $this, 'add_term_fields' ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add_term_fields() {
|
||||||
|
|
||||||
|
$taxonomies = Genesis_Simple_Sidebars()->core->get_public_taxonomies();
|
||||||
|
|
||||||
|
if ( ! empty( $taxonomies ) && is_admin() && is_array( $taxonomies ) ) {
|
||||||
|
|
||||||
|
foreach ( $taxonomies as $tax ) {
|
||||||
|
add_action( "{$tax}_edit_form", array( $this, 'term_sidebar_form' ), 9, 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function term_sidebar_form( $tag, $taxonomy ) {
|
||||||
|
|
||||||
|
require_once( Genesis_Simple_Sidebars()->plugin_dir_path . 'includes/views/term-edit-sidebar-form.php' );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_activation_check() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_deactivate() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_genesis_init() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_register_sidebars() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_sidebars_init() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_do_sidebar() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_do_sidebar_alt() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_do_one_sidebar() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_get_taxonomies() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.2
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_has_3_column_layouts() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function simplesidebars_settings_menu() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_add_inpost_metabox() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_inpost_metabox() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_inpost_metabox_save() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_term_edit_init() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated.
|
||||||
|
*
|
||||||
|
* @since 0.9.0
|
||||||
|
* @deprecated 2.1.0
|
||||||
|
*/
|
||||||
|
function ss_term_sidebar() {
|
||||||
|
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||||
|
}
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
<?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.
|
|
||||||
*/
|
|
||||||
function ss_add_inpost_metabox() {
|
|
||||||
|
|
||||||
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', 'genesis-simple-sidebars' ), 'ss_inpost_metabox', $type, 'side', 'low' );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function ss_inpost_metabox() {
|
|
||||||
|
|
||||||
$_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__ ) ); ?>" />
|
|
||||||
|
|
||||||
<?php
|
|
||||||
if( isset( $wp_registered_sidebars['sidebar'] ) ) {
|
|
||||||
?>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<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%">
|
|
||||||
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></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'] ) );
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
if( isset( $wp_registered_sidebars['sidebar-alt'] ) ) {
|
|
||||||
?>
|
|
||||||
<p>
|
|
||||||
<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%">
|
|
||||||
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></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'] ) );
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action( 'save_post', 'ss_inpost_metabox_save', 1, 2 );
|
|
||||||
/**
|
|
||||||
* This bit of code saves the sidebars chosen as post meta.
|
|
||||||
*/
|
|
||||||
function ss_inpost_metabox_save( $post_id, $post ) {
|
|
||||||
|
|
||||||
//* 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.
|
|
||||||
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 ) )
|
|
||||||
return $post->ID;
|
|
||||||
|
|
||||||
$_sidebars = array(
|
|
||||||
'_ss_sidebar' => $_POST['_ss_sidebar'],
|
|
||||||
'_ss_sidebar_alt' => $_POST['_ss_sidebar_alt'],
|
|
||||||
);
|
|
||||||
|
|
||||||
//* store the custom fields
|
|
||||||
foreach ( $_sidebars as $key => $value ) {
|
|
||||||
|
|
||||||
//* don't try to store data during revision save
|
|
||||||
if ( 'revision' === $post->post_type )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( $value ) {
|
|
||||||
update_post_meta($post->ID, $key, $value);
|
|
||||||
} else {
|
|
||||||
delete_post_meta($post->ID, $key);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* This function, hooked to display on the category/tag edit forms,
|
|
||||||
* adds new fields to select a sidebar. The variables $tag and $taxonomy
|
|
||||||
* are passed via the hook so that we can use them.
|
|
||||||
*/
|
|
||||||
function ss_term_edit_init() {
|
|
||||||
|
|
||||||
$taxonomies = ss_get_taxonomies();
|
|
||||||
|
|
||||||
if ( ! empty( $taxonomies ) && is_admin() && is_array( $taxonomies ) ) {
|
|
||||||
|
|
||||||
foreach( $taxonomies as $tax )
|
|
||||||
add_action( "{$tax}_edit_form", 'ss_term_sidebar', 9, 2 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function ss_term_sidebar($tag, $taxonomy) {
|
|
||||||
|
|
||||||
//* Merge Defaults to prevent notices
|
|
||||||
$tag->meta = wp_parse_args( $tag->meta, array( '_ss_sidebar' => '', '_ss_sidebar_alt' => '' ) );
|
|
||||||
|
|
||||||
//* Pull custom sidebars
|
|
||||||
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<h3><?php _e( 'Sidebar Options', 'genesis-simple-sidebars' ); ?></h3>
|
|
||||||
<table class="form-table">
|
|
||||||
|
|
||||||
<tr class="form-field">
|
|
||||||
<th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar]"><?php _e( 'Primary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
|
|
||||||
<td>
|
|
||||||
<select name="genesis-meta[_ss_sidebar]" id="genesis-meta[_ss_sidebar]" style="padding-right: 10px;">
|
|
||||||
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
|
||||||
<?php
|
|
||||||
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'] ) );
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
//* don't show the option if there are no 3 column layouts registered
|
|
||||||
if ( ss_has_3_column_layouts() ) {
|
|
||||||
?>
|
|
||||||
<tr class="form-field">
|
|
||||||
<th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar_alt]"><?php _e( 'Secondary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
|
|
||||||
<td>
|
|
||||||
<select name="genesis-meta[_ss_sidebar_alt]" id="genesis-meta[_ss_sidebar_alt]" style="padding-right: 10px;">
|
|
||||||
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
|
||||||
<?php
|
|
||||||
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'] ) );
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
if ( array_key_exists( $_REQUEST['id'], (array) $_sidebars ) ) {
|
$sidebars = Genesis_Simple_Sidebars()->core->get_sidebars();
|
||||||
$_sidebar = stripslashes_deep( $_sidebars[$_REQUEST['id']] );
|
|
||||||
|
if ( array_key_exists( $_REQUEST['id'], (array) $sidebars ) ) {
|
||||||
|
$sidebar = stripslashes_deep( $sidebars[ $_REQUEST['id'] ] );
|
||||||
} else {
|
} else {
|
||||||
wp_die( __( 'Nice try, partner. But that sidebar doesn\'t exist. Click back and try again.', 'genesis-simple-sidebars' ) );
|
wp_die( __( 'Nice try, partner. But that sidebar doesn\'t exist. Click back and try again.', 'genesis-simple-sidebars' ) );
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
screen_icon( 'themes' ); ?>
|
<h1><?php _e( 'Edit Sidebar', 'genesis-simple-sidebars' ); ?></h1>
|
||||||
<h2><?php _e( 'Edit Sidebar', 'genesis-simple-sidebars' ); ?></h2>
|
|
||||||
|
|
||||||
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&action=edit' ); ?>">
|
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&action=edit' ); ?>">
|
||||||
<?php wp_nonce_field( 'simple-sidebars-action_edit-sidebar' ); ?>
|
<?php wp_nonce_field( 'simple-sidebars-action_edit-sidebar' ); ?>
|
||||||
@@ -15,21 +16,21 @@ screen_icon( 'themes' ); ?>
|
|||||||
|
|
||||||
<tr class="form-field">
|
<tr class="form-field">
|
||||||
<th scope="row" valign="top"><label for="edit_sidebar[name]"><?php _e( 'Name', 'genesis-simple-sidebars' ); ?></label></th>
|
<th scope="row" valign="top"><label for="edit_sidebar[name]"><?php _e( 'Name', 'genesis-simple-sidebars' ); ?></label></th>
|
||||||
<td><input name="edit_sidebar[name]" id="edit_sidebar[name]" type="text" value="<?php echo esc_html( $_sidebar['name'] ); ?>" size="40" />
|
<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', 'genesis-simple-sidebars' ); ?></p></td>
|
<p class="description"><?php _e( 'A recognizable name for your new sidebar widget area', 'genesis-simple-sidebars' ); ?></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="form-field">
|
<tr class="form-field">
|
||||||
<th scope="row" valign="top"><label for="edit_sidebar[id]"><?php _e( 'ID', 'genesis-simple-sidebars' ); ?></label></th>
|
<th scope="row" valign="top"><label for="edit_sidebar[id]"><?php _e( 'ID', 'genesis-simple-sidebars' ); ?></label></th>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" disabled="disabled" />
|
<input type="text" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" readonly />
|
||||||
<input name="edit_sidebar[id]" id="edit_sidebar[id]" type="hidden" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" />
|
<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)', 'genesis-simple-sidebars' ); ?></p></td>
|
<p class="description"><?php _e( 'The unique ID is used to register the sidebar widget area (cannot be changed)', 'genesis-simple-sidebars' ); ?></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="form-field">
|
<tr class="form-field">
|
||||||
<th scope="row" valign="top"><label for="edit_sidebar[description]"><?php _e( 'Description', 'genesis-simple-sidebars' ); ?></label></th>
|
<th scope="row" valign="top"><label for="edit_sidebar[description]"><?php _e( 'Description', 'genesis-simple-sidebars' ); ?></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>
|
<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>
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php screen_icon( 'themes' ); ?>
|
<h1><?php _e( 'Genesis - Simple Sidebars', 'genesis-simple-sidebars' ); ?></h1>
|
||||||
<h2><?php _e( 'Genesis - Simple Sidebars', 'genesis-simple-sidebars' ); ?></h2>
|
|
||||||
|
|
||||||
<div id="col-container">
|
<div id="col-container">
|
||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
$sidebars = Genesis_Simple_Sidebars()->core->get_sidebars();
|
||||||
|
global $wp_registered_sidebars;
|
||||||
|
wp_nonce_field( 'genesis-simple-sidebars-save-entry', 'genesis-simple-sidebars-save-entry-nonce' );
|
||||||
|
|
||||||
|
if ( is_registered_sidebar( 'header-right' ) ) : ?>
|
||||||
|
<p>
|
||||||
|
<label class="howto" for="genesis_simple_sidebars[_ss_header]"><span><?php echo esc_attr( $wp_registered_sidebars['header-right']['name'] ); ?><span></label>
|
||||||
|
<select name="genesis_simple_sidebars[_ss_header]" id="genesis_simple_sidebars[_ss_header]" style="width: 99%">
|
||||||
|
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></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_header' ), false), esc_html( $info['name'] ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<?php endif;
|
||||||
|
|
||||||
|
if ( is_registered_sidebar( 'sidebar' ) ) : ?>
|
||||||
|
<p>
|
||||||
|
<label class="howto" for="genesis_simple_sidebars[_ss_sidebar]"><span><?php echo esc_attr( $wp_registered_sidebars['sidebar']['name'] ); ?><span></label>
|
||||||
|
<select name="genesis_simple_sidebars[_ss_sidebar]" id="genesis_simple_sidebars[_ss_sidebar]" style="width: 99%">
|
||||||
|
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></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'] ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<?php endif;
|
||||||
|
|
||||||
|
if ( is_registered_sidebar( 'sidebar-alt' ) ) : ?>
|
||||||
|
<p>
|
||||||
|
<label class="howto" for="genesis_simple_sidebars[_ss_sidebar_alt]"><span><?php echo esc_attr( $wp_registered_sidebars['sidebar-alt']['name'] ); ?><span></label>
|
||||||
|
<select name="genesis_simple_sidebars[_ss_sidebar_alt]" id="genesis_simple_sidebars[_ss_sidebar_alt]" style="width: 99%">
|
||||||
|
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></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'] ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<?php endif;
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php $sidebars = Genesis_Simple_Sidebars()->core->get_sidebars(); ?>
|
||||||
|
|
||||||
|
<h3><?php _e( 'Sidebar Options', 'genesis-simple-sidebars' ); ?></h3>
|
||||||
|
<table class="form-table">
|
||||||
|
|
||||||
|
<?php if ( is_registered_sidebar( 'header-right' ) ) : ?>
|
||||||
|
<tr class="form-field">
|
||||||
|
<th scope="row" valign="top"><label for="genesis-meta[_ss_header]"><?php _e( 'Header Right', 'genesis-simple-sidebars' ); ?></label></th>
|
||||||
|
<td>
|
||||||
|
<select name="genesis-meta[_ss_header]" id="genesis-meta[_ss_header]" style="padding-right: 10px;">
|
||||||
|
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
||||||
|
<?php
|
||||||
|
foreach ( (array) $sidebars as $id => $info ) {
|
||||||
|
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_header', true ), false), esc_html( $info['name'] ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<tr class="form-field">
|
||||||
|
<th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar]"><?php _e( 'Primary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
|
||||||
|
<td>
|
||||||
|
<select name="genesis-meta[_ss_sidebar]" id="genesis-meta[_ss_sidebar]" style="padding-right: 10px;">
|
||||||
|
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
||||||
|
<?php
|
||||||
|
foreach ( (array) $sidebars as $id => $info ) {
|
||||||
|
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_sidebar', true ), false), esc_html( $info['name'] ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<?php if ( Genesis_Simple_Sidebars()->core->has_3_column_layout() ) : ?>
|
||||||
|
<tr class="form-field">
|
||||||
|
<th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar_alt]"><?php _e( 'Secondary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
|
||||||
|
<td>
|
||||||
|
<select name="genesis-meta[_ss_sidebar_alt]" id="genesis-meta[_ss_sidebar_alt]" style="padding-right: 10px;">
|
||||||
|
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
||||||
|
<?php
|
||||||
|
foreach ( (array) $sidebars as $id => $info ) {
|
||||||
|
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_sidebar_alt', true ) , false), esc_html( $info['name'] ) );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
</table>
|
||||||
+5
-224
@@ -2,238 +2,19 @@
|
|||||||
/*
|
/*
|
||||||
Plugin Name: Genesis Simple Sidebars
|
Plugin Name: Genesis Simple Sidebars
|
||||||
Plugin URI: http://www.studiopress.com/plugins/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.
|
Description: Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.
|
||||||
|
|
||||||
Author: Nathan Rice
|
Author: Nathan Rice
|
||||||
Author URI: http://www.nathanrice.net/
|
Author URI: http://www.nathanrice.net/
|
||||||
|
|
||||||
|
Version: 2.1.0
|
||||||
|
|
||||||
Text Domain: genesis-simple-sidebars
|
Text Domain: genesis-simple-sidebars
|
||||||
Domain Path: /languages/
|
Domain Path: /languages/
|
||||||
|
|
||||||
Version: 2.0.2
|
|
||||||
|
|
||||||
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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Define our constants */
|
require_once( plugin_dir_path( __FILE__ ) . 'genesis-simple-sidebars.php' );
|
||||||
define( 'SS_SETTINGS_FIELD', 'ss-settings' );
|
|
||||||
define( 'SS_PLUGIN_DIR', dirname( __FILE__ ) );
|
|
||||||
|
|
||||||
register_activation_hook( __FILE__, 'ss_activation_check' );
|
|
||||||
/**
|
|
||||||
* Activation hook callback.
|
|
||||||
*
|
|
||||||
* This functions runs when the plugin is activated. It checks to make sure the user is running
|
|
||||||
* a minimum Genesis version, so there are no conflicts or fatal errors.
|
|
||||||
*
|
|
||||||
* @since 0.9.0
|
|
||||||
*/
|
|
||||||
function ss_activation_check() {
|
|
||||||
|
|
||||||
if ( ! defined( 'PARENT_THEME_VERSION' ) || ! version_compare( PARENT_THEME_VERSION, '2.0.0', '>=' ) )
|
|
||||||
ss_deactivate( '2.0.0', '3.6' );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deactivate Simple Sidebars.
|
|
||||||
*
|
|
||||||
* This function deactivates Simple Sidebars.
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
function ss_deactivate( $genesis_version = '1.8.0', $wp_version = '3.3' ) {
|
|
||||||
|
|
||||||
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.', 'genesis-simple-sidebars' ), $wp_version, 'http://my.studiopress.com/?download_id=91046d629e74d525b3f2978e404e7ffa', $genesis_version ) );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action( 'genesis_init', 'ss_genesis_init', 12 );
|
|
||||||
/**
|
|
||||||
* Plugin initialization.
|
|
||||||
*
|
|
||||||
* Initialize the plugin, set the constants, hook callbacks to actions, and include the plugin library.
|
|
||||||
*
|
|
||||||
* @since 0.9.0
|
|
||||||
*/
|
|
||||||
function ss_genesis_init() {
|
|
||||||
|
|
||||||
//* 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_plugin_textdomain( 'genesis-simple-sidebars', false, 'genesis-simple-sidebars/languages' );
|
|
||||||
|
|
||||||
//* 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
|
|
||||||
if ( ! is_admin() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
//* 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
|
|
||||||
add_action( 'init', 'ss_term_edit_init' );
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Register widget areas.
|
|
||||||
*
|
|
||||||
* This function registers the created sidebars as widget areas
|
|
||||||
*
|
|
||||||
* @since 0.9.0
|
|
||||||
*/
|
|
||||||
function ss_register_sidebars() {
|
|
||||||
|
|
||||||
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
|
||||||
|
|
||||||
//* If no sidebars have been created, do nothing
|
|
||||||
if ( ! $_sidebars )
|
|
||||||
return;
|
|
||||||
|
|
||||||
//* Cycle through created sidebars, register them as widget areas
|
|
||||||
foreach ( (array) $_sidebars as $id => $info ) {
|
|
||||||
|
|
||||||
genesis_register_sidebar( array(
|
|
||||||
'name' => esc_html( $info['name'] ),
|
|
||||||
'id' => $id,
|
|
||||||
'description' => esc_html( $info['description'] ),
|
|
||||||
'editable' => 1,
|
|
||||||
) );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use custom sidebars.
|
|
||||||
*
|
|
||||||
* Remove the default sidebars, run some conditional logic,
|
|
||||||
* use alternate sidebars if necessary, else fallback on default sidebars.
|
|
||||||
*
|
|
||||||
* @since 0.9.0
|
|
||||||
*/
|
|
||||||
function ss_sidebars_init() {
|
|
||||||
|
|
||||||
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
|
|
||||||
remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
|
|
||||||
add_action( 'genesis_sidebar', 'ss_do_sidebar' );
|
|
||||||
add_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display primary sidebar.
|
|
||||||
*
|
|
||||||
* Display custom sidebar if one exists, else display default primary sidebar.
|
|
||||||
*
|
|
||||||
* @since 0.9.0
|
|
||||||
*/
|
|
||||||
function ss_do_sidebar() {
|
|
||||||
|
|
||||||
if ( ! ss_do_one_sidebar( '_ss_sidebar' ) )
|
|
||||||
genesis_do_sidebar();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display secondary sidebar.
|
|
||||||
*
|
|
||||||
* Display custom sidebar if one exists, else display default secondary sidebar.
|
|
||||||
*
|
|
||||||
* @since 0.9.0
|
|
||||||
*/
|
|
||||||
function ss_do_sidebar_alt() {
|
|
||||||
|
|
||||||
if ( ! ss_do_one_sidebar( '_ss_sidebar_alt' ) )
|
|
||||||
genesis_do_sidebar_alt();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sidebar widget area output.
|
|
||||||
*
|
|
||||||
* Helper function to show widgets in a particular sidebar.
|
|
||||||
*
|
|
||||||
* @param string $sidebar_key sidebar id you wish to output.
|
|
||||||
*
|
|
||||||
* @since 0.9.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ss_do_one_sidebar( $sidebar_key = '_ss_sidebar' ) {
|
|
||||||
|
|
||||||
static $taxonomies = null;
|
|
||||||
|
|
||||||
if ( is_singular() && $sidebar_key = genesis_get_custom_field( $sidebar_key ) ) {
|
|
||||||
if ( dynamic_sidebar( $sidebar_key ) ) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_category() ) {
|
|
||||||
$term = get_term( get_query_var( 'cat' ), 'category' );
|
|
||||||
if ( isset( $term->meta[$sidebar_key] ) && dynamic_sidebar( $term->meta[$sidebar_key] ) ) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_tag() ) {
|
|
||||||
$term = get_term( get_query_var( 'tag_id' ), 'post_tag' );
|
|
||||||
if ( isset( $term->meta[$sidebar_key] ) && dynamic_sidebar( $term->meta[$sidebar_key] ) ) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_tax() ) {
|
|
||||||
if ( null === $taxonomies )
|
|
||||||
$taxonomies = ss_get_taxonomies();
|
|
||||||
|
|
||||||
foreach ( $taxonomies as $tax ) {
|
|
||||||
if ( 'post_tag' == $tax || 'category' == $tax )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( is_tax( $tax ) ) {
|
|
||||||
$obj = get_queried_object();
|
|
||||||
$term = get_term( $obj->term_id, $tax );
|
|
||||||
if ( isset( $term->meta[$sidebar_key] ) && dynamic_sidebar( $term->meta[$sidebar_key] ) ) return true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return taxonomy ids.
|
|
||||||
*
|
|
||||||
* Helper function to return the array keys from a taxonomy query.
|
|
||||||
*
|
|
||||||
* @since 0.9.0
|
|
||||||
*/
|
|
||||||
function ss_get_taxonomies() {
|
|
||||||
|
|
||||||
$taxonomies = get_taxonomies( array( 'show_ui' => true, 'public' => true ) );
|
|
||||||
return apply_filters( 'genesis_simple_sidebars_taxonomies', array_keys( $taxonomies ) );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Does this Genesis install have the 3 column layouts deactivated?
|
|
||||||
*
|
|
||||||
* This function checks to see if the Genesis install still has active 3 column layouts. Since
|
|
||||||
* child themes and plugins can deregister layouts, we need to know if they have deregistered the 3 column layouts.
|
|
||||||
*
|
|
||||||
* @since 0.9.2
|
|
||||||
*/
|
|
||||||
function ss_has_3_column_layouts() {
|
|
||||||
|
|
||||||
$_layouts = (array) genesis_get_layouts();
|
|
||||||
$_layouts = array_keys( $_layouts );
|
|
||||||
$_3_column = array_intersect( $_layouts, array( 'content-sidebar-sidebar', 'sidebar-content-sidebar', 'sidebar-sidebar-content' ) );
|
|
||||||
|
|
||||||
return ! empty( $_3_column );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
+26
-20
@@ -3,8 +3,8 @@ 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.6
|
Requires at least: 3.6
|
||||||
Tested up to: 4.3.1
|
Tested up to: 4.5
|
||||||
Stable tag: 2.0.2
|
Stable tag: 2.1.0
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
@@ -37,42 +37,48 @@ Not in the way you're probably thinking. The markup surrounding the widget area
|
|||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 2.1.0 =
|
||||||
|
* Rewrite based on new plugin boilerplate.
|
||||||
|
|
||||||
|
= 2.0.3 =
|
||||||
|
* Fix warnings and notices.
|
||||||
|
|
||||||
= 2.0.2 =
|
= 2.0.2 =
|
||||||
* Change text domain, update POT file.
|
* Change text domain, update POT file.
|
||||||
|
|
||||||
= 2.0.1 =
|
= 2.0.1 =
|
||||||
* Genesis 2.0.1 compatibility with term meta keys
|
* Genesis 2.0.1 compatibility with term meta keys.
|
||||||
* Use actual sidebar name, instead of hard coded names
|
* Use actual sidebar name, instead of hard coded names.
|
||||||
* Fix incorrect textdomain
|
* Fix incorrect textdomain.
|
||||||
|
|
||||||
= 2.0.0 =
|
= 2.0.0 =
|
||||||
* Compatibility with Genesis 2.0
|
* Compatibility with Genesis 2.0.0.
|
||||||
* Standards
|
* Standards.
|
||||||
|
|
||||||
= 1.0.0 =
|
= 1.0.0 =
|
||||||
* Reorganize theme files
|
* Reorganize theme files.
|
||||||
* Standards
|
* Standards
|
||||||
|
|
||||||
= 0.9.2.1 =
|
= 0.9.2.1 =
|
||||||
* Restore default tag/category support
|
* Restore default tag/category support.
|
||||||
* 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.
|
||||||
|
|
||||||
= 0.9.2 =
|
= 0.9.2 =
|
||||||
* Added support for custom taxonomies
|
* Added support for custom taxonomies.
|
||||||
* Added translation support
|
* Added translation support.
|
||||||
* bug fix to prevent invalid sidebar creation
|
* bug fix to prevent invalid sidebar creation.
|
||||||
|
|
||||||
= 0.9.1 =
|
= 0.9.1 =
|
||||||
* Added support for custom post types
|
* Added support for custom post types.
|
||||||
|
|
||||||
= 0.9 =
|
= 0.9 =
|
||||||
* Fixed "is not array" errors reported by users
|
* Fixed "is not array" errors reported by users.
|
||||||
* Added nonce verification for security purposes
|
* Added nonce verification for security purposes.
|
||||||
* Added error and success messages
|
* Added error and success messages.
|
||||||
* Bump to pre-release 0.9 branch
|
* Bump to pre-release 0.9 branch.
|
||||||
|
|
||||||
= 0.1 =
|
= 0.1 =
|
||||||
* Initial Alpha Release
|
* Initial Alpha Release.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user