Core
Core class for the buddypress settings
Description
Source
File: bp-integrations/learndash/buddypress/Core.php
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | 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.