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