Core
Core class for the buddypress settings
Description
Source
File: bp-integrations/learndash/buddypress/Core.php
class Core { /** * Constructor * * @since BuddyBoss 1.0.0 */ public function __construct() { $this->helpers = new Helpers; $this->courses = new Courses; $this->reports = new Reports; $this->ajax = new Ajax; $this->sync = new Sync; $this->hooks = new Hooks; $this->admin = new Admin; $this->group = new Group; add_action('bp_ld_sync/init', [$this, 'init']); } /** * Register actions on init * * @since BuddyBoss 1.0.0 */ public function init() { $this->registerTemplateStack(); $this->registerGroupComponent(); } /** * Add bp template stack so child theme can overwrite template * * @since BuddyBoss 1.0.0 */ protected function registerTemplateStack() { bp_register_template_stack([$this, 'registerPluginTemplate']); } /** * Register BP group extension components based on settings * * @since BuddyBoss 1.0.0 */ protected function registerGroupComponent() { if (! bp_is_group() && ! bp_is_group_create()) { return; } if (bp_ld_sync('settings')->get('learndash.enabled')) { require_once bp_ld_sync()->path('/buddypress/components/BpGroupCourses.php'); $extension = new BpGroupCourses; add_action('bp_actions', [$extension, '_register'], 8); add_action('admin_init', [$extension, '_register']); } if (bp_ld_sync('settings')->get('reports.enabled')) { require_once bp_ld_sync()->path('/buddypress/components/BpGroupReports.php'); $extension = new BpGroupReports; add_action('bp_actions', [$extension, '_register'], 8); add_action('admin_init', [$extension, '_register']); } } /** * Register the path the bp template stack * * @since BuddyBoss 1.0.0 */ public function registerPluginTemplate() { return bp_learndash_path('/templates'); } /** * Get the courses tab's sub menu items in group * * @since BuddyBoss 1.0.0 */ public function coursesSubMenus() { return wp_list_sort(apply_filters('bp_ld_sync/courses_group_tab_subnavs', [ 'courses' => [ 'name' => __('Courses', 'buddyboss'), 'slug' => '', 'position' => 10 ], ]), 'position', 'ASC', true); } /** * Get the reports tab's sub menu items in group * * @since BuddyBoss 1.0.0 */ public function reportsSubMenus() { return wp_list_sort(apply_filters('bp_ld_sync/reports_group_tab_subnavs', [ 'reports' => [ 'name' => __('Reports', 'buddyboss'), 'slug' => '', 'position' => 10 ], ]), 'position', 'ASC', true); } /** * Returns the link to the selected sub menu * * @since BuddyBoss 1.0.0 */ public function subMenuLink($slug) { $groupUrl = untrailingslashit(bp_get_group_permalink(groups_get_current_group())); $action = bp_current_action(); return untrailingslashit("{$groupUrl}/{$action}/{$slug}"); } }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Methods
- __construct — Constructor
- coursesSubMenus — Get the courses tab's sub menu items in group
- init — Register actions on init
- registerGroupComponent — Register BP group extension components based on settings
- registerPluginTemplate — Register the path the bp template stack
- registerTemplateStack — Add bp template stack so child theme can overwrite template
- reportsSubMenus — Get the reports tab's sub menu items in group
- subMenuLink — Returns the link to the selected sub menu
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.