Skip to content

Instantly share code, notes, and snippets.

@thomasplevy
Last active April 26, 2016 00:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save thomasplevy/9ef38871e876be346f97efb52d7d1fe9 to your computer and use it in GitHub Desktop.
LifterLMS Course and Lesson Sidebar compatibility for the Pet Rescue theme (http://themeforest.net/item/pet-rescue-animals-shelter-charity-wp-theme/9347370?ref=gocodeBOX)
<?php // do not paste this line into your functions.php
/**
* Display lesson and course custom sidebars on the appropriate LifterLMS pages
*
* @param array $sidebars_widgets array of registered sidebars
* @return array
*/
function lifterlms_sidebar_compatibility( $sidebars_widgets ) {
// replace the widgets in the primary sidebar with LifterLMS Course sidebar on Course Pages
if ( is_singular( 'course' ) && array_key_exists( 'llms_course_widgets_side', $sidebars_widgets ) ) {
$sidebars_widgets['sidebar_default'] = $sidebars_widgets['llms_course_widgets_side'];
}
// replace the widgets in the primary sidebar with LifterLMS Lesson sidebar on Lesson Pages
elseif ( is_singular( 'lesson' ) && array_key_exists( 'llms_lesson_widgets_side', $sidebars_widgets ) ) {
$sidebars_widgets['sidebar_default'] = $sidebars_widgets['llms_lesson_widgets_side'];
}
return $sidebars_widgets;
}
add_filter( 'sidebars_widgets', 'lifterlms_sidebar_compatibility' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment