Admin
Class for learndash admin related functions
Description
Source
File: bp-integrations/learndash/learndash/Admin.php
class Admin { /** * Constructor * * @since BuddyBoss 1.0.0 */ public function __construct() { add_action('bp_ld_sync/init', [$this, 'init']); } /** * Add actions once integration is ready * * @since BuddyBoss 1.0.0 */ public function init() { if (! bp_ld_sync('settings')->get('learndash.enabled')) { return; } add_action('add_meta_boxes', [$this, 'addGroupSyncMetaBox']); } /** * Add gorup sync metabox to admin * * @since BuddyBoss 1.0.0 */ public function addGroupSyncMetaBox() { add_meta_box( 'bp_ld_sync-learndash-sync', __('Associated Social Group', 'buddyboss'), [$this, 'asyncMetaboxHtml'], 'groups', 'side' ); } /** * Output group sync metabox html * * @since BuddyBoss 1.0.0 */ public function asyncMetaboxHtml() { $groupId = get_the_ID(); $generator = bp_ld_sync('learndash')->sync->generator(null, $groupId); $hasBpGroup = $generator->hasBpGroup(); $bpGroupId = $hasBpGroup? $generator->getBpGroupId() : 0; $bpGroup = groups_get_group($bpGroupId); $availableBpGroups = bp_ld_sync('buddypress')->group->getUnassociatedGroups($groupId); $checked = get_current_screen()->action == 'add'? bp_ld_sync('settings')->get('learndash.default_auto_sync') : $hasBpGroup; require bp_ld_sync()->template('/admin/learndash/sync-meta-box.php'); } }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Methods
- __construct — Constructor
- addGroupSyncMetaBox — Add group sync metabox to admin
- asyncMetaboxHtml — Output group sync metabox html
- init — Add actions once integration is ready
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.