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