PluginProbe
Property Hive / 2.3.0
Property Hive v2.3.0
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-dashboard.php

class-ph-admin-dashboard.php in Property Hive 2.3.0, at includes/admin/class-ph-admin-dashboard.php

137 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin Dashboard
4 *
5 * @author PropertyHive
6 * @category Admin
7 * @package PropertyHive/Admin
8 * @version 1.0.0
9 */
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly
12 }
13 if ( ! class_exists( 'PH_Admin_Dashboard' ) ) :
14
15 /**
16 * PH_Admin_Dashboard Class.
17 */
18 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy public global class PH_Admin_Dashboard; preserving the existing PH_* class name is required for plugin and extension compatibility.
19 class PH_Admin_Dashboard {
20
21 /**
22 * Hook in tabs.
23 */
24 public function __construct() {
25
26 add_action( 'wp_dashboard_setup', array( $this, 'init' ) );
27
28 add_action( 'wp_dashboard_setup', array( $this, 'hide_non_property_hive_widgets' ), 9999 );
29 }
30
31 /**
32 * Init dashboard widgets.
33 */
34 public function init() {
35
36 if ( current_user_can( 'manage_options' ) )
37 {
38 wp_add_dashboard_widget( 'propertyhive_dashboard_news', __( 'Property Hive News', 'propertyhive' ), array( $this, 'news_widget' ) );
39 }
40
41 if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' )
42 {
43 wp_add_dashboard_widget( 'propertyhive_dashboard_viewings_awaiting_applicant_feedback', __( 'Viewings Awaiting Applicant Feedback', 'propertyhive' ), array( $this, 'viewings_awaiting_applicant_feedback_widget' ) );
44 }
45
46 if (
47 (
48 get_option('propertyhive_module_disabled_appraisals', '') != 'yes' &&
49 get_option('propertyhive_module_disabled_viewings', '') != 'yes'
50 )
51 ||
52 apply_filters( 'propertyhive_show_my_upcoming_appointments_dashboard_widget', false ) === true
53 )
54 {
55 wp_add_dashboard_widget( 'propertyhive_dashboard_my_upcoming_appointments', __( 'My Upcoming Appointments', 'propertyhive' ), array( $this, 'my_upcoming_appointments_widget' ) );
56 }
57
58 if (
59 get_option( 'propertyhive_module_disabled_tenancies', '' ) != 'yes' &&
60 get_option( 'propertyhive_active_departments_lettings' ) == 'yes'
61 )
62 {
63 wp_add_dashboard_widget( 'propertyhive_dashboard_upcoming_overdue_key_dates', __( 'Upcoming/Overdue Key Dates', 'propertyhive' ), array( $this, 'upcoming_overdue_key_dates_widget' ) );
64 }
65 }
66
67 /*
68 * Property Hive News Widget
69 */
70 public function news_widget()
71 {
72 echo '<div id="ph_dashboard_news">Loading...</div>';
73 }
74
75 /*
76 * Property Hive Viewings Awaiting Applicant Feedback Widget
77 */
78 public function viewings_awaiting_applicant_feedback_widget()
79 {
80 echo '<div id="ph_dashboard_viewings_awaiting_applicant_feedback">Loading...</div>';
81 }
82
83 /*
84 * Property Hive My Upcoming Appointments Widget
85 */
86 public function my_upcoming_appointments_widget()
87 {
88 echo '<div id="ph_dashboard_my_upcoming_appointments">Loading...</div>';
89 }
90
91 /*
92 * Property Hive Upcoming & Overdue Key Dates Widget
93 */
94 public function upcoming_overdue_key_dates_widget()
95 {
96 echo '<div id="ph_dashboard_upcoming_overdue_key_dates">Loading...</div>';
97 }
98
99 public function hide_non_property_hive_widgets()
100 {
101 $current_user = wp_get_current_user();
102
103 $user_id = $current_user->ID;
104
105 $crm_only_mode = get_user_meta( $user_id, 'crm_only_mode', TRUE );
106
107 if ( $crm_only_mode == '1' )
108 {
109 global $wp_meta_boxes;
110
111 if ( isset($wp_meta_boxes['dashboard']['normal']['core']) )
112 {
113 foreach ( $wp_meta_boxes['dashboard']['normal']['core'] as $key => $widget )
114 {
115 if ( strpos($key, 'property') === false && strpos($key, 'hive') === false )
116 {
117 unset($wp_meta_boxes['dashboard']['normal']['core'][$key]);
118 }
119 }
120 }
121 if ( isset($wp_meta_boxes['dashboard']['side']['core']) )
122 {
123 foreach ( $wp_meta_boxes['dashboard']['side']['core'] as $key => $widget )
124 {
125 if ( strpos($key, 'property') === false && strpos($key, 'hive') === false )
126 {
127 unset($wp_meta_boxes['dashboard']['side']['core'][$key]);
128 }
129 }
130 }
131 }
132 }
133 }
134
135 endif;
136
137 return new PH_Admin_Dashboard();