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/class-notices.php +33 -29 2.30.04.16.9 View file →
@@ -54,9 +54,9 @@
54 54 * @since 1.8.9
55 55 */
56 56 public function __construct() {
57 57 add_action( 'admin_notices', [ $this, 'render_admin_notices' ], 999 );
58 - add_action( 'admin_footer', [ $this, '__reveal_notices' ] );
58 + add_action( 'admin_footer', [$this, 'reveal_notices'] );
59 59 add_action( 'give_dismiss_notices', [ $this, 'dismiss_notices' ] );
60 60
61 61 add_action( 'give_frontend_notices', [ $this, 'render_frontend_notices' ], 999 );
62 62 add_action( 'give_pre_form_output', [ $this, 'render_frontend_form_notices' ], 10, 1 );
@@ -281,33 +281,35 @@
281 281 $this->print_js();
282 282 }
283 283
284 284
285 - /**
286 - * Render give frontend notices.
287 - *
288 - * @since 1.8.9
289 - * @access public
290 - *
291 - * @param int $form_id
292 - */
293 - public function render_frontend_notices( $form_id = 0 ) {
294 - $errors = give_get_errors();
285 + /**
286 + * Render give frontend notices.
287 + *
288 + * @since 3.1.0 Render errors on Ajax request (Donation form validation - v2 forms)
289 + * @since 2.32.0 Display registered error on donation form.
290 + * @since 1.8.9
291 + * @access public
292 + *
293 + * @param int $form_id
294 + */
295 + public function render_frontend_notices($form_id = 0)
296 + {
297 + $errors = give_get_errors();
295 298
296 - $request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0;
299 + $request_form_id = isset($_REQUEST['form-id']) ? absint($_REQUEST['form-id']) : 0;
297 300
298 - // Sanity checks first: Ensure that gateway returned errors display on the appropriate form.
299 - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
300 - return;
301 - }
301 + // Sanity checks first:
302 + // - Ensure that gateway returned errors display on the appropriate form.
303 + // - Error should exist.
304 + if (! $errors || ($request_form_id && $request_form_id !== $form_id)) {
305 + return;
306 + }
302 307
303 - if ( $errors ) {
304 - self::print_frontend_errors( $errors );
308 + self::print_frontend_errors($errors);
309 + give_clear_errors();
310 + }
305 311
306 - give_clear_errors();
307 - }
308 - }
309 -
310 312 /**
311 313 * Renders notices for different actions depending on
312 314 * the type of form display option.
313 315 *
@@ -412,11 +414,12 @@
412 414 /**
413 415 * Show notices
414 416 * Note: only for internal use
415 417 *
418 + * @since 4.9.0 rename function - PHP 8 compatibility
416 419 * @since 2.3.0
417 420 */
418 - public function __reveal_notices() {
421 + public function reveal_notices() {
419 422 ?>
420 423 <script>
421 424 jQuery(document).ready(function($){
422 425 // Fix notice appearance issue.
@@ -635,8 +638,9 @@
635 638 /**
636 639 * Print frontend notice.
637 640 * Notice: notice type can be success/error/warning
638 641 *
642 + * @since 3.7.0 Escape attributes
639 643 * @since 1.8.9
640 644 * @access public
641 645 *
642 646 * @param string $message
@@ -676,9 +680,9 @@
676 680
677 681 $close_icon = 'manual' === $notice_args['dismiss_type'] ?
678 682 sprintf(
679 683 '<img class="notice-dismiss give-notice-close" src="%s" />',
680 - esc_url( GIVE_PLUGIN_URL . 'assets/dist/images/close.svg' )
684 + esc_url( GIVE_PLUGIN_URL . 'build/assets/dist/images/close.svg' )
681 685 ) :
682 686 '';
683 687
684 688 // Note: we will remove give_errors class in future.
@@ -688,13 +692,13 @@
688 692 %5$s
689 693 </p>
690 694 %6$s
691 695 </div>',
692 - $notice_type,
693 - give_clean( $notice_args['dismissible'] ),
694 - absint( $notice_args['dismiss_interval'] ),
695 - give_clean( $notice_args['dismiss_type'] ),
696 - $message,
696 + esc_attr($notice_type),
697 + esc_attr( $notice_args['dismissible'] ),
698 + esc_attr( $notice_args['dismiss_interval'] ),
699 + esc_attr( $notice_args['dismiss_type'] ),
700 + esc_html($message),
697 701 $close_icon
698 702 );
699 703
700 704 if ( ! $echo ) {