This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | $donations = array(); |
||
7 | $donation_history_args = Give()->session->get( 'give_donation_history_args' ); |
||
8 | |||
9 | // User's Donations. |
||
10 | if ( is_user_logged_in() ) { |
||
11 | $donations = give_get_users_donations( get_current_user_id(), 20, true, 'any' ); |
||
12 | } elseif ( Give()->email_access->token_exists ) { |
||
13 | // Email Access Token? |
||
14 | $donations = give_get_users_donations( 0, 20, true, 'any' ); |
||
15 | } elseif ( |
||
16 | false !== Give()->session->get_session_expiration() || |
||
17 | true === give_get_history_session() |
||
18 | ) { |
||
19 | // Session active? |
||
20 | $email = Give()->session->get( 'give_email' ); |
||
21 | $donor = Give()->donors->get_donor_by( 'email', $email ); |
||
0 ignored issues
–
show
|
|||
22 | $donations_count = count( explode( ',', $donor->payment_ids ) ); |
||
23 | |||
24 | if ( $donations_count > give_get_limit_display_donations() ) { |
||
25 | |||
26 | // Restrict Security Email Access option, if donation count of a donor is less than or equal to limit. |
||
27 | if ( true !== Give_Cache::get( "give_cache_email_throttle_limit_exhausted_{$donor->id}" ) ) { |
||
28 | add_action( 'give_donation_history_table_end', 'give_donation_history_table_end' ); |
||
29 | } else { |
||
30 | $value = Give()->email_access->verify_throttle / 60; |
||
31 | |||
32 | /** |
||
33 | * Filter to modify email access exceed notices message. |
||
34 | * |
||
35 | * @since 2.1.3 |
||
36 | * |
||
37 | * @param string $message email access exceed notices message |
||
38 | * @param int $value email access exceed times |
||
39 | * |
||
40 | * @return string $message email access exceed notices message |
||
41 | */ |
||
42 | $message = (string) apply_filters( |
||
43 | 'give_email_access_requests_exceed_notice', |
||
44 | sprintf( |
||
45 | __( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ), |
||
46 | sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value ) |
||
47 | ), |
||
48 | $value |
||
49 | ); |
||
50 | |||
51 | give_set_error( 'give-limited-throttle', |
||
52 | $message |
||
53 | ); |
||
54 | } |
||
55 | |||
56 | $donations = give_get_users_donations( $email, give_get_limit_display_donations(), true, 'any' ); |
||
0 ignored issues
–
show
$email is of type string|array , but the function expects a integer .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
57 | } else { |
||
58 | $donations = give_get_users_donations( $email, 20, true, 'any' ); |
||
0 ignored issues
–
show
$email is of type string|array , but the function expects a integer .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
59 | } |
||
60 | } |
||
61 | |||
62 | Give()->notices->render_frontend_notices( 0 ); |
||
63 | |||
64 | if ( $donations ) : ?> |
||
65 | <?php |
||
66 | $table_headings = array( |
||
67 | 'id' => __( 'ID', 'give' ), |
||
68 | 'date' => __( 'Date', 'give' ), |
||
69 | 'donor' => __( 'Donor', 'give' ), |
||
70 | 'amount' => __( 'Amount', 'give' ), |
||
71 | 'status' => __( 'Status', 'give' ), |
||
72 | 'payment_method' => __( 'Payment Method', 'give' ), |
||
73 | 'details' => __( 'Details', 'give' ), |
||
74 | ); |
||
75 | ?> |
||
76 | <div class="give_user_history_main" > |
||
77 | <div class="give_user_history_notice"></div> |
||
78 | <table id="give_user_history" class="give-table"> |
||
79 | <thead> |
||
80 | <tr class="give-donation-row"> |
||
81 | <?php |
||
82 | /** |
||
83 | * Fires in current user donation history table, before the header row start. |
||
84 | * |
||
85 | * Allows you to add new <th> elements to the header, before other headers in the row. |
||
86 | * |
||
87 | * @since 1.7 |
||
88 | */ |
||
89 | do_action( 'give_donation_history_header_before' ); |
||
90 | |||
91 | foreach ( $donation_history_args as $index => $value ) { |
||
0 ignored issues
–
show
The expression
$donation_history_args of type string|array is not guaranteed to be traversable. How about adding an additional type check?
There are different options of fixing this problem.
![]() |
|||
92 | if ( filter_var( $donation_history_args[ $index ], FILTER_VALIDATE_BOOLEAN ) ) : |
||
93 | echo sprintf( |
||
0 ignored issues
–
show
|
|||
94 | '<th scope="col" class="give-donation-%1$s>">%2$s</th>', |
||
95 | $index, |
||
96 | $table_headings[ $index ] |
||
97 | ); |
||
98 | endif; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Fires in current user donation history table, after the header row ends. |
||
103 | * |
||
104 | * Allows you to add new <th> elements to the header, after other headers in the row. |
||
105 | * |
||
106 | * @since 1.7 |
||
107 | */ |
||
108 | do_action( 'give_donation_history_header_after' ); |
||
109 | ?> |
||
110 | </tr> |
||
111 | </thead> |
||
112 | <?php foreach ( $donations as $post ) : |
||
113 | setup_postdata( $post ); |
||
114 | $donation_data = give_get_payment_meta( $post->ID ); ?> |
||
115 | <tr class="give-donation-row"> |
||
116 | <?php |
||
117 | /** |
||
118 | * Fires in current user donation history table, before the row statrs. |
||
119 | * |
||
120 | * Allows you to add new <td> elements to the row, before other elements in the row. |
||
121 | * |
||
122 | * @since 1.7 |
||
123 | * |
||
124 | * @param int $post_id The ID of the post. |
||
125 | * @param mixed $donation_data Payment meta data. |
||
126 | */ |
||
127 | do_action( 'give_donation_history_row_start', $post->ID, $donation_data ); |
||
128 | |||
129 | if ( filter_var( $donation_history_args['id'], FILTER_VALIDATE_BOOLEAN ) ) : |
||
130 | echo sprintf( |
||
0 ignored issues
–
show
|
|||
131 | '<td class="give-donation-id"><span class="title-for-mobile">%2$s</span>%1$s</td>', |
||
132 | give_get_payment_number( $post->ID ), esc_html( $table_headings['id'] ) |
||
133 | ); |
||
134 | endif; |
||
135 | |||
136 | if ( filter_var( $donation_history_args['date'], FILTER_VALIDATE_BOOLEAN ) ) : |
||
137 | echo sprintf( |
||
0 ignored issues
–
show
|
|||
138 | '<td class="give-donation-date"><span class="title-for-mobile">%2$s</span>%1$s</td>', |
||
139 | date_i18n( give_date_format(), strtotime( get_post_field( 'post_date', $post->ID ) ) ), esc_html( $table_headings['date'] ) |
||
140 | ); |
||
141 | endif; |
||
142 | |||
143 | if ( filter_var( $donation_history_args['donor'], FILTER_VALIDATE_BOOLEAN ) ) : |
||
144 | echo sprintf( |
||
0 ignored issues
–
show
|
|||
145 | '<td class="give-donation-donor"><span class="title-for-mobile">%2$s</span>%1$s</td>', |
||
146 | give_get_donor_name_by( $post->ID ), $table_headings['donor'] |
||
147 | ); |
||
148 | endif; |
||
149 | ?> |
||
150 | |||
151 | <?php if ( filter_var( $donation_history_args['amount'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
||
152 | <td class="give-donation-amount"> |
||
153 | <?php printf( '<span class="title-for-mobile">%1$s</span>', esc_html( $table_headings['amount'] ) ); ?> |
||
154 | <span class="give-donation-amount"> |
||
155 | <?php |
||
156 | $currency_code = give_get_payment_currency_code( $post->ID ); |
||
157 | $donation_amount = give_donation_amount( $post->ID, true ); |
||
158 | |||
159 | /** |
||
160 | * Filters the donation amount on Donation History Page. |
||
161 | * |
||
162 | * @param int $donation_amount Donation Amount. |
||
163 | * @param int $post_id Donation ID. |
||
164 | * |
||
165 | * @since 1.8.13 |
||
166 | * |
||
167 | * @return int |
||
168 | */ |
||
169 | echo apply_filters( 'give_donation_history_row_amount', $donation_amount, $post->ID ); |
||
0 ignored issues
–
show
|
|||
170 | ?> |
||
171 | </span> |
||
172 | </td> |
||
173 | <?php endif; ?> |
||
174 | |||
175 | <?php |
||
176 | View Code Duplication | if ( filter_var( $donation_history_args['status'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
177 | echo sprintf( |
||
0 ignored issues
–
show
|
|||
178 | '<td class="give-donation-status"><span class="title-for-mobile">%2$s</span>%1$s</td>', |
||
179 | give_get_payment_status( $post, true ), |
||
180 | esc_html( $table_headings['status'] ) |
||
181 | ); |
||
182 | endif; |
||
183 | |||
184 | View Code Duplication | if ( filter_var( $donation_history_args['payment_method'], FILTER_VALIDATE_BOOLEAN ) ) : |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
185 | echo sprintf( |
||
0 ignored issues
–
show
|
|||
186 | '<td class="give-donation-payment-method"><span class="title-for-mobile">%2$s</span>%1$s</td>', |
||
187 | give_get_gateway_checkout_label( give_get_payment_gateway( $post->ID ) ), |
||
188 | esc_html( $table_headings['payment_method'] ) |
||
189 | ); |
||
190 | endif; |
||
191 | ?> |
||
192 | <td class="give-donation-details"> |
||
193 | <?php |
||
194 | // Display View Receipt or. |
||
195 | if ( 'publish' !== $post->post_status && 'subscription' !== $post->post_status ) : |
||
196 | echo sprintf( |
||
0 ignored issues
–
show
|
|||
197 | '<span class="title-for-mobile">%4$s</span><a href="%1$s"><span class="give-donation-status %2$s">%3$s</span></a>', |
||
198 | esc_url( |
||
199 | add_query_arg( |
||
200 | 'payment_key', |
||
201 | give_get_payment_key( $post->ID ), |
||
202 | give_get_history_page_uri() |
||
203 | ) |
||
204 | ), |
||
205 | $post->post_status, |
||
206 | __( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »', |
||
0 ignored issues
–
show
|
|||
207 | esc_html( $table_headings['details'] ) |
||
208 | ); |
||
209 | |||
210 | else : |
||
211 | echo sprintf( |
||
0 ignored issues
–
show
|
|||
212 | '<span class="title-for-mobile">%3$s</span><a href="%1$s">%2$s</a>', |
||
213 | esc_url( |
||
214 | add_query_arg( |
||
215 | 'payment_key', |
||
216 | give_get_payment_key( $post->ID ), |
||
217 | give_get_history_page_uri() |
||
218 | ) |
||
219 | ), |
||
220 | __( 'View Receipt »', 'give' ), |
||
221 | esc_html( $table_headings['details'] ) |
||
222 | ); |
||
223 | |||
224 | endif; |
||
225 | ?> |
||
226 | </td> |
||
227 | <?php |
||
228 | /** |
||
229 | * Fires in current user donation history table, after the row ends. |
||
230 | * |
||
231 | * Allows you to add new <td> elements to the row, after other elements in the row. |
||
232 | * |
||
233 | * @since 1.7 |
||
234 | * |
||
235 | * @param int $post_id The ID of the post. |
||
236 | * @param mixed $donation_data Payment meta data. |
||
237 | */ |
||
238 | do_action( 'give_donation_history_row_end', $post->ID, $donation_data ); |
||
239 | ?> |
||
240 | </tr> |
||
241 | <?php endforeach; ?> |
||
242 | |||
243 | <?php |
||
244 | /** |
||
245 | * Fires in footer of user donation history table. |
||
246 | * |
||
247 | * Allows you to add new <tfoot> elements to the row, after other elements in the row. |
||
248 | * |
||
249 | * @since 1.8.17 |
||
250 | */ |
||
251 | do_action( 'give_donation_history_table_end' ); |
||
252 | ?> |
||
253 | </table> |
||
254 | <div id="give-donation-history-pagination" class="give_pagination navigation"> |
||
255 | <?php |
||
256 | $big = 999999; |
||
257 | echo paginate_links( array( |
||
0 ignored issues
–
show
|
|||
258 | 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
||
259 | 'format' => '?paged=%#%', |
||
260 | 'current' => max( 1, get_query_var( 'paged' ) ), |
||
261 | 'total' => ceil( give_count_donations_of_donor() / 20 ), // 20 items per page |
||
262 | ) ); |
||
263 | ?> |
||
264 | </div> |
||
265 | </div> |
||
266 | <?php wp_reset_postdata(); ?> |
||
267 | <?php else : ?> |
||
268 | <?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?> |
||
269 | <?php endif; |
||
270 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: