mirror of
https://github.com/10h30/genesis-simple-sidebars.git
synced 2026-06-05 15:08:34 +09:00
Modify deprecated functions for backward compatibility. see #22.
This commit is contained in:
@@ -117,7 +117,7 @@ class Genesis_Simple_Sidebars {
|
||||
*/
|
||||
public function includes() {
|
||||
|
||||
//require_once( $this->plugin_dir_path . 'includes/functions.php' );
|
||||
require_once( $this->plugin_dir_path . 'includes/functions.php' );
|
||||
require_once( $this->plugin_dir_path . 'includes/deprecated.php' );
|
||||
|
||||
}
|
||||
|
||||
@@ -22,11 +22,21 @@ class Genesis_Simple_Sidebars_Core {
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
add_action( 'after_setup_theme', array( $this, 'backward_compatibility' ) );
|
||||
add_action( 'widgets_init', array( $this, 'register_sidebars' ) );
|
||||
add_filter( 'sidebars_widgets', array( $this, 'sidebars_widgets_filter' ) );
|
||||
|
||||
}
|
||||
|
||||
public function backward_compatibility() {
|
||||
|
||||
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
|
||||
add_action( 'genesis_sidebar', 'ss_do_sidebar' );
|
||||
remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
|
||||
add_action( 'genesis_sidebar_alt', 'ss_do_sidebar_alt' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Take created sidebars and register them with WordPress.
|
||||
*
|
||||
@@ -65,23 +75,27 @@ class Genesis_Simple_Sidebars_Core {
|
||||
*/
|
||||
public function sidebars_widgets_filter( $widgets ) {
|
||||
|
||||
$sidebars = array(
|
||||
'sidebar' => '_ss_sidebar',
|
||||
'sidebar-alt' => '_ss_sidebar_alt',
|
||||
'header-right' => '_ss_header',
|
||||
);
|
||||
$sidebars = array();
|
||||
|
||||
/**
|
||||
* Swappable widget areas.
|
||||
*
|
||||
* An array of original widget area => GSS key for new sidebar. Can be used to add or remove widget areas from being
|
||||
* swappable in the Genesis Simple Sidebars admin.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param array $sidebars Array of widget areas that can be swapped, with the keys used to find the ID of the new widget area to swap in.
|
||||
*/
|
||||
$sidebars = apply_filters( 'genesis_simple_sidebars_widget_areas', $sidebars );
|
||||
if ( is_singular() ) {
|
||||
|
||||
$sidebars = array(
|
||||
'sidebar' => genesis_get_custom_field( '_ss_sidebar' ),
|
||||
'sidebar-alt' => genesis_get_custom_field( '_ss_sidebar_alt' ),
|
||||
'header-right' => genesis_get_custom_field( '_ss_header' ),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if ( is_tax() || is_category() || is_tag() ) {
|
||||
|
||||
$sidebars = array(
|
||||
'sidebar' => get_term_meta( get_queried_object()->term_id, '_ss_sidebar', true ),
|
||||
'sidebar-alt' => get_term_meta( get_queried_object()->term_id, '_ss_sidebar_alt', true ),
|
||||
'header-right' => get_term_meta( get_queried_object()->term_id, '_ss_header', true ),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$widgets = $this->swap_widgets( $widgets, $sidebars );
|
||||
|
||||
@@ -100,30 +114,14 @@ class Genesis_Simple_Sidebars_Core {
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
foreach ( (array) $sidebars as $old_sidebar => $new_sidebar_key ) {
|
||||
foreach ( (array) $sidebars as $old_sidebar => $new_sidebar ) {
|
||||
|
||||
if ( ! is_registered_sidebar( $old_sidebar ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_singular() ) {
|
||||
|
||||
$new_sidebar = genesis_get_custom_field( $new_sidebar_key );
|
||||
|
||||
if ( $new_sidebar && ! empty( $widgets[ $new_sidebar ] ) ) {
|
||||
$widgets[ $old_sidebar ] = $widgets[ $new_sidebar ];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( is_tax() || is_category() || is_tag() ) {
|
||||
|
||||
$new_sidebar = get_term_meta( get_queried_object()->term_id, $new_sidebar_key, true );
|
||||
|
||||
if ( $new_sidebar && ! empty( $widgets[ $new_sidebar ] ) ) {
|
||||
$widgets[ $old_sidebar ] = $widgets[ $new_sidebar ];
|
||||
}
|
||||
|
||||
if ( $new_sidebar && ! empty( $widgets[ $new_sidebar ] ) ) {
|
||||
$widgets[ $old_sidebar ] = $widgets[ $new_sidebar ];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-19
@@ -56,28 +56,20 @@ function ss_sidebars_init() {
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_do_sidebar() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
function ss_do_one_sidebar( $sidebar_key = '' ) {
|
||||
|
||||
/**
|
||||
* 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' );
|
||||
if ( '_ss_sidebar' == $sidebar_key ) {
|
||||
genesis_do_sidebar();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( '_ss_sidebar_alt' == $sidebar_key ) {
|
||||
genesis_do_sidebar_alt();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dummy function for backward compatibility. Outputs the primary sidebar.
|
||||
*
|
||||
* @since 0.9.0
|
||||
*/
|
||||
function ss_do_sidebar() {
|
||||
genesis_do_sidebar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy function for backward compatibility. Outputs the secondary sidebar.
|
||||
*
|
||||
* @since 0.9.0
|
||||
*/
|
||||
function ss_do_sidebar_alt() {
|
||||
genesis_do_sidebar_alt();
|
||||
}
|
||||
+2
-2
@@ -5,8 +5,8 @@ Plugin URI: http://www.studiopress.com/plugins/simple-sidebars
|
||||
|
||||
Description: Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.
|
||||
|
||||
Author: Nathan Rice
|
||||
Author URI: http://www.nathanrice.net/
|
||||
Author: StudioPress
|
||||
Author URI: http://www.studiopress.com/
|
||||
|
||||
Version: 2.1.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user