PluginProbe
Property Hive / 1.4.53
Property Hive v1.4.53
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 1.4.62 All 260 releases
propertyhive / includes / admin / class-ph-admin-menus.php

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

261 lines 9.3 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 $count = '';
58 $args = array(
59 'post_type' => 'enquiry',
60 'nopaging' => true,
61 'fields' => 'ids',
62 'meta_query' => array(
63 array(
64 'key' => '_status',
65 'value' => 'open'
66 ),
67 array(
68 'key' => '_negotiator_id',
69 'value' => ''
70 ),
71 ),
72 );
73 $enquiry_query = new WP_Query( $args );
74 if ( $enquiry_query->have_posts() )
75 {
76 $count = ' <span class="update-plugins count-' . $enquiry_query->found_posts . '"><span class="plugin-count">' . $enquiry_query->found_posts . '</span></span>';
77 }
78 add_submenu_page( 'propertyhive', __( 'Enquiries', 'propertyhive' ), __( 'Enquiries', 'propertyhive' ) . $count, 'manage_propertyhive', 'edit.php?post_type=enquiry'/*, array( $this, 'attributes_page' )*/ );
79 }
80
81 if ( get_option('propertyhive_module_disabled_appraisals', '') != 'yes' )
82 {
83 add_submenu_page( 'propertyhive', __( 'Appraisals', 'propertyhive' ), __( 'Appraisals', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=appraisal'/*, array( $this, 'attributes_page' )*/ );
84 }
85
86 if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' )
87 {
88 add_submenu_page( 'propertyhive', __( 'Viewings', 'propertyhive' ), __( 'Viewings', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=viewing'/*, array( $this, 'attributes_page' )*/ );
89 }
90
91 if ( get_option('propertyhive_module_disabled_offers_sales', '') != 'yes' )
92 {
93 add_submenu_page( 'propertyhive', __( 'Offers', 'propertyhive' ), __( 'Offers', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=offer'/*, array( $this, 'attributes_page' )*/ );
94 add_submenu_page( 'propertyhive', __( 'Sales', 'propertyhive' ), __( 'Sales', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=sale'/*, array( $this, 'attributes_page' )*/ );
95 }
96
97 if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' )
98 {
99 add_submenu_page( null, __( 'Applicant Matching Properties', 'propertyhive'), __( 'Applicant Matching Properties', 'propertyhive' ), 'manage_propertyhive', 'ph-matching-properties', array($this, 'matching_properties_page'));
100 add_submenu_page( null, __( 'Generate Applicant List', 'propertyhive'), __( 'Generate Applicant List', 'propertyhive' ), 'manage_propertyhive', 'ph-generate-applicant-list', array($this, 'generate_applicant_list_page'));
101 add_submenu_page( null, __( 'Applicant Matching Applicants', 'propertyhive'), __( 'Applicant Matching Properties', 'propertyhive' ), 'manage_propertyhive', 'ph-matching-applicants', array($this, 'matching_applicants_page'));
102 }
103 }
104
105 /**
106 * Add menu item
107 */
108 public function reports_menu() {
109 add_submenu_page( 'propertyhive', __( 'Reports', 'propertyhive' ), __( 'Reports', 'propertyhive' ) , 'manage_propertyhive', 'ph-reports', array( $this, 'reports_page' ) );
110 }
111
112 /**
113 * Add menu item
114 */
115 public function settings_menu() {
116 $settings_page = add_submenu_page( 'propertyhive', __( 'Property Hive Settings', 'propertyhive' ), __( 'Settings', 'propertyhive' ) , 'manage_options', 'ph-settings', array( $this, 'settings_page' ) );
117
118 //add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) );
119 }
120
121 /**
122 * Add menu item
123 */
124 public function add_ons_menu() {
125 $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' )*/ );
126 }
127
128 /**
129 * Loads gateways and shipping methods into memory for use within settings.
130 */
131 public function settings_page_init() {
132
133 }
134
135 /**
136 * Highlights the correct top level admin menu item for post type add screens.
137 *
138 * @access public
139 * @return void
140 */
141 public function menu_highlight() {
142
143 global $menu, $submenu, $parent_file, $submenu_file, $self, $post_type, $taxonomy;
144
145 $to_highlight_types = array( 'property', 'contact', 'enquiry', 'appraisal', 'viewing', 'offer', 'sale' );
146
147 if ( isset( $post_type ) ) {
148 if ( in_array( $post_type, $to_highlight_types ) ) {
149 $submenu_file = 'edit.php?post_type=' . esc_attr( $post_type );
150 $parent_file = 'propertyhive';
151 }
152 }
153
154 if ( isset( $submenu['propertyhive'] ) && isset( $submenu['propertyhive'][1] ) ) {
155 $submenu['propertyhive'][0] = $submenu['propertyhive'][1];
156 unset( $submenu['propertyhive'][1] );
157 }
158 }
159
160 /**
161 * Reorder the PH menu items in admin.
162 *
163 * @param mixed $menu_order
164 * @return array
165 */
166 public function menu_order( $menu_order ) {
167
168
169 // Initialize our custom order array
170 $propertyhive_menu_order = array();
171
172 // Get the index of our custom separator
173 $propertyhive_separator = array_search( 'separator-propertyhive', $menu_order );
174
175 // Get index of product menu
176 $propertyhive_property = array_search( 'edit.php?post_type=property', $menu_order );
177
178 // Loop through menu order and do some rearranging
179 foreach ( $menu_order as $index => $item ) :
180
181 if ( ( ( 'propertyhive' ) == $item ) ) :
182 $propertyhive_menu_order[] = 'separator-propertyhive';
183 $propertyhive_menu_order[] = $item;
184 $propertyhive_menu_order[] = 'edit.php?post_type=property';
185 unset( $menu_order[$propertyhive_separator] );
186 unset( $menu_order[$propertyhive_property] );
187 elseif ( !in_array( $item, array( 'separator-propertyhive' ) ) ) :
188 $propertyhive_menu_order[] = $item;
189 endif;
190
191 endforeach;
192
193 // Return order
194 return $propertyhive_menu_order;
195 }
196
197 /**
198 * custom_menu_order
199 * @return bool
200 */
201 public function custom_menu_order() {
202 if ( ! current_user_can( 'manage_propertyhive' ) )
203 return false;
204 return true;
205 }
206
207 /**
208 * Init the reports page
209 */
210 public function reports_page() {
211 include_once( 'class-ph-admin-reports.php' );
212 PH_Admin_Reports::output();
213 }
214
215 /**
216 * Init the settings page
217 */
218 public function settings_page() {
219 include_once( 'class-ph-admin-settings.php' );
220 PH_Admin_Settings::output();
221 }
222
223 /**
224 * Init the applicant matching properties page
225 */
226 public function matching_properties_page() {
227 include_once( 'class-ph-admin-matching-properties.php' );
228 $ph_admin_matching_properties = new PH_Admin_Matching_Properties();
229 $ph_admin_matching_properties->output();
230 }
231
232 /**
233 * Init the applicant list page
234 */
235 public function generate_applicant_list_page() {
236 include_once( 'class-ph-admin-applicant-list.php' );
237 PH_Admin_Applicant_List::output();
238 }
239
240 /**
241 * Init the property matching applicants page
242 */
243 public function matching_applicants_page() {
244 include_once( 'class-ph-admin-matching-applicants.php' );
245 $ph_admin_matching_applicants = new PH_Admin_Matching_Applicants();
246 $ph_admin_matching_applicants->output();
247 }
248
249 /**
250 * Init the status page
251 */
252 public function status_page() {
253 $page = include( 'class-ph-admin-status.php' );
254 $page->output();
255 }
256
257 }
258
259 endif;
260
261 return new PH_Admin_Menus();