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