Skip to:
Content

BuddyPress.org

Opened 3 years ago

Closed 3 years ago

#8505 closed enhancement (fixed)

Add php fallback for dismissing sitewide notices.

Reported by: dcavins's profile dcavins Owned by: dcavins's profile dcavins
Milestone: 9.0.0 Priority: normal
Severity: normal Version: 8.0.0
Component: Messages Keywords: has-patch commit
Cc:

Description

Dismissal of sitewide notices is currently handled via JavaScript in both the Legacy and Nouveau template packs, and there is no php fallback. @imath has suggested that a fallback would be a good improvement.

Additionally, there is no centralized function to handle the change to the user's closed_notices meta, so the logic is repeated in several places in our code base.

Attachments (2)

8505.1.patch (10.7 KB) - added by dcavins 3 years ago.
* Introduce bp_messages_dismiss_sitewide_notice() as centralized function to dismiss a notice for a user. * Watch for requests to {user_profile}/messages/notices/dismiss. * Introduce bp_get_message_notice_dismiss_link() to generate nonced link to the dismiss action URI. * Use new URI for dismissal link in Legacy and Nouveau sitewide notice templates (replacing JS-only button dismissal). * Update Legacy CSS for dismissal link. Nouveau looks OK.
8505-review.patch (1.6 KB) - added by imath 3 years ago.

Download all attachments as: .zip

Change History (5)

@dcavins
3 years ago

  • Introduce bp_messages_dismiss_sitewide_notice() as centralized function to dismiss a notice for a user. * Watch for requests to {user_profile}/messages/notices/dismiss. * Introduce bp_get_message_notice_dismiss_link() to generate nonced link to the dismiss action URI. * Use new URI for dismissal link in Legacy and Nouveau sitewide notice templates (replacing JS-only button dismissal). * Update Legacy CSS for dismissal link. Nouveau looks OK.

@imath
3 years ago

#1 @imath
3 years ago

  • Keywords commit added; dev-feedback removed

Hi @dcavins

It looks good, I love the function you introduced. I've tested it: everything works perfectly. In the patch I've added you'll find some advices. Let's have it in.

#2 @dcavins
3 years ago

In 12989:

Introduce bp_messages_dismiss_sitewide_notice().

Introduce bp_messages_dismiss_sitewide_notice()
as core function to dismiss a notice for a user.
This function allows us to replace code to update the
user's closed_notices meta that is repeated in
several places in BuddyPress.

See #8505.

#3 @dcavins
3 years ago

  • Owner set to dcavins
  • Resolution set to fixed
  • Status changed from new to closed

In 12990:

Add php fallback for dismissing site-wide notices.

Dismissal of sitewide notices has been handled
solely via JavaScript in the Legacy and Nouveau
template packs. This commit adds a new action
URI at {user_profile}/messages/notices/dismiss
that will dismiss the currently active notice for
the logged-in user.

We also add a new template function to create the
nonced link, bp_get_message_notice_dismiss_link(),
and make use of it in the core template function
bp_message_get_notices() and in the Nouveau
template for site-wide notices. In both cases, button
elements have been converted to anchor elements
linking to the new dismissal URI, so the action can be
completed even if there is a problem with JavaScript.

Fixes #8505.

Note: See TracTickets for help on using tickets.