Admin

Admin related actions on the core plugin

Description

Source

File: bp-integrations/learndash/core/Admin.php

19
20
21
22
23
24
25
26
27
28
29
30
31
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
class Admin
{
    /**
     * Constructor
     *
     * @since BuddyBoss 1.0.0
     */
    public function __construct()
    {
        add_action('bp_ld_sync/depencencies_failed', [$this, 'registerDependencyNotices']);
        add_action('bp_ld_sync/requirements_failed', [$this, 'registerRequirementNotices']);
    }
 
    /**
     * Add admin notice hook for dependencies
     *
     * @since BuddyBoss 1.0.0
     */
    public function registerDependencyNotices()
    {
        add_action('admin_notices',  [$this, 'printDependencyAdminNotice']);
    }
 
    /**
     * Add admin notice hook for requirements
     *
     * @since BuddyBoss 1.0.0
     */
    public function registerRequirementNotices()
    {
        // Removed this action because we don't have to display the notice.
        //add_action('admin_notices',  [$this, 'printRequirementAdminNotice']);
    }
 
    /**
     * Output the dependency notice html
     *
     * @since BuddyBoss 1.0.0
     */
    public function printDependencyAdminNotice()
    {
        $missingDepencencies = bp_ld_sync()->dependencies->getMissingDepencencies();
 
        $message = sprintf(
            _n(
                '%s is not initilized, the following required plugins are missing: %s',
                '%s is not initilized, the following required plugin is missing: %s',
                count($missingDepencencies),
                'buddyboss'
            ),
            '<b>' . bp_ld_sync()->pluginName . '</b>',
            '<b>' . implode(',', $missingDepencencies) . '</b>'
        );
 
        printf('<div class="notice notice-error">%s</div>', wpautop($message));
    }
 
    /**
     * Output the requirement notice html
     *
     * @since BuddyBoss 1.0.0
     */
    public function printRequirementAdminNotice()
    {
        foreach (bp_ld_sync()->requirements->getMissingRequirements() as $requirement) {
            printf('<div class="notice notice-error">%s</div>', wpautop($requirement['error']));
        }
    }
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Methods

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.