WPB_Admin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 102
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A enqueue_styles() 0 15 1
A __construct() 0 5 1
A enqueue_scripts() 0 15 1
A register_menus() 0 18 1
1
<?php
2
/**
3
 * The admin-specific functionality of the plugin.
4
 *
5
 * @link       https://github.com/maab16
6
 * @since      1.0.0
7
 */
8
9
/**
10
 * The admin-specific functionality of the plugin.
11
 *
12
 * Defines the plugin name, version, and two examples hooks for how to
13
 * enqueue the admin-specific stylesheet and JavaScript.
14
 *
15
 * @author     Md Abu Ahsan basir <[email protected]>
16
 */
17
class WPB_Admin
18
{
19
    /**
20
     * The ID of this plugin.
21
     *
22
     * @since    1.0.0
23
     *
24
     * @var string The ID of this plugin.
25
     */
26
    private $plugin_name;
27
28
    /**
29
     * The version of this plugin.
30
     *
31
     * @since    1.0.0
32
     *
33
     * @var string The current version of this plugin.
34
     */
35
    private $version;
36
37
    /**
38
     * Initialize the class and set its properties.
39
     *
40
     * @since    1.0.0
41
     *
42
     * @param string $plugin_name The name of this plugin.
43
     * @param string $version     The version of this plugin.
44
     */
45
    public function __construct($plugin_name, $version)
46
    {
47
        $this->plugin_name = $plugin_name;
48
        $this->version = $version;
49
        $this->register_menus();
50
    }
51
52
    /**
53
     * Register the stylesheets for the admin area.
54
     *
55
     * @since    1.0.0
56
     */
57
    public function enqueue_styles()
58
    {
59
60
        /**
61
         * This function is provided for demonstration purposes only.
62
         *
63
         * An instance of this class should be passed to the run() function
64
         * defined in WPB_Loader as all of the hooks are defined
65
         * in that particular class.
66
         *
67
         * The WPB_Loader will then create the relationship
68
         * between the defined hooks and the functions defined in this
69
         * class.
70
         */
71
        wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wpb-admin.css', [], $this->version, 'all');
0 ignored issues
show
Bug introduced by
The function wp_enqueue_style was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

71
        /** @scrutinizer ignore-call */ 
72
        wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wpb-admin.css', [], $this->version, 'all');
Loading history...
Bug introduced by
The function plugin_dir_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

71
        wp_enqueue_style($this->plugin_name, /** @scrutinizer ignore-call */ plugin_dir_url(__FILE__).'css/wpb-admin.css', [], $this->version, 'all');
Loading history...
72
    }
73
74
    /**
75
     * Register the JavaScript for the admin area.
76
     *
77
     * @since    1.0.0
78
     */
79
    public function enqueue_scripts()
80
    {
81
82
        /**
83
         * This function is provided for demonstration purposes only.
84
         *
85
         * An instance of this class should be passed to the run() function
86
         * defined in WPB_Loader as all of the hooks are defined
87
         * in that particular class.
88
         *
89
         * The WPB_Loader will then create the relationship
90
         * between the defined hooks and the functions defined in this
91
         * class.
92
         */
93
        wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/wpb-admin.js', ['jquery'], $this->version, false);
0 ignored issues
show
Bug introduced by
The function plugin_dir_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

93
        wp_enqueue_script($this->plugin_name, /** @scrutinizer ignore-call */ plugin_dir_url(__FILE__).'js/wpb-admin.js', ['jquery'], $this->version, false);
Loading history...
Bug introduced by
The function wp_enqueue_script was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

93
        /** @scrutinizer ignore-call */ 
94
        wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/wpb-admin.js', ['jquery'], $this->version, false);
Loading history...
94
    }
95
96
    /**
97
     * Register all menus here.
98
     *
99
     * @since    1.0.0
100
     */
101
    public function register_menus()
102
    {
103
        // Registerv root menu.
104
        $menu = new WPB_Admin_Menu($this->plugin_name);
105
        $menu->page_title = 'WPB';
106
        $menu->menu_title = 'WPB';
107
        $menu->capability = 'manage_options';
108
        $menu->slug = 'wpb';
109
        $menu->icon = 'dashicons-text';
110
        $menu->save();
111
        // Register submenu for root menu.
112
        $submenu = new WPB_Admin_SubMenu($this->plugin_name);
113
        $submenu->parent_slug = $menu->slug;
0 ignored issues
show
Bug introduced by
The property parent_slug does not seem to exist on WPB_Admin_SubMenu.
Loading history...
114
        $submenu->page_title = 'Settings';
115
        $submenu->menu_title = 'Settings';
116
        $submenu->capability = 'manage_options';
117
        $submenu->slug = 'admin.php?page='.$menu->slug.'#/settings';
118
        $submenu->save();
119
    }
120
}
121