Making WordPress.org

Changeset 11528


Ignore:
Timestamp:
02/08/2022 05:20:50 AM (5 years ago)
Author:
dd32
Message:

Support Forums: Emails: Prefix the plugin/theme name to the email subject for reply notifications to a topic.

Previously this was only applying to notifications of new topics / new replies to topics in subscribed terms, rather than also applying to replies to threads you participated in.

See #6079, #2016.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-term-subscription/inc/class-plugin.php

    r10673 r11528  
    5757                add_action( 'bbp_new_reply', array( $this, 'notify_term_subscribers_of_new_reply' ), 10, 5 );
    5858
     59                // Replace the title of subscription emails with the term-specific prefix.
     60                // This applies to all notification emails sent related to the topic, not just the term-specific emails.
     61                add_filter( 'bbp_forum_subscription_mail_title', array( $this, 'replace_forum_subscription_mail_title' ), 10, 2 );
     62                add_filter( 'bbp_subscription_mail_title',       array( $this, 'replace_topic_subscription_mail_title' ), 10, 3 );
     63
    5964                add_action( 'bbp_template_after_user_subscriptions', array( $this, 'user_subscriptions' ) );
     65
    6066        }
    6167
     
    188194                // Replace forum-specific messaging with term subscription messaging.
    189195                add_filter( 'bbp_forum_subscription_mail_message', array( $this, 'replace_forum_subscription_mail_message' ), 10, 4 );
    190                 add_filter( 'bbp_forum_subscription_mail_title',   array( $this, 'replace_forum_subscription_mail_title' ), 10, 2 );
    191196
    192197                // Replace forum subscriber list with term subscribers, avoiding duplicates.
     
    199204                remove_filter( 'bbp_forum_subscription_user_ids',     array( $this, 'add_term_subscribers_to_forum' ) );
    200205                remove_filter( 'bbp_forum_subscription_mail_message', array( $this, 'replace_forum_subscription_mail_message' ), 10 );
    201                 remove_filter( 'bbp_forum_subscription_mail_title',   array( $this, 'replace_forum_subscription_mail_title' ) );
    202206
    203207        }
     
    256260         */
    257261        public function replace_forum_subscription_mail_title( $title, $topic_id ) {
     262                $terms = get_the_terms( $topic_id, $this->taxonomy );
     263                if ( ! $terms ) {
     264                        return $title;
     265                }
     266
    258267                if ( $this->directory && $this->directory->title() ) {
    259268                        $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     
    306315                // Replace topic-specific messaging with term subscription messaging.
    307316                add_filter( 'bbp_subscription_mail_message', array( $this, 'replace_topic_subscription_mail_message' ), 10, 3 );
    308                 add_filter( 'bbp_subscription_mail_title',   array( $this, 'replace_topic_subscription_mail_title' ), 10, 3 );
    309317
    310318                // Replace forum subscriber list with term subscribers, avoiding duplicates.
     
    317325                remove_filter( 'bbp_topic_subscription_user_ids', array( $this, 'add_term_subscribers_to_topic' ) );
    318326                remove_filter( 'bbp_subscription_mail_message',   array( $this, 'replace_topic_subscription_mail_message' ) );
    319                 remove_filter( 'bbp_subscription_mail_title',     array( $this, 'replace_topic_subscription_mail_title' ) );
    320327        }
    321328
     
    373380         */
    374381        public function replace_topic_subscription_mail_title( $title, $reply_id, $topic_id ) {
     382                $terms = get_the_terms( $topic_id, $this->taxonomy );
     383                if ( ! $terms ) {
     384                        return $title;
     385                }
     386
    375387                if ( $this->directory && $this->directory->title() ) {
    376388                        $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
Note: See TracChangeset for help on using the changeset viewer.