PluginProbe
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce / 1.2.6
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce v1.2.6
1.17.9 1.17.8 1.17.7 1.17.6 1.17.5 1.17.4 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.11 1.3.12 1.3.13 1.3.14 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 143 releases
erp / includes / admin / class-menu.php

class-menu.php in ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce 1.2.6, at includes/admin/class-menu.php

181 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WeDevs\ERP\Admin;
3 use WeDevs\ERP\Framework\Traits\Hooker;
4
5 /**
6 * Administration Menu Class
7 *
8 * @package payroll
9 */
10 class Admin_Menu {
11
12 use Hooker;
13
14 /**
15 * Kick-in the class
16 */
17 public function __construct() {
18 $this->action( 'admin_menu', 'admin_menu', 99 );
19 $this->action( 'admin_menu', 'hide_admin_menus', 100 );
20 $this->action( 'wp_before_admin_bar_render', 'hide_admin_bar_links', 100 );
21 }
22
23 /**
24 * Get the admin menu position
25 *
26 * @return int the position of the menu
27 */
28 public function get_menu_position() {
29 return apply_filters( 'payroll_menu_position', 9999 );
30 }
31
32 /**
33 * Add menu items
34 *
35 * @return void
36 */
37 public function admin_menu() {
38
39 add_menu_page( __( 'ERP', 'erp' ), 'ERP Settings', 'manage_options', 'erp-company', array( $this, 'company_page' ), 'dashicons-admin-settings', $this->get_menu_position() );
40
41 add_submenu_page( 'erp-company', __( 'Company', 'erp' ), __( 'Company', 'erp' ), 'manage_options', 'erp-company', array( $this, 'company_page' ) );
42 add_submenu_page( 'erp-company', __( 'Tools', 'erp' ), __( 'Tools', 'erp' ), 'manage_options', 'erp-tools', array( $this, 'tools_page' ) );
43 add_submenu_page( 'erp-company', __( 'Audit Log', 'erp' ), __( 'Audit Log', 'erp' ), 'manage_options', 'erp-audit-log', array( $this, 'log_page' ) );
44 add_submenu_page( 'erp-company', __( 'Settings', 'erp' ), __( 'Settings', 'erp' ), 'manage_options', 'erp-settings', array( $this, 'settings_page' ) );
45 add_submenu_page( 'erp-company', __( 'Modules', 'erp' ), __( 'Modules', 'erp' ), 'manage_options', 'erp-modules', array( $this, 'module' ) );
46 add_submenu_page( 'erp-company', __( 'Add-Ons', 'erp' ), __( 'Add-Ons', 'erp' ), 'manage_options', 'erp-addons', array( $this, 'addon_page' ) );
47
48 }
49
50 /**
51 * Erp Settings page
52 *
53 * @return void
54 */
55 function settings_page() {
56 new \WeDevs\ERP\Settings();
57 }
58
59 /**
60 * Erp module
61 *
62 * @return void
63 */
64 function module() {
65 new \WeDevs\ERP\Admin\Admin_Module();
66 }
67
68 /**
69 * Hide default WordPress menu's
70 *
71 * @return void
72 */
73 function hide_admin_menus() {
74 global $menu;
75
76 $menus = get_option( '_erp_admin_menu', array() );
77
78 if ( ! $menus ) {
79 return;
80 }
81
82 foreach ($menus as $item) {
83 remove_menu_page( $item );
84 }
85
86 remove_menu_page( 'edit-tags.php?taxonomy=link_category' );
87 remove_menu_page( 'separator1' );
88 remove_menu_page( 'separator2' );
89 remove_menu_page( 'separator-last' );
90
91 $position = 9998;
92 $menu[$position] = array(
93 0 => '',
94 1 => 'read',
95 2 => 'separator' . $position,
96 3 => '',
97 4 => 'wp-menu-separator'
98 );
99 }
100
101 /**
102 * Hide default admin bar links
103 *
104 * @return void
105 */
106 function hide_admin_bar_links() {
107 global $wp_admin_bar;
108
109 $adminbar_menus = get_option( '_erp_adminbar_menu', array() );
110 if ( ! $adminbar_menus ) {
111 return;
112 }
113
114 foreach ($adminbar_menus as $item) {
115 $wp_admin_bar->remove_menu( $item );
116 }
117 }
118
119 /**
120 * Handles the company page
121 *
122 * @return void
123 */
124 public function company_page() {
125 $action = isset( $_GET['action'] ) ? $_GET['action'] : 'list';
126
127 switch ($action) {
128 case 'edit':
129 $company = new \WeDevs\ERP\Company();
130 $template = WPERP_VIEWS . '/company-editor.php';
131 break;
132
133 default:
134 $template = WPERP_VIEWS . '/company.php';
135 break;
136 }
137
138 if ( file_exists( $template ) ) {
139 include $template;
140 }
141 }
142
143 /**
144 * Handles the company locations page
145 *
146 * @return void
147 */
148 public function locations_page() {
149 include_once dirname( __FILE__ ) . '/views/locations.php';
150 }
151
152 /**
153 * Handles the tools page
154 *
155 * @return void
156 */
157 public function tools_page() {
158 include_once dirname( __FILE__ ) . '/views/tools.php';
159 }
160
161 /**
162 * Handles the log page
163 *
164 * @return void
165 */
166 public function log_page() {
167 include_once dirname( __FILE__ ) . '/views/log.php';
168 }
169
170 /**
171 * Handles the log page
172 *
173 * @return void
174 */
175 public function addon_page() {
176 include_once dirname( __FILE__ ) . '/views/add-ons.php';
177 }
178 }
179
180 return new Admin_Menu();
181