PluginProbe
Property Hive / 2.3.0
Property Hive v2.3.0
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
← All changes | includes/admin/class-ph-admin-dashboard.php +61 -5 1.4.562.3.0 View file →
@@ -14,8 +14,9 @@
14 14
15 15 /**
16 16 * PH_Admin_Dashboard Class.
17 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.
18 19 class PH_Admin_Dashboard {
19 20
20 21 /**
21 22 * Hook in tabs.
@@ -20,12 +21,12 @@
20 21 /**
21 22 * Hook in tabs.
22 23 */
23 24 public function __construct() {
24 - // Only hook in admin parts if the user has admin access
25 - if ( current_user_can( 'manage_options' ) ) {
26 - add_action( 'wp_dashboard_setup', array( $this, 'init' ) );
27 - }
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 );
28 29 }
29 30
30 31 /**
31 32 * Init dashboard widgets.
@@ -30,9 +31,13 @@
30 31 /**
31 32 * Init dashboard widgets.
32 33 */
33 34 public function init() {
34 - wp_add_dashboard_widget( 'propertyhive_dashboard_news', __( 'Property Hive News', 'propertyhive' ), array( $this, 'news_widget' ) );
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 + }
35 40
36 41 if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' )
37 42 {
38 43 wp_add_dashboard_widget( 'propertyhive_dashboard_viewings_awaiting_applicant_feedback', __( 'Viewings Awaiting Applicant Feedback', 'propertyhive' ), array( $this, 'viewings_awaiting_applicant_feedback_widget' ) );
@@ -48,8 +53,16 @@
48 53 )
49 54 {
50 55 wp_add_dashboard_widget( 'propertyhive_dashboard_my_upcoming_appointments', __( 'My Upcoming Appointments', 'propertyhive' ), array( $this, 'my_upcoming_appointments_widget' ) );
51 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 + }
52 65 }
53 66
54 67 /*
55 68 * Property Hive News Widget
@@ -72,8 +85,51 @@
72 85 */
73 86 public function my_upcoming_appointments_widget()
74 87 {
75 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 + }
76 132 }
77 133 }
78 134
79 135 endif;