| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display the export button in the campaign exports box. |
| 4 |
* |
| 5 |
* @author David Bisset |
| 6 |
* @package Charitable/Admin View/Campaigns Page |
| 7 |
* @copyright Copyright (c) 2022, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.6.0 |
| 10 |
* @version 1.6.39 |
| 11 |
*/ |
| 12 |
|
| 13 |
/** |
| 14 |
* Filter the class to use for the modal window. |
| 15 |
* |
| 16 |
* @since 1.0.0 |
| 17 |
* |
| 18 |
* @param string $class The class name. |
| 19 |
*/ |
| 20 |
$modal_class = apply_filters( 'charitable_modal_window_class', 'charitable-modal' ); |
| 21 |
|
| 22 |
$start_date_from = isset( $_GET['start_date_from'] ) ? sanitize_text_field( $_GET['start_date_from'] ) : null; |
| 23 |
$start_date_to = isset( $_GET['start_date_to'] ) ? sanitize_text_field( $_GET['start_date_to'] ) : null; |
| 24 |
$end_date_from = isset( $_GET['end_date_from'] ) ? sanitize_text_field( $_GET['end_date_from'] ) : null; |
| 25 |
$end_date_to = isset( $_GET['end_date_to'] ) ? sanitize_text_field( $_GET['end_date_to'] ) : null; |
| 26 |
$status = isset( $_GET['post_status'] ) ? $_GET['post_status'] : 'any'; |
| 27 |
$report_type = isset( $_GET['report_type'] ) ? $_GET['report_type'] : 'campaigns'; |
| 28 |
|
| 29 |
/** |
| 30 |
* Filter the type of exportable report types. |
| 31 |
* |
| 32 |
* @since 1.6.0 |
| 33 |
* |
| 34 |
* @param array $types Types of reports. |
| 35 |
*/ |
| 36 |
$report_types = apply_filters( |
| 37 |
'charitable_campaign_export_report_types', |
| 38 |
array( |
| 39 |
'campaigns' => __( 'Campaigns', 'charitable' ), |
| 40 |
) |
| 41 |
); |
| 42 |
|
| 43 |
$statuses = array( |
| 44 |
'any' => __( 'All', 'charitable' ), |
| 45 |
'pending' => __( 'Pending', 'charitable' ), |
| 46 |
'draft' => __( 'Draft', 'charitable' ), |
| 47 |
'active' => __( 'Active', 'charitable' ), |
| 48 |
'finish' => __( 'Finished', 'charitable' ), |
| 49 |
'publish' => __( 'Published', 'charitable' ), |
| 50 |
); |
| 51 |
|
| 52 |
?> |
| 53 |
<div id="charitable-campaigns-export-modal" style="display: none" class="charitable-campaigns-modal <?php echo esc_attr( $modal_class ); ?>" tabindex="0"> |
| 54 |
<a class="modal-close"></a> |
| 55 |
<h3><?php _e( 'Export Campaigns', 'charitable' ); ?></h3> |
| 56 |
<form class="charitable-campaigns-modal-form charitable-modal-form" method="get" action="<?php echo admin_url( 'admin.php' ); ?>"> |
| 57 |
<?php wp_nonce_field( 'charitable_export_campaigns', '_charitable_export_nonce' ); ?> |
| 58 |
<input type="hidden" name="charitable_action" value="export_campaigns" /> |
| 59 |
<input type="hidden" name="page" value="charitable-campaigns-table" /> |
| 60 |
<input type="hidden" name="post_type" class="post_type_page" value="campaign" /> |
| 61 |
<fieldset> |
| 62 |
<legend><?php _e( 'Filter by Start Date', 'charitable' ); ?></legend> |
| 63 |
<input type="text" id="charitable-export-start_date_from" name="start_date_from" class="charitable-datepicker" autocomplete="off" value="<?php echo $start_date_from; ?>" placeholder="<?php esc_attr_e( 'From:', 'charitable' ); ?>" /> |
| 64 |
<input type="text" id="charitable-export-start_date_to" name="start_date_to" class="charitable-datepicker" autocomplete="off" value="<?php echo $start_date_to; ?>" placeholder="<?php esc_attr_e( 'To:', 'charitable' ); ?>" /> |
| 65 |
</fieldset> |
| 66 |
<fieldset> |
| 67 |
<legend><?php _e( 'Filter by End Date', 'charitable' ); ?></legend> |
| 68 |
<input type="text" id="charitable-export-end_date_from" name="end_date_from" class="charitable-datepicker" autocomplete="off" value="<?php echo $end_date_from; ?>" placeholder="<?php esc_attr_e( 'From:', 'charitable' ); ?>" /> |
| 69 |
<input type="text" id="charitable-export-end_date_to" name="end_date_to" class="charitable-datepicker" autocomplete="off" value="<?php echo $end_date_to; ?>" placeholder="<?php esc_attr_e( 'To:', 'charitable' ); ?>" /> |
| 70 |
</fieldset> |
| 71 |
<label for="charitable-campaigns-export-status"><?php _e( 'Filter by Status', 'charitable' ); ?></label> |
| 72 |
<select id="charitable-campaigns-filter-status" name="status"> |
| 73 |
<?php foreach ( $statuses as $key => $label ) : ?> |
| 74 |
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $status, $key ); ?>><?php echo $label; ?></option> |
| 75 |
<?php endforeach ?> |
| 76 |
</select> |
| 77 |
<?php if ( count( $report_types ) > 1 ) : ?> |
| 78 |
<label for="charitable-campaign-export-report-type"><?php _e( 'Type of Report', 'charitable' ); ?></label> |
| 79 |
<select id="charitable-campaign-export-report-type" name="report_type"> |
| 80 |
<?php foreach ( $report_types as $key => $report_label ) : ?> |
| 81 |
<option value="<?php echo esc_attr( $key ); ?>"><?php echo $report_label; ?></option> |
| 82 |
<?php endforeach; ?> |
| 83 |
</select> |
| 84 |
<?php else : ?> |
| 85 |
<input type="hidden" name="report_type" value="<?php echo esc_attr( key( $report_types ) ); ?>" /> |
| 86 |
<?php |
| 87 |
endif; |
| 88 |
|
| 89 |
/** |
| 90 |
* Add additional exports to the form. |
| 91 |
* |
| 92 |
* @since 1.6.36 |
| 93 |
*/ |
| 94 |
do_action( 'charitable_export_campaigns_form' ); |
| 95 |
?> |
| 96 |
<button type="submit" class="button button-primary"><?php _e( 'Export', 'charitable' ); ?></button> |
| 97 |
</form> |
| 98 |
</div> |
| 99 |
|