PluginProbe
Property Hive / 1.4.46
Property Hive v1.4.46
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / includes / admin / class-ph-admin-menus.php

class-ph-admin-menus.php in Property Hive 1.4.46, at includes/admin/class-ph-admin-menus.php

240 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Setup menus in WP admin.
4 *
5 * @author PropertyHive
6 * @category Admin
7 * @package PropertyHive/Admin
8 * @version 1.0.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
13 if ( ! class_exists( 'PH_Admin_Menus' ) ) :
14
15 /**
16 * PH_Admin_Menus Class
17 */
18 class PH_Admin_Menus {
19
20 /**
21 * Hook in tabs.
22 */
23 public function __construct() {
24 // Add menus
25 add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
26 add_action( 'admin_menu', array( $this, 'reports_menu' ), 20 );
27 add_action( 'admin_menu', array( $this, 'settings_menu' ), 50 );
28 add_action( 'admin_menu', array( $this, 'add_ons_menu' ), 60 );
29
30 add_action( 'admin_head', array( $this, 'menu_highlight' ) );
31 //add_filter( 'menu_order', array( $this, 'menu_order' ) );
32 //add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
33 }
34
35 /**
36 * Add menu items
37 */
38 public function admin_menu() {
39 global $menu, $propertyhive;
40
41 //if ( current_user_can( 'manage_propertyhive' ) )
42 $menu[] = array( '', 'read', 'separator-propertyhive', '', 'wp-menu-separator propertyhive' );
43
44 add_menu_page( __( 'Property Hive', 'propertyhive' ), __( 'Property Hive', 'propertyhive' ), 'manage_propertyhive', 'propertyhive' , array( $this, 'settings_page' ), PH()->plugin_url() . '/assets/images/menu-icon.png', '54.5' );
45
46 add_submenu_page( 'propertyhive', __( 'Properties', 'propertyhive' ), __( 'Properties', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=property'/*, array( $this, 'attributes_page' )*/ );
47
48 if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' )
49 {
50 add_submenu_page( 'propertyhive', __( 'Property Owners and Landlords', 'propertyhive' ), __( 'Owners &amp; Landlords', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=contact&_contact_type=owner'/*, array( $this, 'attributes_page' )*/ );
51 add_submenu_page( 'propertyhive', __( 'Applicants', 'propertyhive' ), __( 'Applicants', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=contact&_contact_type=applicant'/*, array( $this, 'attributes_page' )*/ );
52 add_submenu_page( 'propertyhive', __( 'Third Party Contacts', 'propertyhive' ), __( 'Third Party Contacts', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=contact&_contact_type=thirdparty'/*, array( $this, 'attributes_page' )*/ );
53 }
54
55 if ( get_option('propertyhive_module_disabled_enquiries', '') != 'yes' )
56 {
57 add_submenu_page( 'propertyhive', __( 'Enquiries', 'propertyhive' ), __( 'Enquiries', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=enquiry'/*, array( $this, 'attributes_page' )*/ );
58 }
59
60 if ( get_option('propertyhive_module_disabled_appraisals', '') != 'yes' )
61 {
62 add_submenu_page( 'propertyhive', __( 'Appraisals', 'propertyhive' ), __( 'Appraisals', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=appraisal'/*, array( $this, 'attributes_page' )*/ );
63 }
64
65 if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' )
66 {
67 add_submenu_page( 'propertyhive', __( 'Viewings', 'propertyhive' ), __( 'Viewings', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=viewing'/*, array( $this, 'attributes_page' )*/ );
68 }
69
70 if ( get_option('propertyhive_module_disabled_offers_sales', '') != 'yes' )
71 {
72 add_submenu_page( 'propertyhive', __( 'Offers', 'propertyhive' ), __( 'Offers', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=offer'/*, array( $this, 'attributes_page' )*/ );
73 add_submenu_page( 'propertyhive', __( 'Sales', 'propertyhive' ), __( 'Sales', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=sale'/*, array( $this, 'attributes_page' )*/ );
74 }
75
76 if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' )
77 {
78 add_submenu_page( null, __( 'Applicant Matching Properties', 'propertyhive'), __( 'Applicant Matching Properties', 'propertyhive' ), 'manage_propertyhive', 'ph-matching-properties', array($this, 'matching_properties_page'));
79 add_submenu_page( null, __( 'Generate Applicant List', 'propertyhive'), __( 'Generate Applicant List', 'propertyhive' ), 'manage_propertyhive', 'ph-generate-applicant-list', array($this, 'generate_applicant_list_page'));
80 add_submenu_page( null, __( 'Applicant Matching Applicants', 'propertyhive'), __( 'Applicant Matching Properties', 'propertyhive' ), 'manage_propertyhive', 'ph-matching-applicants', array($this, 'matching_applicants_page'));
81 }
82 }
83
84 /**
85 * Add menu item
86 */
87 public function reports_menu() {
88 add_submenu_page( 'propertyhive', __( 'Reports', 'propertyhive' ), __( 'Reports', 'propertyhive' ) , 'manage_propertyhive', 'ph-reports', array( $this, 'reports_page' ) );
89 }
90
91 /**
92 * Add menu item
93 */
94 public function settings_menu() {
95 $settings_page = add_submenu_page( 'propertyhive', __( 'Property Hive Settings', 'propertyhive' ), __( 'Settings', 'propertyhive' ) , 'manage_options', 'ph-settings', array( $this, 'settings_page' ) );
96
97 //add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) );
98 }
99
100 /**
101 * Add menu item
102 */
103 public function add_ons_menu() {
104 $settings_page = add_submenu_page( 'propertyhive', __( 'Add Ons', 'propertyhive' ), __( 'Add Ons', 'propertyhive' ) , 'manage_options', 'admin.php?page=ph-settings&tab=addons'/*, array( $this, 'settings_page' )*/ );
105 }
106
107 /**
108 * Loads gateways and shipping methods into memory for use within settings.
109 */
110 public function settings_page_init() {
111
112 }
113
114 /**
115 * Highlights the correct top level admin menu item for post type add screens.
116 *
117 * @access public
118 * @return void
119 */
120 public function menu_highlight() {
121
122 global $menu, $submenu, $parent_file, $submenu_file, $self, $post_type, $taxonomy;
123
124 $to_highlight_types = array( 'property', 'contact', 'enquiry', 'appraisal', 'viewing', 'offer', 'sale' );
125
126 if ( isset( $post_type ) ) {
127 if ( in_array( $post_type, $to_highlight_types ) ) {
128 $submenu_file = 'edit.php?post_type=' . esc_attr( $post_type );
129 $parent_file = 'propertyhive';
130 }
131 }
132
133 if ( isset( $submenu['propertyhive'] ) && isset( $submenu['propertyhive'][1] ) ) {
134 $submenu['propertyhive'][0] = $submenu['propertyhive'][1];
135 unset( $submenu['propertyhive'][1] );
136 }
137 }
138
139 /**
140 * Reorder the PH menu items in admin.
141 *
142 * @param mixed $menu_order
143 * @return array
144 */
145 public function menu_order( $menu_order ) {
146
147
148 // Initialize our custom order array
149 $propertyhive_menu_order = array();
150
151 // Get the index of our custom separator
152 $propertyhive_separator = array_search( 'separator-propertyhive', $menu_order );
153
154 // Get index of product menu
155 $propertyhive_property = array_search( 'edit.php?post_type=property', $menu_order );
156
157 // Loop through menu order and do some rearranging
158 foreach ( $menu_order as $index => $item ) :
159
160 if ( ( ( 'propertyhive' ) == $item ) ) :
161 $propertyhive_menu_order[] = 'separator-propertyhive';
162 $propertyhive_menu_order[] = $item;
163 $propertyhive_menu_order[] = 'edit.php?post_type=property';
164 unset( $menu_order[$propertyhive_separator] );
165 unset( $menu_order[$propertyhive_property] );
166 elseif ( !in_array( $item, array( 'separator-propertyhive' ) ) ) :
167 $propertyhive_menu_order[] = $item;
168 endif;
169
170 endforeach;
171
172 // Return order
173 return $propertyhive_menu_order;
174 }
175
176 /**
177 * custom_menu_order
178 * @return bool
179 */
180 public function custom_menu_order() {
181 if ( ! current_user_can( 'manage_propertyhive' ) )
182 return false;
183 return true;
184 }
185
186 /**
187 * Init the reports page
188 */
189 public function reports_page() {
190 include_once( 'class-ph-admin-reports.php' );
191 PH_Admin_Reports::output();
192 }
193
194 /**
195 * Init the settings page
196 */
197 public function settings_page() {
198 include_once( 'class-ph-admin-settings.php' );
199 PH_Admin_Settings::output();
200 }
201
202 /**
203 * Init the applicant matching properties page
204 */
205 public function matching_properties_page() {
206 include_once( 'class-ph-admin-matching-properties.php' );
207 $ph_admin_matching_properties = new PH_Admin_Matching_Properties();
208 $ph_admin_matching_properties->output();
209 }
210
211 /**
212 * Init the applicant list page
213 */
214 public function generate_applicant_list_page() {
215 include_once( 'class-ph-admin-applicant-list.php' );
216 PH_Admin_Applicant_List::output();
217 }
218
219 /**
220 * Init the property matching applicants page
221 */
222 public function matching_applicants_page() {
223 include_once( 'class-ph-admin-matching-applicants.php' );
224 $ph_admin_matching_applicants = new PH_Admin_Matching_Applicants();
225 $ph_admin_matching_applicants->output();
226 }
227
228 /**
229 * Init the status page
230 */
231 public function status_page() {
232 $page = include( 'class-ph-admin-status.php' );
233 $page->output();
234 }
235
236 }
237
238 endif;
239
240 return new PH_Admin_Menus();