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