PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.24.0
GiveWP – Donation Plugin and Fundraising Platform v2.24.0
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / donors / donors.php
give / includes / admin / donors Last commit date
class-donor-table.php 4 years ago donor-actions.php 4 years ago donor-functions.php 6 years ago donors.php 4 years ago
donors.php
1185 lines
1 <?php
2 /**
3 * Donors.
4 *
5 * @package Give
6 * @subpackage Admin/Donors
7 * @copyright Copyright (c) 2016, GiveWP
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17
18 /**
19 * Get formatted address
20 *
21 * @since 2.0
22 *
23 * @param array $address
24 * @param array $address_args
25 *
26 * @return string
27 */
28 function __give_get_format_address( $address, $address_args = array() ) {
29 $address_html = '';
30 $address_args = wp_parse_args(
31 $address_args,
32 array(
33 'type' => '',
34 'id' => null,
35 'index' => null,
36 'default_address' => false,
37 )
38 );
39
40 $address_id = $address_args['type'];
41
42 // Bailout.
43 if ( empty( $address ) || ! is_array( $address ) ) {
44 return $address_html;
45 }
46
47 // Address html.
48 $address_html = '';
49 $address_html .= sprintf(
50 '<span data-address-type="line1">%1$s</span>%2$s',
51 $address['line1'],
52 ( ! empty( $address['line2'] ) ? '<br>' : '' )
53 );
54 $address_html .= sprintf(
55 '<span data-address-type="line2">%1$s</span>%2$s',
56 $address['line2'],
57 ( ! empty( $address['city'] ) ? '<br>' : '' )
58 );
59 $address_html .= sprintf(
60 '<span data-address-type="city">%1$s</span><span data-address-type="state">%2$s</span><span data-address-type="zip">%3$s</span>%4$s',
61 $address['city'],
62 ( ! empty( $address['state'] ) ? ", {$address['state']}" : '' ),
63 ( ! empty( $address['zip'] ) ? " {$address['zip']}" : '' ),
64 ( ! empty( $address['country'] ) ? '<br>' : '' )
65 );
66 $address_html .= sprintf(
67 '<span data-address-type="country">%s</span><br>',
68 $address['country']
69 );
70
71 // Address action.
72 $address_html .= sprintf(
73 '<br><a href="#" class="js-edit">%1$s</a> | <a href="#" class="js-remove">%2$s</a>',
74 __( 'Edit', 'give' ),
75 __( 'Remove', 'give' )
76 );
77
78 /**
79 * Filter the address label
80 *
81 * @since 2.0
82 */
83 $address_label = apply_filters( "give_donor_{$address_args['type']}_address_label", ucfirst( $address_args['type'] ), $address_args );
84
85 // Set unique id and index for multi type address.
86 if ( isset( $address_args['index'] ) ) {
87 $address_label = "{$address_label} #{$address_args['index']}";
88 }
89
90 if ( isset( $address_args['id'] ) ) {
91 $address_id = "{$address_id}_{$address_args['id']}";
92 }
93
94 // Add address wrapper.
95 $address_html = sprintf(
96 '<div class="give-grid-col-4"><div data-address-id="%s" class="address"><span class="alignright address-number-label">%s</span>%s</div></div>',
97 $address_id,
98 $address_label,
99 $address_html
100 );
101
102 return $address_html;
103 }
104
105 /**
106 * Donors Page.
107 *
108 * Renders the donors page contents.
109 *
110 * @since 1.0
111 * @return void
112 */
113 function give_donors_page() {
114 $default_views = give_donor_views();
115 $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors';
116 if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) {
117 give_render_donor_view( $requested_view, $default_views );
118 }
119 else {
120 $userId = get_current_user_id();
121 $showLegacy = get_user_meta($userId, '_give_donors_archive_show_legacy', true);
122 if ($showLegacy == 1)
123 {
124 give_donors_list();
125 }
126 }
127 }
128
129 /**
130 * Register the views for donor management.
131 *
132 * @since 1.0
133 * @return array Array of views and their callbacks.
134 */
135 function give_donor_views() {
136
137 $views = array();
138
139 return apply_filters( 'give_donor_views', $views );
140
141 }
142
143 /**
144 * Register the tabs for donor management.
145 *
146 * @since 1.0
147 * @return array Array of tabs for the donor.
148 */
149 function give_donor_tabs() {
150
151 $tabs = array();
152
153 return apply_filters( 'give_donor_tabs', $tabs );
154
155 }
156
157 /**
158 * List table of donors.
159 *
160 * @since 1.0
161 * @return void
162 */
163 function give_donors_list() {
164
165 include GIVE_PLUGIN_DIR . 'includes/admin/donors/class-donor-table.php';
166
167 $donors_table = new Give_Donor_List_Table();
168 $donors_table->prepare_items();
169 ?>
170 <div class="wrap">
171 <h1 class="wp-heading-inline"><?php echo get_admin_page_title(); ?></h1>
172 <?php
173 /**
174 * Fires in donors screen, above the table.
175 *
176 * @since 1.0
177 */
178 do_action( 'give_donors_table_top' );
179 ?>
180
181 <hr class="wp-header-end">
182 <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>">
183 <?php
184 $donors_table->advanced_filters();
185 $donors_table->display();
186 ?>
187 <input type="hidden" name="post_type" value="give_forms"/>
188 <input type="hidden" name="page" value="give-donors"/>
189 <input type="hidden" name="view" value="donors"/>
190 </form>
191 <?php
192 /**
193 * Fires in donors screen, below the table.
194 *
195 * @since 1.0
196 */
197 do_action( 'give_donors_table_bottom' );
198 ?>
199 </div>
200 <?php
201 }
202
203 /**
204 * Renders the donor view wrapper.
205 *
206 * @since 1.0
207 *
208 * @param string $view The View being requested.
209 * @param array $callbacks The Registered views and their callback functions.
210 *
211 * @return void
212 */
213 function give_render_donor_view( $view, $callbacks ) {
214
215 $render = true;
216
217 $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
218
219 if ( ! current_user_can( $donor_view_role ) ) {
220 give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) );
221 $render = false;
222 }
223
224 if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
225 give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) );
226 $render = false;
227 }
228
229 $donor_id = (int) $_GET['id'];
230 $reconnect_user_id = ! empty( $_GET['user_id'] ) ? (int) $_GET['user_id'] : '';
231 $donor = new Give_Donor( $donor_id );
232
233 // Reconnect User with Donor profile.
234 if ( $reconnect_user_id ) {
235 give_connect_user_donor_profile( $donor, array( 'user_id' => $reconnect_user_id ), array() );
236 }
237
238 if ( empty( $donor->id ) ) {
239 give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) );
240 $render = false;
241 }
242
243 ?>
244
245 <div class='wrap'>
246
247 <h1 class="wp-heading-inline">
248 <?php
249 printf(
250 /* translators: %s: donor first name */
251 __( 'Edit Donor: %1$s %2$s', 'give' ),
252 $donor->get_first_name(),
253 $donor->get_last_name()
254 );
255 ?>
256 </h1>
257
258 <hr class="wp-header-end">
259
260 <?php if ( give_get_errors() ) : ?>
261 <div class="error settings-error">
262 <?php Give()->notices->render_frontend_notices( 0 ); ?>
263 </div>
264 <?php endif; ?>
265
266 <?php if ( $donor && $render ) : ?>
267
268 <div class="nav-tab-wrapper give-nav-tab-wrapper">
269 <?php
270
271 $donor_tabs = give_donor_tabs();
272
273 foreach ( $donor_tabs as $key => $tab ) :
274 $active = $key === $view ? true : false;
275 $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab';
276 printf(
277 '<a href="%1$s" class="%2$s">%3$s</a>' . "\n",
278 esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ),
279 esc_attr( $class ),
280 esc_html( $tab['title'] )
281 );
282 endforeach;
283 ?>
284 </div>
285
286 <div id="give-donor-card-wrapper">
287 <?php $callbacks[ $view ]( $donor ); ?>
288 </div>
289
290 <?php endif; ?>
291
292 </div>
293 <?php
294
295 }
296
297
298 /**
299 * View a donor
300 *
301 * @since 1.0
302 *
303 * @param Give_Donor $donor The Donor object being displayed.
304 *
305 * @return void
306 */
307 function give_donor_view( $donor ) {
308
309 $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
310
311 /**
312 * Fires in donor profile screen, above the donor card.
313 *
314 * @since 1.0
315 *
316 * @param object $donor The donor object being displayed.
317 */
318 do_action( 'give_donor_card_top', $donor );
319
320 // Set Read only to the fields which needs to be locked.
321 $read_only = '';
322 if ( $donor->user_id ) {
323 $read_only = 'readonly="readonly"';
324 }
325
326 // List of title prefixes.
327 $title_prefixes = give_get_name_title_prefixes();
328
329 // Prepend title prefix to name if it is set.
330 $title_prefix = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true );
331 $donor_name_without_prefix = $donor->name;
332 $donor->name = give_get_donor_name_with_title_prefixes( $title_prefix, $donor->name );
333 ?>
334 <div id="donor-summary" class="info-wrapper donor-section postbox">
335 <form id="edit-donor-info" method="post"
336 action="<?php echo esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); ?>">
337 <div class="donor-info">
338 <div class="donor-bio-header clearfix">
339 <div class="avatar-wrap left" id="donor-avatar">
340 <?php
341
342 // Check whether a Gravatar exists for a donor or not.
343 $validate_gravatar_image = give_validate_gravatar( $donor->email );
344
345 // Get donor's initials for non-gravatars
346 $donor_name_array = explode( ' ', $donor_name_without_prefix );
347 $donor_name_args['firstname'] = ! empty( $donor_name_array[0] ) ? $donor_name_array[0] : '';
348 $donor_name_args['lastname'] = ! empty( $donor_name_array[1] ) ? $donor_name_array[1] : '';
349 $donor_name_initial = give_get_name_initial( $donor_name_args );
350
351 // Gravatars image for donor
352 if ( $validate_gravatar_image ) {
353 $donor_gravatar_image = get_avatar( $donor->email );
354 } else {
355 $donor_gravatar_image = '<div class="give-donor-admin-avatar">' . $donor_name_initial . '</div>';
356 }
357
358 echo $donor_gravatar_image;
359 ?>
360 </div>
361 <div id="donor-name-wrap" class="left">
362 <span class="donor-name info-item edit-item">
363 <select name="donor_info[title]">
364 <option disabled value="0"><?php esc_html_e( 'Title', 'give' ); ?></option>
365 <option value="">&nbsp;</option>
366 <?php
367 if ( is_array( $title_prefixes ) && count( $title_prefixes ) > 0 ) {
368 foreach ( $title_prefixes as $title ) {
369 echo sprintf(
370 '<option %1$s value="%2$s">%2$s</option>',
371 selected( $title_prefix, $title, false ),
372 esc_html( $title )
373 );
374 }
375 }
376 ?>
377 </select>
378 <input <?php echo $read_only; ?> size="15" data-key="first_name"
379 name="donor_info[first_name]" type="text"
380 value="<?php echo esc_html( $donor->get_first_name() ); ?>"
381 placeholder="<?php esc_html_e( 'First Name', 'give' ); ?>"/>
382 <?php if ( $donor->user_id ) : ?>
383 <a href="#" class="give-lock-block">
384 <i class="give-icon give-icon-locked"></i>
385 </a>
386 <?php endif; ?>
387 <input <?php echo $read_only; ?> size="15" data-key="last_name"
388 name="donor_info[last_name]" type="text"
389 value="<?php echo esc_html( $donor->get_last_name() ); ?>"
390 placeholder="<?php esc_html_e( 'Last Name', 'give' ); ?>"/>
391 <?php if ( $donor->user_id ) : ?>
392 <a href="#" class="give-lock-block">
393 <i class="give-icon give-icon-locked"></i>
394 </a>
395 <?php endif; ?>
396 </span>
397 <span class="donor-name info-item editable">
398 <span data-key="name"><?php echo esc_html( $donor->name ); ?></span>
399 </span>
400 </div>
401 <p class="donor-since info-item">
402 <?php esc_html_e( 'Donor since', 'give' ); ?>
403 <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ); ?>
404 </p>
405 <?php if ( current_user_can( $donor_edit_role ) ) : ?>
406 <a href="#" id="edit-donor" class="button info-item editable donor-edit-link">
407 <?php esc_html_e( 'Edit Donor', 'give' ); ?>
408 </a>
409 <?php endif; ?>
410 </div>
411 <!-- /donor-bio-header -->
412
413 <div class="donor-main-wrapper">
414
415 <table class="widefat striped">
416 <tbody>
417 <tr>
418 <th scope="col"><label for="tablecell"><?php esc_html_e( 'Donor ID:', 'give' ); ?></label>
419 </th>
420 <td><?php echo intval( $donor->id ); ?></td>
421 </tr>
422 <tr>
423 <th scope="col"><label for="tablecell"><?php esc_html_e( 'User ID:', 'give' ); ?></label>
424 </th>
425 <td>
426 <span class="donor-user-id info-item edit-item">
427 <?php
428
429 $user_id = $donor->user_id > 0 ? $donor->user_id : '';
430
431 $data_atts = array(
432 'key' => 'user_login',
433 'search-type' => 'user',
434 );
435 $user_args = array(
436 'name' => 'donor_info[user_id]',
437 'class' => 'give-user-dropdown',
438 'data' => $data_atts,
439 );
440
441 if ( ! empty( $user_id ) ) {
442 $userdata = get_userdata( $user_id );
443 $user_args['selected'] = $user_id;
444 }
445
446 echo Give()->html->ajax_user_search( $user_args );
447 ?>
448 </span>
449
450 <span class="donor-user-id info-item editable">
451 <?php if ( ! empty( $userdata ) ) : ?>
452 <span
453 data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span>
454 <?php else : ?>
455 <span
456 data-key="user_id"><?php esc_html_e( 'Unregistered', 'give' ); ?></span>
457 <?php endif; ?>
458 <?php
459 if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) :
460
461 echo sprintf(
462 '- <span class="disconnect-user">
463 <a id="disconnect-donor" href="#disconnect" aria-label="%1$s">%2$s</a>
464 </span> |
465 <span class="view-user-profile">
466 <a id="view-user-profile" href="%3$s" aria-label="%4$s">%5$s</a>
467 </span>',
468 esc_html__( 'Disconnects the current user ID from this donor record.', 'give' ),
469 esc_html__( 'Disconnect User', 'give' ),
470 esc_url( 'user-edit.php?user_id=' . $donor->user_id ),
471 esc_html__( 'View User Profile of current user ID.', 'give' ),
472 esc_html__( 'View User Profile', 'give' )
473 );
474
475 endif;
476 ?>
477 </span>
478 </td>
479 </tr>
480
481 <?php
482 $donor_company = $donor->get_meta( '_give_donor_company', true );
483 ?>
484 <tr class="alternate">
485 <th scope="col">
486 <label for="tablecell"><?php esc_html_e( 'Company Name:', 'give' ); ?></label>
487 </th>
488 <td>
489 <span class="donor-user-id info-item edit-item">
490 <input name="give_donor_company" value="<?php echo $donor_company; ?>" type="text">
491 </span>
492
493 <span class="donor-user-id info-item editable">
494 <?php echo $donor_company; ?>
495 </span>
496 </td>
497 </tr>
498 </tbody>
499 </table>
500 </div>
501
502 </div>
503
504 <span id="donor-edit-actions" class="edit-item">
505 <input type="hidden" data-key="id" name="donor_info[id]" value="<?php echo intval( $donor->id ); ?>"/>
506 <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?>
507 <input type="hidden" name="give_action" value="edit-donor"/>
508 <input type="submit" id="give-edit-donor-save" class="button-secondary"
509 value="<?php esc_html_e( 'Update Donor', 'give' ); ?>"/>
510 <a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
511 </span>
512
513 </form>
514
515 </div>
516
517 <?php
518 /**
519 * Fires in donor profile screen, above the stats list.
520 *
521 * @since 1.0
522 *
523 * @param Give_Donor $donor The donor object being displayed.
524 */
525 do_action( 'give_donor_before_stats', $donor );
526 ?>
527
528 <div id="donor-stats-wrapper" class="donor-section postbox clear">
529 <ul>
530 <li>
531 <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor->id ) ); ?>">
532 <span class="dashicons dashicons-heart"></span>
533 <?php
534 // Completed Donations.
535 $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count );
536 echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor );
537 ?>
538 </a>
539 </li>
540 <li>
541 <span class="dashicons dashicons-chart-area"></span>
542 <?php echo give_currency_filter( give_format_amount( $donor->get_total_donation_amount(), array( 'sanitize' => false ) ) ); ?> <?php _e( 'Lifetime Donations', 'give' ); ?>
543 </li>
544 <?php
545 /**
546 * Fires in donor profile screen, in the stats list.
547 *
548 * Allows you to add more list items to the stats list.
549 *
550 * @since 1.0
551 *
552 * @param object $donor The donor object being displayed.
553 */
554 do_action( 'give_donor_stats_list', $donor );
555 ?>
556 </ul>
557 </div>
558
559 <?php
560 /**
561 * Fires in donor profile screen, above the address list.
562 *
563 * @since 1.8.14
564 *
565 * @param Give_Donor $donor The donor object being displayed.
566 */
567 do_action( 'give_donor_before_address', $donor );
568 ?>
569
570 <div id="donor-address-wrapper" class="donor-section clear">
571 <h3><?php _e( 'Addresses', 'give' ); ?></h3>
572
573 <div class="postbox give-donor-addresses">
574 <div class="give-spinner-wrapper">
575 <span class="give-spinner spinner aligncenter"></span>
576 </div>
577 <div class="inside">
578 <div class="all-address">
579 <div class="give-grid-row">
580 <?php
581 if ( ! empty( $donor->address ) ) :
582 // Default address always will be at zero array index.
583 $is_set_as_default = null;
584
585 foreach ( $donor->address as $address_type => $addresses ) {
586
587 switch ( true ) {
588 case is_array( end( $addresses ) ):
589 $index = 1;
590 foreach ( $addresses as $id => $address ) {
591 echo __give_get_format_address(
592 $address,
593 array(
594 'type' => $address_type,
595 'id' => $id,
596 'index' => $index,
597 )
598 );
599
600 $index ++;
601 }
602 break;
603
604 case is_string( end( $addresses ) ):
605 echo __give_get_format_address(
606 $addresses,
607 array(
608 'type' => $address_type,
609 )
610 );
611 break;
612 }
613 }
614 endif;
615 ?>
616 </div>
617 <span class="give-no-address-message
618 <?php
619 if ( ! empty( $donor->address ) ) {
620 echo ' give-hidden';
621 }
622 ?>
623 ">
624 <?php _e( 'This donor does not have any addresses saved.', 'give' ); ?>
625 </span>
626 <button class="button add-new-address">
627 <?php _e( 'Add Address', 'give' ); ?>
628 </button>
629 </div>
630
631 <div class="address-form add-new-address-form-hidden">
632 <form action="" method="post">
633 <table class="widefat striped">
634 <tbody>
635 <tr>
636 <th class="col">
637 <label class="country"><?php esc_html_e( 'Country:', 'give' ); ?></label>
638 </th>
639 <td>
640 <?php
641 echo Give()->html->select(
642 array(
643 'options' => give_get_country_list(),
644 'name' => 'country',
645 'selected' => give_get_option( 'base_country' ),
646 'show_option_all' => false,
647 'show_option_none' => false,
648 'chosen' => true,
649 'placeholder' => esc_attr__( 'Select a country', 'give' ),
650 'data' => array( 'search-type' => 'no_ajax' ),
651 'autocomplete' => 'country',
652 )
653 );
654 ?>
655 </td>
656 </tr>
657 <tr>
658 <th class="col">
659 <label for="line1"><?php esc_html_e( 'Address 1:', 'give' ); ?></label>
660 </th>
661 <td>
662 <input id="line1" name="line1" type="text" class="medium-text"/>
663 </td>
664 </tr>
665 <tr>
666 <th class="col">
667 <label for="line2"><?php esc_html_e( 'Address 2:', 'give' ); ?></label>
668 </th>
669 <td>
670 <input id="line2" type="text" name="line2" value="" class="medium-text"/>
671
672 </td>
673 </tr>
674 <tr>
675 <th class="col">
676 <label for="city"><?php esc_html_e( 'City:', 'give' ); ?></label>
677 </th>
678 <td>
679 <input id="city" type="text" name="city" value="" class="medium-text"/>
680 </td>
681 </tr>
682 <?php
683 $no_states_country = give_no_states_country_list();
684 $base_country = give_get_option( 'base_country' );
685 if ( ! array_key_exists( $base_country, $no_states_country ) ) {
686 ?>
687 <tr class="give-field-wrap">
688 <th class="col">
689 <label
690 for="state"><?php esc_html_e( 'State / Province / County:', 'give' ); ?></label>
691 </th>
692 <td>
693 <?php
694 $states = give_get_states( $base_country );
695 $state_args = array(
696 'name' => 'state',
697 'class' => 'regular-text',
698 'autocomplete' => 'address-level1',
699 );
700
701 if ( empty( $states ) ) {
702
703 // Show Text field, if empty states.
704 $state_args = wp_parse_args(
705 $state_args,
706 array(
707 'value' => give_get_option( 'base_state' ),
708 )
709 );
710 echo Give()->html->text( $state_args );
711 } else {
712
713 // Show Chosen DropDown, if states are not empty.
714 $state_args = wp_parse_args(
715 $state_args,
716 array(
717 'options' => $states,
718 'selected' => give_get_option( 'base_state' ),
719 'show_option_all' => false,
720 'show_option_none' => false,
721 'chosen' => true,
722 'placeholder' => __( 'Select a state', 'give' ),
723 'data' => array( 'search-type' => 'no_ajax' ),
724 )
725 );
726 echo Give()->html->select( $state_args );
727 }
728 ?>
729 </td>
730 </tr>
731 <?php
732 }
733 ?>
734 <tr>
735 <th class="col">
736 <label for="zip"><?php esc_html_e( 'Zip / Postal Code:', 'give' ); ?></label>
737 </th>
738 <td>
739 <input id="zip" type="text" name="zip" value="" class="medium-text"/>
740 </td>
741 </tr>
742 <tr>
743 <td colspan="2">
744 <?php wp_nonce_field( 'give-manage-donor-addresses', '_wpnonce', false ); ?>
745 <input type="hidden" name="address-action" value="add">
746 <input type="hidden" name="address-id" value="">
747 <input type="submit" class="button button-primary js-save"
748 value="<?php _e( 'Save', 'give' ); ?>">&nbsp;&nbsp;<button
749 class="button js-cancel"><?php _e( 'Cancel', 'give' ); ?></button>
750 </td>
751 </tr>
752 </tbody>
753 </table>
754 </form>
755 </div>
756 </div>
757 </div>
758 </div>
759
760 <?php
761 /**
762 * Fires in donor profile screen, above the tables wrapper.
763 *
764 * @since 1.0
765 *
766 * @param Give_Donor $donor The donor object being displayed.
767 */
768 do_action( 'give_donor_before_tables_wrapper', $donor );
769 ?>
770
771 <div id="donor-tables-wrapper" class="donor-section">
772
773 <?php
774 /**
775 * Fires in donor profile screen, above the tables.
776 *
777 * @since 1.0
778 *
779 * @param object $donor The donor object being displayed.
780 */
781 do_action( 'give_donor_before_tables', $donor );
782 ?>
783
784 <h3><?php _e( 'Donor Emails', 'give' ); ?></h3>
785
786 <table class="wp-list-table widefat striped emails">
787 <thead>
788 <tr>
789 <th><?php _e( 'Email', 'give' ); ?></th>
790 <th><?php _e( 'Actions', 'give' ); ?></th>
791 </tr>
792 </thead>
793
794 <tbody>
795 <?php if ( ! empty( $donor->emails ) ) { ?>
796
797 <?php foreach ( $donor->emails as $key => $email ) : ?>
798 <tr data-key="<?php echo $key; ?>">
799 <td>
800 <?php echo $email; ?>
801 <?php if ( 'primary' === $key ) : ?>
802 <span class="dashicons dashicons-star-filled primary-email-icon"></span>
803 <?php endif; ?>
804 </td>
805 <td>
806 <?php if ( 'primary' !== $key ) : ?>
807 <?php
808 $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id );
809 $promote_url = wp_nonce_url(
810 add_query_arg(
811 array(
812 'email' => rawurlencode( $email ),
813 'give_action' => 'set_donor_primary_email',
814 ),
815 $base_url
816 ),
817 'give-set-donor-primary-email'
818 );
819 $remove_url = wp_nonce_url(
820 add_query_arg(
821 array(
822 'email' => rawurlencode( $email ),
823 'give_action' => 'remove_donor_email',
824 ),
825 $base_url
826 ),
827 'give-remove-donor-email'
828 );
829 ?>
830 <a href="<?php echo esc_url( $promote_url ); ?>"><?php _e( 'Make Primary', 'give' ); ?></a>
831 &nbsp;|&nbsp;
832 <a href="<?php echo esc_url( $remove_url ); ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a>
833 <?php endif; ?>
834 </td>
835 </tr>
836 <?php endforeach; ?>
837
838 <tr class="add-donor-email-row">
839 <td colspan="2" class="add-donor-email-td">
840 <div class="add-donor-email-wrapper">
841 <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>"/>
842 <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?>
843 <input type="email" name="additional-email" value=""
844 placeholder="<?php _e( 'Email Address', 'give' ); ?>"/>&nbsp;
845 <input type="checkbox" name="make-additional-primary" value="1"
846 id="make-additional-primary"/>&nbsp;<label
847 for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label>
848 <button class="button-secondary give-add-donor-email"
849 id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button>
850 <span class="spinner"></span>
851 </div>
852 <div class="notice-wrap"></div>
853 </td>
854 </tr>
855 <?php } else { ?>
856 <tr>
857 <td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td>
858 </tr>
859 <?php
860 }// End if().
861 ?>
862 </tbody>
863 </table>
864
865 <h3><?php _e( 'Recent Donations', 'give' ); ?></h3>
866 <?php
867 $payment_ids = explode( ',', $donor->payment_ids );
868 $payments = give_get_payments(
869 array(
870 'post__in' => $payment_ids,
871 )
872 );
873 $payments = array_slice( $payments, 0, 10 );
874 ?>
875 <table class="wp-list-table widefat striped payments">
876 <thead>
877 <tr>
878 <th scope="col"><?php _e( 'ID', 'give' ); ?></th>
879 <th scope="col"><?php _e( 'Amount', 'give' ); ?></th>
880 <th scope="col"><?php _e( 'Date', 'give' ); ?></th>
881 <th scope="col"><?php _e( 'Status', 'give' ); ?></th>
882 <th scope="col"><?php _e( 'Actions', 'give' ); ?></th>
883 </tr>
884 </thead>
885 <tbody>
886 <?php if ( ! empty( $payments ) ) { ?>
887 <?php foreach ( $payments as $payment ) : ?>
888 <tr>
889 <td><?php echo Give()->seq_donation_number->get_serial_code( $payment->ID ); ?></td>
890 <td>
891 <?php
892 echo give_donation_amount(
893 $payment->ID,
894 array(
895 'currency' => true,
896 'amount' => true,
897 'type' => 'donor',
898 )
899 );
900 ?>
901 </td>
902 <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td>
903 <td><?php echo give_get_payment_status( $payment, true ); ?></td>
904 <td>
905 <?php
906 printf(
907 '<a href="%1$s" aria-label="%2$s">%3$s</a>',
908 admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ),
909 sprintf(
910 /* translators: %s: Donation ID */
911 esc_attr__( 'View Donation %s.', 'give' ),
912 $payment->ID
913 ),
914 __( 'View Donation', 'give' )
915 );
916 ?>
917
918 <?php
919 /**
920 * Fires in donor profile screen, in the recent donations tables action links.
921 *
922 * Allows you to add more action links for each donation, after the 'View Donation' action link.
923 *
924 * @since 1.0
925 *
926 * @param object $donor The donor object being displayed.
927 * @param object $payment The payment object being displayed.
928 */
929 do_action( 'give_donor_recent_purchases_actions', $donor, $payment );
930 ?>
931 </td>
932 </tr>
933 <?php endforeach; ?>
934 <?php } else { ?>
935 <tr>
936 <td colspan="5"><?php _e( 'No donations found.', 'give' ); ?></td>
937 </tr>
938 <?php
939 }// End if().
940 ?>
941 </tbody>
942 </table>
943
944 <h3><?php _e( 'Completed Forms', 'give' ); ?></h3>
945 <?php
946 $donations = give_get_users_completed_donations( $donor->email );
947 ?>
948 <table class="wp-list-table widefat striped donations">
949 <thead>
950 <tr>
951 <th scope="col"><?php _e( 'Form', 'give' ); ?></th>
952 <th scope="col" width="120px"><?php _e( 'Actions', 'give' ); ?></th>
953 </tr>
954 </thead>
955 <tbody>
956 <?php if ( ! empty( $donations ) ) { ?>
957 <?php foreach ( $donations as $donation ) : ?>
958 <tr>
959 <td><?php echo $donation->post_title; ?></td>
960 <td>
961 <?php
962 printf(
963 '<a href="%1$s" aria-label="%2$s">%3$s</a>',
964 esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ),
965 sprintf(
966 /* translators: %s: form name */
967 esc_attr__( 'View Form %s.', 'give' ),
968 $donation->post_title
969 ),
970 __( 'View Form', 'give' )
971 );
972 ?>
973 </td>
974 </tr>
975 <?php endforeach; ?>
976 <?php } else { ?>
977 <tr>
978 <td colspan="2"><?php _e( 'No completed donations found.', 'give' ); ?></td>
979 </tr>
980 <?php } ?>
981 </tbody>
982 </table>
983 <?php
984 /**
985 * Fires in donor profile screen, below the tables.
986 *
987 * @since 1.0
988 *
989 * @param object $donor The donor object being displayed.
990 */
991 do_action( 'give_donor_after_tables', $donor );
992 ?>
993
994 </div>
995
996 <?php
997 /**
998 * Fires in donor profile screen, below the donor card.
999 *
1000 * @since 1.0
1001 *
1002 * @param object $donor The donor object being displayed.
1003 */
1004 do_action( 'give_donor_card_bottom', $donor );
1005
1006 }
1007
1008 /**
1009 * View the notes of a donor.
1010 *
1011 * @since 1.0
1012 *
1013 * @param Give_Donor $donor The donor object being displayed.
1014 *
1015 * @return void
1016 */
1017 function give_donor_notes_view( $donor ) {
1018
1019 $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1;
1020 $paged = absint( $paged );
1021 $note_count = $donor->get_notes_count();
1022 $per_page = apply_filters( 'give_donor_notes_per_page', 20 );
1023 $total_pages = ceil( $note_count / $per_page );
1024 $donor_notes = $donor->get_notes( $per_page, $paged );
1025 ?>
1026
1027 <div id="donor-notes-wrapper">
1028 <div class="donor-notes-header">
1029 <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span>
1030 </div>
1031 <h3><?php _e( 'Notes', 'give' ); ?></h3>
1032
1033 <?php if ( 1 == $paged ) : ?>
1034 <div style="display: block; margin-bottom: 55px;">
1035 <form id="give-add-donor-note" method="post"
1036 action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>">
1037 <textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea>
1038 <br/>
1039 <input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>"/>
1040 <input type="hidden" name="give_action" value="add-donor-note"/>
1041 <?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?>
1042 <input id="add-donor-note" class="right button-primary" type="submit" value="Add Note"/>
1043 </form>
1044 </div>
1045 <?php endif; ?>
1046
1047 <?php
1048 $pagination_args = array(
1049 'base' => '%_%',
1050 'format' => '?paged=%#%',
1051 'total' => $total_pages,
1052 'current' => $paged,
1053 'show_all' => true,
1054 );
1055
1056 echo paginate_links( $pagination_args );
1057 ?>
1058
1059 <div id="give-donor-notes" class="postbox">
1060 <?php if ( count( $donor_notes ) > 0 ) { ?>
1061 <?php foreach ( $donor_notes as $key => $note ) : ?>
1062 <div class="donor-note-wrapper dashboard-comment-wrap comment-item">
1063 <span class="note-content-wrap">
1064 <?php echo stripslashes( $note ); ?>
1065 </span>
1066 </div>
1067 <?php endforeach; ?>
1068 <?php } else { ?>
1069 <div class="give-no-donor-notes">
1070 <?php _e( 'No donor notes found.', 'give' ); ?>
1071 </div>
1072 <?php } ?>
1073 </div>
1074
1075 <?php echo paginate_links( $pagination_args ); ?>
1076
1077 </div>
1078
1079 <?php
1080 }
1081
1082 /**
1083 * The donor delete view.
1084 *
1085 * @since 1.0
1086 *
1087 * @param object $donor The donor object being displayed.
1088 *
1089 * @return void
1090 */
1091 function give_donor_delete_view( $donor ) {
1092
1093 $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
1094
1095 /**
1096 * Fires in donor delete screen, above the content.
1097 *
1098 * @since 1.0
1099 *
1100 * @param object $donor The donor object being displayed.
1101 */
1102 do_action( 'give_donor_delete_top', $donor );
1103 ?>
1104
1105 <div class="info-wrapper donor-section">
1106
1107 <form id="delete-donor" method="post"
1108 action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>">
1109
1110 <div class="donor-notes-header">
1111 <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span>
1112 </div>
1113
1114
1115 <div class="donor-info delete-donor">
1116
1117 <span class="delete-donor-options">
1118 <p>
1119 <?php
1120 echo Give()->html->checkbox(
1121 array(
1122 'name' => 'give-donor-delete-confirm',
1123 )
1124 );
1125 ?>
1126 <label
1127 for="give-donor-delete-confirm"><?php _e( 'Are you sure you want to delete this donor?', 'give' ); ?></label>
1128 </p>
1129
1130 <p>
1131 <?php
1132 echo Give()->html->checkbox(
1133 array(
1134 'name' => 'give-donor-delete-records',
1135 'options' => array(
1136 'disabled' => true,
1137 ),
1138 )
1139 );
1140 ?>
1141 <label
1142 for="give-donor-delete-records"><?php _e( 'Delete all associated donations and records?', 'give' ); ?></label>
1143 </p>
1144
1145 <?php
1146 /**
1147 * Fires in donor delete screen, bellow the delete inputs.
1148 *
1149 * Allows you to add custom delete inputs.
1150 *
1151 * @since 1.0
1152 *
1153 * @param object $donor The donor object being displayed.
1154 */
1155 do_action( 'give_donor_delete_inputs', $donor );
1156 ?>
1157 </span>
1158
1159 <span id="donor-edit-actions">
1160 <input type="hidden" name="donor_id" value="<?php echo $donor->id; ?>"/>
1161 <?php wp_nonce_field( 'give-delete-donor', '_wpnonce', false, true ); ?>
1162 <input type="hidden" name="give_action" value="delete_donor"/>
1163 <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary"
1164 value="<?php _e( 'Delete Donor', 'give' ); ?>"/>
1165 <a id="give-delete-donor-cancel"
1166 href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"
1167 class="delete"><?php _e( 'Cancel', 'give' ); ?></a>
1168 </span>
1169
1170 </div>
1171
1172 </form>
1173 </div>
1174
1175 <?php
1176 /**
1177 * Fires in donor delete screen, bellow the content.
1178 *
1179 * @since 1.0
1180 *
1181 * @param object $donor The donor object being displayed.
1182 */
1183 do_action( 'give_donor_delete_bottom', $donor );
1184 }
1185