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