| @@ -3,13 +3,17 @@ | ||
| 3 | 3 | * Donors. |
| 4 | 4 | * |
| 5 | 5 | * @package Give |
| 6 | 6 | * @subpackage Admin/Donors |
| 7 | - * @copyright Copyright (c) 2016, WordImpress | |
| 7 | + * @copyright Copyright (c) 2016, GiveWP | |
| 8 | 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
| 9 | 9 | * @since 1.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | +use Give\Donors\DonorsAdminPage; | |
| 13 | +use Give\Donors\Models\Donor; | |
| 14 | +use Give\Helpers\IntlTelInput; | |
| 15 | + | |
| 12 | 16 | // Exit if accessed directly. |
| 13 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 18 | exit; |
| 15 | 19 | } |
| @@ -17,8 +21,9 @@ | ||
| 17 | 21 | |
| 18 | 22 | /** |
| 19 | 23 | * Get formatted address |
| 20 | 24 | * |
| 25 | + * @since 4.9.0 rename function - PHP 8 compatibility | |
| 21 | 26 | * @since 2.0 |
| 22 | 27 | * |
| 23 | 28 | * @param array $address |
| 24 | 29 | * @param array $address_args |
| @@ -24,9 +29,9 @@ | ||
| 24 | 29 | * @param array $address_args |
| 25 | 30 | * |
| 26 | 31 | * @return string |
| 27 | 32 | */ |
| 28 | -function __give_get_format_address( $address, $address_args = array() ) { | |
| 33 | +function give_get_format_address( $address, $address_args = array() ) { | |
| 29 | 34 | $address_html = ''; |
| 30 | 35 | $address_args = wp_parse_args( |
| 31 | 36 | $address_args, |
| 32 | 37 | array( |
| @@ -44,9 +49,9 @@ | ||
| 44 | 49 | return $address_html; |
| 45 | 50 | } |
| 46 | 51 | |
| 47 | 52 | // Address html. |
| 48 | - $address_html = ''; | |
| 53 | + $address_html = ''; | |
| 49 | 54 | $address_html .= sprintf( |
| 50 | 55 | '<span data-address-type="line1">%1$s</span>%2$s', |
| 51 | 56 | $address['line1'], |
| 52 | 57 | ( ! empty( $address['line2'] ) ? '<br>' : '' ) |
| @@ -106,19 +111,30 @@ | ||
| 106 | 111 | * Donors Page. |
| 107 | 112 | * |
| 108 | 113 | * Renders the donors page contents. |
| 109 | 114 | * |
| 115 | + * @since 4.13.1 add early return if showing new details page | |
| 110 | 116 | * @since 1.0 |
| 111 | 117 | * @return void |
| 112 | 118 | */ |
| 113 | 119 | function give_donors_page() { |
| 120 | + if (DonorsAdminPage::isShowingNewDetailsPage()) { | |
| 121 | + return; | |
| 122 | + } | |
| 123 | + | |
| 114 | 124 | $default_views = give_donor_views(); |
| 115 | 125 | $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors'; |
| 116 | 126 | if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
| 117 | 127 | give_render_donor_view( $requested_view, $default_views ); |
| 118 | - } else { | |
| 119 | - give_donors_list(); | |
| 120 | 128 | } |
| 129 | + else { | |
| 130 | + $userId = get_current_user_id(); | |
| 131 | + $showLegacy = get_user_meta($userId, '_give_donors_archive_show_legacy', true); | |
| 132 | + if ($showLegacy == 1) | |
| 133 | + { | |
| 134 | + give_donors_list(); | |
| 135 | + } | |
| 136 | + } | |
| 121 | 137 | } |
| 122 | 138 | |
| 123 | 139 | /** |
| 124 | 140 | * Register the views for donor management. |
| @@ -155,9 +171,9 @@ | ||
| 155 | 171 | * @return void |
| 156 | 172 | */ |
| 157 | 173 | function give_donors_list() { |
| 158 | 174 | |
| 159 | - include GIVE_PLUGIN_DIR . 'includes/admin/donors/class-donor-table.php'; | |
| 175 | + include GIVE_PLUGIN_DIR . 'includes/admin/donors/class-donor-table.php'; | |
| 160 | 176 | |
| 161 | 177 | $donors_table = new Give_Donor_List_Table(); |
| 162 | 178 | $donors_table->prepare_items(); |
| 163 | 179 | ?> |
| @@ -172,21 +188,17 @@ | ||
| 172 | 188 | do_action( 'give_donors_table_top' ); |
| 173 | 189 | ?> |
| 174 | 190 | |
| 175 | 191 | <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' ); ?> | |
| 192 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> | |
| 193 | + <?php | |
| 194 | + $donors_table->advanced_filters(); | |
| 195 | + $donors_table->display(); | |
| 196 | + ?> | |
| 179 | 197 | <input type="hidden" name="post_type" value="give_forms"/> |
| 180 | 198 | <input type="hidden" name="page" value="give-donors"/> |
| 181 | 199 | <input type="hidden" name="view" value="donors"/> |
| 182 | 200 | </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 | 201 | <?php |
| 190 | 202 | /** |
| 191 | 203 | * Fires in donors screen, below the table. |
| 192 | 204 | * |
| @@ -200,12 +212,13 @@ | ||
| 200 | 212 | |
| 201 | 213 | /** |
| 202 | 214 | * Renders the donor view wrapper. |
| 203 | 215 | * |
| 216 | + * @since 4.16.8 Relinking donors is handled only through the nonce-protected edit action. | |
| 204 | 217 | * @since 1.0 |
| 205 | 218 | * |
| 206 | 219 | * @param string $view The View being requested. |
| 207 | - * @param array $callbacks The Registered views and their callback functions. | |
| 220 | + * @param array $callbacks The Registered views and their callback functions. | |
| 208 | 221 | * |
| 209 | 222 | * @return void |
| 210 | 223 | */ |
| 211 | 224 | function give_render_donor_view( $view, $callbacks ) { |
| @@ -224,37 +237,24 @@ | ||
| 224 | 237 | $render = false; |
| 225 | 238 | } |
| 226 | 239 | |
| 227 | 240 | $donor_id = (int) $_GET['id']; |
| 228 | - $reconnect_user_id = ! empty( $_GET['user_id'] ) ? (int) $_GET['user_id'] : ''; | |
| 229 | 241 | $donor = new Give_Donor( $donor_id ); |
| 230 | 242 | |
| 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 | 243 | if ( empty( $donor->id ) ) { |
| 237 | 244 | give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
| 238 | 245 | $render = false; |
| 239 | 246 | } |
| 240 | 247 | |
| 241 | - $donor_tabs = give_donor_tabs(); | |
| 242 | 248 | ?> |
| 243 | 249 | |
| 244 | 250 | <div class='wrap'> |
| 245 | 251 | |
| 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 | 252 | <h1 class="wp-heading-inline"> |
| 253 | 253 | <?php |
| 254 | 254 | printf( |
| 255 | - /* translators: %s: donor first name */ | |
| 256 | - __( 'Edit Donor: %s %s', 'give' ), | |
| 255 | + /* translators: %s: donor first name */ | |
| 256 | + __( 'Edit Donor: %1$s %2$s', 'give' ), | |
| 257 | 257 | $donor->get_first_name(), |
| 258 | 258 | $donor->get_last_name() |
| 259 | 259 | ); |
| 260 | 260 | ?> |
| @@ -261,28 +261,36 @@ | ||
| 261 | 261 | </h1> |
| 262 | 262 | |
| 263 | 263 | <hr class="wp-header-end"> |
| 264 | 264 | |
| 265 | + <?php if ( give_get_errors() ) : ?> | |
| 266 | + <div class="error settings-error"> | |
| 267 | + <?php Give()->notices->render_frontend_notices( 0 ); ?> | |
| 268 | + </div> | |
| 269 | + <?php endif; ?> | |
| 270 | + | |
| 265 | 271 | <?php if ( $donor && $render ) : ?> |
| 266 | 272 | |
| 267 | - <h2 class="nav-tab-wrapper"> | |
| 273 | + <div class="nav-tab-wrapper give-nav-tab-wrapper"> | |
| 268 | 274 | <?php |
| 275 | + | |
| 276 | + $donor_tabs = give_donor_tabs(); | |
| 277 | + | |
| 269 | 278 | foreach ( $donor_tabs as $key => $tab ) : |
| 270 | 279 | $active = $key === $view ? true : false; |
| 271 | 280 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
| 272 | 281 | printf( |
| 273 | - '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n", | |
| 282 | + '<a href="%1$s" class="%2$s">%3$s</a>' . "\n", | |
| 274 | 283 | esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ), |
| 275 | 284 | esc_attr( $class ), |
| 276 | - sanitize_html_class( $tab['dashicon'] ), | |
| 277 | 285 | esc_html( $tab['title'] ) |
| 278 | 286 | ); |
| 279 | 287 | endforeach; |
| 280 | 288 | ?> |
| 281 | - </h2> | |
| 289 | + </div> | |
| 282 | 290 | |
| 283 | 291 | <div id="give-donor-card-wrapper"> |
| 284 | - <?php $callbacks[ $view ]( $donor ) ?> | |
| 292 | + <?php $callbacks[ $view ]( $donor ); ?> | |
| 285 | 293 | </div> |
| 286 | 294 | |
| 287 | 295 | <?php endif; ?> |
| 288 | 296 | |
| @@ -294,8 +302,10 @@ | ||
| 294 | 302 | |
| 295 | 303 | /** |
| 296 | 304 | * View a donor |
| 297 | 305 | * |
| 306 | + * @since 4.16.4 Escaped the donor company and phone output. | |
| 307 | + * @since 3.7.0 Add "phone" field | |
| 298 | 308 | * @since 1.0 |
| 299 | 309 | * |
| 300 | 310 | * @param Give_Donor $donor The Donor object being displayed. |
| 301 | 311 | * |
| @@ -323,23 +333,44 @@ | ||
| 323 | 333 | // List of title prefixes. |
| 324 | 334 | $title_prefixes = give_get_name_title_prefixes(); |
| 325 | 335 | |
| 326 | 336 | // 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 ); | |
| 337 | + $title_prefix = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true ); | |
| 338 | + $donor_name_without_prefix = $donor->name; | |
| 339 | + $donor->name = give_get_donor_name_with_title_prefixes( $title_prefix, $donor->name ); | |
| 329 | 340 | ?> |
| 330 | 341 | <div id="donor-summary" class="info-wrapper donor-section postbox"> |
| 331 | 342 | <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 ) ); ?>"> | |
| 343 | + action="<?php echo esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=legacy-overview&id=' . $donor->id ) ); ?>"> | |
| 333 | 344 | <div class="donor-info"> |
| 334 | 345 | <div class="donor-bio-header clearfix"> |
| 335 | 346 | <div class="avatar-wrap left" id="donor-avatar"> |
| 336 | - <?php echo get_avatar( $donor->email ); ?> | |
| 347 | + <?php | |
| 348 | + | |
| 349 | + // Check whether a Gravatar exists for a donor or not. | |
| 350 | + $validate_gravatar_image = give_validate_gravatar( $donor->email ); | |
| 351 | + | |
| 352 | + // Get donor's initials for non-gravatars | |
| 353 | + $donor_name_array = explode( ' ', $donor_name_without_prefix ); | |
| 354 | + $donor_name_args['firstname'] = ! empty( $donor_name_array[0] ) ? $donor_name_array[0] : ''; | |
| 355 | + $donor_name_args['lastname'] = ! empty( $donor_name_array[1] ) ? $donor_name_array[1] : ''; | |
| 356 | + $donor_name_initial = give_get_name_initial( $donor_name_args ); | |
| 357 | + | |
| 358 | + // Gravatars image for donor | |
| 359 | + if ( $validate_gravatar_image ) { | |
| 360 | + $donor_gravatar_image = get_avatar( $donor->email ); | |
| 361 | + } else { | |
| 362 | + $donor_gravatar_image = '<div class="give-donor-admin-avatar">' . $donor_name_initial . '</div>'; | |
| 363 | + } | |
| 364 | + | |
| 365 | + echo $donor_gravatar_image; | |
| 366 | + ?> | |
| 337 | 367 | </div> |
| 338 | 368 | <div id="donor-name-wrap" class="left"> |
| 339 | 369 | <span class="donor-name info-item edit-item"> |
| 340 | 370 | <select name="donor_info[title]"> |
| 341 | 371 | <option disabled value="0"><?php esc_html_e( 'Title', 'give' ); ?></option> |
| 372 | + <option value=""> </option> | |
| 342 | 373 | <?php |
| 343 | 374 | if ( is_array( $title_prefixes ) && count( $title_prefixes ) > 0 ) { |
| 344 | 375 | foreach ( $title_prefixes as $title ) { |
| 345 | 376 | echo sprintf( |
| @@ -351,11 +382,11 @@ | ||
| 351 | 382 | } |
| 352 | 383 | ?> |
| 353 | 384 | </select> |
| 354 | 385 | <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' ); ?>"/> | |
| 386 | + name="donor_info[first_name]" type="text" | |
| 387 | + value="<?php echo esc_html( $donor->get_first_name() ); ?>" | |
| 388 | + placeholder="<?php esc_html_e( 'First Name', 'give' ); ?>"/> | |
| 358 | 389 | <?php if ( $donor->user_id ) : ?> |
| 359 | 390 | <a href="#" class="give-lock-block"> |
| 360 | 391 | <i class="give-icon give-icon-locked"></i> |
| 361 | 392 | </a> |
| @@ -360,11 +391,11 @@ | ||
| 360 | 391 | <i class="give-icon give-icon-locked"></i> |
| 361 | 392 | </a> |
| 362 | 393 | <?php endif; ?> |
| 363 | 394 | <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' ); ?>"/> | |
| 395 | + name="donor_info[last_name]" type="text" | |
| 396 | + value="<?php echo esc_html( $donor->get_last_name() ); ?>" | |
| 397 | + placeholder="<?php esc_html_e( 'Last Name', 'give' ); ?>"/> | |
| 367 | 398 | <?php if ( $donor->user_id ) : ?> |
| 368 | 399 | <a href="#" class="give-lock-block"> |
| 369 | 400 | <i class="give-icon give-icon-locked"></i> |
| 370 | 401 | </a> |
| @@ -375,9 +406,9 @@ | ||
| 375 | 406 | </span> |
| 376 | 407 | </div> |
| 377 | 408 | <p class="donor-since info-item"> |
| 378 | 409 | <?php esc_html_e( 'Donor since', 'give' ); ?> |
| 379 | - <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> | |
| 410 | + <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ); ?> | |
| 380 | 411 | </p> |
| 381 | 412 | <?php if ( current_user_can( $donor_edit_role ) ) : ?> |
| 382 | 413 | <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"> |
| 383 | 414 | <?php esc_html_e( 'Edit Donor', 'give' ); ?> |
| @@ -430,14 +461,15 @@ | ||
| 430 | 461 | <?php else : ?> |
| 431 | 462 | <span |
| 432 | 463 | data-key="user_id"><?php esc_html_e( 'Unregistered', 'give' ); ?></span> |
| 433 | 464 | <?php endif; ?> |
| 434 | - <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) : | |
| 465 | + <?php | |
| 466 | + if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) : | |
| 435 | 467 | |
| 436 | 468 | echo sprintf( |
| 437 | 469 | '- <span class="disconnect-user"> |
| 438 | 470 | <a id="disconnect-donor" href="#disconnect" aria-label="%1$s">%2$s</a> |
| 439 | - </span> | | |
| 471 | + </span> | | |
| 440 | 472 | <span class="view-user-profile"> |
| 441 | 473 | <a id="view-user-profile" href="%3$s" aria-label="%4$s">%5$s</a> |
| 442 | 474 | </span>', |
| 443 | 475 | esc_html__( 'Disconnects the current user ID from this donor record.', 'give' ), |
| @@ -446,27 +478,49 @@ | ||
| 446 | 478 | esc_html__( 'View User Profile of current user ID.', 'give' ), |
| 447 | 479 | esc_html__( 'View User Profile', 'give' ) |
| 448 | 480 | ); |
| 449 | 481 | |
| 450 | - endif; ?> | |
| 482 | + endif; | |
| 483 | + ?> | |
| 451 | 484 | </span> |
| 452 | 485 | </td> |
| 453 | 486 | </tr> |
| 454 | 487 | |
| 455 | - <?php | |
| 488 | + <?php | |
| 489 | + | |
| 490 | + $donor_phone_number = Donor::find($donor->id)->phone; | |
| 491 | + ?> | |
| 492 | + <tr class="alternate"> | |
| 493 | + <th scope="col"> | |
| 494 | + <label for="tablecell"><?php | |
| 495 | + esc_html_e('Phone:', 'give'); ?></label> | |
| 496 | + </th> | |
| 497 | + <td> | |
| 498 | + <span class="donor-user-id info-item edit-item"> | |
| 499 | + <?php | |
| 500 | + echo IntlTelInput::getHtmlInput($donor_phone_number, "give_donor_phone_number"); ?> | |
| 501 | + </span> | |
| 502 | + | |
| 503 | + <span class="donor-user-id info-item editable"> | |
| 504 | + <?php | |
| 505 | + echo esc_html( $donor_phone_number ); ?> | |
| 506 | + </span> | |
| 507 | + </td> | |
| 508 | + </tr> | |
| 509 | + <?php | |
| 456 | 510 | $donor_company = $donor->get_meta( '_give_donor_company', true ); |
| 457 | 511 | ?> |
| 458 | - <tr class="alternate"> | |
| 512 | + <tr class=""> | |
| 459 | 513 | <th scope="col"> |
| 460 | 514 | <label for="tablecell"><?php esc_html_e( 'Company Name:', 'give' ); ?></label> |
| 461 | 515 | </th> |
| 462 | 516 | <td> |
| 463 | 517 | <span class="donor-user-id info-item edit-item"> |
| 464 | - <input name="give_donor_company" value="<?php echo $donor_company ?>" type="text"> | |
| 518 | + <input name="give_donor_company" value="<?php echo esc_attr( $donor_company ); ?>" type="text"> | |
| 465 | 519 | </span> |
| 466 | 520 | |
| 467 | 521 | <span class="donor-user-id info-item editable"> |
| 468 | - <?php echo $donor_company; ?> | |
| 522 | + <?php echo esc_html( $donor_company ); ?> | |
| 469 | 523 | </span> |
| 470 | 524 | </td> |
| 471 | 525 | </tr> |
| 472 | 526 | </tbody> |
| @@ -479,9 +533,9 @@ | ||
| 479 | 533 | <input type="hidden" data-key="id" name="donor_info[id]" value="<?php echo intval( $donor->id ); ?>"/> |
| 480 | 534 | <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?> |
| 481 | 535 | <input type="hidden" name="give_action" value="edit-donor"/> |
| 482 | 536 | <input type="submit" id="give-edit-donor-save" class="button-secondary" |
| 483 | - value="<?php esc_html_e( 'Update Donor', 'give' ); ?>"/> | |
| 537 | + value="<?php esc_html_e( 'Update Donor', 'give' ); ?>"/> | |
| 484 | 538 | <a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
| 485 | 539 | </span> |
| 486 | 540 | |
| 487 | 541 | </form> |
| @@ -543,9 +597,9 @@ | ||
| 543 | 597 | |
| 544 | 598 | <div id="donor-address-wrapper" class="donor-section clear"> |
| 545 | 599 | <h3><?php _e( 'Addresses', 'give' ); ?></h3> |
| 546 | 600 | |
| 547 | - <div class="postbox"> | |
| 601 | + <div class="postbox give-donor-addresses"> | |
| 548 | 602 | <div class="give-spinner-wrapper"> |
| 549 | 603 | <span class="give-spinner spinner aligncenter"></span> |
| 550 | 604 | </div> |
| 551 | 605 | <div class="inside"> |
| @@ -561,13 +615,13 @@ | ||
| 561 | 615 | switch ( true ) { |
| 562 | 616 | case is_array( end( $addresses ) ): |
| 563 | 617 | $index = 1; |
| 564 | 618 | foreach ( $addresses as $id => $address ) { |
| 565 | - echo __give_get_format_address( | |
| 619 | + echo give_get_format_address( | |
| 566 | 620 | $address, |
| 567 | 621 | array( |
| 568 | - 'type' => $address_type, | |
| 569 | - 'id' => $id, | |
| 622 | + 'type' => $address_type, | |
| 623 | + 'id' => $id, | |
| 570 | 624 | 'index' => $index, |
| 571 | 625 | ) |
| 572 | 626 | ); |
| 573 | 627 | |
| @@ -575,9 +629,9 @@ | ||
| 575 | 629 | } |
| 576 | 630 | break; |
| 577 | 631 | |
| 578 | 632 | case is_string( end( $addresses ) ): |
| 579 | - echo __give_get_format_address( | |
| 633 | + echo give_get_format_address( | |
| 580 | 634 | $addresses, |
| 581 | 635 | array( |
| 582 | 636 | 'type' => $address_type, |
| 583 | 637 | ) |
| @@ -587,11 +641,15 @@ | ||
| 587 | 641 | } |
| 588 | 642 | endif; |
| 589 | 643 | ?> |
| 590 | 644 | </div> |
| 591 | - <span class="give-no-address-message<?php if ( ! empty( $donor->address ) ) { | |
| 645 | + <span class="give-no-address-message | |
| 646 | + <?php | |
| 647 | + if ( ! empty( $donor->address ) ) { | |
| 592 | 648 | echo ' give-hidden'; |
| 593 | - } ?>"> | |
| 649 | + } | |
| 650 | + ?> | |
| 651 | + "> | |
| 594 | 652 | <?php _e( 'This donor does not have any addresses saved.', 'give' ); ?> |
| 595 | 653 | </span> |
| 596 | 654 | <button class="button add-new-address"> |
| 597 | 655 | <?php _e( 'Add Address', 'give' ); ?> |
| @@ -607,18 +665,21 @@ | ||
| 607 | 665 | <label class="country"><?php esc_html_e( 'Country:', 'give' ); ?></label> |
| 608 | 666 | </th> |
| 609 | 667 | <td> |
| 610 | 668 | <?php |
| 611 | - echo Give()->html->select( array( | |
| 612 | - 'options' => give_get_country_list(), | |
| 613 | - 'name' => 'country', | |
| 614 | - 'selected' => give_get_option( 'base_country' ), | |
| 615 | - 'show_option_all' => false, | |
| 616 | - 'show_option_none' => false, | |
| 617 | - 'chosen' => true, | |
| 618 | - 'placeholder' => esc_attr__( 'Select a country', 'give' ), | |
| 619 | - 'data' => array( 'search-type' => 'no_ajax' ), | |
| 620 | - ) ); | |
| 669 | + echo Give()->html->select( | |
| 670 | + array( | |
| 671 | + 'options' => give_get_country_list(), | |
| 672 | + 'name' => 'country', | |
| 673 | + 'selected' => give_get_option( 'base_country' ), | |
| 674 | + 'show_option_all' => false, | |
| 675 | + 'show_option_none' => false, | |
| 676 | + 'chosen' => true, | |
| 677 | + 'placeholder' => esc_attr__( 'Select a country', 'give' ), | |
| 678 | + 'data' => array( 'search-type' => 'no_ajax' ), | |
| 679 | + 'autocomplete' => 'country', | |
| 680 | + ) | |
| 681 | + ); | |
| 621 | 682 | ?> |
| 622 | 683 | </td> |
| 623 | 684 | </tr> |
| 624 | 685 | <tr> |
| @@ -659,31 +720,38 @@ | ||
| 659 | 720 | <td> |
| 660 | 721 | <?php |
| 661 | 722 | $states = give_get_states( $base_country ); |
| 662 | 723 | $state_args = array( |
| 663 | - 'name' => 'state', | |
| 664 | - 'class' => 'regular-text', | |
| 724 | + 'name' => 'state', | |
| 725 | + 'class' => 'regular-text', | |
| 726 | + 'autocomplete' => 'address-level1', | |
| 665 | 727 | ); |
| 666 | 728 | |
| 667 | 729 | if ( empty( $states ) ) { |
| 668 | 730 | |
| 669 | 731 | // Show Text field, if empty states. |
| 670 | - $state_args = wp_parse_args( $state_args, array( | |
| 671 | - 'value' => give_get_option( 'base_state' ), | |
| 672 | - ) ); | |
| 732 | + $state_args = wp_parse_args( | |
| 733 | + $state_args, | |
| 734 | + array( | |
| 735 | + 'value' => give_get_option( 'base_state' ), | |
| 736 | + ) | |
| 737 | + ); | |
| 673 | 738 | echo Give()->html->text( $state_args ); |
| 674 | 739 | } else { |
| 675 | 740 | |
| 676 | 741 | // Show Chosen DropDown, if states are not empty. |
| 677 | - $state_args = wp_parse_args( $state_args, array( | |
| 678 | - 'options' => $states, | |
| 679 | - 'selected' => give_get_option( 'base_state' ), | |
| 680 | - 'show_option_all' => false, | |
| 681 | - 'show_option_none' => false, | |
| 682 | - 'chosen' => true, | |
| 683 | - 'placeholder' => __( 'Select a state', 'give' ), | |
| 684 | - 'data' => array( 'search-type' => 'no_ajax' ), | |
| 685 | - ) ); | |
| 742 | + $state_args = wp_parse_args( | |
| 743 | + $state_args, | |
| 744 | + array( | |
| 745 | + 'options' => $states, | |
| 746 | + 'selected' => give_get_option( 'base_state' ), | |
| 747 | + 'show_option_all' => false, | |
| 748 | + 'show_option_none' => false, | |
| 749 | + 'chosen' => true, | |
| 750 | + 'placeholder' => __( 'Select a state', 'give' ), | |
| 751 | + 'data' => array( 'search-type' => 'no_ajax' ), | |
| 752 | + ) | |
| 753 | + ); | |
| 686 | 754 | echo Give()->html->select( $state_args ); |
| 687 | 755 | } |
| 688 | 756 | ?> |
| 689 | 757 | </td> |
| @@ -704,9 +772,9 @@ | ||
| 704 | 772 | <?php wp_nonce_field( 'give-manage-donor-addresses', '_wpnonce', false ); ?> |
| 705 | 773 | <input type="hidden" name="address-action" value="add"> |
| 706 | 774 | <input type="hidden" name="address-id" value=""> |
| 707 | 775 | <input type="submit" class="button button-primary js-save" |
| 708 | - value="<?php _e( 'Save', 'give' ); ?>"> <button | |
| 776 | + value="<?php _e( 'Save', 'give' ); ?>"> <button | |
| 709 | 777 | class="button js-cancel"><?php _e( 'Cancel', 'give' ); ?></button> |
| 710 | 778 | </td> |
| 711 | 779 | </tr> |
| 712 | 780 | </tbody> |
| @@ -756,9 +824,9 @@ | ||
| 756 | 824 | |
| 757 | 825 | <?php foreach ( $donor->emails as $key => $email ) : ?> |
| 758 | 826 | <tr data-key="<?php echo $key; ?>"> |
| 759 | 827 | <td> |
| 760 | - <?php echo $email; ?> | |
| 828 | + <?php echo esc_html( $email ); ?> | |
| 761 | 829 | <?php if ( 'primary' === $key ) : ?> |
| 762 | 830 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
| 763 | 831 | <?php endif; ?> |
| 764 | 832 | </td> |
| @@ -764,21 +832,33 @@ | ||
| 764 | 832 | </td> |
| 765 | 833 | <td> |
| 766 | 834 | <?php if ( 'primary' !== $key ) : ?> |
| 767 | 835 | <?php |
| 768 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); | |
| 769 | - $promote_url = wp_nonce_url( add_query_arg( array( | |
| 770 | - 'email' => rawurlencode( $email ), | |
| 771 | - 'give_action' => 'set_donor_primary_email', | |
| 772 | - ), $base_url ), 'give-set-donor-primary-email' ); | |
| 773 | - $remove_url = wp_nonce_url( add_query_arg( array( | |
| 774 | - 'email' => rawurlencode( $email ), | |
| 775 | - 'give_action' => 'remove_donor_email', | |
| 776 | - ), $base_url ), 'give-remove-donor-email' ); | |
| 836 | + $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=legacy-overview&id=' . $donor->id ); | |
| 837 | + $promote_url = wp_nonce_url( | |
| 838 | + add_query_arg( | |
| 839 | + array( | |
| 840 | + 'email' => rawurlencode( $email ), | |
| 841 | + 'give_action' => 'set_donor_primary_email', | |
| 842 | + ), | |
| 843 | + $base_url | |
| 844 | + ), | |
| 845 | + 'give-set-donor-primary-email' | |
| 846 | + ); | |
| 847 | + $remove_url = wp_nonce_url( | |
| 848 | + add_query_arg( | |
| 849 | + array( | |
| 850 | + 'email' => rawurlencode( $email ), | |
| 851 | + 'give_action' => 'remove_donor_email', | |
| 852 | + ), | |
| 853 | + $base_url | |
| 854 | + ), | |
| 855 | + 'give-remove-donor-email' | |
| 856 | + ); | |
| 777 | 857 | ?> |
| 778 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> | |
| 858 | + <a href="<?php echo esc_url( $promote_url ); ?>"><?php _e( 'Make Primary', 'give' ); ?></a> | |
| 779 | 859 | | |
| 780 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> | |
| 860 | + <a href="<?php echo esc_url( $remove_url ); ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> | |
| 781 | 861 | <?php endif; ?> |
| 782 | 862 | </td> |
| 783 | 863 | </tr> |
| 784 | 864 | <?php endforeach; ?> |
| @@ -788,14 +868,14 @@ | ||
| 788 | 868 | <div class="add-donor-email-wrapper"> |
| 789 | 869 | <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>"/> |
| 790 | 870 | <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
| 791 | 871 | <input type="email" name="additional-email" value="" |
| 792 | - placeholder="<?php _e( 'Email Address', 'give' ); ?>"/> | |
| 872 | + placeholder="<?php _e( 'Email Address', 'give' ); ?>"/> | |
| 793 | 873 | <input type="checkbox" name="make-additional-primary" value="1" |
| 794 | - id="make-additional-primary"/> <label | |
| 874 | + id="make-additional-primary"/> <label | |
| 795 | 875 | for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
| 796 | 876 | <button class="button-secondary give-add-donor-email" |
| 797 | - id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> | |
| 877 | + id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> | |
| 798 | 878 | <span class="spinner"></span> |
| 799 | 879 | </div> |
| 800 | 880 | <div class="notice-wrap"></div> |
| 801 | 881 | </td> |
| @@ -803,9 +883,10 @@ | ||
| 803 | 883 | <?php } else { ?> |
| 804 | 884 | <tr> |
| 805 | 885 | <td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td> |
| 806 | 886 | </tr> |
| 807 | - <?php }// End if(). | |
| 887 | + <?php | |
| 888 | + }// End if(). | |
| 808 | 889 | ?> |
| 809 | 890 | </tbody> |
| 810 | 891 | </table> |
| 811 | 892 | |
| @@ -811,11 +892,13 @@ | ||
| 811 | 892 | |
| 812 | 893 | <h3><?php _e( 'Recent Donations', 'give' ); ?></h3> |
| 813 | 894 | <?php |
| 814 | 895 | $payment_ids = explode( ',', $donor->payment_ids ); |
| 815 | - $payments = give_get_payments( array( | |
| 816 | - 'post__in' => $payment_ids, | |
| 817 | - ) ); | |
| 896 | + $payments = give_get_payments( | |
| 897 | + array( | |
| 898 | + 'post__in' => $payment_ids, | |
| 899 | + ) | |
| 900 | + ); | |
| 818 | 901 | $payments = array_slice( $payments, 0, 10 ); |
| 819 | 902 | ?> |
| 820 | 903 | <table class="wp-list-table widefat striped payments"> |
| 821 | 904 | <thead> |
| @@ -831,13 +914,20 @@ | ||
| 831 | 914 | <?php if ( ! empty( $payments ) ) { ?> |
| 832 | 915 | <?php foreach ( $payments as $payment ) : ?> |
| 833 | 916 | <tr> |
| 834 | 917 | <td><?php echo Give()->seq_donation_number->get_serial_code( $payment->ID ); ?></td> |
| 835 | - <td><?php echo give_donation_amount( $payment->ID, array( | |
| 918 | + <td> | |
| 919 | + <?php | |
| 920 | + echo give_donation_amount( | |
| 921 | + $payment->ID, | |
| 922 | + array( | |
| 836 | 923 | 'currency' => true, |
| 837 | 924 | 'amount' => true, |
| 838 | - 'type' => 'donor' | |
| 839 | - ) ); ?></td> | |
| 925 | + 'type' => 'donor', | |
| 926 | + ) | |
| 927 | + ); | |
| 928 | + ?> | |
| 929 | + </td> | |
| 840 | 930 | <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
| 841 | 931 | <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
| 842 | 932 | <td> |
| 843 | 933 | <?php |
| @@ -844,9 +934,9 @@ | ||
| 844 | 934 | printf( |
| 845 | 935 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
| 846 | 936 | admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ), |
| 847 | 937 | sprintf( |
| 848 | - /* translators: %s: Donation ID */ | |
| 938 | + /* translators: %s: Donation ID */ | |
| 849 | 939 | esc_attr__( 'View Donation %s.', 'give' ), |
| 850 | 940 | $payment->ID |
| 851 | 941 | ), |
| 852 | 942 | __( 'View Donation', 'give' ) |
| @@ -872,9 +962,10 @@ | ||
| 872 | 962 | <?php } else { ?> |
| 873 | 963 | <tr> |
| 874 | 964 | <td colspan="5"><?php _e( 'No donations found.', 'give' ); ?></td> |
| 875 | 965 | </tr> |
| 876 | - <?php }// End if(). | |
| 966 | + <?php | |
| 967 | + }// End if(). | |
| 877 | 968 | ?> |
| 878 | 969 | </tbody> |
| 879 | 970 | </table> |
| 880 | 971 | |
| @@ -899,9 +990,9 @@ | ||
| 899 | 990 | printf( |
| 900 | 991 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
| 901 | 992 | esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
| 902 | 993 | sprintf( |
| 903 | - /* translators: %s: form name */ | |
| 994 | + /* translators: %s: form name */ | |
| 904 | 995 | esc_attr__( 'View Form %s.', 'give' ), |
| 905 | 996 | $donation->post_title |
| 906 | 997 | ), |
| 907 | 998 | __( 'View Form', 'give' ) |
| @@ -944,8 +1035,10 @@ | ||
| 944 | 1035 | |
| 945 | 1036 | /** |
| 946 | 1037 | * View the notes of a donor. |
| 947 | 1038 | * |
| 1039 | + * @since 4.16.6 Escaped the donor name output in the donor notes header. | |
| 1040 | + * @since 4.6.0 Escape donor note | |
| 948 | 1041 | * @since 1.0 |
| 949 | 1042 | * |
| 950 | 1043 | * @param Give_Donor $donor The donor object being displayed. |
| 951 | 1044 | * |
| @@ -962,9 +1055,9 @@ | ||
| 962 | 1055 | ?> |
| 963 | 1056 | |
| 964 | 1057 | <div id="donor-notes-wrapper"> |
| 965 | 1058 | <div class="donor-notes-header"> |
| 966 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> | |
| 1059 | + <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo esc_html( $donor->name ); ?></span> | |
| 967 | 1060 | </div> |
| 968 | 1061 | <h3><?php _e( 'Notes', 'give' ); ?></h3> |
| 969 | 1062 | |
| 970 | 1063 | <?php if ( 1 == $paged ) : ?> |
| @@ -969,9 +1062,9 @@ | ||
| 969 | 1062 | |
| 970 | 1063 | <?php if ( 1 == $paged ) : ?> |
| 971 | 1064 | <div style="display: block; margin-bottom: 55px;"> |
| 972 | 1065 | <form id="give-add-donor-note" method="post" |
| 973 | - action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>"> | |
| 1066 | + action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>"> | |
| 974 | 1067 | <textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea> |
| 975 | 1068 | <br/> |
| 976 | 1069 | <input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>"/> |
| 977 | 1070 | <input type="hidden" name="give_action" value="add-donor-note"/> |
| @@ -997,9 +1090,9 @@ | ||
| 997 | 1090 | <?php if ( count( $donor_notes ) > 0 ) { ?> |
| 998 | 1091 | <?php foreach ( $donor_notes as $key => $note ) : ?> |
| 999 | 1092 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
| 1000 | 1093 | <span class="note-content-wrap"> |
| 1001 | - <?php echo stripslashes( $note ); ?> | |
| 1094 | + <?php echo stripslashes( esc_html( $note ) ); ?> | |
| 1002 | 1095 | </span> |
| 1003 | 1096 | </div> |
| 1004 | 1097 | <?php endforeach; ?> |
| 1005 | 1098 | <?php } else { ?> |
| @@ -1016,10 +1109,11 @@ | ||
| 1016 | 1109 | <?php |
| 1017 | 1110 | } |
| 1018 | 1111 | |
| 1019 | 1112 | /** |
| 1020 | - * Thw donor delete view. | |
| 1113 | + * The donor delete view. | |
| 1021 | 1114 | * |
| 1115 | + * @since 4.16.6 Escaped the donor name output in the delete donor view. | |
| 1022 | 1116 | * @since 1.0 |
| 1023 | 1117 | * |
| 1024 | 1118 | * @param object $donor The donor object being displayed. |
| 1025 | 1119 | * |
| @@ -1041,12 +1135,12 @@ | ||
| 1041 | 1135 | |
| 1042 | 1136 | <div class="info-wrapper donor-section"> |
| 1043 | 1137 | |
| 1044 | 1138 | <form id="delete-donor" method="post" |
| 1045 | - action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>"> | |
| 1139 | + action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>"> | |
| 1046 | 1140 | |
| 1047 | 1141 | <div class="donor-notes-header"> |
| 1048 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> | |
| 1142 | + <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo esc_html( $donor->name ); ?></span> | |
| 1049 | 1143 | </div> |
| 1050 | 1144 | |
| 1051 | 1145 | |
| 1052 | 1146 | <div class="donor-info delete-donor"> |
| @@ -1052,22 +1146,30 @@ | ||
| 1052 | 1146 | <div class="donor-info delete-donor"> |
| 1053 | 1147 | |
| 1054 | 1148 | <span class="delete-donor-options"> |
| 1055 | 1149 | <p> |
| 1056 | - <?php echo Give()->html->checkbox( array( | |
| 1057 | - 'name' => 'give-donor-delete-confirm', | |
| 1058 | - ) ); ?> | |
| 1150 | + <?php | |
| 1151 | + echo Give()->html->checkbox( | |
| 1152 | + array( | |
| 1153 | + 'name' => 'give-donor-delete-confirm', | |
| 1154 | + ) | |
| 1155 | + ); | |
| 1156 | + ?> | |
| 1059 | 1157 | <label |
| 1060 | 1158 | for="give-donor-delete-confirm"><?php _e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
| 1061 | 1159 | </p> |
| 1062 | 1160 | |
| 1063 | 1161 | <p> |
| 1064 | - <?php echo Give()->html->checkbox( array( | |
| 1065 | - 'name' => 'give-donor-delete-records', | |
| 1066 | - 'options' => array( | |
| 1067 | - 'disabled' => true, | |
| 1068 | - ), | |
| 1069 | - ) ); ?> | |
| 1162 | + <?php | |
| 1163 | + echo Give()->html->checkbox( | |
| 1164 | + array( | |
| 1165 | + 'name' => 'give-donor-delete-records', | |
| 1166 | + 'options' => array( | |
| 1167 | + 'disabled' => true, | |
| 1168 | + ), | |
| 1169 | + ) | |
| 1170 | + ); | |
| 1171 | + ?> | |
| 1070 | 1172 | <label |
| 1071 | 1173 | for="give-donor-delete-records"><?php _e( 'Delete all associated donations and records?', 'give' ); ?></label> |
| 1072 | 1174 | </p> |
| 1073 | 1175 | |
| @@ -1089,11 +1191,11 @@ | ||
| 1089 | 1191 | <input type="hidden" name="donor_id" value="<?php echo $donor->id; ?>"/> |
| 1090 | 1192 | <?php wp_nonce_field( 'give-delete-donor', '_wpnonce', false, true ); ?> |
| 1091 | 1193 | <input type="hidden" name="give_action" value="delete_donor"/> |
| 1092 | 1194 | <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" |
| 1093 | - value="<?php _e( 'Delete Donor', 'give' ); ?>"/> | |
| 1195 | + value="<?php _e( 'Delete Donor', 'give' ); ?>"/> | |
| 1094 | 1196 | <a id="give-delete-donor-cancel" |
| 1095 | - href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>" | |
| 1197 | + href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=legacy-overview&id=' . $donor->id ); ?>" | |
| 1096 | 1198 | class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
| 1097 | 1199 | </span> |
| 1098 | 1200 | |
| 1099 | 1201 | </div> |