@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Admin View: Exports |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if ( ! defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } ?> |
9 | 9 | |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @since 1.0 |
20 | 20 | */ |
21 | - do_action( 'give_tools_tab_export_content_top' ); |
|
21 | + do_action('give_tools_tab_export_content_top'); |
|
22 | 22 | ?> |
23 | 23 | |
24 | 24 | <table class="widefat export-options-table give-table"> |
25 | 25 | <thead> |
26 | 26 | <tr> |
27 | - <th scope="col"><?php esc_html_e( 'Export Type', 'give' ); ?></th> |
|
28 | - <th scope="col"><?php esc_html_e( 'Export Options', 'give' ); ?></th> |
|
27 | + <th scope="col"><?php esc_html_e('Export Type', 'give'); ?></th> |
|
28 | + <th scope="col"><?php esc_html_e('Export Options', 'give'); ?></th> |
|
29 | 29 | </tr> |
30 | 30 | </thead> |
31 | 31 | <tbody> |
@@ -38,43 +38,43 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @since 1.0 |
40 | 40 | */ |
41 | - do_action( 'give_tools_tab_export_table_top' ); |
|
41 | + do_action('give_tools_tab_export_table_top'); |
|
42 | 42 | ?> |
43 | 43 | <tr class="give-export-pdf-sales-earnings"> |
44 | 44 | <td scope="row" class="row-title"> |
45 | 45 | <h3> |
46 | - <span><?php esc_html_e( 'Export PDF of Donations and Income', 'give' ); ?></span> |
|
46 | + <span><?php esc_html_e('Export PDF of Donations and Income', 'give'); ?></span> |
|
47 | 47 | </h3> |
48 | - <p><?php esc_html_e( 'Download a PDF of Donations and Income reports for all forms for the current year.', 'give' ); ?></p> |
|
48 | + <p><?php esc_html_e('Download a PDF of Donations and Income reports for all forms for the current year.', 'give'); ?></p> |
|
49 | 49 | </td> |
50 | 50 | <td> |
51 | 51 | <a class="button" |
52 | - href="<?php echo wp_nonce_url( add_query_arg( [ |
|
52 | + href="<?php echo wp_nonce_url(add_query_arg([ |
|
53 | 53 | 'give-action' => 'generate_pdf', |
54 | - ] ), 'give_generate_pdf' ); ?>"><?php esc_html_e( 'Generate PDF', 'give' ); ?></a> |
|
54 | + ]), 'give_generate_pdf'); ?>"><?php esc_html_e('Generate PDF', 'give'); ?></a> |
|
55 | 55 | </td> |
56 | 56 | </tr> |
57 | 57 | <tr class="alternate give-export-sales-earnings"> |
58 | 58 | <td scope="row" class="row-title"> |
59 | 59 | <h3> |
60 | - <span><?php esc_html_e( 'Export Income and Donation Stats', 'give' ); ?></span> |
|
60 | + <span><?php esc_html_e('Export Income and Donation Stats', 'give'); ?></span> |
|
61 | 61 | </h3> |
62 | - <p><?php esc_html_e( 'Download a CSV of income and donations over time.', 'give' ); ?></p> |
|
62 | + <p><?php esc_html_e('Download a CSV of income and donations over time.', 'give'); ?></p> |
|
63 | 63 | </td> |
64 | 64 | <td> |
65 | 65 | <form method="post"> |
66 | 66 | <?php |
67 | 67 | printf( |
68 | 68 | /* translators: 1: start date dropdown 2: end date dropdown */ |
69 | - esc_html__( '%1$s to %2$s', 'give' ), |
|
70 | - Give()->html->year_dropdown( 'start_year' ) . ' ' . Give()->html->month_dropdown( 'start_month' ), |
|
71 | - Give()->html->year_dropdown( 'end_year' ) . ' ' . Give()->html->month_dropdown( 'end_month' ) |
|
69 | + esc_html__('%1$s to %2$s', 'give'), |
|
70 | + Give()->html->year_dropdown('start_year').' '.Give()->html->month_dropdown('start_month'), |
|
71 | + Give()->html->year_dropdown('end_year').' '.Give()->html->month_dropdown('end_month') |
|
72 | 72 | ); |
73 | 73 | ?> |
74 | 74 | <input type="hidden" name="give-action" |
75 | 75 | value="earnings_export"/> |
76 | 76 | <input type="submit" |
77 | - value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" |
|
77 | + value="<?php esc_attr_e('Generate CSV', 'give'); ?>" |
|
78 | 78 | class="button-secondary"/> |
79 | 79 | </form> |
80 | 80 | </td> |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | <tr class="give-export-payment-history"> |
83 | 83 | <td scope="row" class="row-title"> |
84 | 84 | <h3> |
85 | - <span><?php esc_html_e( 'Export Donation History', 'give' ); ?></span> |
|
85 | + <span><?php esc_html_e('Export Donation History', 'give'); ?></span> |
|
86 | 86 | </h3> |
87 | - <p><?php esc_html_e( 'Download a CSV of all donations recorded.', 'give' ); ?></p> |
|
87 | + <p><?php esc_html_e('Download a CSV of all donations recorded.', 'give'); ?></p> |
|
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <form id="give-export-payments" |
@@ -93,27 +93,27 @@ discard block |
||
93 | 93 | $args = [ |
94 | 94 | 'id' => 'give-payment-export-start', |
95 | 95 | 'name' => 'start', |
96 | - 'placeholder' => esc_attr__( 'Start date', 'give' ), |
|
96 | + 'placeholder' => esc_attr__('Start date', 'give'), |
|
97 | 97 | ]; |
98 | - echo Give()->html->date_field( $args ); ?> |
|
98 | + echo Give()->html->date_field($args); ?> |
|
99 | 99 | <?php |
100 | 100 | $args = [ |
101 | 101 | 'id' => 'give-payment-export-end', |
102 | 102 | 'name' => 'end', |
103 | - 'placeholder' => esc_attr__( 'End date', 'give' ), |
|
103 | + 'placeholder' => esc_attr__('End date', 'give'), |
|
104 | 104 | ]; |
105 | - echo Give()->html->date_field( $args ); ?> |
|
105 | + echo Give()->html->date_field($args); ?> |
|
106 | 106 | <select name="status"> |
107 | - <option value="any"><?php esc_html_e( 'All Statuses', 'give' ); ?></option> |
|
107 | + <option value="any"><?php esc_html_e('All Statuses', 'give'); ?></option> |
|
108 | 108 | <?php |
109 | 109 | $statuses = give_get_payment_statuses(); |
110 | - foreach ( $statuses as $status => $label ) { |
|
111 | - echo '<option value="' . $status . '">' . $label . '</option>'; |
|
110 | + foreach ($statuses as $status => $label) { |
|
111 | + echo '<option value="'.$status.'">'.$label.'</option>'; |
|
112 | 112 | } |
113 | 113 | ?> |
114 | 114 | </select> |
115 | 115 | <?php |
116 | - if ( give_is_setting_enabled( give_get_option( 'categories' ) ) ) { |
|
116 | + if (give_is_setting_enabled(give_get_option('categories'))) { |
|
117 | 117 | echo Give()->html->category_dropdown( |
118 | 118 | 'give_forms_categories[]', |
119 | 119 | 0, |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | 'multiple' => true, |
124 | 124 | 'selected' => [], |
125 | 125 | 'show_option_all' => false, |
126 | - 'placeholder' => __( 'Choose one or more from categories', 'give' ), |
|
126 | + 'placeholder' => __('Choose one or more from categories', 'give'), |
|
127 | 127 | ] |
128 | 128 | ); |
129 | 129 | } |
130 | 130 | |
131 | - if ( give_is_setting_enabled( give_get_option( 'tags' ) ) ) { |
|
131 | + if (give_is_setting_enabled(give_get_option('tags'))) { |
|
132 | 132 | echo Give()->html->tags_dropdown( |
133 | 133 | 'give_forms_tags[]', |
134 | 134 | 0, |
@@ -138,18 +138,18 @@ discard block |
||
138 | 138 | 'multiple' => true, |
139 | 139 | 'selected' => [], |
140 | 140 | 'show_option_all' => false, |
141 | - 'placeholder' => __( 'Choose one or more from tags', 'give' ), |
|
141 | + 'placeholder' => __('Choose one or more from tags', 'give'), |
|
142 | 142 | ] |
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
146 | - wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); |
|
146 | + wp_nonce_field('give_ajax_export', 'give_ajax_export'); |
|
147 | 147 | ?> |
148 | 148 | <input type="hidden" name="give-export-class" |
149 | 149 | value="Give_Batch_Payments_Export"/> |
150 | 150 | <span> |
151 | 151 | <input type="submit" |
152 | - value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" |
|
152 | + value="<?php esc_attr_e('Generate CSV', 'give'); ?>" |
|
153 | 153 | class="button-secondary"/> |
154 | 154 | <span class="spinner"></span> |
155 | 155 | </span> |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | <tr class="alternate give-export-donors"> |
160 | 160 | <td scope="row" class="row-title"> |
161 | 161 | <h3> |
162 | - <span><?php esc_html_e( 'Export Donors in CSV', 'give' ); ?></span> |
|
162 | + <span><?php esc_html_e('Export Donors in CSV', 'give'); ?></span> |
|
163 | 163 | </h3> |
164 | - <p><?php esc_html_e( 'Download an export of donors for all donation forms or only those who have given to a particular form.', 'give' ); ?></p> |
|
164 | + <p><?php esc_html_e('Download an export of donors for all donation forms or only those who have given to a particular form.', 'give'); ?></p> |
|
165 | 165 | </td> |
166 | 166 | <td> |
167 | 167 | <form method="post" id="give_donor_export" |
@@ -173,73 +173,73 @@ discard block |
||
173 | 173 | 'id' => 'give_donor_export_form', |
174 | 174 | 'chosen' => true, |
175 | 175 | ]; |
176 | - echo Give()->html->forms_dropdown( $args ); ?> |
|
176 | + echo Give()->html->forms_dropdown($args); ?> |
|
177 | 177 | |
178 | 178 | <input type="submit" |
179 | - value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" |
|
179 | + value="<?php esc_attr_e('Generate CSV', 'give'); ?>" |
|
180 | 180 | class="button-secondary"/> |
181 | 181 | |
182 | 182 | <div id="export-donor-options-wrap" |
183 | 183 | class="give-clearfix"> |
184 | - <p><?php esc_html_e( 'Export Columns:', 'give' ); ?></p> |
|
184 | + <p><?php esc_html_e('Export Columns:', 'give'); ?></p> |
|
185 | 185 | <ul id="give-export-option-ul"> |
186 | 186 | <li> |
187 | 187 | <label for="give-export-fullname"> |
188 | 188 | <input type="checkbox" checked |
189 | 189 | name="give_export_option[full_name]" |
190 | - id="give-export-fullname"><?php esc_html_e( 'Name', 'give' ); ?> |
|
190 | + id="give-export-fullname"><?php esc_html_e('Name', 'give'); ?> |
|
191 | 191 | </label> |
192 | 192 | </li> |
193 | 193 | <li> |
194 | 194 | <label for="give-export-email"> |
195 | 195 | <input type="checkbox" checked |
196 | 196 | name="give_export_option[email]" |
197 | - id="give-export-email"><?php esc_html_e( 'Email', 'give' ); ?> |
|
197 | + id="give-export-email"><?php esc_html_e('Email', 'give'); ?> |
|
198 | 198 | </label> |
199 | 199 | </li> |
200 | 200 | <li> |
201 | 201 | <label for="give-export-address"> |
202 | 202 | <input type="checkbox" checked |
203 | 203 | name="give_export_option[address]" |
204 | - id="give-export-address"><?php esc_html_e( 'Address', 'give' ); ?> |
|
204 | + id="give-export-address"><?php esc_html_e('Address', 'give'); ?> |
|
205 | 205 | </label> |
206 | 206 | </li> |
207 | 207 | <li> |
208 | 208 | <label for="give-export-userid"> |
209 | 209 | <input type="checkbox" checked |
210 | 210 | name="give_export_option[userid]" |
211 | - id="give-export-userid"><?php esc_html_e( 'User ID', 'give' ); ?> |
|
211 | + id="give-export-userid"><?php esc_html_e('User ID', 'give'); ?> |
|
212 | 212 | </label> |
213 | 213 | </li> |
214 | 214 | <li> |
215 | 215 | <label for="give-export-first-donation-date"> |
216 | 216 | <input type="checkbox" checked |
217 | 217 | name="give_export_option[date_first_donated]" |
218 | - id="give-export-first-donation-date"><?php esc_html_e( 'First Donation Date', 'give' ); ?> |
|
218 | + id="give-export-first-donation-date"><?php esc_html_e('First Donation Date', 'give'); ?> |
|
219 | 219 | </label> |
220 | 220 | </li> |
221 | 221 | <li> |
222 | 222 | <label for="give-export-donation-number"> |
223 | 223 | <input type="checkbox" checked |
224 | 224 | name="give_export_option[donations]" |
225 | - id="give-export-donation-number"><?php esc_html_e( 'Number of Donations', 'give' ); ?> |
|
225 | + id="give-export-donation-number"><?php esc_html_e('Number of Donations', 'give'); ?> |
|
226 | 226 | </label> |
227 | 227 | </li> |
228 | 228 | <li> |
229 | 229 | <label for="give-export-donation-sum"> |
230 | 230 | <input type="checkbox" checked |
231 | 231 | name="give_export_option[donation_sum]" |
232 | - id="give-export-donation-sum"><?php esc_html_e( 'Total Donated', 'give' ); ?> |
|
232 | + id="give-export-donation-sum"><?php esc_html_e('Total Donated', 'give'); ?> |
|
233 | 233 | </label> |
234 | 234 | </li> |
235 | 235 | </ul> |
236 | 236 | </div> |
237 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
237 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
238 | 238 | <input type="hidden" name="give-export-class" |
239 | 239 | value="Give_Batch_Customers_Export"/> |
240 | 240 | <input type="hidden" |
241 | 241 | name="give_export_option[query_id]" |
242 | - value="<?php echo uniqid( 'give_' ); ?>"/> |
|
242 | + value="<?php echo uniqid('give_'); ?>"/> |
|
243 | 243 | </form> |
244 | 244 | </td> |
245 | 245 | </tr> |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @since 1.0 |
254 | 254 | */ |
255 | - do_action( 'give_tools_tab_export_table_bottom' ); |
|
255 | + do_action('give_tools_tab_export_table_bottom'); |
|
256 | 256 | ?> |
257 | 257 | </tbody> |
258 | 258 | </table> |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @since 1.0 |
265 | 265 | */ |
266 | - do_action( 'give_tools_tab_export_content_bottom' ); |
|
266 | + do_action('give_tools_tab_export_content_bottom'); |
|
267 | 267 | ?> |
268 | 268 | |
269 | 269 | </div> |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | - 'ajax' => false,// Does this table support ajax? |
|
52 | - ) ); |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | + 'ajax' => false, // Does this table support ajax? |
|
52 | + )); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - public function search_box( $text, $input_id ) { |
|
67 | - $input_id = $input_id . '-search-input'; |
|
66 | + public function search_box($text, $input_id) { |
|
67 | + $input_id = $input_id.'-search-input'; |
|
68 | 68 | |
69 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
70 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
69 | + if ( ! empty($_REQUEST['orderby'])) { |
|
70 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
71 | 71 | } |
72 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
73 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
72 | + if ( ! empty($_REQUEST['order'])) { |
|
73 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
74 | 74 | } |
75 | 75 | ?> |
76 | 76 | <p class="search-box" role="search"> |
77 | 77 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
78 | 78 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
79 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
79 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
80 | 80 | </p> |
81 | 81 | <?php |
82 | 82 | } |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function get_columns() { |
92 | 92 | $columns = array( |
93 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
94 | - 'details' => esc_html__( 'Request Details', 'give' ), |
|
95 | - 'ip' => esc_html__( 'Request IP', 'give' ), |
|
96 | - 'date' => esc_html__( 'Date', 'give' ), |
|
93 | + 'ID' => esc_html__('Log ID', 'give'), |
|
94 | + 'details' => esc_html__('Request Details', 'give'), |
|
95 | + 'ip' => esc_html__('Request IP', 'give'), |
|
96 | + 'date' => esc_html__('Date', 'give'), |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | return $columns; |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string Column Name |
112 | 112 | */ |
113 | - public function column_default( $item, $column_name ) { |
|
114 | - switch ( $column_name ) { |
|
113 | + public function column_default($item, $column_name) { |
|
114 | + switch ($column_name) { |
|
115 | 115 | default: |
116 | - return $item[ $column_name ]; |
|
116 | + return $item[$column_name]; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -127,26 +127,26 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public function column_details( $item ) { |
|
130 | + public function column_details($item) { |
|
131 | 131 | ?> |
132 | - <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e( 'View Request', 'give' ); ?></a> |
|
132 | + <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e('View Request', 'give'); ?></a> |
|
133 | 133 | <div id="log-details-<?php echo $item['ID']; ?>" style="display:none;"> |
134 | 134 | <?php |
135 | 135 | |
136 | - $request = get_post_field( 'post_excerpt', $item['ID'] ); |
|
137 | - $error = get_post_field( 'post_content', $item['ID'] ); |
|
138 | - echo '<p><strong>' . esc_html__( 'API Request:', 'give' ) . '</strong></p>'; |
|
139 | - echo '<div>' . $request . '</div>'; |
|
140 | - if ( ! empty( $error ) ) { |
|
141 | - echo '<p><strong>' . esc_html__( 'Error', 'give' ) . '</strong></p>'; |
|
142 | - echo '<div>' . esc_html( $error ) . '</div>'; |
|
136 | + $request = get_post_field('post_excerpt', $item['ID']); |
|
137 | + $error = get_post_field('post_content', $item['ID']); |
|
138 | + echo '<p><strong>'.esc_html__('API Request:', 'give').'</strong></p>'; |
|
139 | + echo '<div>'.$request.'</div>'; |
|
140 | + if ( ! empty($error)) { |
|
141 | + echo '<p><strong>'.esc_html__('Error', 'give').'</strong></p>'; |
|
142 | + echo '<div>'.esc_html($error).'</div>'; |
|
143 | 143 | } |
144 | - echo '<p><strong>' . esc_html__( 'API User:', 'give' ) . '</strong></p>'; |
|
145 | - echo '<div>' . give_get_meta( $item['ID'], '_give_log_user', true ) . '</div>'; |
|
146 | - echo '<p><strong>' . esc_html__( 'API Key:', 'give' ) . '</strong></p>'; |
|
147 | - echo '<div>' . give_get_meta( $item['ID'], '_give_log_key', true ) . '</div>'; |
|
148 | - echo '<p><strong>' . esc_html__( 'Request Date:', 'give' ) . '</strong></p>'; |
|
149 | - echo '<div>' . get_post_field( 'post_date', $item['ID'] ) . '</div>'; |
|
144 | + echo '<p><strong>'.esc_html__('API User:', 'give').'</strong></p>'; |
|
145 | + echo '<div>'.give_get_meta($item['ID'], '_give_log_user', true).'</div>'; |
|
146 | + echo '<p><strong>'.esc_html__('API Key:', 'give').'</strong></p>'; |
|
147 | + echo '<div>'.give_get_meta($item['ID'], '_give_log_key', true).'</div>'; |
|
148 | + echo '<p><strong>'.esc_html__('Request Date:', 'give').'</strong></p>'; |
|
149 | + echo '<div>'.get_post_field('post_date', $item['ID']).'</div>'; |
|
150 | 150 | ?> |
151 | 151 | </div> |
152 | 152 | <?php |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return string|bool String if search is present, false otherwise |
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
163 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param string $which |
178 | 178 | */ |
179 | - protected function display_tablenav( $which ) { |
|
180 | - if ( 'top' === $which ) { |
|
181 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
179 | + protected function display_tablenav($which) { |
|
180 | + if ('top' === $which) { |
|
181 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
182 | 182 | } |
183 | 183 | ?> |
184 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
184 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
185 | 185 | |
186 | 186 | <div class="alignleft actions bulkactions"> |
187 | - <?php $this->bulk_actions( $which ); ?> |
|
187 | + <?php $this->bulk_actions($which); ?> |
|
188 | 188 | </div> |
189 | 189 | <?php |
190 | - $this->extra_tablenav( $which ); |
|
191 | - $this->pagination( $which ); |
|
190 | + $this->extra_tablenav($which); |
|
191 | + $this->pagination($which); |
|
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <br class="clear"/> |
@@ -210,31 +210,31 @@ discard block |
||
210 | 210 | |
211 | 211 | $search = $this->get_search(); |
212 | 212 | |
213 | - if ( $search ) { |
|
214 | - if ( filter_var( $search, FILTER_VALIDATE_IP ) ) { |
|
213 | + if ($search) { |
|
214 | + if (filter_var($search, FILTER_VALIDATE_IP)) { |
|
215 | 215 | // This is an IP address search |
216 | 216 | $key = '_give_log_request_ip'; |
217 | - } elseif ( is_email( $search ) ) { |
|
217 | + } elseif (is_email($search)) { |
|
218 | 218 | // This is an email search |
219 | - $userdata = get_user_by( 'email', $search ); |
|
219 | + $userdata = get_user_by('email', $search); |
|
220 | 220 | |
221 | - if ( $userdata ) { |
|
221 | + if ($userdata) { |
|
222 | 222 | $search = $userdata->ID; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $key = '_give_log_user'; |
226 | - } elseif ( strlen( $search ) == 32 ) { |
|
226 | + } elseif (strlen($search) == 32) { |
|
227 | 227 | // Look for an API key |
228 | 228 | $key = '_give_log_key'; |
229 | - } elseif ( stristr( $search, 'token:' ) ) { |
|
229 | + } elseif (stristr($search, 'token:')) { |
|
230 | 230 | // Look for an API token |
231 | - $search = str_ireplace( 'token:', '', $search ); |
|
231 | + $search = str_ireplace('token:', '', $search); |
|
232 | 232 | $key = '_give_log_token'; |
233 | 233 | } else { |
234 | 234 | // This is (probably) a user ID search |
235 | - $userdata = get_userdata( $search ); |
|
235 | + $userdata = get_userdata($search); |
|
236 | 236 | |
237 | - if ( $userdata ) { |
|
237 | + if ($userdata) { |
|
238 | 238 | $search = $userdata->ID; |
239 | 239 | } |
240 | 240 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @return int Current page number |
261 | 261 | */ |
262 | 262 | public function get_paged() { |
263 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
263 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @since 1.0 |
271 | 271 | * @return void |
272 | 272 | */ |
273 | - function bulk_actions( $which = '' ) { |
|
273 | + function bulk_actions($which = '') { |
|
274 | 274 | give_log_views(); |
275 | 275 | } |
276 | 276 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | 'meta_query' => $this->get_meta_query(), |
294 | 294 | ); |
295 | 295 | |
296 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
296 | + $logs = $give_logs->get_connected_logs($log_query); |
|
297 | 297 | |
298 | - if ( $logs ) { |
|
299 | - foreach ( $logs as $log ) { |
|
298 | + if ($logs) { |
|
299 | + foreach ($logs as $log) { |
|
300 | 300 | |
301 | 301 | $logs_data[] = array( |
302 | 302 | 'ID' => $log->ID, |
303 | - 'ip' => give_get_meta( $log->ID, '_give_log_request_ip', true ), |
|
303 | + 'ip' => give_get_meta($log->ID, '_give_log_request_ip', true), |
|
304 | 304 | 'date' => $log->post_date, |
305 | 305 | ); |
306 | 306 | } |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | $columns = $this->get_columns(); |
329 | 329 | $hidden = array(); // No hidden columns |
330 | 330 | $sortable = $this->get_sortable_columns(); |
331 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
331 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
332 | 332 | $this->items = $this->get_logs(); |
333 | - $total_items = $give_logs->get_log_count( 0, 'api_request' ); |
|
333 | + $total_items = $give_logs->get_log_count(0, 'api_request'); |
|
334 | 334 | |
335 | - $this->set_pagination_args( array( |
|
335 | + $this->set_pagination_args(array( |
|
336 | 336 | 'total_items' => $total_items, |
337 | 337 | 'per_page' => $this->per_page, |
338 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
338 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
339 | 339 | ) |
340 | 340 | ); |
341 | 341 | } |
@@ -158,20 +158,20 @@ |
||
158 | 158 | |
159 | 159 | $current_user = wp_get_current_user(); |
160 | 160 | |
161 | - // Get notice id. |
|
162 | - $notice_id = sanitize_text_field( $_POST['_give_hide_license_notices_shortly'] ); |
|
161 | + // Get notice id. |
|
162 | + $notice_id = sanitize_text_field( $_POST['_give_hide_license_notices_shortly'] ); |
|
163 | 163 | |
164 | - // Transient key name. |
|
165 | - $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}"; |
|
164 | + // Transient key name. |
|
165 | + $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}"; |
|
166 | 166 | |
167 | - if ( Give_Cache::get( $transient_key, true ) ) { |
|
168 | - return; |
|
169 | - } |
|
167 | + if ( Give_Cache::get( $transient_key, true ) ) { |
|
168 | + return; |
|
169 | + } |
|
170 | 170 | |
171 | - // Hide notice for 24 hours. |
|
172 | - Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
171 | + // Hide notice for 24 hours. |
|
172 | + Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
173 | 173 | |
174 | - die(); |
|
174 | + die(); |
|
175 | 175 | |
176 | 176 | } |
177 | 177 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,53 +24,53 @@ discard block |
||
24 | 24 | function give_hide_subscription_notices() { |
25 | 25 | |
26 | 26 | // Hide subscription notices permanently. |
27 | - if ( ! empty( $_GET['_give_hide_license_notices_permanently'] ) ) { |
|
27 | + if ( ! empty($_GET['_give_hide_license_notices_permanently'])) { |
|
28 | 28 | $current_user = wp_get_current_user(); |
29 | 29 | |
30 | 30 | // check previously disabled notice ids. |
31 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
31 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
32 | 32 | ? $already_dismiss_notices |
33 | 33 | : array(); |
34 | 34 | |
35 | 35 | // Get notice id. |
36 | - $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_permanently'] ); |
|
36 | + $notice_id = sanitize_text_field($_GET['_give_hide_license_notices_permanently']); |
|
37 | 37 | |
38 | - if ( ! in_array( $notice_id, $already_dismiss_notices ) ) { |
|
38 | + if ( ! in_array($notice_id, $already_dismiss_notices)) { |
|
39 | 39 | $already_dismiss_notices[] = $notice_id; |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Store subscription ids. |
43 | - update_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices ); |
|
43 | + update_user_meta($current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices); |
|
44 | 44 | |
45 | 45 | // Redirect user. |
46 | - wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'] ) ); |
|
46 | + wp_safe_redirect(remove_query_arg('_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'])); |
|
47 | 47 | exit(); |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Hide subscription notices shortly. |
51 | - if ( ! empty( $_GET['_give_hide_license_notices_shortly'] ) ) { |
|
51 | + if ( ! empty($_GET['_give_hide_license_notices_shortly'])) { |
|
52 | 52 | $current_user = wp_get_current_user(); |
53 | 53 | |
54 | 54 | // Get notice id. |
55 | - $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_shortly'] ); |
|
55 | + $notice_id = sanitize_text_field($_GET['_give_hide_license_notices_shortly']); |
|
56 | 56 | |
57 | 57 | // Transient key name. |
58 | 58 | $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}"; |
59 | 59 | |
60 | - if ( Give_Cache::get( $transient_key, true ) ) { |
|
60 | + if (Give_Cache::get($transient_key, true)) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Hide notice for 24 hours. |
65 | - Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
65 | + Give_Cache::set($transient_key, true, DAY_IN_SECONDS, true); |
|
66 | 66 | |
67 | 67 | // Redirect user. |
68 | - wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'] ) ); |
|
68 | + wp_safe_redirect(remove_query_arg('_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'])); |
|
69 | 69 | exit(); |
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | -add_action( 'admin_init', 'give_hide_subscription_notices' ); |
|
73 | +add_action('admin_init', 'give_hide_subscription_notices'); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Load wp editor by ajax. |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | * @since 1.8 |
79 | 79 | */ |
80 | 80 | function give_load_wp_editor() { |
81 | - if ( ! isset( $_POST['wp_editor'] ) ) { |
|
81 | + if ( ! isset($_POST['wp_editor'])) { |
|
82 | 82 | die(); |
83 | 83 | } |
84 | 84 | |
85 | - $wp_editor = json_decode( base64_decode( $_POST['wp_editor'] ), true ); |
|
85 | + $wp_editor = json_decode(base64_decode($_POST['wp_editor']), true); |
|
86 | 86 | $wp_editor[2]['textarea_name'] = $_POST['textarea_name']; |
87 | 87 | |
88 | - wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] ); |
|
88 | + wp_editor($wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2]); |
|
89 | 89 | |
90 | 90 | die(); |
91 | 91 | } |
92 | 92 | |
93 | -add_action( 'wp_ajax_give_load_wp_editor', 'give_load_wp_editor' ); |
|
93 | +add_action('wp_ajax_give_load_wp_editor', 'give_load_wp_editor'); |
|
94 | 94 | |
95 | 95 | |
96 | 96 | /** |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | ); |
110 | 110 | |
111 | 111 | // Get current page. |
112 | - $current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : ''; |
|
112 | + $current_page = isset($_GET['page']) ? esc_attr($_GET['page']) : ''; |
|
113 | 113 | |
114 | 114 | // Bailout. |
115 | 115 | if ( |
116 | - empty( $current_page ) |
|
117 | - || empty( $_GET['_wp_http_referer'] ) |
|
118 | - || ! in_array( $current_page, $give_pages ) |
|
116 | + empty($current_page) |
|
117 | + || empty($_GET['_wp_http_referer']) |
|
118 | + || ! in_array($current_page, $give_pages) |
|
119 | 119 | ) { |
120 | 120 | return false; |
121 | 121 | } |
@@ -125,21 +125,21 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @since 1.8 |
127 | 127 | */ |
128 | - $redirect = apply_filters( "give_validate_{$current_page}", true ); |
|
128 | + $redirect = apply_filters("give_validate_{$current_page}", true); |
|
129 | 129 | |
130 | - if ( $redirect ) { |
|
130 | + if ($redirect) { |
|
131 | 131 | // Redirect. |
132 | 132 | wp_redirect( |
133 | 133 | remove_query_arg( |
134 | - array( '_wp_http_referer', '_wpnonce' ), |
|
135 | - wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
134 | + array('_wp_http_referer', '_wpnonce'), |
|
135 | + wp_unslash($_SERVER['REQUEST_URI']) |
|
136 | 136 | ) |
137 | 137 | ); |
138 | 138 | exit; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' ); |
|
142 | +add_action('admin_init', 'give_redirect_to_clean_url_admin_pages'); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Hide License Notice Shortly. |
@@ -152,27 +152,27 @@ discard block |
||
152 | 152 | */ |
153 | 153 | function give_hide_license_notice() { |
154 | 154 | |
155 | - if ( ! isset( $_POST['_give_hide_license_notices_shortly'] ) ) { |
|
155 | + if ( ! isset($_POST['_give_hide_license_notices_shortly'])) { |
|
156 | 156 | die(); |
157 | 157 | } |
158 | 158 | |
159 | 159 | $current_user = wp_get_current_user(); |
160 | 160 | |
161 | 161 | // Get notice id. |
162 | - $notice_id = sanitize_text_field( $_POST['_give_hide_license_notices_shortly'] ); |
|
162 | + $notice_id = sanitize_text_field($_POST['_give_hide_license_notices_shortly']); |
|
163 | 163 | |
164 | 164 | // Transient key name. |
165 | 165 | $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}"; |
166 | 166 | |
167 | - if ( Give_Cache::get( $transient_key, true ) ) { |
|
167 | + if (Give_Cache::get($transient_key, true)) { |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | 171 | // Hide notice for 24 hours. |
172 | - Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
172 | + Give_Cache::set($transient_key, true, DAY_IN_SECONDS, true); |
|
173 | 173 | |
174 | 174 | die(); |
175 | 175 | |
176 | 176 | } |
177 | 177 | |
178 | -add_action( 'wp_ajax_give_hide_license_notice', 'give_hide_license_notice' ); |
|
178 | +add_action('wp_ajax_give_hide_license_notice', 'give_hide_license_notice'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_customers_page() { |
26 | 26 | $default_views = give_customer_views(); |
27 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'customers'; |
|
28 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
29 | - give_render_customer_view( $requested_view, $default_views ); |
|
27 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'customers'; |
|
28 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
29 | + give_render_customer_view($requested_view, $default_views); |
|
30 | 30 | } else { |
31 | 31 | give_customers_list(); |
32 | 32 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $views = array(); |
44 | 44 | |
45 | - return apply_filters( 'give_customer_views', $views ); |
|
45 | + return apply_filters('give_customer_views', $views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $tabs = array(); |
58 | 58 | |
59 | - return apply_filters( 'give_customer_tabs', $tabs ); |
|
59 | + return apply_filters('give_customer_tabs', $tabs); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | function give_customers_list() { |
70 | - include( dirname( __FILE__ ) . '/class-customer-table.php' ); |
|
70 | + include(dirname(__FILE__).'/class-customer-table.php'); |
|
71 | 71 | |
72 | 72 | $customers_table = new Give_Customer_Reports_Table(); |
73 | 73 | $customers_table->prepare_items(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - do_action( 'give_donors_table_top' ); |
|
83 | + do_action('give_donors_table_top'); |
|
84 | 84 | ?> |
85 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
85 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
86 | 86 | <?php |
87 | - $customers_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' ); |
|
87 | + $customers_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors'); |
|
88 | 88 | $customers_table->display(); |
89 | 89 | ?> |
90 | 90 | <input type="hidden" name="post_type" value="give_forms" /> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @since 1.0 |
99 | 99 | */ |
100 | - do_action( 'give_donors_table_bottom' ); |
|
100 | + do_action('give_donors_table_bottom'); |
|
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | <?php |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | -function give_render_customer_view( $view, $callbacks ) { |
|
116 | +function give_render_customer_view($view, $callbacks) { |
|
117 | 117 | |
118 | 118 | $render = true; |
119 | 119 | |
120 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
120 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
121 | 121 | |
122 | - if ( ! current_user_can( $customer_view_role ) ) { |
|
123 | - give_set_error( 'give-no-access', esc_html__( 'You are not permitted to view this data.', 'give' ) ); |
|
122 | + if ( ! current_user_can($customer_view_role)) { |
|
123 | + give_set_error('give-no-access', esc_html__('You are not permitted to view this data.', 'give')); |
|
124 | 124 | $render = false; |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
128 | - give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
127 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
128 | + give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give')); |
|
129 | 129 | $render = false; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $customer_id = (int) $_GET['id']; |
133 | - $customer = new Give_Customer( $customer_id ); |
|
133 | + $customer = new Give_Customer($customer_id); |
|
134 | 134 | |
135 | - if ( empty( $customer->id ) ) { |
|
136 | - give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
135 | + if (empty($customer->id)) { |
|
136 | + give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give')); |
|
137 | 137 | $render = false; |
138 | 138 | } |
139 | 139 | |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | |
143 | 143 | <div class='wrap'> |
144 | 144 | |
145 | - <?php if ( give_get_errors() ) : ?> |
|
145 | + <?php if (give_get_errors()) : ?> |
|
146 | 146 | <div class="error settings-error"> |
147 | - <?php give_print_errors( 0 ); ?> |
|
147 | + <?php give_print_errors(0); ?> |
|
148 | 148 | </div> |
149 | 149 | <?php endif; ?> |
150 | 150 | |
151 | - <h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1> |
|
151 | + <h1 class="screen-reader-text"><?php esc_html_e('Donor', 'give'); ?></h1> |
|
152 | 152 | |
153 | - <?php if ( $customer && $render ) : ?> |
|
153 | + <?php if ($customer && $render) : ?> |
|
154 | 154 | |
155 | 155 | <h2 class="nav-tab-wrapper"> |
156 | 156 | <?php |
157 | - foreach ( $customer_tabs as $key => $tab ) : |
|
157 | + foreach ($customer_tabs as $key => $tab) : |
|
158 | 158 | $active = $key === $view ? true : false; |
159 | 159 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
160 | 160 | printf( |
161 | - '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n", |
|
162 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $customer->id ) ), |
|
163 | - esc_attr( $class ), |
|
164 | - sanitize_html_class( $tab['dashicon'] ), |
|
165 | - esc_html( $tab['title'] ) |
|
161 | + '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
|
162 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$customer->id)), |
|
163 | + esc_attr($class), |
|
164 | + sanitize_html_class($tab['dashicon']), |
|
165 | + esc_html($tab['title']) |
|
166 | 166 | ); |
167 | 167 | endforeach; |
168 | 168 | ?> |
169 | 169 | </h2> |
170 | 170 | |
171 | 171 | <div id="give-customer-card-wrapper"> |
172 | - <?php $callbacks[ $view ]( $customer ) ?> |
|
172 | + <?php $callbacks[$view]($customer) ?> |
|
173 | 173 | </div> |
174 | 174 | |
175 | 175 | <?php endif; ?> |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return void |
191 | 191 | */ |
192 | -function give_customers_view( $customer ) { |
|
192 | +function give_customers_view($customer) { |
|
193 | 193 | |
194 | - $customer_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
194 | + $customer_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Fires in donor profile screen, above the donor card. |
@@ -200,32 +200,32 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param object $customer The customer object being displayed. |
202 | 202 | */ |
203 | - do_action( 'give_donor_card_top', $customer ); |
|
203 | + do_action('give_donor_card_top', $customer); |
|
204 | 204 | ?> |
205 | 205 | |
206 | 206 | <div id="donor-summary" class="info-wrapper customer-section postbox"> |
207 | 207 | |
208 | - <form id="edit-customer-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>"> |
|
208 | + <form id="edit-customer-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>"> |
|
209 | 209 | |
210 | 210 | <div class="customer-info"> |
211 | 211 | |
212 | 212 | <div class="donor-bio-header clearfix"> |
213 | 213 | |
214 | 214 | <div class="avatar-wrap left" id="customer-avatar"> |
215 | - <?php echo get_avatar( $customer->email ); ?> |
|
215 | + <?php echo get_avatar($customer->email); ?> |
|
216 | 216 | </div> |
217 | 217 | |
218 | 218 | <div id="customer-name-wrap" class="left"> |
219 | 219 | <span class="customer-id">#<?php echo $customer->id; ?></span> |
220 | - <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $customer->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span> |
|
220 | + <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($customer->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span> |
|
221 | 221 | <span class="customer-name info-item editable"><span data-key="name"><?php echo $customer->name; ?></span></span> |
222 | 222 | </div> |
223 | 223 | <p class="customer-since info-item"> |
224 | - <?php esc_html_e( 'Donor since', 'give' ); ?> |
|
225 | - <?php echo date_i18n( give_date_format(), strtotime( $customer->date_created ) ) ?> |
|
224 | + <?php esc_html_e('Donor since', 'give'); ?> |
|
225 | + <?php echo date_i18n(give_date_format(), strtotime($customer->date_created)) ?> |
|
226 | 226 | </p> |
227 | - <?php if ( current_user_can( $customer_edit_role ) ) : ?> |
|
228 | - <a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a> |
|
227 | + <?php if (current_user_can($customer_edit_role)) : ?> |
|
228 | + <a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a> |
|
229 | 229 | <?php endif; ?> |
230 | 230 | </div> |
231 | 231 | <!-- /donor-bio-header --> |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | <table class="widefat"> |
236 | 236 | <tbody> |
237 | 237 | <tr class="alternate"> |
238 | - <th scope="col"><label for="tablecell"><?php esc_html_e( 'User:', 'give' ); ?></label></th> |
|
238 | + <th scope="col"><label for="tablecell"><?php esc_html_e('User:', 'give'); ?></label></th> |
|
239 | 239 | <td> |
240 | 240 | <span class="customer-user-id info-item edit-item"> |
241 | 241 | <?php |
@@ -252,37 +252,37 @@ discard block |
||
252 | 252 | 'data' => $data_atts, |
253 | 253 | ); |
254 | 254 | |
255 | - if ( ! empty( $user_id ) ) { |
|
256 | - $userdata = get_userdata( $user_id ); |
|
255 | + if ( ! empty($user_id)) { |
|
256 | + $userdata = get_userdata($user_id); |
|
257 | 257 | $user_args['value'] = $userdata->user_login; |
258 | 258 | } |
259 | 259 | |
260 | - echo Give()->html->ajax_user_search( $user_args ); |
|
260 | + echo Give()->html->ajax_user_search($user_args); |
|
261 | 261 | ?> |
262 | 262 | </span> |
263 | 263 | |
264 | 264 | <span class="customer-user-id info-item editable"> |
265 | - <?php if ( !empty( $userdata ) ) { ?> |
|
266 | - <span data-key="user_id">#<?php echo $customer->user_id . ' - ' . $userdata->display_name; ?></span> |
|
265 | + <?php if ( ! empty($userdata)) { ?> |
|
266 | + <span data-key="user_id">#<?php echo $customer->user_id.' - '.$userdata->display_name; ?></span> |
|
267 | 267 | <?php } else { ?> |
268 | - <span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span> |
|
268 | + <span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span> |
|
269 | 269 | <?php } ?> |
270 | - <?php if ( current_user_can( $customer_edit_role ) && intval( $customer->user_id ) > 0 ) { ?> |
|
271 | - <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this customer record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span> |
|
270 | + <?php if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) { ?> |
|
271 | + <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e('Disconnects the current user ID from this customer record.', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span> |
|
272 | 272 | <?php } ?> |
273 | 273 | </span> |
274 | 274 | </td> |
275 | 275 | </tr> |
276 | - <?php if ( isset( $customer->user_id ) && $customer->user_id > 0 ) : ?> |
|
276 | + <?php if (isset($customer->user_id) && $customer->user_id > 0) : ?> |
|
277 | 277 | |
278 | 278 | <tr> |
279 | - <th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th> |
|
279 | + <th scope="col"><?php esc_html_e('Address:', 'give'); ?></th> |
|
280 | 280 | <td class="row-title"> |
281 | 281 | |
282 | 282 | <div class="customer-address-wrapper"> |
283 | 283 | |
284 | 284 | <?php |
285 | - $address = get_user_meta( $customer->user_id, '_give_user_address', true ); |
|
285 | + $address = get_user_meta($customer->user_id, '_give_user_address', true); |
|
286 | 286 | $defaults = array( |
287 | 287 | 'line1' => '', |
288 | 288 | 'line2' => '', |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | 'zip' => '', |
293 | 293 | ); |
294 | 294 | |
295 | - $address = wp_parse_args( $address, $defaults ); |
|
295 | + $address = wp_parse_args($address, $defaults); |
|
296 | 296 | ?> |
297 | 297 | |
298 | - <?php if ( ! empty( $address ) ) { ?> |
|
298 | + <?php if ( ! empty($address)) { ?> |
|
299 | 299 | <span class="customer-address info-item editable"> |
300 | 300 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
301 | 301 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | </span> |
307 | 307 | <?php } ?> |
308 | 308 | <span class="customer-address info-item edit-item"> |
309 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
309 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
312 | 312 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
313 | 313 | <?php |
314 | 314 | |
315 | 315 | $selected_country = $address['country']; |
316 | 316 | |
317 | 317 | $countries = give_get_country_list(); |
318 | - foreach ( $countries as $country_code => $country ) { |
|
319 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
318 | + foreach ($countries as $country_code => $country) { |
|
319 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
320 | 320 | } |
321 | 321 | ?> |
322 | 322 | </select> |
323 | 323 | <?php |
324 | 324 | $selected_state = give_get_state(); |
325 | - $states = give_get_states( $selected_country ); |
|
325 | + $states = give_get_states($selected_country); |
|
326 | 326 | |
327 | - $selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state; |
|
327 | + $selected_state = isset($address['state']) ? $address['state'] : $selected_state; |
|
328 | 328 | |
329 | - if ( ! empty( $states ) ) { |
|
329 | + if ( ! empty($states)) { |
|
330 | 330 | ?> |
331 | 331 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
332 | 332 | <?php |
333 | - foreach ( $states as $state_code => $state ) { |
|
334 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
333 | + foreach ($states as $state_code => $state) { |
|
334 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
335 | 335 | } |
336 | 336 | ?> |
337 | 337 | </select> |
338 | 338 | <?php |
339 | 339 | } else { |
340 | 340 | ?> |
341 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>" /> |
|
341 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>" /> |
|
342 | 342 | <?php |
343 | 343 | } |
344 | 344 | ?> |
345 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
345 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
346 | 346 | </span> |
347 | 347 | |
348 | 348 | </div> |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | |
359 | 359 | <span id="customer-edit-actions" class="edit-item"> |
360 | 360 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $customer->id; ?>" /> |
361 | - <?php wp_nonce_field( 'edit-customer', '_wpnonce', false, true ); ?> |
|
361 | + <?php wp_nonce_field('edit-customer', '_wpnonce', false, true); ?> |
|
362 | 362 | <input type="hidden" name="give_action" value="edit-customer" /> |
363 | - <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" /> |
|
364 | - <a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
363 | + <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" /> |
|
364 | + <a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
365 | 365 | </span> |
366 | 366 | |
367 | 367 | </form> |
@@ -376,24 +376,24 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param object $customer The customer object being displayed. |
378 | 378 | */ |
379 | - do_action( 'give_donor_before_stats', $customer ); |
|
379 | + do_action('give_donor_before_stats', $customer); |
|
380 | 380 | ?> |
381 | 381 | |
382 | 382 | <div id="customer-stats-wrapper" class="customer-section postbox clear"> |
383 | 383 | <ul> |
384 | 384 | <li> |
385 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $customer->email ) ); ?>"> |
|
385 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($customer->email)); ?>"> |
|
386 | 386 | <span class="dashicons dashicons-heart"></span> |
387 | 387 | <?php |
388 | 388 | // Completed Donations |
389 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give' ), $customer->purchase_count ); |
|
390 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $customer ); |
|
389 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give'), $customer->purchase_count); |
|
390 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $customer); |
|
391 | 391 | ?> |
392 | 392 | </a> |
393 | 393 | </li> |
394 | 394 | <li> |
395 | 395 | <span class="dashicons dashicons-chart-area"></span> |
396 | - <?php echo give_currency_filter( give_format_amount( $customer->purchase_value ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?> |
|
396 | + <?php echo give_currency_filter(give_format_amount($customer->purchase_value)); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?> |
|
397 | 397 | </li> |
398 | 398 | <?php |
399 | 399 | /** |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @param object $customer The customer object being displayed. |
407 | 407 | */ |
408 | - do_action( 'give_donor_stats_list', $customer ); |
|
408 | + do_action('give_donor_stats_list', $customer); |
|
409 | 409 | ?> |
410 | 410 | </ul> |
411 | 411 | </div> |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param object $customer The customer object being displayed. |
420 | 420 | */ |
421 | - do_action( 'give_donor_before_tables_wrapper', $customer ); |
|
421 | + do_action('give_donor_before_tables_wrapper', $customer); |
|
422 | 422 | ?> |
423 | 423 | |
424 | 424 | <div id="customer-tables-wrapper" class="customer-section"> |
@@ -431,46 +431,46 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @param object $customer The customer object being displayed. |
433 | 433 | */ |
434 | - do_action( 'give_donor_before_tables', $customer ); |
|
434 | + do_action('give_donor_before_tables', $customer); |
|
435 | 435 | ?> |
436 | 436 | |
437 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
437 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
438 | 438 | |
439 | 439 | <table class="wp-list-table widefat striped emails"> |
440 | 440 | <thead> |
441 | 441 | <tr> |
442 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
443 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
442 | + <th><?php _e('Email', 'give'); ?></th> |
|
443 | + <th><?php _e('Actions', 'give'); ?></th> |
|
444 | 444 | </tr> |
445 | 445 | </thead> |
446 | 446 | |
447 | 447 | <tbody> |
448 | - <?php if ( ! empty( $customer->emails ) ) { ?> |
|
448 | + <?php if ( ! empty($customer->emails)) { ?> |
|
449 | 449 | |
450 | - <?php foreach ( $customer->emails as $key => $email ) : ?> |
|
450 | + <?php foreach ($customer->emails as $key => $email) : ?> |
|
451 | 451 | <tr data-key="<?php echo $key; ?>"> |
452 | 452 | <td> |
453 | 453 | <?php echo $email; ?> |
454 | - <?php if ( 'primary' === $key ) : ?> |
|
454 | + <?php if ('primary' === $key) : ?> |
|
455 | 455 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
456 | 456 | <?php endif; ?> |
457 | 457 | </td> |
458 | 458 | <td> |
459 | - <?php if ( 'primary' !== $key ) : ?> |
|
459 | + <?php if ('primary' !== $key) : ?> |
|
460 | 460 | <?php |
461 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); |
|
462 | - $promote_url = wp_nonce_url( add_query_arg( array( |
|
463 | - 'email' => rawurlencode( $email ), |
|
461 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); |
|
462 | + $promote_url = wp_nonce_url(add_query_arg(array( |
|
463 | + 'email' => rawurlencode($email), |
|
464 | 464 | 'give_action' => 'set_donor_primary_email', |
465 | - ), $base_url ), 'give-set-donor-primary-email' ); |
|
466 | - $remove_url = wp_nonce_url( add_query_arg( array( |
|
467 | - 'email' => rawurlencode( $email ), |
|
465 | + ), $base_url), 'give-set-donor-primary-email'); |
|
466 | + $remove_url = wp_nonce_url(add_query_arg(array( |
|
467 | + 'email' => rawurlencode($email), |
|
468 | 468 | 'give_action' => 'remove_donor_email', |
469 | - ), $base_url ), 'give-remove-donor-email' ); |
|
469 | + ), $base_url), 'give-remove-donor-email'); |
|
470 | 470 | ?> |
471 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
471 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
472 | 472 | | |
473 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
473 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
474 | 474 | <?php endif; ?> |
475 | 475 | </td> |
476 | 476 | </tr> |
@@ -480,59 +480,59 @@ discard block |
||
480 | 480 | <td colspan="2" class="add-customer-email-td"> |
481 | 481 | <div class="add-customer-email-wrapper"> |
482 | 482 | <input type="hidden" name="customer-id" value="<?php echo $customer->id; ?>" /> |
483 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
484 | - <input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" /> |
|
485 | - <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
486 | - <button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
483 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
484 | + <input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" /> |
|
485 | + <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
486 | + <button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e('Add Email', 'give'); ?></button> |
|
487 | 487 | <span class="spinner"></span> |
488 | 488 | </div> |
489 | 489 | <div class="notice-wrap"></div> |
490 | 490 | </td> |
491 | 491 | </tr> |
492 | 492 | <?php } else { ?> |
493 | - <tr><td colspan="2"><?php _e( 'No Emails Found', 'easy-digital-downloads' ); ?></td></tr> |
|
493 | + <tr><td colspan="2"><?php _e('No Emails Found', 'easy-digital-downloads'); ?></td></tr> |
|
494 | 494 | <?php }// End if(). |
495 | 495 | ?> |
496 | 496 | </tbody> |
497 | 497 | </table> |
498 | 498 | |
499 | - <h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3> |
|
499 | + <h3><?php esc_html_e('Recent Donations', 'give'); ?></h3> |
|
500 | 500 | <?php |
501 | - $payment_ids = explode( ',', $customer->payment_ids ); |
|
502 | - $payments = give_get_payments( array( |
|
501 | + $payment_ids = explode(',', $customer->payment_ids); |
|
502 | + $payments = give_get_payments(array( |
|
503 | 503 | 'post__in' => $payment_ids, |
504 | - ) ); |
|
505 | - $payments = array_slice( $payments, 0, 10 ); |
|
504 | + )); |
|
505 | + $payments = array_slice($payments, 0, 10); |
|
506 | 506 | ?> |
507 | 507 | <table class="wp-list-table widefat striped payments"> |
508 | 508 | <thead> |
509 | 509 | <tr> |
510 | - <th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th> |
|
511 | - <th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th> |
|
512 | - <th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th> |
|
513 | - <th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th> |
|
514 | - <th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
510 | + <th scope="col"><?php esc_html_e('ID', 'give'); ?></th> |
|
511 | + <th scope="col"><?php esc_html_e('Amount', 'give'); ?></th> |
|
512 | + <th scope="col"><?php esc_html_e('Date', 'give'); ?></th> |
|
513 | + <th scope="col"><?php esc_html_e('Status', 'give'); ?></th> |
|
514 | + <th scope="col"><?php esc_html_e('Actions', 'give'); ?></th> |
|
515 | 515 | </tr> |
516 | 516 | </thead> |
517 | 517 | <tbody> |
518 | - <?php if ( ! empty( $payments ) ) { ?> |
|
519 | - <?php foreach ( $payments as $payment ) : ?> |
|
518 | + <?php if ( ! empty($payments)) { ?> |
|
519 | + <?php foreach ($payments as $payment) : ?> |
|
520 | 520 | <tr> |
521 | 521 | <td><?php echo $payment->ID; ?></td> |
522 | - <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
|
523 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
524 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
522 | + <td><?php echo give_payment_amount($payment->ID); ?></td> |
|
523 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
524 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
525 | 525 | <td> |
526 | 526 | <?php |
527 | 527 | printf( |
528 | 528 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
529 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID ), |
|
529 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment->ID), |
|
530 | 530 | sprintf( |
531 | 531 | /* translators: %s: Donation ID */ |
532 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
532 | + esc_attr__('View Donation %s.', 'give'), |
|
533 | 533 | $payment->ID |
534 | 534 | ), |
535 | - esc_html__( 'View Donation', 'give' ) |
|
535 | + esc_html__('View Donation', 'give') |
|
536 | 536 | ); |
537 | 537 | ?> |
538 | 538 | |
@@ -547,47 +547,47 @@ discard block |
||
547 | 547 | * @param object $customer The customer object being displayed. |
548 | 548 | * @param object $payment The payment object being displayed. |
549 | 549 | */ |
550 | - do_action( 'give_donor_recent_purchases_actions', $customer, $payment ); |
|
550 | + do_action('give_donor_recent_purchases_actions', $customer, $payment); |
|
551 | 551 | ?> |
552 | 552 | </td> |
553 | 553 | </tr> |
554 | 554 | <?php endforeach; ?> |
555 | 555 | <?php } else { ?> |
556 | 556 | <tr> |
557 | - <td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td> |
|
557 | + <td colspan="5"><?php esc_html_e('No donations found.', 'give'); ?></td> |
|
558 | 558 | </tr> |
559 | 559 | <?php }// End if(). |
560 | 560 | ?> |
561 | 561 | </tbody> |
562 | 562 | </table> |
563 | 563 | |
564 | - <h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3> |
|
564 | + <h3><?php esc_html_e('Completed Forms', 'give'); ?></h3> |
|
565 | 565 | <?php |
566 | - $donations = give_get_users_completed_donations( $customer->email ); |
|
566 | + $donations = give_get_users_completed_donations($customer->email); |
|
567 | 567 | ?> |
568 | 568 | <table class="wp-list-table widefat striped donations"> |
569 | 569 | <thead> |
570 | 570 | <tr> |
571 | - <th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th> |
|
572 | - <th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
571 | + <th scope="col"><?php esc_html_e('Form', 'give'); ?></th> |
|
572 | + <th scope="col" width="120px"><?php esc_html_e('Actions', 'give'); ?></th> |
|
573 | 573 | </tr> |
574 | 574 | </thead> |
575 | 575 | <tbody> |
576 | - <?php if ( ! empty( $donations ) ) { ?> |
|
577 | - <?php foreach ( $donations as $donation ) : ?> |
|
576 | + <?php if ( ! empty($donations)) { ?> |
|
577 | + <?php foreach ($donations as $donation) : ?> |
|
578 | 578 | <tr> |
579 | 579 | <td><?php echo $donation->post_title; ?></td> |
580 | 580 | <td> |
581 | 581 | <?php |
582 | 582 | printf( |
583 | 583 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
584 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
584 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: form name */ |
587 | - esc_attr__( 'View Form %s.', 'give' ), |
|
587 | + esc_attr__('View Form %s.', 'give'), |
|
588 | 588 | $donation->post_title |
589 | 589 | ), |
590 | - esc_html__( 'View Form', 'give' ) |
|
590 | + esc_html__('View Form', 'give') |
|
591 | 591 | ); |
592 | 592 | ?> |
593 | 593 | </td> |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | <?php endforeach; ?> |
596 | 596 | <?php } else { ?> |
597 | 597 | <tr> |
598 | - <td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td> |
|
598 | + <td colspan="2"><?php esc_html_e('No completed donations found.', 'give'); ?></td> |
|
599 | 599 | </tr> |
600 | 600 | <?php } ?> |
601 | 601 | </tbody> |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | * |
610 | 610 | * @param object $customer The customer object being displayed. |
611 | 611 | */ |
612 | - do_action( 'give_donor_after_tables', $customer ); |
|
612 | + do_action('give_donor_after_tables', $customer); |
|
613 | 613 | ?> |
614 | 614 | |
615 | 615 | </div> |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * |
623 | 623 | * @param object $customer The customer object being displayed. |
624 | 624 | */ |
625 | - do_action( 'give_donor_card_bottom', $customer ); |
|
625 | + do_action('give_donor_card_bottom', $customer); |
|
626 | 626 | |
627 | 627 | } |
628 | 628 | |
@@ -635,30 +635,30 @@ discard block |
||
635 | 635 | * |
636 | 636 | * @return void |
637 | 637 | */ |
638 | -function give_customer_notes_view( $customer ) { |
|
638 | +function give_customer_notes_view($customer) { |
|
639 | 639 | |
640 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
641 | - $paged = absint( $paged ); |
|
640 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
641 | + $paged = absint($paged); |
|
642 | 642 | $note_count = $customer->get_notes_count(); |
643 | - $per_page = apply_filters( 'give_customer_notes_per_page', 20 ); |
|
644 | - $total_pages = ceil( $note_count / $per_page ); |
|
645 | - $customer_notes = $customer->get_notes( $per_page, $paged ); |
|
643 | + $per_page = apply_filters('give_customer_notes_per_page', 20); |
|
644 | + $total_pages = ceil($note_count / $per_page); |
|
645 | + $customer_notes = $customer->get_notes($per_page, $paged); |
|
646 | 646 | ?> |
647 | 647 | |
648 | 648 | <div id="customer-notes-wrapper"> |
649 | 649 | <div class="customer-notes-header"> |
650 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
650 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
651 | 651 | </div> |
652 | - <h3><?php esc_html_e( 'Notes', 'give' ); ?></h3> |
|
652 | + <h3><?php esc_html_e('Notes', 'give'); ?></h3> |
|
653 | 653 | |
654 | - <?php if ( 1 == $paged ) : ?> |
|
654 | + <?php if (1 == $paged) : ?> |
|
655 | 655 | <div style="display: block; margin-bottom: 55px;"> |
656 | - <form id="give-add-customer-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $customer->id ); ?>"> |
|
656 | + <form id="give-add-customer-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$customer->id); ?>"> |
|
657 | 657 | <textarea id="customer-note" name="customer_note" class="customer-note-input" rows="10"></textarea> |
658 | 658 | <br /> |
659 | 659 | <input type="hidden" id="customer-id" name="customer_id" value="<?php echo $customer->id; ?>" /> |
660 | 660 | <input type="hidden" name="give_action" value="add-customer-note" /> |
661 | - <?php wp_nonce_field( 'add-customer-note', 'add_customer_note_nonce', true, true ); ?> |
|
661 | + <?php wp_nonce_field('add-customer-note', 'add_customer_note_nonce', true, true); ?> |
|
662 | 662 | <input id="add-customer-note" class="right button-primary" type="submit" value="Add Note" /> |
663 | 663 | </form> |
664 | 664 | </div> |
@@ -673,26 +673,26 @@ discard block |
||
673 | 673 | 'show_all' => true, |
674 | 674 | ); |
675 | 675 | |
676 | - echo paginate_links( $pagination_args ); |
|
676 | + echo paginate_links($pagination_args); |
|
677 | 677 | ?> |
678 | 678 | |
679 | 679 | <div id="give-customer-notes" class="postbox"> |
680 | - <?php if ( count( $customer_notes ) > 0 ) { ?> |
|
681 | - <?php foreach ( $customer_notes as $key => $note ) : ?> |
|
680 | + <?php if (count($customer_notes) > 0) { ?> |
|
681 | + <?php foreach ($customer_notes as $key => $note) : ?> |
|
682 | 682 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
683 | 683 | <span class="note-content-wrap"> |
684 | - <?php echo stripslashes( $note ); ?> |
|
684 | + <?php echo stripslashes($note); ?> |
|
685 | 685 | </span> |
686 | 686 | </div> |
687 | 687 | <?php endforeach; ?> |
688 | 688 | <?php } else { ?> |
689 | 689 | <div class="give-no-customer-notes"> |
690 | - <?php esc_html_e( 'No donor notes found.', 'give' ); ?> |
|
690 | + <?php esc_html_e('No donor notes found.', 'give'); ?> |
|
691 | 691 | </div> |
692 | 692 | <?php } ?> |
693 | 693 | </div> |
694 | 694 | |
695 | - <?php echo paginate_links( $pagination_args ); ?> |
|
695 | + <?php echo paginate_links($pagination_args); ?> |
|
696 | 696 | |
697 | 697 | </div> |
698 | 698 | |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @return void |
710 | 710 | */ |
711 | -function give_customers_delete_view( $customer ) { |
|
711 | +function give_customers_delete_view($customer) { |
|
712 | 712 | |
713 | - $customer_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
713 | + $customer_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
714 | 714 | |
715 | 715 | /** |
716 | 716 | * Fires in donor delete screen, above the content. |
@@ -719,15 +719,15 @@ discard block |
||
719 | 719 | * |
720 | 720 | * @param object $customer The customer object being displayed. |
721 | 721 | */ |
722 | - do_action( 'give_customer_delete_top', $customer ); |
|
722 | + do_action('give_customer_delete_top', $customer); |
|
723 | 723 | ?> |
724 | 724 | |
725 | 725 | <div class="info-wrapper customer-section"> |
726 | 726 | |
727 | - <form id="delete-customer" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer->id ); ?>"> |
|
727 | + <form id="delete-customer" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer->id); ?>"> |
|
728 | 728 | |
729 | 729 | <div class="customer-notes-header"> |
730 | - <?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span> |
|
730 | + <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span> |
|
731 | 731 | </div> |
732 | 732 | |
733 | 733 | |
@@ -735,20 +735,20 @@ discard block |
||
735 | 735 | |
736 | 736 | <span class="delete-customer-options"> |
737 | 737 | <p> |
738 | - <?php echo Give()->html->checkbox( array( |
|
738 | + <?php echo Give()->html->checkbox(array( |
|
739 | 739 | 'name' => 'give-customer-delete-confirm', |
740 | - ) ); ?> |
|
741 | - <label for="give-customer-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
740 | + )); ?> |
|
741 | + <label for="give-customer-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
742 | 742 | </p> |
743 | 743 | |
744 | 744 | <p> |
745 | - <?php echo Give()->html->checkbox( array( |
|
745 | + <?php echo Give()->html->checkbox(array( |
|
746 | 746 | 'name' => 'give-customer-delete-records', |
747 | 747 | 'options' => array( |
748 | 748 | 'disabled' => true, |
749 | 749 | ), |
750 | - ) ); ?> |
|
751 | - <label for="give-customer-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
750 | + )); ?> |
|
751 | + <label for="give-customer-delete-records"><?php esc_html_e('Delete all associated donations and records?', 'give'); ?></label> |
|
752 | 752 | </p> |
753 | 753 | |
754 | 754 | <?php |
@@ -761,16 +761,16 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @param object $customer The customer object being displayed. |
763 | 763 | */ |
764 | - do_action( 'give_customer_delete_inputs', $customer ); |
|
764 | + do_action('give_customer_delete_inputs', $customer); |
|
765 | 765 | ?> |
766 | 766 | </span> |
767 | 767 | |
768 | 768 | <span id="customer-edit-actions"> |
769 | 769 | <input type="hidden" name="customer_id" value="<?php echo $customer->id; ?>" /> |
770 | - <?php wp_nonce_field( 'delete-customer', '_wpnonce', false, true ); ?> |
|
770 | + <?php wp_nonce_field('delete-customer', '_wpnonce', false, true); ?> |
|
771 | 771 | <input type="hidden" name="give_action" value="delete-customer" /> |
772 | - <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" /> |
|
773 | - <a id="give-delete-customer-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
772 | + <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" /> |
|
773 | + <a id="give-delete-customer-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
774 | 774 | </span> |
775 | 775 | |
776 | 776 | </div> |
@@ -786,5 +786,5 @@ discard block |
||
786 | 786 | * |
787 | 787 | * @param object $customer The customer object being displayed. |
788 | 788 | */ |
789 | - do_action( 'give_customer_delete_bottom', $customer ); |
|
789 | + do_action('give_customer_delete_bottom', $customer); |
|
790 | 790 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | |
50 | 50 | $donor = new Give_Customer( $donor_id ); |
51 | 51 | |
52 | - if ( empty( $donor->id ) ) { |
|
52 | + if ( empty( $donor->id ) ) { |
|
53 | 53 | return false; |
54 | 54 | } |
55 | 55 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array|bool $output Response messages |
25 | 25 | */ |
26 | -function give_edit_donor( $args ) { |
|
26 | +function give_edit_donor($args) { |
|
27 | 27 | |
28 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
28 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
29 | 29 | |
30 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
31 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
30 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
31 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
32 | 32 | 'response' => 403, |
33 | - ) ); |
|
33 | + )); |
|
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $args ) ) { |
|
36 | + if (empty($args)) { |
|
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | $donor_id = (int) $args['customerinfo']['id']; |
42 | 42 | $nonce = $args['_wpnonce']; |
43 | 43 | |
44 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
45 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
44 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
45 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
46 | 46 | 'response' => 400, |
47 | - ) ); |
|
47 | + )); |
|
48 | 48 | } |
49 | 49 | |
50 | - $donor = new Give_Customer( $donor_id ); |
|
50 | + $donor = new Give_Customer($donor_id); |
|
51 | 51 | |
52 | - if ( empty( $donor->id ) ) { |
|
52 | + if (empty($donor->id)) { |
|
53 | 53 | return false; |
54 | 54 | } |
55 | 55 | |
@@ -58,70 +58,70 @@ discard block |
||
58 | 58 | 'user_id' => 0, |
59 | 59 | ); |
60 | 60 | |
61 | - $donor_info = wp_parse_args( $donor_info, $defaults ); |
|
61 | + $donor_info = wp_parse_args($donor_info, $defaults); |
|
62 | 62 | |
63 | - if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) { |
|
63 | + if ((int) $donor_info['user_id'] !== (int) $donor->user_id) { |
|
64 | 64 | |
65 | 65 | // Make sure we don't already have this user attached to a donor. |
66 | - if ( ! empty( $donor_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $donor_info['user_id'] ) ) { |
|
67 | - give_set_error( 'give-invalid-customer-user_id', sprintf( __( 'The User ID #%d is already associated with a different donor.', 'give' ), $donor_info['user_id'] ) ); |
|
66 | + if ( ! empty($donor_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $donor_info['user_id'])) { |
|
67 | + give_set_error('give-invalid-customer-user_id', sprintf(__('The User ID #%d is already associated with a different donor.', 'give'), $donor_info['user_id'])); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Make sure it's actually a user. |
71 | - $user = get_user_by( 'id', $donor_info['user_id'] ); |
|
72 | - if ( ! empty( $donor_info['user_id'] ) && false === $user ) { |
|
73 | - give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ), $donor_info['user_id'] ) ); |
|
71 | + $user = get_user_by('id', $donor_info['user_id']); |
|
72 | + if ( ! empty($donor_info['user_id']) && false === $user) { |
|
73 | + give_set_error('give-invalid-user_id', sprintf(__('The User ID #%d does not exist. Please assign an existing user.', 'give'), $donor_info['user_id'])); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Record this for later. |
78 | 78 | $previous_user_id = $donor->user_id; |
79 | 79 | |
80 | - if ( give_get_errors() ) { |
|
80 | + if (give_get_errors()) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
84 | 84 | // Setup the donor address, if present. |
85 | 85 | $address = array(); |
86 | - if ( intval( $donor_info['user_id'] ) > 0 ) { |
|
86 | + if (intval($donor_info['user_id']) > 0) { |
|
87 | 87 | |
88 | - $current_address = get_user_meta( $donor_info['user_id'], '_give_user_address', true ); |
|
88 | + $current_address = get_user_meta($donor_info['user_id'], '_give_user_address', true); |
|
89 | 89 | |
90 | - if ( false === $current_address ) { |
|
91 | - $address['line1'] = isset( $donor_info['line1'] ) ? $donor_info['line1'] : ''; |
|
92 | - $address['line2'] = isset( $donor_info['line2'] ) ? $donor_info['line2'] : ''; |
|
93 | - $address['city'] = isset( $donor_info['city'] ) ? $donor_info['city'] : ''; |
|
94 | - $address['country'] = isset( $donor_info['country'] ) ? $donor_info['country'] : ''; |
|
95 | - $address['zip'] = isset( $donor_info['zip'] ) ? $donor_info['zip'] : ''; |
|
96 | - $address['state'] = isset( $donor_info['state'] ) ? $donor_info['state'] : ''; |
|
90 | + if (false === $current_address) { |
|
91 | + $address['line1'] = isset($donor_info['line1']) ? $donor_info['line1'] : ''; |
|
92 | + $address['line2'] = isset($donor_info['line2']) ? $donor_info['line2'] : ''; |
|
93 | + $address['city'] = isset($donor_info['city']) ? $donor_info['city'] : ''; |
|
94 | + $address['country'] = isset($donor_info['country']) ? $donor_info['country'] : ''; |
|
95 | + $address['zip'] = isset($donor_info['zip']) ? $donor_info['zip'] : ''; |
|
96 | + $address['state'] = isset($donor_info['state']) ? $donor_info['state'] : ''; |
|
97 | 97 | } else { |
98 | - $current_address = wp_parse_args( $current_address, array( |
|
98 | + $current_address = wp_parse_args($current_address, array( |
|
99 | 99 | 'line1', |
100 | 100 | 'line2', |
101 | 101 | 'city', |
102 | 102 | 'zip', |
103 | 103 | 'state', |
104 | 104 | 'country', |
105 | - ) ); |
|
106 | - $address['line1'] = isset( $donor_info['line1'] ) ? $donor_info['line1'] : $current_address['line1']; |
|
107 | - $address['line2'] = isset( $donor_info['line2'] ) ? $donor_info['line2'] : $current_address['line2']; |
|
108 | - $address['city'] = isset( $donor_info['city'] ) ? $donor_info['city'] : $current_address['city']; |
|
109 | - $address['country'] = isset( $donor_info['country'] ) ? $donor_info['country'] : $current_address['country']; |
|
110 | - $address['zip'] = isset( $donor_info['zip'] ) ? $donor_info['zip'] : $current_address['zip']; |
|
111 | - $address['state'] = isset( $donor_info['state'] ) ? $donor_info['state'] : $current_address['state']; |
|
105 | + )); |
|
106 | + $address['line1'] = isset($donor_info['line1']) ? $donor_info['line1'] : $current_address['line1']; |
|
107 | + $address['line2'] = isset($donor_info['line2']) ? $donor_info['line2'] : $current_address['line2']; |
|
108 | + $address['city'] = isset($donor_info['city']) ? $donor_info['city'] : $current_address['city']; |
|
109 | + $address['country'] = isset($donor_info['country']) ? $donor_info['country'] : $current_address['country']; |
|
110 | + $address['zip'] = isset($donor_info['zip']) ? $donor_info['zip'] : $current_address['zip']; |
|
111 | + $address['state'] = isset($donor_info['state']) ? $donor_info['state'] : $current_address['state']; |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Sanitize the inputs |
116 | 116 | $donor_data = array(); |
117 | - $donor_data['name'] = strip_tags( stripslashes( $donor_info['name'] ) ); |
|
117 | + $donor_data['name'] = strip_tags(stripslashes($donor_info['name'])); |
|
118 | 118 | $donor_data['user_id'] = $donor_info['user_id']; |
119 | 119 | |
120 | - $donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id ); |
|
121 | - $address = apply_filters( 'give_edit_donor_address', $address, $donor_id ); |
|
120 | + $donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id); |
|
121 | + $address = apply_filters('give_edit_donor_address', $address, $donor_id); |
|
122 | 122 | |
123 | - $donor_data = array_map( 'sanitize_text_field', $donor_data ); |
|
124 | - $address = array_map( 'sanitize_text_field', $address ); |
|
123 | + $donor_data = array_map('sanitize_text_field', $donor_data); |
|
124 | + $address = array_map('sanitize_text_field', $address); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Fires before editing a donor. |
@@ -132,27 +132,27 @@ discard block |
||
132 | 132 | * @param array $donor_data The donor data. |
133 | 133 | * @param array $address The donor's address. |
134 | 134 | */ |
135 | - do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address ); |
|
135 | + do_action('give_pre_edit_donor', $donor_id, $donor_data, $address); |
|
136 | 136 | |
137 | 137 | $output = array(); |
138 | 138 | |
139 | - if ( $donor->update( $donor_data ) ) { |
|
139 | + if ($donor->update($donor_data)) { |
|
140 | 140 | |
141 | - if ( ! empty( $donor->user_id ) && $donor->user_id > 0 ) { |
|
142 | - update_user_meta( $donor->user_id, '_give_user_address', $address ); |
|
141 | + if ( ! empty($donor->user_id) && $donor->user_id > 0) { |
|
142 | + update_user_meta($donor->user_id, '_give_user_address', $address); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Update some donation meta if we need to. |
146 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
146 | + $payments_array = explode(',', $donor->payment_ids); |
|
147 | 147 | |
148 | - if ( $donor->user_id != $previous_user_id ) { |
|
149 | - foreach ( $payments_array as $payment_id ) { |
|
150 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $donor->user_id ); |
|
148 | + if ($donor->user_id != $previous_user_id) { |
|
149 | + foreach ($payments_array as $payment_id) { |
|
150 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $donor->user_id); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | 154 | $output['success'] = true; |
155 | - $donor_data = array_merge( $donor_data, $address ); |
|
155 | + $donor_data = array_merge($donor_data, $address); |
|
156 | 156 | $output['customer_info'] = $donor_data; |
157 | 157 | |
158 | 158 | } else { |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param int $donor_id The ID of the donor. |
170 | 170 | * @param array $donor_data The donor data. |
171 | 171 | */ |
172 | - do_action( 'give_post_edit_donor', $donor_id, $donor_data ); |
|
172 | + do_action('give_post_edit_donor', $donor_id, $donor_data); |
|
173 | 173 | |
174 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
175 | - header( 'Content-Type: application/json' ); |
|
176 | - echo json_encode( $output ); |
|
174 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
175 | + header('Content-Type: application/json'); |
|
176 | + echo json_encode($output); |
|
177 | 177 | wp_die(); |
178 | 178 | } |
179 | 179 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | } |
183 | 183 | |
184 | -add_action( 'give_edit-customer', 'give_edit_donor', 10, 1 ); |
|
184 | +add_action('give_edit-customer', 'give_edit_donor', 10, 1); |
|
185 | 185 | |
186 | 186 | /** |
187 | 187 | * Save a customer note being added |
@@ -192,40 +192,40 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return int The Note ID that was saved, or 0 if nothing was saved |
194 | 194 | */ |
195 | -function give_customer_save_note( $args ) { |
|
195 | +function give_customer_save_note($args) { |
|
196 | 196 | |
197 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
197 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
198 | 198 | |
199 | - if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) { |
|
200 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
199 | + if ( ! is_admin() || ! current_user_can($customer_view_role)) { |
|
200 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array( |
|
201 | 201 | 'response' => 403, |
202 | - ) ); |
|
202 | + )); |
|
203 | 203 | } |
204 | 204 | |
205 | - if ( empty( $args ) ) { |
|
205 | + if (empty($args)) { |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
209 | - $customer_note = trim( sanitize_text_field( $args['customer_note'] ) ); |
|
209 | + $customer_note = trim(sanitize_text_field($args['customer_note'])); |
|
210 | 210 | $customer_id = (int) $args['customer_id']; |
211 | 211 | $nonce = $args['add_customer_note_nonce']; |
212 | 212 | |
213 | - if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) { |
|
214 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
213 | + if ( ! wp_verify_nonce($nonce, 'add-customer-note')) { |
|
214 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array( |
|
215 | 215 | 'response' => 400, |
216 | - ) ); |
|
216 | + )); |
|
217 | 217 | } |
218 | 218 | |
219 | - if ( empty( $customer_note ) ) { |
|
220 | - give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) ); |
|
219 | + if (empty($customer_note)) { |
|
220 | + give_set_error('empty-customer-note', esc_html__('A note is required.', 'give')); |
|
221 | 221 | } |
222 | 222 | |
223 | - if ( give_get_errors() ) { |
|
223 | + if (give_get_errors()) { |
|
224 | 224 | return; |
225 | 225 | } |
226 | 226 | |
227 | - $customer = new Give_Customer( $customer_id ); |
|
228 | - $new_note = $customer->add_note( $customer_note ); |
|
227 | + $customer = new Give_Customer($customer_id); |
|
228 | + $new_note = $customer->add_note($customer_note); |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Fires before inserting customer note. |
@@ -235,22 +235,22 @@ discard block |
||
235 | 235 | * @param int $customer_id The ID of the customer. |
236 | 236 | * @param string $new_note Note content. |
237 | 237 | */ |
238 | - do_action( 'give_pre_insert_customer_note', $customer_id, $new_note ); |
|
238 | + do_action('give_pre_insert_customer_note', $customer_id, $new_note); |
|
239 | 239 | |
240 | - if ( ! empty( $new_note ) && ! empty( $customer->id ) ) { |
|
240 | + if ( ! empty($new_note) && ! empty($customer->id)) { |
|
241 | 241 | |
242 | 242 | ob_start(); |
243 | 243 | ?> |
244 | 244 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
245 | 245 | <span class="note-content-wrap"> |
246 | - <?php echo stripslashes( $new_note ); ?> |
|
246 | + <?php echo stripslashes($new_note); ?> |
|
247 | 247 | </span> |
248 | 248 | </div> |
249 | 249 | <?php |
250 | 250 | $output = ob_get_contents(); |
251 | 251 | ob_end_clean(); |
252 | 252 | |
253 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
253 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
254 | 254 | echo $output; |
255 | 255 | exit; |
256 | 256 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | |
264 | 264 | } |
265 | 265 | |
266 | -add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 ); |
|
266 | +add_action('give_add-customer-note', 'give_customer_save_note', 10, 1); |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Delete a customer |
@@ -274,41 +274,41 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return int Whether it was a successful deletion |
276 | 276 | */ |
277 | -function give_customer_delete( $args ) { |
|
277 | +function give_customer_delete($args) { |
|
278 | 278 | |
279 | - $customer_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
279 | + $customer_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
280 | 280 | |
281 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
282 | - wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
281 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
282 | + wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array( |
|
283 | 283 | 'response' => 403, |
284 | - ) ); |
|
284 | + )); |
|
285 | 285 | } |
286 | 286 | |
287 | - if ( empty( $args ) ) { |
|
287 | + if (empty($args)) { |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
291 | 291 | $customer_id = (int) $args['customer_id']; |
292 | - $confirm = ! empty( $args['give-customer-delete-confirm'] ) ? true : false; |
|
293 | - $remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false; |
|
292 | + $confirm = ! empty($args['give-customer-delete-confirm']) ? true : false; |
|
293 | + $remove_data = ! empty($args['give-customer-delete-records']) ? true : false; |
|
294 | 294 | $nonce = $args['_wpnonce']; |
295 | 295 | |
296 | - if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) { |
|
297 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
296 | + if ( ! wp_verify_nonce($nonce, 'delete-customer')) { |
|
297 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array( |
|
298 | 298 | 'response' => 400, |
299 | - ) ); |
|
299 | + )); |
|
300 | 300 | } |
301 | 301 | |
302 | - if ( ! $confirm ) { |
|
303 | - give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
302 | + if ( ! $confirm) { |
|
303 | + give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give')); |
|
304 | 304 | } |
305 | 305 | |
306 | - if ( give_get_errors() ) { |
|
307 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) ); |
|
306 | + if (give_get_errors()) { |
|
307 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id)); |
|
308 | 308 | exit; |
309 | 309 | } |
310 | 310 | |
311 | - $customer = new Give_Customer( $customer_id ); |
|
311 | + $customer = new Give_Customer($customer_id); |
|
312 | 312 | |
313 | 313 | /** |
314 | 314 | * Fires before deleting customer. |
@@ -319,50 +319,50 @@ discard block |
||
319 | 319 | * @param bool $confirm Delete confirmation. |
320 | 320 | * @param bool $remove_data Records delete confirmation. |
321 | 321 | */ |
322 | - do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data ); |
|
322 | + do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data); |
|
323 | 323 | |
324 | - if ( $customer->id > 0 ) { |
|
324 | + if ($customer->id > 0) { |
|
325 | 325 | |
326 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
327 | - $success = Give()->customers->delete( $customer->id ); |
|
326 | + $payments_array = explode(',', $customer->payment_ids); |
|
327 | + $success = Give()->customers->delete($customer->id); |
|
328 | 328 | |
329 | - if ( $success ) { |
|
329 | + if ($success) { |
|
330 | 330 | |
331 | - if ( $remove_data ) { |
|
331 | + if ($remove_data) { |
|
332 | 332 | |
333 | 333 | // Remove all donations, logs, etc |
334 | - foreach ( $payments_array as $payment_id ) { |
|
335 | - give_delete_purchase( $payment_id ); |
|
334 | + foreach ($payments_array as $payment_id) { |
|
335 | + give_delete_purchase($payment_id); |
|
336 | 336 | } |
337 | 337 | } else { |
338 | 338 | |
339 | 339 | // Just set the donations to customer_id of 0 |
340 | - foreach ( $payments_array as $payment_id ) { |
|
341 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
340 | + foreach ($payments_array as $payment_id) { |
|
341 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' ); |
|
345 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted'); |
|
346 | 346 | |
347 | 347 | } else { |
348 | 348 | |
349 | - give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) ); |
|
350 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id ); |
|
349 | + give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give')); |
|
350 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id); |
|
351 | 351 | |
352 | 352 | } |
353 | 353 | } else { |
354 | 354 | |
355 | - give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
356 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
355 | + give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give')); |
|
356 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
357 | 357 | |
358 | 358 | } |
359 | 359 | |
360 | - wp_redirect( $redirect ); |
|
360 | + wp_redirect($redirect); |
|
361 | 361 | exit; |
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | -add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 ); |
|
365 | +add_action('give_delete-customer', 'give_customer_delete', 10, 1); |
|
366 | 366 | |
367 | 367 | /** |
368 | 368 | * Disconnect a user ID from a donor |
@@ -373,32 +373,32 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return bool|array If the disconnect was successful. |
375 | 375 | */ |
376 | -function give_disconnect_donor_user_id( $args ) { |
|
376 | +function give_disconnect_donor_user_id($args) { |
|
377 | 377 | |
378 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
378 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
379 | 379 | |
380 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
381 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
380 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
381 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
382 | 382 | 'response' => 403, |
383 | - ) ); |
|
383 | + )); |
|
384 | 384 | } |
385 | 385 | |
386 | - if ( empty( $args ) ) { |
|
386 | + if (empty($args)) { |
|
387 | 387 | return false; |
388 | 388 | } |
389 | 389 | |
390 | 390 | $donor_id = (int) $args['customer_id']; |
391 | 391 | |
392 | - $nonce = $args['_wpnonce']; |
|
392 | + $nonce = $args['_wpnonce']; |
|
393 | 393 | |
394 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
395 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
394 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
395 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
396 | 396 | 'response' => 400, |
397 | - ) ); |
|
397 | + )); |
|
398 | 398 | } |
399 | 399 | |
400 | - $donor = new Give_Customer( $donor_id ); |
|
401 | - if ( empty( $donor->id ) ) { |
|
400 | + $donor = new Give_Customer($donor_id); |
|
401 | + if (empty($donor->id)) { |
|
402 | 402 | return false; |
403 | 403 | } |
404 | 404 | |
@@ -412,18 +412,18 @@ discard block |
||
412 | 412 | * @param int $donor_id The ID of the donor. |
413 | 413 | * @param int $user_id The ID of the user. |
414 | 414 | */ |
415 | - do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id ); |
|
415 | + do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id); |
|
416 | 416 | |
417 | - $output = array(); |
|
417 | + $output = array(); |
|
418 | 418 | $donor_args = array( |
419 | 419 | 'user_id' => 0, |
420 | 420 | ); |
421 | 421 | |
422 | - if ( $donor->update( $donor_args ) ) { |
|
422 | + if ($donor->update($donor_args)) { |
|
423 | 423 | global $wpdb; |
424 | 424 | |
425 | - if ( ! empty( $donor->payment_ids ) ) { |
|
426 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )" ); |
|
425 | + if ( ! empty($donor->payment_ids)) { |
|
426 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )"); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | $output['success'] = true; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } else { |
432 | 432 | |
433 | 433 | $output['success'] = false; |
434 | - give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) ); |
|
434 | + give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give')); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -441,11 +441,11 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @param int $donor_id The ID of the donor. |
443 | 443 | */ |
444 | - do_action( 'give_post_donor_disconnect_user_id', $donor_id ); |
|
444 | + do_action('give_post_donor_disconnect_user_id', $donor_id); |
|
445 | 445 | |
446 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
447 | - header( 'Content-Type: application/json' ); |
|
448 | - echo json_encode( $output ); |
|
446 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
447 | + header('Content-Type: application/json'); |
|
448 | + echo json_encode($output); |
|
449 | 449 | wp_die(); |
450 | 450 | } |
451 | 451 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | |
454 | 454 | } |
455 | 455 | |
456 | -add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 ); |
|
456 | +add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1); |
|
457 | 457 | |
458 | 458 | /** |
459 | 459 | * Add an email address to the donor from within the admin and log a donor note |
@@ -464,82 +464,82 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string) |
466 | 466 | */ |
467 | -function give_add_donor_email( $args ) { |
|
468 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
467 | +function give_add_donor_email($args) { |
|
468 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
469 | 469 | |
470 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
471 | - wp_die( __( 'You do not have permission to edit this donor.', 'edit' ) ); |
|
470 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
471 | + wp_die(__('You do not have permission to edit this donor.', 'edit')); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | $output = array(); |
475 | - if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) { |
|
475 | + if (empty($args) || empty($args['email']) || empty($args['customer_id'])) { |
|
476 | 476 | $output['success'] = false; |
477 | - if ( empty( $args['email'] ) ) { |
|
478 | - $output['message'] = __( 'Email address is required.', 'give' ); |
|
479 | - } elseif ( empty( $args['customer_id'] ) ) { |
|
480 | - $output['message'] = __( 'Donor ID is required.', 'give' ); |
|
477 | + if (empty($args['email'])) { |
|
478 | + $output['message'] = __('Email address is required.', 'give'); |
|
479 | + } elseif (empty($args['customer_id'])) { |
|
480 | + $output['message'] = __('Donor ID is required.', 'give'); |
|
481 | 481 | } else { |
482 | - $output['message'] = __( 'An error has occurred. Please try again.', 'give' ); |
|
482 | + $output['message'] = __('An error has occurred. Please try again.', 'give'); |
|
483 | 483 | } |
484 | - } elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) { |
|
484 | + } elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) { |
|
485 | 485 | $output = array( |
486 | 486 | 'success' => false, |
487 | - 'message' => esc_html__( 'Nonce verification failed.', 'give' ), |
|
487 | + 'message' => esc_html__('Nonce verification failed.', 'give'), |
|
488 | 488 | ); |
489 | - } elseif ( ! is_email( $args['email'] ) ) { |
|
489 | + } elseif ( ! is_email($args['email'])) { |
|
490 | 490 | $output = array( |
491 | 491 | 'success' => false, |
492 | - 'message' => esc_html__( 'Invalid email.', 'give' ), |
|
492 | + 'message' => esc_html__('Invalid email.', 'give'), |
|
493 | 493 | ); |
494 | 494 | } else { |
495 | - $email = sanitize_email( $args['email'] ); |
|
495 | + $email = sanitize_email($args['email']); |
|
496 | 496 | $customer_id = (int) $args['customer_id']; |
497 | 497 | $primary = 'true' === $args['primary'] ? true : false; |
498 | - $customer = new Give_Customer( $customer_id ); |
|
499 | - if ( false === $customer->add_email( $email, $primary ) ) { |
|
500 | - if ( in_array( $email, $customer->emails ) ) { |
|
498 | + $customer = new Give_Customer($customer_id); |
|
499 | + if (false === $customer->add_email($email, $primary)) { |
|
500 | + if (in_array($email, $customer->emails)) { |
|
501 | 501 | $output = array( |
502 | 502 | 'success' => false, |
503 | - 'message' => __( 'Email already associated with this donor.', 'give' ), |
|
503 | + 'message' => __('Email already associated with this donor.', 'give'), |
|
504 | 504 | ); |
505 | 505 | } else { |
506 | 506 | $output = array( |
507 | 507 | 'success' => false, |
508 | - 'message' => __( 'Email address is already associated with another donor.', 'give' ), |
|
508 | + 'message' => __('Email address is already associated with another donor.', 'give'), |
|
509 | 509 | ); |
510 | 510 | } |
511 | 511 | } else { |
512 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id . '&give-message=email-added' ); |
|
512 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id.'&give-message=email-added'); |
|
513 | 513 | $output = array( |
514 | 514 | 'success' => true, |
515 | - 'message' => __( 'Email successfully added to donor.', 'give' ), |
|
515 | + 'message' => __('Email successfully added to donor.', 'give'), |
|
516 | 516 | 'redirect' => $redirect, |
517 | 517 | ); |
518 | 518 | |
519 | 519 | $user = wp_get_current_user(); |
520 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
521 | - $customer_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login ); |
|
522 | - $customer->add_note( $customer_note ); |
|
520 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
521 | + $customer_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login); |
|
522 | + $customer->add_note($customer_note); |
|
523 | 523 | |
524 | - if ( $primary ) { |
|
525 | - $customer_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login ); |
|
526 | - $customer->add_note( $customer_note ); |
|
524 | + if ($primary) { |
|
525 | + $customer_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login); |
|
526 | + $customer->add_note($customer_note); |
|
527 | 527 | } |
528 | 528 | } |
529 | 529 | }// End if(). |
530 | 530 | |
531 | - do_action( 'give_post_add_customer_email', $customer_id, $args ); |
|
531 | + do_action('give_post_add_customer_email', $customer_id, $args); |
|
532 | 532 | |
533 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
534 | - header( 'Content-Type: application/json' ); |
|
535 | - echo json_encode( $output ); |
|
533 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
534 | + header('Content-Type: application/json'); |
|
535 | + echo json_encode($output); |
|
536 | 536 | wp_die(); |
537 | 537 | } |
538 | 538 | |
539 | 539 | return $output; |
540 | 540 | } |
541 | 541 | |
542 | -add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 ); |
|
542 | +add_action('give_add_donor_email', 'give_add_donor_email', 10, 1); |
|
543 | 543 | |
544 | 544 | |
545 | 545 | /** |
@@ -550,39 +550,39 @@ discard block |
||
550 | 550 | * @return bool|null |
551 | 551 | */ |
552 | 552 | function give_remove_donor_email() { |
553 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
553 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
554 | 554 | return false; |
555 | 555 | } |
556 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
556 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
557 | 557 | return false; |
558 | 558 | } |
559 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
559 | + if (empty($_GET['_wpnonce'])) { |
|
560 | 560 | return false; |
561 | 561 | } |
562 | 562 | |
563 | 563 | $nonce = $_GET['_wpnonce']; |
564 | - if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) { |
|
565 | - wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
564 | + if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) { |
|
565 | + wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array( |
|
566 | 566 | 'response' => 403, |
567 | - ) ); |
|
567 | + )); |
|
568 | 568 | } |
569 | 569 | |
570 | - $customer = new Give_Customer( $_GET['id'] ); |
|
571 | - if ( $customer->remove_email( $_GET['email'] ) ) { |
|
572 | - $url = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) ); |
|
570 | + $customer = new Give_Customer($_GET['id']); |
|
571 | + if ($customer->remove_email($_GET['email'])) { |
|
572 | + $url = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id)); |
|
573 | 573 | $user = wp_get_current_user(); |
574 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
575 | - $customer_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
576 | - $customer->add_note( $customer_note ); |
|
574 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
575 | + $customer_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login); |
|
576 | + $customer->add_note($customer_note); |
|
577 | 577 | } else { |
578 | - $url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) ); |
|
578 | + $url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id)); |
|
579 | 579 | } |
580 | 580 | |
581 | - wp_safe_redirect( $url ); |
|
581 | + wp_safe_redirect($url); |
|
582 | 582 | exit; |
583 | 583 | } |
584 | 584 | |
585 | -add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 ); |
|
585 | +add_action('give_remove_donor_email', 'give_remove_donor_email', 10); |
|
586 | 586 | |
587 | 587 | |
588 | 588 | /** |
@@ -593,41 +593,41 @@ discard block |
||
593 | 593 | * @return bool|null |
594 | 594 | */ |
595 | 595 | function give_set_donor_primary_email() { |
596 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
596 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
597 | 597 | return false; |
598 | 598 | } |
599 | 599 | |
600 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
600 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
601 | 601 | return false; |
602 | 602 | } |
603 | 603 | |
604 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
604 | + if (empty($_GET['_wpnonce'])) { |
|
605 | 605 | return false; |
606 | 606 | } |
607 | 607 | |
608 | 608 | $nonce = $_GET['_wpnonce']; |
609 | 609 | |
610 | - if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) { |
|
611 | - wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
610 | + if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) { |
|
611 | + wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array( |
|
612 | 612 | 'response' => 403, |
613 | - ) ); |
|
613 | + )); |
|
614 | 614 | } |
615 | 615 | |
616 | - $donor = new Give_Customer( $_GET['id'] ); |
|
616 | + $donor = new Give_Customer($_GET['id']); |
|
617 | 617 | |
618 | - if ( $donor->set_primary_email( $_GET['email'] ) ) { |
|
619 | - $url = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
618 | + if ($donor->set_primary_email($_GET['email'])) { |
|
619 | + $url = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
620 | 620 | $user = wp_get_current_user(); |
621 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
622 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
621 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
622 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login); |
|
623 | 623 | |
624 | - $donor->add_note( $donor_note ); |
|
624 | + $donor->add_note($donor_note); |
|
625 | 625 | } else { |
626 | - $url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
626 | + $url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
627 | 627 | } |
628 | 628 | |
629 | - wp_safe_redirect( $url ); |
|
629 | + wp_safe_redirect($url); |
|
630 | 630 | exit; |
631 | 631 | } |
632 | 632 | |
633 | -add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 ); |
|
633 | +add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10); |