ravinderk /
Give
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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 | * Donors Page. |
||
| 19 | * |
||
| 20 | * Renders the donors page contents. |
||
| 21 | * |
||
| 22 | * @since 1.0 |
||
| 23 | * @return void |
||
| 24 | */ |
||
| 25 | function give_donors_page() { |
||
| 26 | $default_views = give_donor_views(); |
||
| 27 | $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors'; |
||
| 28 | if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
||
| 29 | give_render_donor_view( $requested_view, $default_views ); |
||
| 30 | } else { |
||
| 31 | give_donors_list(); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Register the views for donor management. |
||
| 37 | * |
||
| 38 | * @since 1.0 |
||
| 39 | * @return array Array of views and their callbacks. |
||
| 40 | */ |
||
| 41 | function give_donor_views() { |
||
| 42 | |||
| 43 | $views = array(); |
||
| 44 | |||
| 45 | return apply_filters( 'give_donor_views', $views ); |
||
| 46 | |||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Register the tabs for donor management. |
||
| 51 | * |
||
| 52 | * @since 1.0 |
||
| 53 | * @return array Array of tabs for the donor. |
||
| 54 | */ |
||
| 55 | function give_donor_tabs() { |
||
| 56 | |||
| 57 | $tabs = array(); |
||
| 58 | |||
| 59 | return apply_filters( 'give_donor_tabs', $tabs ); |
||
| 60 | |||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * List table of donors. |
||
| 65 | * |
||
| 66 | * @since 1.0 |
||
| 67 | * @return void |
||
| 68 | */ |
||
| 69 | function give_donors_list() { |
||
| 70 | include dirname( __FILE__ ) . '/class-donor-table.php'; |
||
| 71 | |||
| 72 | $donors_table = new Give_Donor_List_Table(); |
||
| 73 | $donors_table->prepare_items(); |
||
| 74 | ?> |
||
| 75 | <div class="wrap"> |
||
| 76 | <h1><?php echo get_admin_page_title(); ?></h1> |
||
| 77 | <?php |
||
| 78 | /** |
||
| 79 | * Fires in donors screen, above the table. |
||
| 80 | * |
||
| 81 | * @since 1.0 |
||
| 82 | */ |
||
| 83 | do_action( 'give_donors_table_top' ); |
||
| 84 | ?> |
||
| 85 | <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
||
| 86 | <?php |
||
| 87 | $donors_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' ); |
||
| 88 | $donors_table->display(); |
||
| 89 | ?> |
||
| 90 | <input type="hidden" name="post_type" value="give_forms" /> |
||
| 91 | <input type="hidden" name="page" value="give-donors" /> |
||
| 92 | <input type="hidden" name="view" value="donors" /> |
||
| 93 | </form> |
||
| 94 | <?php |
||
| 95 | /** |
||
| 96 | * Fires in donors screen, below the table. |
||
| 97 | * |
||
| 98 | * @since 1.0 |
||
| 99 | */ |
||
| 100 | do_action( 'give_donors_table_bottom' ); |
||
| 101 | ?> |
||
| 102 | </div> |
||
| 103 | <?php |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Renders the donor view wrapper. |
||
| 108 | * |
||
| 109 | * @since 1.0 |
||
| 110 | * |
||
| 111 | * @param string $view The View being requested. |
||
| 112 | * @param array $callbacks The Registered views and their callback functions. |
||
| 113 | * |
||
| 114 | * @return void |
||
| 115 | */ |
||
| 116 | function give_render_donor_view( $view, $callbacks ) { |
||
| 117 | |||
| 118 | $render = true; |
||
| 119 | |||
| 120 | $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
||
| 121 | |||
| 122 | if ( ! current_user_can( $donor_view_role ) ) { |
||
| 123 | give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) ); |
||
| 124 | $render = false; |
||
| 125 | } |
||
| 126 | |||
| 127 | if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
||
| 128 | give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
||
| 129 | $render = false; |
||
| 130 | } |
||
| 131 | |||
| 132 | $donor_id = (int) $_GET['id']; |
||
| 133 | $donor = new Give_Donor( $donor_id ); |
||
| 134 | |||
| 135 | if ( empty( $donor->id ) ) { |
||
| 136 | give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
||
| 137 | $render = false; |
||
| 138 | } |
||
| 139 | |||
| 140 | $donor_tabs = give_donor_tabs(); |
||
| 141 | ?> |
||
| 142 | |||
| 143 | <div class='wrap'> |
||
| 144 | |||
| 145 | <?php if ( give_get_errors() ) : ?> |
||
| 146 | <div class="error settings-error"> |
||
| 147 | <?php give_print_errors( 0 ); ?> |
||
| 148 | </div> |
||
| 149 | <?php endif; ?> |
||
| 150 | |||
| 151 | <h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1> |
||
| 152 | |||
| 153 | <?php if ( $donor && $render ) : ?> |
||
| 154 | |||
| 155 | <h2 class="nav-tab-wrapper"> |
||
| 156 | <?php |
||
| 157 | foreach ( $donor_tabs as $key => $tab ) : |
||
| 158 | $active = $key === $view ? true : false; |
||
| 159 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
||
| 160 | printf( |
||
| 161 | '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n", |
||
| 162 | esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ), |
||
| 163 | esc_attr( $class ), |
||
| 164 | sanitize_html_class( $tab['dashicon'] ), |
||
| 165 | esc_html( $tab['title'] ) |
||
| 166 | ); |
||
| 167 | endforeach; |
||
| 168 | ?> |
||
| 169 | </h2> |
||
| 170 | |||
| 171 | <div id="give-donor-card-wrapper"> |
||
| 172 | <?php $callbacks[ $view ]( $donor ) ?> |
||
| 173 | </div> |
||
| 174 | |||
| 175 | <?php endif; ?> |
||
| 176 | |||
| 177 | </div> |
||
| 178 | <?php |
||
| 179 | |||
| 180 | } |
||
| 181 | |||
| 182 | |||
| 183 | /** |
||
| 184 | * View a donor |
||
| 185 | * |
||
| 186 | * @since 1.0 |
||
| 187 | * |
||
| 188 | * @param object $donor The Donor object being displayed. |
||
| 189 | * |
||
| 190 | * @return void |
||
| 191 | */ |
||
| 192 | function give_donor_view( $donor ) { |
||
| 193 | |||
| 194 | $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Fires in donor profile screen, above the donor card. |
||
| 198 | * |
||
| 199 | * @since 1.0 |
||
| 200 | * |
||
| 201 | * @param object $donor The donor object being displayed. |
||
| 202 | */ |
||
| 203 | do_action( 'give_donor_card_top', $donor ); |
||
| 204 | ?> |
||
| 205 | |||
| 206 | <div id="donor-summary" class="info-wrapper donor-section postbox"> |
||
| 207 | |||
| 208 | <form id="edit-donor-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"> |
||
| 209 | |||
| 210 | <div class="donor-info"> |
||
| 211 | |||
| 212 | <div class="donor-bio-header clearfix"> |
||
| 213 | |||
| 214 | <div class="avatar-wrap left" id="donor-avatar"> |
||
| 215 | <?php echo get_avatar( $donor->email ); ?> |
||
| 216 | </div> |
||
| 217 | |||
| 218 | <div id="donor-name-wrap" class="left"> |
||
| 219 | <span class="donor-id">#<?php echo $donor->id; ?></span> |
||
| 220 | <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $donor->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span> |
||
| 221 | <span class="donor-name info-item editable"><span data-key="name"><?php echo $donor->name; ?></span></span> |
||
| 222 | </div> |
||
| 223 | <p class="donor-since info-item"> |
||
| 224 | <?php esc_html_e( 'Donor since', 'give' ); ?> |
||
| 225 | <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> |
||
| 226 | </p> |
||
| 227 | <?php if ( current_user_can( $donor_edit_role ) ) : ?> |
||
| 228 | <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a> |
||
| 229 | <?php endif; ?> |
||
| 230 | </div> |
||
| 231 | <!-- /donor-bio-header --> |
||
| 232 | |||
| 233 | <div class="donor-main-wrapper"> |
||
| 234 | |||
| 235 | <table class="widefat"> |
||
| 236 | <tbody> |
||
| 237 | <tr class="alternate"> |
||
| 238 | <th scope="col"><label for="tablecell"><?php esc_html_e( 'User:', 'give' ); ?></label></th> |
||
| 239 | <td> |
||
| 240 | <span class="donor-user-id info-item edit-item"> |
||
| 241 | <?php |
||
| 242 | |||
| 243 | $user_id = $donor->user_id > 0 ? $donor->user_id : ''; |
||
| 244 | |||
| 245 | $data_atts = array( |
||
| 246 | 'key' => 'user_login', |
||
| 247 | 'search-type' => 'user', |
||
| 248 | ); |
||
| 249 | $user_args = array( |
||
| 250 | 'name' => 'customerinfo[user_id]', |
||
| 251 | 'class' => 'give-user-dropdown', |
||
| 252 | 'data' => $data_atts, |
||
| 253 | ); |
||
| 254 | |||
| 255 | if ( ! empty( $user_id ) ) { |
||
| 256 | $userdata = get_userdata( $user_id ); |
||
| 257 | $user_args['selected'] = $user_id; |
||
| 258 | } |
||
| 259 | |||
| 260 | echo Give()->html->ajax_user_search( $user_args ); |
||
| 261 | ?> |
||
| 262 | </span> |
||
| 263 | |||
| 264 | <span class="donor-user-id info-item editable"> |
||
| 265 | <?php if ( ! empty( $userdata ) ) { ?> |
||
| 266 | <span data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span> |
||
| 267 | <?php } else { ?> |
||
| 268 | <span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span> |
||
| 269 | <?php } ?> |
||
| 270 | <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) { ?> |
||
| 271 | <span class="disconnect-user"> - <a id="disconnect-donor" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this donor record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span> |
||
| 272 | <?php } ?> |
||
| 273 | </span> |
||
| 274 | </td> |
||
| 275 | </tr> |
||
| 276 | <?php if ( isset( $donor->user_id ) && $donor->user_id > 0 ) : ?> |
||
| 277 | |||
| 278 | <tr> |
||
| 279 | <th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th> |
||
| 280 | <td class="row-title"> |
||
| 281 | |||
| 282 | <div class="donor-address-wrapper"> |
||
| 283 | |||
| 284 | <?php |
||
| 285 | $address = get_user_meta( $donor->user_id, '_give_user_address', true ); |
||
| 286 | $defaults = array( |
||
| 287 | 'line1' => '', |
||
| 288 | 'line2' => '', |
||
| 289 | 'city' => '', |
||
| 290 | 'state' => '', |
||
| 291 | 'country' => '', |
||
| 292 | 'zip' => '', |
||
| 293 | ); |
||
| 294 | |||
| 295 | $address = wp_parse_args( $address, $defaults ); |
||
| 296 | ?> |
||
| 297 | |||
| 298 | <?php if ( ! empty( $address ) ) { ?> |
||
| 299 | <span class="donor-address info-item editable"> |
||
| 300 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
||
| 301 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
||
| 302 | <span class="info-item" data-key="city"><?php echo $address['city']; ?></span> |
||
| 303 | <span class="info-item" data-key="state"><?php echo $address['state']; ?></span> |
||
| 304 | <span class="info-item" data-key="country"><?php echo $address['country']; ?></span> |
||
| 305 | <span class="info-item" data-key="zip"><?php echo $address['zip']; ?></span> |
||
| 306 | </span> |
||
| 307 | <?php } ?> |
||
| 308 | <span class="donor-address info-item edit-item"> |
||
| 309 | <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
||
| 310 | <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
||
| 311 | <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
||
| 312 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
||
| 313 | <?php |
||
| 314 | |||
| 315 | $selected_country = $address['country']; |
||
| 316 | |||
| 317 | $countries = give_get_country_list(); |
||
| 318 | foreach ( $countries as $country_code => $country ) { |
||
| 319 | echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
||
| 320 | } |
||
| 321 | ?> |
||
| 322 | </select> |
||
| 323 | <?php |
||
| 324 | $selected_state = give_get_state(); |
||
| 325 | $states = give_get_states( $selected_country ); |
||
| 326 | |||
| 327 | $selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state; |
||
| 328 | |||
| 329 | if ( ! empty( $states ) ) { |
||
| 330 | ?> |
||
| 331 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
||
| 332 | <?php |
||
| 333 | foreach ( $states as $state_code => $state ) { |
||
| 334 | echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
||
| 335 | } |
||
| 336 | ?> |
||
| 337 | </select> |
||
| 338 | <?php |
||
| 339 | } else { |
||
| 340 | ?> |
||
| 341 | <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>" /> |
||
| 342 | <?php |
||
| 343 | } |
||
| 344 | ?> |
||
| 345 | <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
||
| 346 | </span> |
||
| 347 | |||
| 348 | </div> |
||
| 349 | </td> |
||
| 350 | </tr> |
||
| 351 | <?php endif; ?> |
||
| 352 | </tbody> |
||
| 353 | </table> |
||
| 354 | |||
| 355 | </div> |
||
| 356 | |||
| 357 | </div> |
||
| 358 | |||
| 359 | <span id="donor-edit-actions" class="edit-item"> |
||
| 360 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $donor->id; ?>" /> |
||
| 361 | <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?> |
||
| 362 | <input type="hidden" name="give_action" value="edit-donor" /> |
||
| 363 | <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" /> |
||
| 364 | <a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
||
| 365 | </span> |
||
| 366 | |||
| 367 | </form> |
||
| 368 | |||
| 369 | </div> |
||
| 370 | |||
| 371 | <?php |
||
| 372 | /** |
||
| 373 | * Fires in donor profile screen, above the stats list. |
||
| 374 | * |
||
| 375 | * @since 1.0 |
||
| 376 | * |
||
| 377 | * @param object $donor The donor object being displayed. |
||
| 378 | */ |
||
| 379 | do_action( 'give_donor_before_stats', $donor ); |
||
| 380 | ?> |
||
| 381 | |||
| 382 | <div id="donor-stats-wrapper" class="donor-section postbox clear"> |
||
| 383 | <ul> |
||
| 384 | <li> |
||
| 385 | <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $donor->email ) ); ?>"> |
||
| 386 | <span class="dashicons dashicons-heart"></span> |
||
| 387 | <?php |
||
| 388 | // Completed Donations |
||
| 389 | $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count ); |
||
| 390 | echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor ); |
||
| 391 | ?> |
||
| 392 | </a> |
||
| 393 | </li> |
||
| 394 | <li> |
||
| 395 | <span class="dashicons dashicons-chart-area"></span> |
||
| 396 | <?php echo give_currency_filter( give_format_amount( $donor->purchase_value ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?> |
||
| 397 | </li> |
||
| 398 | <?php |
||
| 399 | /** |
||
| 400 | * Fires in donor profile screen, in the stats list. |
||
| 401 | * |
||
| 402 | * Allows you to add more list items to the stats list. |
||
| 403 | * |
||
| 404 | * @since 1.0 |
||
| 405 | * |
||
| 406 | * @param object $donor The donor object being displayed. |
||
| 407 | */ |
||
| 408 | do_action( 'give_donor_stats_list', $donor ); |
||
| 409 | ?> |
||
| 410 | </ul> |
||
| 411 | </div> |
||
| 412 | |||
| 413 | <?php |
||
| 414 | /** |
||
| 415 | * Fires in donor profile screen, above the tables wrapper. |
||
| 416 | * |
||
| 417 | * @since 1.0 |
||
| 418 | * |
||
| 419 | * @param object $donor The donor object being displayed. |
||
| 420 | */ |
||
| 421 | do_action( 'give_donor_before_tables_wrapper', $donor ); |
||
| 422 | ?> |
||
| 423 | |||
| 424 | <div id="donor-tables-wrapper" class="donor-section"> |
||
| 425 | |||
| 426 | <?php |
||
| 427 | /** |
||
| 428 | * Fires in donor profile screen, above the tables. |
||
| 429 | * |
||
| 430 | * @since 1.0 |
||
| 431 | * |
||
| 432 | * @param object $donor The donor object being displayed. |
||
| 433 | */ |
||
| 434 | do_action( 'give_donor_before_tables', $donor ); |
||
| 435 | ?> |
||
| 436 | |||
| 437 | <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
||
| 438 | |||
| 439 | <table class="wp-list-table widefat striped emails"> |
||
| 440 | <thead> |
||
| 441 | <tr> |
||
| 442 | <th><?php _e( 'Email', 'give' ); ?></th> |
||
| 443 | <th><?php _e( 'Actions', 'give' ); ?></th> |
||
| 444 | </tr> |
||
| 445 | </thead> |
||
| 446 | |||
| 447 | <tbody> |
||
| 448 | <?php if ( ! empty( $donor->emails ) ) { ?> |
||
| 449 | |||
| 450 | <?php foreach ( $donor->emails as $key => $email ) : ?> |
||
| 451 | <tr data-key="<?php echo $key; ?>"> |
||
| 452 | <td> |
||
| 453 | <?php echo $email; ?> |
||
| 454 | <?php if ( 'primary' === $key ) : ?> |
||
| 455 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
||
| 456 | <?php endif; ?> |
||
| 457 | </td> |
||
| 458 | <td> |
||
| 459 | <?php if ( 'primary' !== $key ) : ?> |
||
| 460 | <?php |
||
| 461 | $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); |
||
| 462 | $promote_url = wp_nonce_url( add_query_arg( array( |
||
| 463 | 'email' => rawurlencode( $email ), |
||
| 464 | 'give_action' => 'set_donor_primary_email', |
||
| 465 | ), $base_url ), 'give-set-donor-primary-email' ); |
||
| 466 | $remove_url = wp_nonce_url( add_query_arg( array( |
||
| 467 | 'email' => rawurlencode( $email ), |
||
| 468 | 'give_action' => 'remove_donor_email', |
||
| 469 | ), $base_url ), 'give-remove-donor-email' ); |
||
| 470 | ?> |
||
| 471 | <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
||
| 472 | | |
||
| 473 | <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
||
| 474 | <?php endif; ?> |
||
| 475 | </td> |
||
| 476 | </tr> |
||
| 477 | <?php endforeach; ?> |
||
| 478 | |||
| 479 | <tr class="add-donor-email-row"> |
||
| 480 | <td colspan="2" class="add-donor-email-td"> |
||
| 481 | <div class="add-donor-email-wrapper"> |
||
| 482 | <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>" /> |
||
| 483 | <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
||
| 484 | <input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" /> |
||
| 485 | <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
||
| 486 | <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> |
||
| 487 | <span class="spinner"></span> |
||
| 488 | </div> |
||
| 489 | <div class="notice-wrap"></div> |
||
| 490 | </td> |
||
| 491 | </tr> |
||
| 492 | <?php } else { ?> |
||
| 493 | <tr><td colspan="2"><?php _e( 'No Emails Found', 'easy-digital-downloads' ); ?></td></tr> |
||
| 494 | <?php }// End if(). |
||
|
0 ignored issues
–
show
|
|||
| 495 | ?> |
||
| 496 | </tbody> |
||
| 497 | </table> |
||
| 498 | |||
| 499 | <h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3> |
||
| 500 | <?php |
||
| 501 | $payment_ids = explode( ',', $donor->payment_ids ); |
||
| 502 | $payments = give_get_payments( array( |
||
| 503 | 'post__in' => $payment_ids, |
||
| 504 | ) ); |
||
| 505 | $payments = array_slice( $payments, 0, 10 ); |
||
| 506 | ?> |
||
| 507 | <table class="wp-list-table widefat striped payments"> |
||
| 508 | <thead> |
||
| 509 | <tr> |
||
| 510 | <th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th> |
||
| 511 | <th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th> |
||
| 512 | <th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th> |
||
| 513 | <th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th> |
||
| 514 | <th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
||
| 515 | </tr> |
||
| 516 | </thead> |
||
| 517 | <tbody> |
||
| 518 | <?php if ( ! empty( $payments ) ) { ?> |
||
| 519 | <?php foreach ( $payments as $payment ) : ?> |
||
| 520 | <tr> |
||
| 521 | <td><?php echo $payment->ID; ?></td> |
||
| 522 | <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
||
| 523 | <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
||
| 524 | <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
||
| 525 | <td> |
||
| 526 | <?php |
||
| 527 | printf( |
||
| 528 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
||
| 529 | admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ), |
||
| 530 | sprintf( |
||
| 531 | /* translators: %s: Donation ID */ |
||
| 532 | esc_attr__( 'View Donation %s.', 'give' ), |
||
| 533 | $payment->ID |
||
| 534 | ), |
||
| 535 | esc_html__( 'View Donation', 'give' ) |
||
| 536 | ); |
||
| 537 | ?> |
||
| 538 | |||
| 539 | <?php |
||
| 540 | /** |
||
| 541 | * Fires in donor profile screen, in the recent donations tables action links. |
||
| 542 | * |
||
| 543 | * Allows you to add more action links for each donation, after the 'View Donation' action link. |
||
| 544 | * |
||
| 545 | * @since 1.0 |
||
| 546 | * |
||
| 547 | * @param object $donor The donor object being displayed. |
||
| 548 | * @param object $payment The payment object being displayed. |
||
| 549 | */ |
||
| 550 | do_action( 'give_donor_recent_purchases_actions', $donor, $payment ); |
||
| 551 | ?> |
||
| 552 | </td> |
||
| 553 | </tr> |
||
| 554 | <?php endforeach; ?> |
||
| 555 | <?php } else { ?> |
||
| 556 | <tr> |
||
| 557 | <td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td> |
||
| 558 | </tr> |
||
| 559 | <?php }// End if(). |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 560 | ?> |
||
| 561 | </tbody> |
||
| 562 | </table> |
||
| 563 | |||
| 564 | <h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3> |
||
| 565 | <?php |
||
| 566 | $donations = give_get_users_completed_donations( $donor->email ); |
||
| 567 | ?> |
||
| 568 | <table class="wp-list-table widefat striped donations"> |
||
| 569 | <thead> |
||
| 570 | <tr> |
||
| 571 | <th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th> |
||
| 572 | <th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
||
| 573 | </tr> |
||
| 574 | </thead> |
||
| 575 | <tbody> |
||
| 576 | <?php if ( ! empty( $donations ) ) { ?> |
||
| 577 | <?php foreach ( $donations as $donation ) : ?> |
||
| 578 | <tr> |
||
| 579 | <td><?php echo $donation->post_title; ?></td> |
||
| 580 | <td> |
||
| 581 | <?php |
||
| 582 | printf( |
||
| 583 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
||
| 584 | esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
||
| 585 | sprintf( |
||
| 586 | /* translators: %s: form name */ |
||
| 587 | esc_attr__( 'View Form %s.', 'give' ), |
||
| 588 | $donation->post_title |
||
| 589 | ), |
||
| 590 | esc_html__( 'View Form', 'give' ) |
||
| 591 | ); |
||
| 592 | ?> |
||
| 593 | </td> |
||
| 594 | </tr> |
||
| 595 | <?php endforeach; ?> |
||
| 596 | <?php } else { ?> |
||
| 597 | <tr> |
||
| 598 | <td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td> |
||
| 599 | </tr> |
||
| 600 | <?php } ?> |
||
| 601 | </tbody> |
||
| 602 | </table> |
||
| 603 | |||
| 604 | <?php |
||
| 605 | /** |
||
| 606 | * Fires in donor profile screen, below the tables. |
||
| 607 | * |
||
| 608 | * @since 1.0 |
||
| 609 | * |
||
| 610 | * @param object $donor The donor object being displayed. |
||
| 611 | */ |
||
| 612 | do_action( 'give_donor_after_tables', $donor ); |
||
| 613 | ?> |
||
| 614 | |||
| 615 | </div> |
||
| 616 | |||
| 617 | <?php |
||
| 618 | /** |
||
| 619 | * Fires in donor profile screen, below the donor card. |
||
| 620 | * |
||
| 621 | * @since 1.0 |
||
| 622 | * |
||
| 623 | * @param object $donor The donor object being displayed. |
||
| 624 | */ |
||
| 625 | do_action( 'give_donor_card_bottom', $donor ); |
||
| 626 | |||
| 627 | } |
||
| 628 | |||
| 629 | /** |
||
| 630 | * View the notes of a donor. |
||
| 631 | * |
||
| 632 | * @since 1.0 |
||
| 633 | * |
||
| 634 | * @param object $donor The donor object being displayed. |
||
| 635 | * |
||
| 636 | * @return void |
||
| 637 | */ |
||
| 638 | function give_donor_notes_view( $donor ) { |
||
| 639 | |||
| 640 | $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
||
| 641 | $paged = absint( $paged ); |
||
| 642 | $note_count = $donor->get_notes_count(); |
||
| 643 | $per_page = apply_filters( 'give_donor_notes_per_page', 20 ); |
||
| 644 | $total_pages = ceil( $note_count / $per_page ); |
||
| 645 | $donor_notes = $donor->get_notes( $per_page, $paged ); |
||
| 646 | ?> |
||
| 647 | |||
| 648 | <div id="donor-notes-wrapper"> |
||
| 649 | <div class="donor-notes-header"> |
||
| 650 | <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
||
| 651 | </div> |
||
| 652 | <h3><?php esc_html_e( 'Notes', 'give' ); ?></h3> |
||
| 653 | |||
| 654 | <?php if ( 1 == $paged ) : ?> |
||
| 655 | <div style="display: block; margin-bottom: 55px;"> |
||
| 656 | <form id="give-add-donor-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>"> |
||
| 657 | <textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea> |
||
| 658 | <br /> |
||
| 659 | <input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>" /> |
||
| 660 | <input type="hidden" name="give_action" value="add-donor-note" /> |
||
| 661 | <?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?> |
||
| 662 | <input id="add-donor-note" class="right button-primary" type="submit" value="Add Note" /> |
||
| 663 | </form> |
||
| 664 | </div> |
||
| 665 | <?php endif; ?> |
||
| 666 | |||
| 667 | <?php |
||
| 668 | $pagination_args = array( |
||
| 669 | 'base' => '%_%', |
||
| 670 | 'format' => '?paged=%#%', |
||
| 671 | 'total' => $total_pages, |
||
| 672 | 'current' => $paged, |
||
| 673 | 'show_all' => true, |
||
| 674 | ); |
||
| 675 | |||
| 676 | echo paginate_links( $pagination_args ); |
||
| 677 | ?> |
||
| 678 | |||
| 679 | <div id="give-donor-notes" class="postbox"> |
||
| 680 | <?php if ( count( $donor_notes ) > 0 ) { ?> |
||
| 681 | <?php foreach ( $donor_notes as $key => $note ) : ?> |
||
| 682 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
||
| 683 | <span class="note-content-wrap"> |
||
| 684 | <?php echo stripslashes( $note ); ?> |
||
| 685 | </span> |
||
| 686 | </div> |
||
| 687 | <?php endforeach; ?> |
||
| 688 | <?php } else { ?> |
||
| 689 | <div class="give-no-donor-notes"> |
||
| 690 | <?php esc_html_e( 'No donor notes found.', 'give' ); ?> |
||
| 691 | </div> |
||
| 692 | <?php } ?> |
||
| 693 | </div> |
||
| 694 | |||
| 695 | <?php echo paginate_links( $pagination_args ); ?> |
||
| 696 | |||
| 697 | </div> |
||
| 698 | |||
| 699 | <?php |
||
| 700 | } |
||
| 701 | |||
| 702 | /** |
||
| 703 | * Thw donor delete view. |
||
| 704 | * |
||
| 705 | * @since 1.0 |
||
| 706 | * |
||
| 707 | * @param object $donor The donor object being displayed. |
||
| 708 | * |
||
| 709 | * @return void |
||
| 710 | */ |
||
| 711 | function give_donor_delete_view( $donor ) { |
||
| 712 | |||
| 713 | $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
||
| 714 | |||
| 715 | /** |
||
| 716 | * Fires in donor delete screen, above the content. |
||
| 717 | * |
||
| 718 | * @since 1.0 |
||
| 719 | * |
||
| 720 | * @param object $donor The donor object being displayed. |
||
| 721 | */ |
||
| 722 | do_action( 'give_donor_delete_top', $donor ); |
||
| 723 | ?> |
||
| 724 | |||
| 725 | <div class="info-wrapper donor-section"> |
||
| 726 | |||
| 727 | <form id="delete-donor" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>"> |
||
| 728 | |||
| 729 | <div class="donor-notes-header"> |
||
| 730 | <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
||
| 731 | </div> |
||
| 732 | |||
| 733 | |||
| 734 | <div class="donor-info delete-donor"> |
||
| 735 | |||
| 736 | <span class="delete-donor-options"> |
||
| 737 | <p> |
||
| 738 | <?php echo Give()->html->checkbox( array( |
||
| 739 | 'name' => 'give-donor-delete-confirm', |
||
| 740 | ) ); ?> |
||
| 741 | <label for="give-donor-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
||
| 742 | </p> |
||
| 743 | |||
| 744 | <p> |
||
| 745 | <?php echo Give()->html->checkbox( array( |
||
| 746 | 'name' => 'give-donor-delete-records', |
||
| 747 | 'options' => array( |
||
| 748 | 'disabled' => true, |
||
| 749 | ), |
||
| 750 | ) ); ?> |
||
| 751 | <label for="give-donor-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label> |
||
| 752 | </p> |
||
| 753 | |||
| 754 | <?php |
||
| 755 | /** |
||
| 756 | * Fires in donor delete screen, bellow the delete inputs. |
||
| 757 | * |
||
| 758 | * Allows you to add custom delete inputs. |
||
| 759 | * |
||
| 760 | * @since 1.0 |
||
| 761 | * |
||
| 762 | * @param object $donor The donor object being displayed. |
||
| 763 | */ |
||
| 764 | do_action( 'give_donor_delete_inputs', $donor ); |
||
| 765 | ?> |
||
| 766 | </span> |
||
| 767 | |||
| 768 | <span id="donor-edit-actions"> |
||
| 769 | <input type="hidden" name="customer_id" value="<?php echo $donor->id; ?>" /> |
||
| 770 | <?php wp_nonce_field( 'delete-donor', '_wpnonce', false, true ); ?> |
||
| 771 | <input type="hidden" name="give_action" value="delete-donor" /> |
||
| 772 | <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" /> |
||
| 773 | <a id="give-delete-donor-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
||
| 774 | </span> |
||
| 775 | |||
| 776 | </div> |
||
| 777 | |||
| 778 | </form> |
||
| 779 | </div> |
||
| 780 | |||
| 781 | <?php |
||
| 782 | /** |
||
| 783 | * Fires in donor delete screen, bellow the content. |
||
| 784 | * |
||
| 785 | * @since 1.0 |
||
| 786 | * |
||
| 787 | * @param object $donor The donor object being displayed. |
||
| 788 | */ |
||
| 789 | do_action( 'give_donor_delete_bottom', $donor ); |
||
| 790 | } |
||
| 791 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.