| 1 |
<?php |
| 2 |
/** |
| 3 |
* Sets up the Donations dashboard widget. |
| 4 |
* |
| 5 |
* @package Charitable/Classes/Charitable_Donations_Dashboard_Widget |
| 6 |
* @version 1.2.0 |
| 7 |
* @author David Bisset |
| 8 |
* @copyright Copyright (c) 2022, WP Charitable LLC |
| 9 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 10 |
*/ |
| 11 |
|
| 12 |
// Exit if accessed directly. |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
if ( ! class_exists( 'Charitable_Donations_Dashboard_Widget' ) ) : |
| 18 |
|
| 19 |
/** |
| 20 |
* Charitable_Donations_Dashboard_Widget |
| 21 |
* |
| 22 |
* @since 1.2.0 |
| 23 |
*/ |
| 24 |
class Charitable_Donations_Dashboard_Widget { |
| 25 |
|
| 26 |
/** |
| 27 |
* The widget ID. |
| 28 |
*/ |
| 29 |
const ID = 'charitable_dashboard_donations'; |
| 30 |
|
| 31 |
/** |
| 32 |
* Create class object. |
| 33 |
* |
| 34 |
* @since 1.2.0 |
| 35 |
*/ |
| 36 |
public static function register() { |
| 37 |
if ( ! current_user_can( 'view_charitable_sensitive_data' ) ) { |
| 38 |
return; |
| 39 |
} |
| 40 |
|
| 41 |
wp_add_dashboard_widget( self::ID, __( 'Charitable Donation Statistics', 'charitable' ), array( 'Charitable_Donations_Dashboard_Widget', 'display' ) ); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Print the widget contents. |
| 46 |
* |
| 47 |
* @since 1.2.0 |
| 48 |
* |
| 49 |
* @return void |
| 50 |
*/ |
| 51 |
public static function display() { |
| 52 |
?> |
| 53 |
<p class="hide-if-no-js"> |
| 54 |
<img src="<?php echo charitable()->get_path( 'assets', false ) ?>/images/charitable-loading.gif" width="60" height="60" alt="<?php esc_attr_e( 'Loading…', 'charitable' ) ?>" /> |
| 55 |
</p> |
| 56 |
<?php |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Return the content to display inside the widget. |
| 61 |
* |
| 62 |
* @since 1.2.0 |
| 63 |
* |
| 64 |
* @return void |
| 65 |
*/ |
| 66 |
public static function get_content() { |
| 67 |
charitable_admin_view( 'dashboard-widgets/donations-widget' ); |
| 68 |
die(); |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
endif; |
| 73 |
|