PluginProbe
Property Hive / 1.4.6
Property Hive v1.4.6
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.6, at includes/admin/class-ph-admin-menus.php

216 lines 7.5 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_viewings', '') != 'yes' )
61 {
62 add_submenu_page( 'propertyhive', __( 'Viewings', 'propertyhive' ), __( 'Viewings', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=viewing'/*, array( $this, 'attributes_page' )*/ );
63 }
64
65 if ( get_option('propertyhive_module_disabled_offers_sales', '') != 'yes' )
66 {
67 add_submenu_page( 'propertyhive', __( 'Offers', 'propertyhive' ), __( 'Offers', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=offer'/*, array( $this, 'attributes_page' )*/ );
68 add_submenu_page( 'propertyhive', __( 'Sales', 'propertyhive' ), __( 'Sales', 'propertyhive' ), 'manage_propertyhive', 'edit.php?post_type=sale'/*, array( $this, 'attributes_page' )*/ );
69 }
70
71 if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' )
72 {
73 add_submenu_page( null, __( 'Applicant Matching Properties', 'propertyhive'), __( 'Applicant Matching Properties', 'propertyhive' ), 'manage_propertyhive', 'ph-matching-properties', array($this, 'matching_properties_page'));
74 }
75 }
76
77 /**
78 * Add menu item
79 */
80 public function reports_menu() {
81 add_submenu_page( 'propertyhive', __( 'Reports', 'propertyhive' ), __( 'Reports', 'propertyhive' ) , 'manage_propertyhive', 'ph-reports', array( $this, 'reports_page' ) );
82 }
83
84 /**
85 * Add menu item
86 */
87 public function settings_menu() {
88 $settings_page = add_submenu_page( 'propertyhive', __( 'Property Hive Settings', 'propertyhive' ), __( 'Settings', 'propertyhive' ) , 'manage_options', 'ph-settings', array( $this, 'settings_page' ) );
89
90 //add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) );
91 }
92
93 /**
94 * Add menu item
95 */
96 public function add_ons_menu() {
97 $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' )*/ );
98 }
99
100 /**
101 * Loads gateways and shipping methods into memory for use within settings.
102 */
103 public function settings_page_init() {
104
105 }
106
107 /**
108 * Highlights the correct top level admin menu item for post type add screens.
109 *
110 * @access public
111 * @return void
112 */
113 public function menu_highlight() {
114
115 global $menu, $submenu, $parent_file, $submenu_file, $self, $post_type, $taxonomy;
116
117 $to_highlight_types = array( 'property', 'contact', 'enquiry', 'viewing', 'offer', 'sale' );
118
119 if ( isset( $post_type ) ) {
120 if ( in_array( $post_type, $to_highlight_types ) ) {
121 $submenu_file = 'edit.php?post_type=' . esc_attr( $post_type );
122 $parent_file = 'propertyhive';
123 }
124 }
125
126 if ( isset( $submenu['propertyhive'] ) && isset( $submenu['propertyhive'][1] ) ) {
127 $submenu['propertyhive'][0] = $submenu['propertyhive'][1];
128 unset( $submenu['propertyhive'][1] );
129 }
130 }
131
132 /**
133 * Reorder the PH menu items in admin.
134 *
135 * @param mixed $menu_order
136 * @return array
137 */
138 public function menu_order( $menu_order ) {
139
140
141 // Initialize our custom order array
142 $propertyhive_menu_order = array();
143
144 // Get the index of our custom separator
145 $propertyhive_separator = array_search( 'separator-propertyhive', $menu_order );
146
147 // Get index of product menu
148 $propertyhive_property = array_search( 'edit.php?post_type=property', $menu_order );
149
150 // Loop through menu order and do some rearranging
151 foreach ( $menu_order as $index => $item ) :
152
153 if ( ( ( 'propertyhive' ) == $item ) ) :
154 $propertyhive_menu_order[] = 'separator-propertyhive';
155 $propertyhive_menu_order[] = $item;
156 $propertyhive_menu_order[] = 'edit.php?post_type=property';
157 unset( $menu_order[$propertyhive_separator] );
158 unset( $menu_order[$propertyhive_property] );
159 elseif ( !in_array( $item, array( 'separator-propertyhive' ) ) ) :
160 $propertyhive_menu_order[] = $item;
161 endif;
162
163 endforeach;
164
165 // Return order
166 return $propertyhive_menu_order;
167 }
168
169 /**
170 * custom_menu_order
171 * @return bool
172 */
173 public function custom_menu_order() {
174 if ( ! current_user_can( 'manage_propertyhive' ) )
175 return false;
176 return true;
177 }
178
179 /**
180 * Init the reports page
181 */
182 public function reports_page() {
183 include_once( 'class-ph-admin-reports.php' );
184 PH_Admin_Reports::output();
185 }
186
187 /**
188 * Init the settings page
189 */
190 public function settings_page() {
191 include_once( 'class-ph-admin-settings.php' );
192 PH_Admin_Settings::output();
193 }
194
195 /**
196 * Init the applicant matching properties page
197 */
198 public function matching_properties_page() {
199 include_once( 'class-ph-admin-matching-properties.php' );
200 $ph_admin_matching_properties = new PH_Admin_Matching_Properties();
201 $ph_admin_matching_properties->output();
202 }
203
204 /**
205 * Init the status page
206 */
207 public function status_page() {
208 $page = include( 'class-ph-admin-status.php' );
209 $page->output();
210 }
211
212 }
213
214 endif;
215
216 return new PH_Admin_Menus();