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