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