← All changes
|
includes/admin/views/campaigns-page/export-form.php
+84
-39
1.6.7
→
1.8.13
View file →
| @@ -1,62 +1,107 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 3 | +// Exit if accessed directly. | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | + | |
| 2 | 8 | /** |
| 3 | - * Display the export button in the campaign filters box. | |
| 9 | + * Display the export button in the campaign exports box. | |
| 4 | 10 | * |
| 5 | - * @author Eric Daams | |
| 11 | + * @author David Bisset | |
| 6 | 12 | * @package Charitable/Admin View/Campaigns Page |
| 7 | - * @copyright Copyright (c) 2018, Studio 164a | |
| 13 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 14 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 15 | * @since 1.6.0 |
| 10 | - * @version 1.6.0 | |
| 16 | + * @version 1.8.9.1 | |
| 17 | + * @version 1.8.8.6 | |
| 11 | 18 | */ |
| 12 | 19 | |
| 13 | - $modal_class = apply_filters( 'charitable_modal_window_class', 'charitable-modal' ); | |
| 14 | - $start_date = isset( $_GET['start_date'] ) ? sanitize_text_field( $_GET['start_date'] ) : null; | |
| 15 | - $end_date = isset( $_GET['end_date'] ) ? sanitize_text_field( $_GET['end_date'] ) : null; | |
| 16 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : ''; | |
| 17 | - $report_type = isset( $_GET['report_type'] ) ? $_GET['report_type'] : 'campaigns'; | |
| 18 | - $report_types = apply_filters( 'charitable_campaign_export_report_types', array( | |
| 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( | |
| 19 | 48 | 'campaigns' => __( 'Campaigns', 'charitable' ), |
| 20 | - ) ); | |
| 21 | - $statuses = array( | |
| 22 | - '' => __( 'Any', 'charitable' ), | |
| 23 | - 'pending' => __( 'Pending', 'charitable' ), | |
| 24 | - 'draft' => __( 'Draft', 'charitable' ), | |
| 25 | - 'active' => __( 'Active', 'charitable' ), | |
| 26 | - 'finish' => __( 'Finished', 'charitable' ), | |
| 27 | - 'publish' => __( 'Published', 'charitable' ), | |
| 28 | - ); | |
| 49 | + ) | |
| 50 | +); | |
| 29 | 51 | |
| 30 | - ?> | |
| 31 | -<div id="charitable-campaigns-export-modal" style="display: none;" class="charitable-campaigns-modal <?php echo esc_attr( $modal_class ); ?>" tabindex="0"> | |
| 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"> | |
| 32 | 63 | <a class="modal-close"></a> |
| 33 | - <h3><?php _e( 'Export Campaigns', 'charitable' ); ?></h3> | |
| 34 | - <form class="charitable-campaigns-modal-form charitable-modal-form" method="get" action="<?php echo admin_url( 'admin.php' ); ?>"> | |
| 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' ) ); ?>"> | |
| 35 | 66 | <?php wp_nonce_field( 'charitable_export_campaigns', '_charitable_export_nonce' ); ?> |
| 36 | 67 | <input type="hidden" name="charitable_action" value="export_campaigns" /> |
| 37 | 68 | <input type="hidden" name="page" value="charitable-campaigns-table" /> |
| 69 | + <input type="hidden" name="post_type" class="post_type_page" value="campaign" /> | |
| 38 | 70 | <fieldset> |
| 39 | - <legend><?php _e( 'Filter by Date Created', 'charitable' ); ?></legend> | |
| 40 | - <input type="text" id="charitable-export-start_date" name="start_date" class="charitable-datepicker" value="<?php echo $start_date; ?>" placeholder="<?php esc_attr_e( 'From:', 'charitable' ); ?>" /> | |
| 41 | - <input type="text" id="charitable-export-end_date" name="end_date" class="charitable-datepicker" value="<?php echo $end_date; ?>" placeholder="<?php esc_attr_e( 'To:', 'charitable' ); ?>" /> | |
| 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' ); ?>" /> | |
| 42 | 74 | </fieldset> |
| 43 | - <label for="charitable-campaigns-export-campaign"><?php _e( 'Filter by Status', 'charitable' ); ?></label> | |
| 44 | - <select id="charitable-campaigns-export-campaign" name="status"> | |
| 45 | - <?php foreach ( $statuses as $key => $label ) : ?> | |
| 46 | - <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $status ); ?>><?php echo $label; ?></option> | |
| 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> | |
| 47 | 84 | <?php endforeach ?> |
| 48 | 85 | </select> |
| 49 | - <?php if ( count( $report_types ) > 1 ) : ?> | |
| 50 | - <label for="charitable-campaigns-export-report-type"><?php _e( 'Type of Report', 'charitable' ); ?></label> | |
| 51 | - <select id="charitable-campaigns-export-report-type" name="report_type"> | |
| 52 | - <?php foreach ( $report_types as $key => $report_label ) : ?> | |
| 53 | - <option value="<?php echo esc_attr( $key ); ?>"><?php echo $report_label; ?></option> | |
| 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> | |
| 54 | 91 | <?php endforeach; ?> |
| 55 | 92 | </select> |
| 56 | 93 | <?php else : ?> |
| 57 | - <input type="hidden" name="report_type" value="<?php echo esc_attr( key( $report_types ) ); ?>" /> | |
| 58 | - <?php endif ?> | |
| 59 | - <?php do_action( 'charitable_export_campaigns_form' ); ?> | |
| 60 | - <button name="charitable-export-campaigns" class="button button-primary"><?php _e( 'Export', 'charitable' ); ?></button> | |
| 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> | |
| 61 | 106 | </form> |
| 62 | 107 | </div> |