From 0e6c82a48f5275931269aa5917ec971d69fed492 Mon Sep 17 00:00:00 2001 From: atanas-angelov-dev Date: Fri, 8 Jun 2018 12:09:02 +0300 Subject: [PATCH] Add ability to change default sidebar in Sidebar::getCurrentSidebarId() --- src/Sidebar/Sidebar.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Sidebar/Sidebar.php b/src/Sidebar/Sidebar.php index 510cf37..6f11f8c 100644 --- a/src/Sidebar/Sidebar.php +++ b/src/Sidebar/Sidebar.php @@ -32,20 +32,20 @@ protected function getSidebarPostId() { /** * Get the current sidebar id. * - * @param string $meta_key Meta key to check for a sidebar id. + * @param string $default Default sidebar to use if a custom one is not specified. + * @param string $meta_key Meta key to check for a custom sidebar id. * @return string */ - public function getCurrentSidebarId( $meta_key = '_app_custom_sidebar' ) { + public function getCurrentSidebarId( $default = 'default-sidebar', $meta_key = '_app_custom_sidebar' ) { $post_id = $this->getSidebarPostId(); - $default_sidebar = 'default-sidebar'; - $sidebar = $default_sidebar; + $sidebar = $default; if ( $post_id ) { $sidebar = get_post_meta( $post_id, $meta_key, true ); } if ( empty( $sidebar ) ) { - $sidebar = $default_sidebar; + $sidebar = $default; } return $sidebar;