| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Display the export button in the donation filters box. |
| 10 |
* |
| 11 |
* @author WP Charitable LLC |
| 12 |
* @package Charitable/Admin View/Donations Page |
| 13 |
* @since 1.0.0 |
| 14 |
* @version 1.6.39 |
| 15 |
* @version 1.8.8.6 |
| 16 |
*/ |
| 17 |
|
| 18 |
/** |
| 19 |
* Filter the class to use for the modal window. |
| 20 |
* |
| 21 |
* @since 1.0.0 |
| 22 |
* |
| 23 |
* @param string $class The class name. |
| 24 |
*/ |
| 25 |
$charitable_modal_class = apply_filters( 'charitable_modal_window_class', 'charitable-modal' ); |
| 26 |
|
| 27 |
$charitable_start_date = isset( $_GET['start_date'] ) ? charitable_sanitize_date_export_format( $_GET['start_date'] ) : null; // phpcs:ignore |
| 28 |
$charitable_end_date = isset( $_GET['end_date'] ) ? charitable_sanitize_date_export_format( $_GET['end_date'] ) : null; // phpcs:ignore |
| 29 |
$charitable_post_status = isset( $_GET['post_status'] ) ? esc_html( $_GET['post_status'] ) : 'all'; // phpcs:ignore |
| 30 |
$charitable_report_type = isset( $_GET['report_type'] ) ? esc_html( $_GET['report_type'] ) : 'donations'; // phpcs:ignore |
| 31 |
|
| 32 |
$charitable_campaigns = get_posts( |
| 33 |
array( |
| 34 |
'post_type' => 'campaign', |
| 35 |
'post_status' => array( 'draft', 'pending', 'private', 'publish' ), |
| 36 |
'perm' => 'readable', |
| 37 |
'posts_per_page' => -1, |
| 38 |
) |
| 39 |
); |
| 40 |
|
| 41 |
/** |
| 42 |
* Filter the type of exportable report types. |
| 43 |
* |
| 44 |
* @since 1.6.0 |
| 45 |
* |
| 46 |
* @param array $types Types of reports. |
| 47 |
*/ |
| 48 |
$charitable_report_types = apply_filters( |
| 49 |
'charitable_donation_export_report_types', |
| 50 |
array( |
| 51 |
'donations' => __( 'Donations', 'charitable' ), |
| 52 |
) |
| 53 |
); |
| 54 |
?> |
| 55 |
<div id="charitable-donations-export-modal" style="display: none;" class="charitable-donations-modal <?php echo esc_attr( $charitable_modal_class ); ?>" tabindex="0"> |
| 56 |
<a class="modal-close"></a> |
| 57 |
<h3><?php esc_html_e( 'Export Donations', 'charitable' ); ?></h3> |
| 58 |
<form class="charitable-donations-modal-form charitable-modal-form" method="get" action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>"> |
| 59 |
<?php wp_nonce_field( 'charitable_export_donations', '_charitable_export_nonce' ); ?> |
| 60 |
<input type="hidden" name="charitable_action" value="export_donations" /> |
| 61 |
<input type="hidden" name="page" value="charitable-donations-table" /> |
| 62 |
<fieldset> |
| 63 |
<legend><?php esc_html_e( 'Filter by Date', 'charitable' ); ?></legend> |
| 64 |
<input type="text" id="charitable-export-start_date" name="start_date" class="charitable-datepicker" autocomplete="off" value="<?php echo esc_attr( $charitable_start_date ); ?>" placeholder="<?php esc_attr_e( 'From:', 'charitable' ); ?>" /> |
| 65 |
<input type="text" id="charitable-export-end_date" name="end_date" class="charitable-datepicker" autocomplete="off" value="<?php echo esc_attr( $charitable_end_date ); ?>" placeholder="<?php esc_attr_e( 'To:', 'charitable' ); ?>" /> |
| 66 |
</fieldset> |
| 67 |
<label for="charitable-donations-export-status"><?php esc_html_e( 'Filter by Status', 'charitable' ); ?></label> |
| 68 |
<select id="charitable-donations-export-status" name="status"> |
| 69 |
<option value="all" <?php selected( $charitable_post_status, 'all' ); ?>><?php esc_html_e( 'All', 'charitable' ); ?></option> |
| 70 |
<?php foreach ( charitable_get_valid_donation_statuses() as $charitable_key => $status ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?> |
| 71 |
<option value="<?php echo esc_attr( $charitable_key ); ?>" <?php selected( $charitable_post_status, $charitable_key ); ?>><?php echo esc_html( $status ); ?></option> |
| 72 |
<?php endforeach ?> |
| 73 |
</select> |
| 74 |
<label for="charitable-donations-export-campaign"><?php esc_html_e( 'Filter by Campaign', 'charitable' ); ?></label> |
| 75 |
<select id="charitable-donations-export-campaign" name="campaign_id"> |
| 76 |
<option value="all"><?php esc_html_e( 'All Campaigns', 'charitable' ); ?></option> |
| 77 |
<?php |
| 78 |
foreach ( $charitable_campaigns as $charitable_campaign ) : |
| 79 |
?> |
| 80 |
<option value="<?php echo esc_attr( $charitable_campaign->ID ); ?>"><?php echo esc_html( get_the_title( $charitable_campaign->ID ) ); ?></option> |
| 81 |
<?php endforeach ?> |
| 82 |
</select> |
| 83 |
<?php if ( count( $charitable_report_types ) > 1 ) : ?> |
| 84 |
<label for="charitable-donations-export-report-type"><?php esc_html_e( 'Type of Report', 'charitable' ); ?></label> |
| 85 |
<select id="charitable-donations-export-report-type" name="report_type"> |
| 86 |
<?php foreach ( $charitable_report_types as $charitable_key => $charitable_report_label ) : ?> |
| 87 |
<option value="<?php echo esc_attr( $charitable_key ); ?>"><?php echo esc_html( $charitable_report_label ); ?></option> |
| 88 |
<?php endforeach; ?> |
| 89 |
</select> |
| 90 |
<?php else : ?> |
| 91 |
<input type="hidden" name="report_type" value="<?php echo esc_attr( key( $charitable_report_types ) ); ?>" /> |
| 92 |
<?php endif ?> |
| 93 |
<?php |
| 94 |
/** |
| 95 |
* Add additional fields to the end of the donations export form. |
| 96 |
* |
| 97 |
* @since 1.4.0 |
| 98 |
*/ |
| 99 |
do_action( 'charitable_export_donations_form' ); |
| 100 |
?> |
| 101 |
<button name="charitable-export-donations" class="button button-primary"><?php esc_html_e( 'Export', 'charitable' ); ?></button> |
| 102 |
</form> |
| 103 |
</div> |
| 104 |
|