PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 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 All 255 releases
← All changes | includes/admin/forms/dashboard-columns.php +247 -43 2.3.14.16.9 View file →
@@ -29,9 +29,9 @@
29 29 */
30 30 function give_form_columns( $give_form_columns ) {
31 31
32 32 // Standard columns
33 - $give_form_columns = array(
33 + $give_form_columns = [
34 34 'cb' => '<input type="checkbox"/>',
35 35 'title' => __( 'Name', 'give' ),
36 36 'form_category' => __( 'Categories', 'give' ),
37 37 'form_tag' => __( 'Tags', 'give' ),
@@ -37,12 +37,12 @@
37 37 'form_tag' => __( 'Tags', 'give' ),
38 38 'price' => __( 'Amount', 'give' ),
39 39 'goal' => __( 'Goal', 'give' ),
40 40 'donations' => __( 'Donations', 'give' ),
41 - 'earnings' => __( 'Income', 'give' ),
41 + 'earnings' => __( 'Revenue', 'give' ),
42 42 'shortcode' => __( 'Shortcode', 'give' ),
43 43 'date' => __( 'Date', 'give' ),
44 - );
44 + ];
45 45
46 46 // Does the user want categories / tags?
47 47 if ( ! give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
48 48 unset( $give_form_columns['form_category'] );
@@ -58,8 +58,9 @@
58 58
59 59 /**
60 60 * Render Give Form Columns
61 61 *
62 + * @since 3.16.0 Add new filters for the "donations count" and "revenue" columns
62 63 * @since 1.0
63 64 *
64 65 * @param string $column_name Column name
65 66 * @param int $post_id Give Form (Post) ID
@@ -85,8 +86,9 @@
85 86 }
86 87 break;
87 88 case 'goal':
88 89 if ( give_is_setting_enabled( give_get_meta( $post_id, '_give_goal_option', true ) ) ) {
90 + do_action('give_admin_form_list_view_donations_goal_column_before', $post_id);
89 91
90 92 echo give_admin_form_goal_stats( $post_id );
91 93
92 94 } else {
@@ -104,9 +106,9 @@
104 106 if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
105 107 printf(
106 108 '<a href="%1$s">%2$s</a>',
107 109 esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . $post_id ) ),
108 - give_get_form_sales_stats( $post_id )
110 + apply_filters('give_admin_form_list_view_donations_count_column_value', give_get_form_sales_stats( $post_id ), $post_id)
109 111 );
110 112 } else {
111 113 echo '-';
112 114 }
@@ -115,9 +117,9 @@
115 117 if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
116 118 printf(
117 119 '<a href="%1$s">%2$s</a>',
118 120 esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $post_id ) ),
119 - give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ), array( 'sanitize' => false ) ) )
121 + apply_filters('give_admin_form_list_view_revenue_column_value', give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ), [ 'sanitize' => false ] ) ), $post_id)
120 122 );
121 123 } else {
122 124 echo '-';
123 125 }
@@ -124,9 +126,16 @@
124 126 break;
125 127 case 'shortcode':
126 128 $shortcode = sprintf( '[give_form id="%s"]', absint( $post_id ) );
127 129 printf(
128 - '<button type="button" class="button hint-tooltip hint--top js-give-shortcode-button" aria-label="%1$s" data-give-shortcode="%2$s"><span class="dashicons dashicons-admin-page"></span> %3$s</button>',
130 + '<button
131 + type="button"
132 + class="button hint-tooltip hint--top js-give-shortcode-button"
133 + aria-label="%1$s"
134 + data-give-shortcode="%2$s">
135 + <span class="dashicons dashicons-admin-page"></span>
136 + <span class="give-button-text"> %3$s</span>
137 + </button>',
129 138 esc_attr( $shortcode ),
130 139 esc_attr( $shortcode ),
131 140 esc_html__( 'Copy Shortcode', 'give' )
132 141 );
@@ -160,8 +169,10 @@
160 169
161 170 /**
162 171 * Sorts Columns in the Forms List Table
163 172 *
173 + * @since 3.16.0 Remove "give_donate_form_get_sales" filter logic
174 + * @since 3.14.0 Use the "give_donate_form_get_sales" filter to ensure the correct donation count will be used
164 175 * @since 1.0
165 176 *
166 177 * @param array $vars Array of all the sort variables.
167 178 *
@@ -177,12 +188,12 @@
177 188 // Check if 'orderby' is set to "sales".
178 189 case 'sales':
179 190 $vars = array_merge(
180 191 $vars,
181 - array(
192 + [
182 193 'meta_key' => '_give_form_sales',
183 194 'orderby' => 'meta_value_num',
184 - )
195 + ]
185 196 );
186 197 break;
187 198
188 199 // Check if "orderby" is set to "earnings".
@@ -188,12 +199,12 @@
188 199 // Check if "orderby" is set to "earnings".
189 200 case 'earnings':
190 201 $vars = array_merge(
191 202 $vars,
192 - array(
203 + [
193 204 'meta_key' => '_give_form_earnings',
194 205 'orderby' => 'meta_value_num',
195 - )
206 + ]
196 207 );
197 208 break;
198 209
199 210 // Check if "orderby" is set to "price/amount".
@@ -200,30 +211,34 @@
200 211 case 'amount':
201 212 $multi_level_meta_key = ( 'asc' === $vars['order'] ) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount';
202 213
203 214 $vars['orderby'] = 'meta_value_num';
204 - $vars['meta_query'] = array(
215 + $vars['meta_query'] = [
205 216 'relation' => 'OR',
206 - array(
217 + [
207 218 'key' => $multi_level_meta_key,
208 219 'type' => 'NUMERIC',
209 - ),
210 - array(
220 + ],
221 + [
211 222 'key' => '_give_set_price',
212 223 'type' => 'NUMERIC',
213 - )
214 - );
224 + ],
225 + ];
215 226
216 227 break;
217 228
218 229 // Check if "orderby" is set to "goal".
219 230 case 'goal':
231 + $meta_key = give_has_upgrade_completed( 'v240_update_form_goal_progress' )
232 + ? '_give_form_goal_progress'
233 + : '_give_set_goal'; // Backward compatibility
234 +
220 235 $vars = array_merge(
221 236 $vars,
222 - array(
223 - 'meta_key' => '_give_set_goal',
237 + [
238 + 'meta_key' => $meta_key,
224 239 'orderby' => 'meta_value_num',
225 - )
240 + ]
226 241 );
227 242 break;
228 243
229 244 // Check if "orderby" is set to "donations".
@@ -229,12 +244,12 @@
229 244 // Check if "orderby" is set to "donations".
230 245 case 'donations':
231 246 $vars = array_merge(
232 247 $vars,
233 - array(
248 + [
234 249 'meta_key' => '_give_form_sales',
235 250 'orderby' => 'meta_value_num',
236 - )
251 + ]
237 252 );
238 253 break;
239 254 }// End switch().
240 255
@@ -257,17 +272,21 @@
257 272 if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) {
258 273
259 274 $author_id = $_REQUEST['author'];
260 275 if ( (int) $author_id !== get_current_user_id() ) {
261 - wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array(
262 - 'response' => 403,
263 - ) );
276 + wp_die(
277 + esc_html__( 'You do not have permission to view this data.', 'give' ),
278 + esc_html__( 'Error', 'give' ),
279 + [
280 + 'response' => 403,
281 + ]
282 + );
264 283 }
265 284 $vars = array_merge(
266 285 $vars,
267 - array(
286 + [
268 287 'author' => get_current_user_id(),
269 - )
288 + ]
270 289 );
271 290
272 291 }
273 292 }
@@ -305,9 +324,9 @@
305 324 function give_remove_month_filter( $dates ) {
306 325 global $typenow;
307 326
308 327 if ( $typenow == 'give_forms' ) {
309 - $dates = array();
328 + $dates = [];
310 329 }
311 330
312 331 return $dates;
313 332 }
@@ -352,31 +371,216 @@
352 371
353 372 add_action( 'save_post', 'give_price_save_quick_edit' );
354 373
355 374 /**
356 - * Process bulk edit actions via AJAX
375 + * Function is used to filter the query for search result.
357 376 *
358 - * @since 1.0
359 - * @return void
377 + * @since 2.4.0
378 + *
379 + * @param $wp WP WordPress environment instance (passed by reference).
360 380 */
361 -function give_save_bulk_edit() {
381 +function give_form_search_query_filter( $wp ) {
362 382
363 - $post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
383 + if (
384 + isset( $wp->query_vars['post_type'] )
385 + && 'give_forms' == $wp->query_vars['post_type']
386 + && isset( $_GET['give-forms-goal-filter'] )
387 + ) {
364 388
365 - if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
366 - $price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0;
367 - foreach ( $post_ids as $post_id ) {
389 + $wp->query_vars['date_query'] =
390 + [
391 + 'after' => ! empty( $_GET['start-date'] ) ? date( 'Y-m-d', strtotime( give_clean( $_GET['start-date'] ) ) ) : false,
392 + 'before' => ! empty( $_GET['end-date'] ) ? date( 'Y-m-d 23:59:59 ', strtotime( give_clean( $_GET['end-date'] ) ) ) : false,
393 + 'inclusive' => true,
394 + ];
395 + switch ( $_GET['give-forms-goal-filter'] ) {
396 + case 'goal_in_progress':
397 + $wp->query_vars['meta_query'] =
398 + [
399 + 'relation' => 'AND',
400 + [
401 + 'key' => '_give_form_goal_progress',
402 + 'value' => [ 1, 99 ],
403 + 'compare' => 'BETWEEN',
404 + 'type' => 'NUMERIC',
405 + ],
406 + ];
368 407
369 - if ( ! current_user_can( 'edit_post', $post_id ) ) {
370 - continue;
371 - }
408 + break;
409 + case 'goal_achieved':
410 + $wp->query_vars['meta_query'] =
411 + [
412 + 'relation' => 'AND',
413 + [
414 + 'key' => '_give_form_goal_progress',
415 + 'value' => 100,
416 + 'compare' => '>=',
417 + 'type' => 'NUMERIC',
418 + ],
419 + ];
420 + break;
421 + case 'goal_not_set':
422 + $wp->query_vars['meta_query'] =
423 + [
424 + 'relation' => 'OR',
425 + [
426 + 'key' => '_give_goal_option',
427 + 'value' => 'disabled',
428 + 'compare' => '=',
429 + ],
430 + [
431 + 'key' => '_give_goal_option',
432 + 'compare' => 'NOT EXISTS',
433 + ],
434 + ];
435 + break;
436 + }
437 + }
438 +}
372 439
373 - if ( ! empty( $price ) ) {
374 - give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( $price ) );
375 - }
440 +add_action( 'parse_request', 'give_form_search_query_filter' );
441 +
442 +/**
443 + * function is used to search give forms by ID or title.
444 + *
445 + * @since 2.4.0
446 + *
447 + * @param $query WP_Query the WP_Query instance (passed by reference).
448 + */
449 +
450 +function give_search_form_by_id( $query ) {
451 + // Verify that we are on the give forms list page.
452 + if (
453 + empty( $query->query_vars['post_type'] )
454 + || 'give_forms' !== $query->query_vars['post_type']
455 + ) {
456 + return;
457 + }
458 +
459 + if ( '' !== $query->query_vars['s'] && is_search() ) {
460 + if ( absint( $query->query_vars['s'] ) ) {
461 + // Set the post id value
462 + $query->set( 'p', $query->query_vars['s'] );
463 + // Reset the search value
464 + $query->set( 's', '' );
376 465 }
377 466 }
467 +}
378 468
379 - die();
469 +add_filter( 'pre_get_posts', 'give_search_form_by_id' );
470 +
471 +/**
472 + * Outputs advanced filter html in Give forms list admin screen.
473 + *
474 + * @sicne 2.4.0
475 + *
476 + * @param $which
477 + */
478 +function give_forms_advanced_filter( $which ) {
479 + /* @var stdClass $screen */
480 + $screen = get_current_screen();
481 +
482 + if ( 'edit' !== $screen->parent_base || 'give_forms' !== $screen->post_type ) {
483 + return;
484 + }
485 +
486 + // Apply this only on a specific post type
487 + if ( 'top' !== $which ) {
488 + return;
489 + }
490 +
491 + $start_date = isset( $_GET['start-date'] ) ? strtotime( give_clean( $_GET['start-date'] ) ) : '';
492 + $end_date = isset( $_GET['end-date'] ) ? strtotime( give_clean( $_GET['end-date'] ) ) : '';
493 + $search = isset( $_GET['s'] ) ? give_clean( $_GET['s'] ) : '';
494 + $give_forms_goal_filter = isset( $_GET['give-forms-goal-filter'] ) ? $_GET['give-forms-goal-filter'] : '';
495 + ?>
496 + <div id="give-forms-advanced-filter" class="give-filters">
497 + <div class="give-filter give-filter-search">
498 + <input type="text" id="give-forms-search-input" placeholder="<?php _e( 'Form Name or ID', 'give' ); ?>" name="s" value="<?php echo esc_attr( $search ); ?>">
499 + <?php
500 + submit_button(
501 + __( 'Search', 'give' ),
502 + 'button',
503 + false,
504 + false,
505 + [
506 + 'ID' => 'form-search-submit',
507 + ]
508 + );
509 + ?>
510 + </div>
511 + <div id="give-payment-date-filters">
512 + <div class="give-filter give-filter-half">
513 + <label for="start-date"
514 + class="give-start-date-label"><?php _e( 'Start Date', 'give' ); ?></label>
515 + <input type="text"
516 + id="start-date"
517 + name="start-date"
518 + class="give_datepicker"
519 + autocomplete="off"
520 + value="<?php echo $start_date ? date_i18n( give_date_format(), $start_date ) : ''; ?>"
521 + data-standard-date="<?php echo $start_date ? date( 'Y-m-d', $start_date ) : $start_date; ?>"
522 + placeholder="<?php _e( 'Start Date', 'give' ); ?>"
523 + />
524 + </div>
525 + <div class="give-filter give-filter-half">
526 + <label for="end-date" class="give-end-date-label"><?php _e( 'End Date', 'give' ); ?></label>
527 + <input type="text"
528 + id="end-date"
529 + name="end-date"
530 + class="give_datepicker"
531 + autocomplete="off"
532 + value="<?php echo $end_date ? date_i18n( give_date_format(), $end_date ) : ''; ?>"
533 + data-standard-date="<?php echo $end_date ? date( 'Y-m-d', $end_date ) : $end_date; ?>"
534 + placeholder="<?php _e( 'End Date', 'give' ); ?>"
535 + />
536 + </div>
537 + </div>
538 + <div id="give-payment-form-filter" class="give-filter">
539 + <label for="give-donation-forms-filter"
540 + class="give-donation-forms-filter-label"><?php _e( 'Goal', 'give' ); ?></label>
541 + <select id="give-forms-goal-filter" name="give-forms-goal-filter" class="give-forms-goal-filter">
542 + <option value="any_goal_status"
543 + <?php
544 + if ( 'any_goal_status' === $give_forms_goal_filter ) {
545 + echo 'selected';
546 + }
547 + ?>
548 + ><?php _e( 'Any Goal Status', 'give' ); ?></option>
549 + <option value="goal_achieved"
550 + <?php
551 + if ( 'goal_achieved' === $give_forms_goal_filter ) {
552 + echo 'selected';
553 + }
554 + ?>
555 + ><?php _e( 'Goal Achieved', 'give' ); ?></option>
556 + <option value="goal_in_progress"
557 + <?php
558 + if ( 'goal_in_progress' === $give_forms_goal_filter ) {
559 + echo 'selected';
560 + }
561 + ?>
562 + ><?php _e( 'Goal In Progress', 'give' ); ?></option>
563 + <option value="goal_not_set"
564 + <?php
565 + if ( 'goal_not_set' === $give_forms_goal_filter ) {
566 + echo 'selected';
567 + }
568 + ?>
569 + ><?php _e( 'Goal Not Set', 'give' ); ?></option>
570 + </select>
571 + </div>
572 + <div class="give-filter">
573 + <?php submit_button( __( 'Apply', 'give' ), 'secondary', '', false ); ?>
574 + <?php
575 + // Clear active filters button.
576 + if ( ! empty( $start_date ) || ! empty( $end_date ) || ! empty( $search ) || ! empty( $give_forms_goal_filter ) ) :
577 + ?>
578 + <a href="<?php echo admin_url( 'edit.php?post_type=give_forms' ); ?>"
579 + class="button give-clear-filters-button"><?php _e( 'Clear Filters', 'give' ); ?></a>
580 + <?php endif; ?>
581 + </div>
582 + </div>
583 + <?php
380 584 }
381 585
382 -add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' );
586 +add_action( 'manage_posts_extra_tablenav', 'give_forms_advanced_filter', 10, 1 );