Test Failed
Push — release/1.8.12 ( b58a2f...d255b1 )
by Ravinder
375:09 queued 372:17
created

templates/history-donations.php (7 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * This template is used to display the donation history of the current user.
4
 */
5
6
// User's Donations
7
if ( is_user_logged_in() ) {
8
	$donations = give_get_users_donations( get_current_user_id(), 20, true, 'any' );
9
} elseif ( Give()->email_access->token_exists ) {
10
	// Email Access Token?
11
	$donations = give_get_users_donations( 0, 20, true, 'any' );
12
} elseif ( Give()->session->get_session_expiration() !== false ) {
0 ignored issues
show
Found "!== false". Use Yoda Condition checks, you must
Loading history...
13
	// Session active?
14
	$email     = Give()->session->get( 'give_email' );
15
	$donations = give_get_users_donations( $email, 20, true, 'any' );
16
}
17
18
if ( $donations ) : ?>
19
    <table id="give_user_history" class="give-table">
20
        <thead>
21
        <tr class="give-donation-row">
22
			<?php
23
			/**
24
			 * Fires in current user donation history table, before the header row start.
25
			 *
26
			 * Allows you to add new <th> elements to the header, before other headers in the row.
27
			 *
28
			 * @since 1.7
29
			 */
30
			do_action( 'give_donation_history_header_before' );
31
			?>
32
            <th scope="col" class="give-donation-id"><?php esc_html_e( 'ID', 'give' ); ?></th>
33
            <th scope="col" class="give-donation-date"><?php esc_html_e( 'Date', 'give' ); ?></th>
34
            <th scope="col" class="give-donation-amount"><?php esc_html_e( 'Amount', 'give' ); ?></th>
35
            <th scope="col" class="give-donation-details"><?php esc_html_e( 'Details', 'give' ); ?></th>
36
			<?php
37
			/**
38
			 * Fires in current user donation history table, after the header row ends.
39
			 *
40
			 * Allows you to add new <th> elements to the header, after other headers in the row.
41
			 *
42
			 * @since 1.7
43
			 */
44
			do_action( 'give_donation_history_header_after' );
45
			?>
46
        </tr>
47
        </thead>
48
		<?php foreach ( $donations as $post ) :
49
			setup_postdata( $post );
50
			$donation_data = give_get_payment_meta( $post->ID ); ?>
51
            <tr class="give-donation-row">
52
				<?php
53
				/**
54
				 * Fires in current user donation history table, before the row statrs.
55
				 *
56
				 * Allows you to add new <td> elements to the row, before other elements in the row.
57
				 *
58
				 * @since 1.7
59
				 *
60
				 * @param int   $post_id       The ID of the post.
61
				 * @param mixed $donation_data Payment meta data.
62
				 */
63
				do_action( 'give_donation_history_row_start', $post->ID, $donation_data );
64
				?>
65
                <td class="give-donation-id">#<?php echo give_get_payment_number( $post->ID ); ?></td>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'give_get_payment_number'
Loading history...
66
                <td class="give-donation-date"><?php echo date_i18n( give_date_format(), strtotime( get_post_field( 'post_date', $post->ID ) ) ); ?></td>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'date_i18n'
Loading history...
67
                <td class="give-donation-amount">
68
                    <span class="give-donation-amount"><?php echo give_currency_filter( give_format_amount( give_get_payment_amount( $post->ID ), array( 'sanitize' => false ) ) ); ?></span>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'give_currency_filter'
Loading history...
69
                </td>
70
                <td class="give-donation-details">
71
					<?php
72
					// Display View Receipt or
73
					if ( 'publish' !== $post->post_status
74
					     && 'subscription' !== $post->post_status
75
					) : ?>
76
                        <a href="<?php echo esc_url( add_query_arg( 'payment_key', give_get_payment_key( $post->ID ), give_get_history_page_uri() ) ); ?>"><span
77
                                    class="give-donation-status <?php echo $post->post_status; ?>"><?php echo esc_html__( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' &raquo;'; ?></span></a>
0 ignored issues
show
Expected next thing to be a escaping function, not '$post'
Loading history...
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'give_get_payment_status'
Loading history...
78
					<?php else : ?>
79
                        <a href="<?php echo esc_url( add_query_arg( 'payment_key', give_get_payment_key( $post->ID ), give_get_history_page_uri() ) ); ?>"><?php esc_html_e( 'View Receipt &raquo;', 'give' ); ?></a>
80
					<?php endif; ?>
81
                </td>
82
				<?php
83
				/**
84
				 * Fires in current user donation history table, after the row ends.
85
				 *
86
				 * Allows you to add new <td> elements to the row, after other elements in the row.
87
				 *
88
				 * @since 1.7
89
				 *
90
				 * @param int   $post_id       The ID of the post.
91
				 * @param mixed $donation_data Payment meta data.
92
				 */
93
				do_action( 'give_donation_history_row_end', $post->ID, $donation_data );
94
				?>
95
            </tr>
96
		<?php endforeach; ?>
97
    </table>
98
    <div id="give-donation-history-pagination" class="give_pagination navigation">
99
		<?php
100
		$big = 999999;
101
		echo paginate_links( array(
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'paginate_links'
Loading history...
102
			'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
103
			'format'  => '?paged=%#%',
104
			'current' => max( 1, get_query_var( 'paged' ) ),
105
			'total'   => ceil( give_count_donations_of_donor() / 20 ) // 20 items per page
106
		) );
107
		?>
108
    </div>
109
	<?php wp_reset_postdata(); ?>
110
<?php else : ?>
111
	<?php Give()->notices->print_frontend_notice( esc_html__( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?>
112
<?php endif;
113