PluginProbe
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce / 1.3.13
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce v1.3.13
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.3.13, at includes/admin/class-menu.php

191 lines 4.9 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', __( 'Status', 'erp' ), __( 'Status', 'erp' ), 'manage_options', 'erp-status', array( $this, 'status_page' ) );
46 add_submenu_page( 'erp-company', __( 'Modules', 'erp' ), __( 'Modules', 'erp' ), 'manage_options', 'erp-modules', array( $this, 'module' ) );
47 add_submenu_page( 'erp-company', __( 'Add-Ons', 'erp' ), __( 'Add-Ons', 'erp' ), 'manage_options', 'erp-addons', array( $this, 'addon_page' ) );
48
49 }
50
51 /**
52 * Erp Settings page
53 *
54 * @return void
55 */
56 function settings_page() {
57 new \WeDevs\ERP\Settings();
58 }
59
60 /**
61 * Erp Status page
62 *
63 * @return void
64 */
65 function status_page() {
66 new \WeDevs\ERP\Status();
67 }
68
69 /**
70 * Erp module
71 *
72 * @return void
73 */
74 function module() {
75 new \WeDevs\ERP\Admin\Admin_Module();
76 }
77
78 /**
79 * Hide default WordPress menu's
80 *
81 * @return void
82 */
83 function hide_admin_menus() {
84 global $menu;
85
86 $menus = get_option( '_erp_admin_menu', array() );
87
88 if ( ! $menus ) {
89 return;
90 }
91
92 foreach ($menus as $item) {
93 remove_menu_page( $item );
94 }
95
96 remove_menu_page( 'edit-tags.php?taxonomy=link_category' );
97 remove_menu_page( 'separator1' );
98 remove_menu_page( 'separator2' );
99 remove_menu_page( 'separator-last' );
100
101 $position = 9998;
102 $menu[$position] = array(
103 0 => '',
104 1 => 'read',
105 2 => 'separator' . $position,
106 3 => '',
107 4 => 'wp-menu-separator'
108 );
109 }
110
111 /**
112 * Hide default admin bar links
113 *
114 * @return void
115 */
116 function hide_admin_bar_links() {
117 global $wp_admin_bar;
118
119 $adminbar_menus = get_option( '_erp_adminbar_menu', array() );
120 if ( ! $adminbar_menus ) {
121 return;
122 }
123
124 foreach ($adminbar_menus as $item) {
125 $wp_admin_bar->remove_menu( $item );
126 }
127 }
128
129 /**
130 * Handles the company page
131 *
132 * @return void
133 */
134 public function company_page() {
135 $action = isset( $_GET['action'] ) ? $_GET['action'] : 'list';
136
137 switch ($action) {
138 case 'edit':
139 $company = new \WeDevs\ERP\Company();
140 $template = WPERP_VIEWS . '/company-editor.php';
141 break;
142
143 default:
144 $template = WPERP_VIEWS . '/company.php';
145 break;
146 }
147
148 if ( file_exists( $template ) ) {
149 include $template;
150 }
151 }
152
153 /**
154 * Handles the company locations page
155 *
156 * @return void
157 */
158 public function locations_page() {
159 include_once dirname( __FILE__ ) . '/views/locations.php';
160 }
161
162 /**
163 * Handles the tools page
164 *
165 * @return void
166 */
167 public function tools_page() {
168 include_once dirname( __FILE__ ) . '/views/tools.php';
169 }
170
171 /**
172 * Handles the log page
173 *
174 * @return void
175 */
176 public function log_page() {
177 include_once dirname( __FILE__ ) . '/views/log.php';
178 }
179
180 /**
181 * Handles the log page
182 *
183 * @return void
184 */
185 public function addon_page() {
186 include_once dirname( __FILE__ ) . '/views/add-ons.php';
187 }
188 }
189
190 return new Admin_Menu();
191