Skip to content

Commit

Permalink
Add ability to change default sidebar in Sidebar::getCurrentSidebarId()
Browse files Browse the repository at this point in the history
  • Loading branch information
atanas-dev committed Jun 8, 2018
1 parent d71ef01 commit 0e6c82a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Sidebar/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0e6c82a

Please sign in to comment.