| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Display the main reports page wrapper. |
| 10 |
* |
| 11 |
* @author David Bisset |
| 12 |
* @package Charitable/Admin View/Settings |
| 13 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 14 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 15 |
* @since 1.8.1 |
| 16 |
* @version 1.8.1 |
| 17 |
* @version 1.8.8.6 |
| 18 |
*/ |
| 19 |
|
| 20 |
require_once ABSPATH . 'wp-admin/includes/translation-install.php'; |
| 21 |
|
| 22 |
$charitable_gateways = Charitable_Gateways::get_instance()->get_active_gateways_names(); |
| 23 |
$charitable_campaigns = wp_count_posts( 'campaign' ); |
| 24 |
$charitable_campaigns_count = $charitable_campaigns->publish + $charitable_campaigns->draft + $charitable_campaigns->future + $charitable_campaigns->pending + $charitable_campaigns->private; |
| 25 |
$charitable_emails = charitable_get_helper( 'emails' )->get_enabled_emails_names(); |
| 26 |
$charitable_install = isset( $_GET['install'] ) && $_GET['install']; // phpcs:ignore |
| 27 |
$charitable_languages = function_exists( 'wp_get_available_translations' ) ? wp_get_available_translations() : array(); |
| 28 |
$charitable_locale = get_locale(); // phpcs:ignore |
| 29 |
$charitable_language = isset( $charitable_languages[ $charitable_locale ]['native_name'] ) ? $charitable_languages[ $charitable_locale ]['native_name'] : $charitable_locale; |
| 30 |
$charitable_currency = charitable_get_default_currency(); |
| 31 |
$charitable_currencies = charitable_get_currency_helper()->get_all_currencies(); |
| 32 |
|
| 33 |
$charitable_dashboard = Charitable_Dashboard_Legacy::get_instance(); |
| 34 |
$charitable_start_date = $charitable_dashboard->get_start_date(); |
| 35 |
$charitable_end_date = $charitable_dashboard->get_end_date(); |
| 36 |
$charitable_days = $charitable_dashboard->get_days(); |
| 37 |
|
| 38 |
$charitable_notices = $charitable_dashboard->get_notices(); |
| 39 |
|
| 40 |
$charitable_show_gt_chart_notice = apply_filters( 'charitable_show_growth_tools_dashboard_notice', $charitable_dashboard->maybe_show_dashboard_growth_tool_chart_notice() ); |
| 41 |
$charitable_show_gt_chart_notice_headline = ''; |
| 42 |
|
| 43 |
if ( $charitable_show_gt_chart_notice ) { |
| 44 |
|
| 45 |
$charitable_total_donations_array = (array) wp_count_posts( 'donation' ); // the function caches this, so we shouldn't have to. |
| 46 |
$charitable_total_donations = array_sum( $charitable_total_donations_array ); |
| 47 |
$charitable_show_gt_chart_notice_headline = ( false !== $charitable_total_donations_array && is_array( $charitable_total_donations_array ) && $charitable_total_donations > 0 ) ? esc_html__( 'No donations recently? Let Charitable help!', 'charitable' ) . ' 🚀' : esc_html__( 'Excited to make your first donation? Let Charitable help!', 'charitable' ) . ' 🚀'; |
| 48 |
|
| 49 |
if ( $charitable_total_donations_array['publish'] > 0 ) { |
| 50 |
$charitable_show_gt_chart_notice = false; |
| 51 |
} |
| 52 |
$charitable_suggestion = Charitable_Guide_Tools::get_instance()->get_suggestion( 'dashboard', $charitable_total_donations ); |
| 53 |
if ( false === $charitable_suggestion || ! is_array( $charitable_suggestion ) || empty( $charitable_suggestion ) ) { |
| 54 |
$charitable_show_gt_chart_notice = false; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
$charitable_is_cached = $charitable_dashboard->maybe_cache_dashboard(); |
| 59 |
$charitable_cached = $charitable_dashboard->is_dashboard_data_cached(); |
| 60 |
|
| 61 |
$charitable_html = $charitable_dashboard->generate_dashboard_report_html(); |
| 62 |
|
| 63 |
ob_start(); |
| 64 |
?> |
| 65 |
<div id="charitable-reports" class="wrap"> |
| 66 |
<h1 class="screen-reader-text"><?php echo esc_html( get_admin_page_title() ); ?></h1> |
| 67 |
<?php do_action( 'charitable_maybe_show_notification' ); ?> |
| 68 |
<?php |
| 69 |
/** |
| 70 |
* Do or render something right before the dashboard area. |
| 71 |
* |
| 72 |
* @since 1.8.1 |
| 73 |
*/ |
| 74 |
do_action( 'charitable_before_admin_dashboard' ); |
| 75 |
?> |
| 76 |
|
| 77 |
<div class="tablenav top"> |
| 78 |
<div class="alignleft actions"> |
| 79 |
<h1><?php echo esc_html__( 'Dashboard', 'charitable' ); ?> <?php |
| 80 |
if ( $charitable_cached && $charitable_is_cached ) : |
| 81 |
echo '<span class="badge">Last cached ' . esc_html( $charitable_cached ) . '</span>'; |
| 82 |
endif; |
| 83 |
?> |
| 84 |
</h1> |
| 85 |
</div> |
| 86 |
<div class="alignright"> |
| 87 |
|
| 88 |
<form action="" method="post" target="_blank" class="charitable-report-print" id="charitable-dashboard-print"> |
| 89 |
<input name="charitable_report_action" type="hidden" value="charitable_report_print_dashboard" /> |
| 90 |
<input name="start_date" type="hidden" value="<?php echo esc_attr( $charitable_start_date ); ?>" /> |
| 91 |
<input name="end_date" type="hidden" value="<?php echo esc_attr( $charitable_end_date ); ?>" /> |
| 92 |
<input name="days" type="hidden" value="<?php echo esc_attr( $charitable_days ); ?>" /> |
| 93 |
<?php wp_nonce_field( 'charitable_export_report', 'charitable_export_report_nonce' ); ?> |
| 94 |
<button value="Print" type="submit" class="button with-icon charitable-report-print-button" title="<?php echo esc_html__( 'Print Summary', 'charitable' ); ?>" class="button with-icon charitable-report-ui" data-nonce="<?php echo wp_create_nonce( 'charitable_export_report' ); // phpcs:ignore ?>"><label><?php echo esc_html__( 'Print', 'charitable' ); ?></label><img width="15" height="15" src="<?php echo esc_url( charitable()->get_path( 'assets', false ) . 'images/icons/print.svg' ); ?>" alt=""></button> |
| 95 |
</form> |
| 96 |
|
| 97 |
<?php echo $charitable_dashboard->get_filter_dropdown(); // phpcs:ignore ?> |
| 98 |
|
| 99 |
<input type="hidden" value="<?php echo esc_html( $charitable_start_date ); ?>" name="charitable-dashboard-report-start-date" id="charitable-dashboard-report-start-date"> |
| 100 |
<input type="hidden" value="<?php echo esc_html( $charitable_end_date ); ?>" name="charitable-dashboard-report-end-date" id="charitable-dashboard-report-end-date"> |
| 101 |
|
| 102 |
</div> |
| 103 |
<br class="clear"> |
| 104 |
</div> |
| 105 |
|
| 106 |
<?php |
| 107 |
/** |
| 108 |
* Do or render something after the dashboard title bar but before the reporting. |
| 109 |
* |
| 110 |
* @since 1.8.2 |
| 111 |
*/ |
| 112 |
do_action( 'charitable_before_admin_dashboard_reports' ); |
| 113 |
?> |
| 114 |
|
| 115 |
<div id="charitable-dashboard-report-container"> |
| 116 |
|
| 117 |
<div class="charitable-dashboard-report"> |
| 118 |
|
| 119 |
<!--- dashboard welcome start --> |
| 120 |
|
| 121 |
<?php |
| 122 |
/** |
| 123 |
* Do or render something after the dashboard title bar but before the reporting. |
| 124 |
* |
| 125 |
* @since 1.8.2 |
| 126 |
*/ |
| 127 |
do_action( 'charitable_admin_dashboard_notifications' ); |
| 128 |
?> |
| 129 |
|
| 130 |
<div class="charitable-dashboard-title-cards"> |
| 131 |
|
| 132 |
<?php |
| 133 |
/** |
| 134 |
* Do or render something above dashboard items (like a notice). |
| 135 |
* |
| 136 |
* @since 1.8.1.15 |
| 137 |
*/ |
| 138 |
do_action( 'charitable_after_getting_started_dashboard' ); |
| 139 |
?> |
| 140 |
|
| 141 |
</div> |
| 142 |
|
| 143 |
<!--- dashboard welcome end --> |
| 144 |
|
| 145 |
<div class="charitable-headline-reports"> |
| 146 |
|
| 147 |
<div id="charitable-dashboard-report-cards"> |
| 148 |
<?php echo $charitable_html['charitable_cards']; // phpcs:ignore ?> |
| 149 |
</div> |
| 150 |
|
| 151 |
<div class="charitable-container charitable-report-ui charitable-headline-graph-container |
| 152 |
<?php |
| 153 |
if ( $charitable_show_gt_chart_notice ) : |
| 154 |
?> |
| 155 |
charitable-with-growth-tools<?php endif; ?>"> |
| 156 |
|
| 157 |
<?php if ( $charitable_show_gt_chart_notice ) : ?> |
| 158 |
|
| 159 |
<div id="charitable-growth-tools-notice" class="charitable-growth-tools-notice charitable-growth-tools-dashboard charitable-hidden" data-notice-type="dashboard" data-nonce="<?php echo wp_create_nonce( 'charitable_dismiss_growth_tools' ); // phpcs:ignore ?>"> |
| 160 |
|
| 161 |
<div class="charitable-growth-tools-notice-interior"> |
| 162 |
|
| 163 |
<?php |
| 164 |
|
| 165 |
$charitable_notice_html = Charitable_Guide_Tools::get_instance()->get_dashboard_notice_html( $charitable_suggestion, $charitable_show_gt_chart_notice_headline ); |
| 166 |
echo $charitable_notice_html; // phpcs:ignore |
| 167 |
|
| 168 |
?> |
| 169 |
|
| 170 |
</div> |
| 171 |
|
| 172 |
</div> |
| 173 |
|
| 174 |
<?php endif; ?> |
| 175 |
|
| 176 |
<div id="charitable-headline-graph" class="charitable-headline-graph"></div> |
| 177 |
|
| 178 |
</div> |
| 179 |
|
| 180 |
</div> |
| 181 |
|
| 182 |
<div class="charitable-section charitable-section-flexible"> |
| 183 |
|
| 184 |
<div id="charitable-dashboard-report-sections"> |
| 185 |
<?php echo $charitable_html['charitable_reports']; // phpcs:ignore ?> |
| 186 |
</div> |
| 187 |
|
| 188 |
</div> |
| 189 |
|
| 190 |
</div> |
| 191 |
|
| 192 |
</div> |
| 193 |
|
| 194 |
<?php |
| 195 |
/** |
| 196 |
* Do or render something right after the dashboard area. |
| 197 |
* |
| 198 |
* @since 1.8.1 |
| 199 |
*/ |
| 200 |
do_action( 'charitable_after_admin_dashboard' ); |
| 201 |
?> |
| 202 |
</div> |
| 203 |
<?php |
| 204 |
echo ob_get_clean(); // phpcs:ignore |
| 205 |
|