← All changes
|
includes/admin/tools/views/html-admin-page-exports.php
+48
-83
2.3.0
→
4.17.0
View file →
| @@ -48,9 +48,9 @@ | ||
| 48 | 48 | </h3> |
| 49 | 49 | <p><?php esc_html_e( 'Download a CSV of all donations recorded.', 'give' ); ?></p> |
| 50 | 50 | </td> |
| 51 | 51 | <td> |
| 52 | - <a class="button" href="<?php echo add_query_arg( array( 'type' => 'export_donations' ) ); ?>"> | |
| 52 | + <a class="button" href="<?php echo esc_url( add_query_arg( [ 'type' => 'export_donations' ] ) ); ?>"> | |
| 53 | 53 | <?php esc_html_e( 'Generate CSV', 'give' ); ?> |
| 54 | 54 | </a> |
| 55 | 55 | </td> |
| 56 | 56 | </tr> |
| @@ -57,14 +57,14 @@ | ||
| 57 | 57 | |
| 58 | 58 | <tr class="give-export-pdf-sales-earnings"> |
| 59 | 59 | <td scope="row" class="row-title"> |
| 60 | 60 | <h3> |
| 61 | - <span><?php esc_html_e( 'Export PDF of Donations and Income', 'give' ); ?></span> | |
| 61 | + <span><?php esc_html_e( 'Export PDF of Donations and Revenue', 'give' ); ?></span> | |
| 62 | 62 | </h3> |
| 63 | - <p><?php esc_html_e( 'Download a PDF of Donations and Income reports for all forms for the current year.', 'give' ); ?></p> | |
| 63 | + <p><?php esc_html_e( 'Download a PDF of Donations and Revenue reports for all forms for the current year.', 'give' ); ?></p> | |
| 64 | 64 | </td> |
| 65 | 65 | <td> |
| 66 | - <a class="button" href="<?php echo wp_nonce_url( add_query_arg( array( 'give-action' => 'generate_pdf' ) ), 'give_generate_pdf' ); ?>"> | |
| 66 | + <a class="button" href="<?php echo esc_url( wp_nonce_url( add_query_arg( [ 'give-action' => 'generate_pdf' ] ), 'give_generate_pdf' ) ); ?>"> | |
| 67 | 67 | <?php esc_html_e( 'Generate PDF', 'give' ); ?> |
| 68 | 68 | </a> |
| 69 | 69 | </td> |
| 70 | 70 | </tr> |
| @@ -70,98 +70,63 @@ | ||
| 70 | 70 | </tr> |
| 71 | 71 | <tr class="give-export-sales-earnings"> |
| 72 | 72 | <td scope="row" class="row-title"> |
| 73 | 73 | <h3> |
| 74 | - <span><?php esc_html_e( 'Export Income and Donation Stats', 'give' ); ?></span> | |
| 74 | + <span><?php esc_html_e( 'Export Revenue and Donation Stats', 'give' ); ?></span> | |
| 75 | 75 | </h3> |
| 76 | - <p><?php esc_html_e( 'Download a CSV of income and donations over time.', 'give' ); ?></p> | |
| 76 | + <p><?php esc_html_e( 'Download a CSV of revenue and donations over time.', 'give' ); ?></p> | |
| 77 | 77 | </td> |
| 78 | 78 | <td> |
| 79 | 79 | <form method="post"> |
| 80 | - <?php | |
| 81 | - printf( | |
| 82 | - /* translators: 1: start date dropdown 2: end date dropdown */ | |
| 83 | - esc_html__( '%1$s to %2$s', 'give' ), | |
| 84 | - Give()->html->year_dropdown( 'start_year' ) . ' ' . Give()->html->month_dropdown( 'start_month' ), | |
| 85 | - Give()->html->year_dropdown( 'end_year' ) . ' ' . Give()->html->month_dropdown( 'end_month' ) | |
| 86 | - ); | |
| 87 | - ?> | |
| 80 | + <?php | |
| 81 | + // @since 2.21.2 | |
| 82 | + // Year in year dropdown should begin from first donation year instead of only display first five recent year. | |
| 83 | + $firstDonation = give()->donations->getFirstDonation(); | |
| 84 | + $firstDonationDate = $firstDonation->createdAt ?? null; | |
| 85 | + $currentYear = date('Y', current_time('timestamp')); | |
| 86 | + | |
| 87 | + $start_year_dropdown = Give()->html->year_dropdown( | |
| 88 | + 'start_year', | |
| 89 | + 0, | |
| 90 | + $firstDonationDate ? ($currentYear - $firstDonationDate->format('Y')) : 0 | |
| 91 | + ); | |
| 92 | + | |
| 93 | + $end_year_dropdown = Give()->html->year_dropdown( | |
| 94 | + 'end_year', | |
| 95 | + 0, | |
| 96 | + $firstDonationDate ? ($currentYear - $firstDonationDate->format('Y')) : 0 | |
| 97 | + ); | |
| 98 | + printf( | |
| 99 | + esc_html__('%1$s to %2$s', 'give'), | |
| 100 | + $start_year_dropdown . ' ' . Give()->html->month_dropdown('start_month'), | |
| 101 | + $end_year_dropdown . ' ' . Give()->html->month_dropdown('end_month') | |
| 102 | + ); | |
| 103 | + ?> | |
| 88 | 104 | <input type="hidden" name="give-action" value="earnings_export"/> |
| 105 | + <input type="hidden" name="give-nonce" value="<?= wp_create_nonce('give_earnings_export') ?>"/> | |
| 89 | 106 | <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
| 90 | 107 | </form> |
| 91 | 108 | </td> |
| 92 | 109 | </tr> |
| 93 | 110 | |
| 94 | - <tr class="give-export-donors"> | |
| 95 | - <td scope="row" class="row-title"> | |
| 96 | - <h3> | |
| 97 | - <span><?php esc_html_e( 'Export Donors', 'give' ); ?></span> | |
| 98 | - </h3> | |
| 99 | - <p><?php esc_html_e( 'Download a CSV of donors. Column values reflect totals across all donation forms by default, or a single donation form if selected.', 'give' ); ?></p> | |
| 100 | - </td> | |
| 101 | - <td> | |
| 102 | - <form method="post" id="give_donor_export" class="give-export-form"> | |
| 103 | - <?php | |
| 104 | - // Start Date form field for donors. | |
| 105 | - echo Give()->html->date_field( array( | |
| 106 | - 'id' => 'give_donor_export_start_date', | |
| 107 | - 'name' => 'donor_export_start_date', | |
| 108 | - 'placeholder' => esc_attr__( 'Start Date', 'give' ), | |
| 109 | - 'autocomplete' => 'off', | |
| 110 | - ) ); | |
| 111 | + <?php | |
| 112 | + /** | |
| 113 | + * @since 2.21.2 | |
| 114 | + */ | |
| 115 | + do_action( 'give_tools_tab_export_after_donation_history' ); | |
| 116 | + ?> | |
| 111 | 117 | |
| 112 | - // End Date form field for donors. | |
| 113 | - echo Give()->html->date_field( array( | |
| 114 | - 'id' => 'give_donor_export_end_date', | |
| 115 | - 'name' => 'donor_export_end_date', | |
| 116 | - 'placeholder' => esc_attr__( 'End Date', 'give' ), | |
| 117 | - 'autocomplete' => 'off', | |
| 118 | - ) ); | |
| 118 | + <?php | |
| 119 | + /** | |
| 120 | + * @since 2.21.2 | |
| 121 | + */ | |
| 122 | + do_action( 'give_tools_tab_export_before_core_settings' ); | |
| 123 | + ?> | |
| 119 | 124 | |
| 120 | - // Donation forms dropdown for donors export. | |
| 121 | - echo Give()->html->forms_dropdown( array( | |
| 122 | - 'name' => 'forms', | |
| 123 | - 'id' => 'give_donor_export_form', | |
| 124 | - 'chosen' => true, | |
| 125 | - ) ); | |
| 126 | - ?> | |
| 127 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> | |
| 128 | - | |
| 129 | - <div id="export-donor-options-wrap" class="give-clearfix"> | |
| 130 | - <p><?php esc_html_e( 'Export Columns:', 'give' ); ?></p> | |
| 131 | - <ul id="give-export-option-ul"> | |
| 132 | - <?php | |
| 133 | - $donor_export_columns = give_export_donors_get_default_columns(); | |
| 134 | - | |
| 135 | - foreach ( $donor_export_columns as $column_name => $column_label ) { | |
| 136 | - ?> | |
| 137 | - <li> | |
| 138 | - <label for="give-export-<?php echo esc_attr( $column_name ); ?>"> | |
| 139 | - <input | |
| 140 | - type="checkbox" | |
| 141 | - checked | |
| 142 | - name="give_export_option[<?php echo esc_attr( $column_name ); ?>]" | |
| 143 | - id="give-export-<?php echo esc_attr( $column_name ); ?>" | |
| 144 | - /> | |
| 145 | - <?php echo esc_attr( $column_label ); ?> | |
| 146 | - </label> | |
| 147 | - </li> | |
| 148 | - <?php | |
| 149 | - } | |
| 150 | - ?> | |
| 151 | - </ul> | |
| 152 | - </div> | |
| 153 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> | |
| 154 | - <input type="hidden" name="give-export-class" value="Give_Batch_Donors_Export"/> | |
| 155 | - <input type="hidden" name="give_export_option[query_id]" value="<?php echo uniqid( 'give_' ); ?>"/> | |
| 156 | - </form> | |
| 157 | - </td> | |
| 158 | - </tr> | |
| 159 | - | |
| 160 | 125 | <tr class="give-export-core-settings"> |
| 161 | 126 | <td scope="row" class="row-title"> |
| 162 | 127 | <h3> |
| 163 | - <span><?php esc_html_e( 'Export Give Settings', 'give' ); ?></span> | |
| 128 | + <span><?php esc_html_e( 'Export GiveWP Settings', 'give' ); ?></span> | |
| 164 | 129 | </h3> |
| 165 | 130 | <p><?php esc_html_e( 'Download an export of Give\'s settings and import it in a new WordPress installation.', 'give' ); ?></p> |
| 166 | 131 | </td> |
| 167 | 132 | <td> |
| @@ -166,9 +131,9 @@ | ||
| 166 | 131 | </td> |
| 167 | 132 | <td> |
| 168 | 133 | <form method="post"> |
| 169 | 134 | <?php |
| 170 | - $export_excludes = apply_filters( 'give_settings_export_excludes', array() ); | |
| 135 | + $export_excludes = apply_filters( 'give_settings_export_excludes', [] ); | |
| 171 | 136 | if ( ! empty( $export_excludes ) ) { |
| 172 | 137 | ?> |
| 173 | 138 | <i class="settings-excludes-title"><?php esc_html_e( 'Checked options from the list will not be exported.', 'give' ); ?></i> |
| 174 | 139 | <ul class="settings-excludes-list"> |
| @@ -173,14 +138,14 @@ | ||
| 173 | 138 | <i class="settings-excludes-title"><?php esc_html_e( 'Checked options from the list will not be exported.', 'give' ); ?></i> |
| 174 | 139 | <ul class="settings-excludes-list"> |
| 175 | 140 | <?php foreach ( $export_excludes as $option_key => $option_label ) { ?> |
| 176 | 141 | <li> |
| 177 | - <label for="settings_export_excludes[<?php echo $option_key ?>]"> | |
| 142 | + <label for="settings_export_excludes[<?php echo $option_key; ?>]"> | |
| 178 | 143 | <input |
| 179 | 144 | type="checkbox" |
| 180 | 145 | checked |
| 181 | - name="settings_export_excludes[<?php echo $option_key ?>]" | |
| 182 | - id="settings_export_excludes[<?php echo $option_key ?>]" | |
| 146 | + name="settings_export_excludes[<?php echo $option_key; ?>]" | |
| 147 | + id="settings_export_excludes[<?php echo $option_key; ?>]" | |
| 183 | 148 | /> |
| 184 | 149 | <?php echo esc_html( $option_label ); ?> |
| 185 | 150 | </label> |
| 186 | 151 | </li> |