| 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 |
class PH_Admin_Dashboard { |
| 19 |
|
| 20 |
/** |
| 21 |
* Hook in tabs. |
| 22 |
*/ |
| 23 |
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 |
} |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Init dashboard widgets. |
| 32 |
*/ |
| 33 |
public function init() { |
| 34 |
wp_add_dashboard_widget( 'propertyhive_dashboard_news', __( 'Property Hive News', 'propertyhive' ), array( $this, 'news_widget' ) ); |
| 35 |
|
| 36 |
if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' ) |
| 37 |
{ |
| 38 |
wp_add_dashboard_widget( 'propertyhive_dashboard_viewings_awaiting_applicant_feedback', __( 'Viewings Awaiting Applicant Feedback', 'propertyhive' ), array( $this, 'viewings_awaiting_applicant_feedback_widget' ) ); |
| 39 |
} |
| 40 |
|
| 41 |
if ( |
| 42 |
( |
| 43 |
get_option('propertyhive_module_disabled_appraisals', '') != 'yes' && |
| 44 |
get_option('propertyhive_module_disabled_viewings', '') != 'yes' |
| 45 |
) |
| 46 |
|| |
| 47 |
apply_filters( 'propertyhive_show_my_upcoming_appointments_dashboard_widget', false ) === true |
| 48 |
) |
| 49 |
{ |
| 50 |
wp_add_dashboard_widget( 'propertyhive_dashboard_my_upcoming_appointments', __( 'My Upcoming Appointments', 'propertyhive' ), array( $this, 'my_upcoming_appointments_widget' ) ); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
/* |
| 55 |
* Property Hive News Widget |
| 56 |
*/ |
| 57 |
public function news_widget() |
| 58 |
{ |
| 59 |
echo '<div id="ph_dashboard_news">Loading...</div>'; |
| 60 |
} |
| 61 |
|
| 62 |
/* |
| 63 |
* Property Hive Viewings Awaiting Applicant Feedback Widget |
| 64 |
*/ |
| 65 |
public function viewings_awaiting_applicant_feedback_widget() |
| 66 |
{ |
| 67 |
echo '<div id="ph_dashboard_viewings_awaiting_applicant_feedback">Loading...</div>'; |
| 68 |
} |
| 69 |
|
| 70 |
/* |
| 71 |
* Property Hive My Upcoming Appointments Widget |
| 72 |
*/ |
| 73 |
public function my_upcoming_appointments_widget() |
| 74 |
{ |
| 75 |
echo '<div id="ph_dashboard_my_upcoming_appointments">Loading...</div>'; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
endif; |
| 80 |
|
| 81 |
return new PH_Admin_Dashboard(); |