Making WordPress.org

Changeset 8081


Ignore:
Timestamp:
01/15/2019 03:10:41 AM (6 years ago)
Author:
dd32
Message:

Support Forums: Prefix notifications from the Plugin/Theme forums with the plugin name.

For example: [WordPress.org] [Example Plugin Name] Example Topic Title.

Fixes #2016.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-support-compat.php

    r7293 r8081  
    355355        if ( class_exists( 'WordPressdotorg\Forums\Term_Subscription\Plugin' ) ) {
    356356            Plugin::get_instance()->plugin_subscriptions = new Term_Subscription\Plugin( array(
    357                 'taxonomy' => 'topic-plugin',
    358                 'labels'   => array(
     357                'taxonomy'  => 'topic-plugin',
     358                'directory' => Plugin::get_instance()->plugins,
     359                'labels'    => array(
    359360                    'subscribed_header'      => __( 'Subscribed Plugins', 'wporg-forums' ),
    360361                    'subscribed_user_notice' => __( 'You are not currently subscribed to any plugins.', 'wporg-forums' ),
    361362                    'subscribed_anon_notice' => __( 'This user is not currently subscribed to any plugins.', 'wporg-forums' ),
    362                     'receipt'                => __( 'You are receiving this email because you are subscribed to a plugin.', 'wporg-forums' ),
     363                    /* translators: %s: Plugin Name. */
     364                    'receipt'                => __( 'You are receiving this email because you are subscribed to the %s plugin.', 'wporg-forums' ),
    363365                ),
    364366            ) );
    365367            Plugin::get_instance()->theme_subscriptions = new Term_Subscription\Plugin( array(
    366                 'taxonomy' => 'topic-theme',
    367                 'labels'   => array(
     368                'taxonomy'  => 'topic-theme',
     369                'directory' => Plugin::get_instance()->themes,
     370                'labels'    => array(
    368371                    'subscribed_header'      => __( 'Subscribed Themes', 'wporg-forums' ),
    369372                    'subscribed_user_notice' => __( 'You are not currently subscribed to any themes.', 'wporg-forums' ),
    370373                    'subscribed_anon_notice' => __( 'This user is not currently subscribed to any themes.', 'wporg-forums' ),
    371                     'receipt'                => __( 'You are receiving this email because you are subscribed to a theme.', 'wporg-forums' ),
     374                    /* translators: %s: Theme Name. */
     375                    'receipt'                => __( 'You are receiving this email because you are subscribed to the %s theme.', 'wporg-forums' ),
    372376                ),
    373377            ) );
     
    394398             FROM {$prefix}posts AS p
    395399             LEFT JOIN {$prefix}term_relationships AS tr ON p.ID = tr.object_id
    396              LEFT JOIN {$prefix}term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id 
     400             LEFT JOIN {$prefix}term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
    397401             LEFT JOIN {$prefix}terms AS t ON tt.term_id = t.term_id
    398402             WHERE tt.taxonomy = 'plugin_committers' AND p.post_status = 'publish' AND p.post_type = 'plugin' AND t.slug = %s
     
    412416             FROM {$prefix}posts AS p
    413417             LEFT JOIN {$prefix}term_relationships AS tr ON p.ID = tr.object_id
    414              LEFT JOIN {$prefix}term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id 
     418             LEFT JOIN {$prefix}term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
    415419             LEFT JOIN {$prefix}terms AS t ON tt.term_id = t.term_id
    416420             WHERE tt.taxonomy = 'plugin_contributors' AND p.post_status = 'publish' AND p.post_type = 'plugin' AND t.slug = %s
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-term-subscription/inc/class-plugin.php

    r7560 r8081  
    1212    private $subscribers = array();
    1313
    14     public $taxonomy = false;
    15     public $labels   = array();
     14    public $taxonomy  = false;
     15    public $labels    = array();
     16    public $directory = false;
    1617
    1718    const META_KEY = '_bbp_term_subscription';
     
    1920    public function __construct( $args = array() ) {
    2021        $r = wp_parse_args( $args, array(
    21             'taxonomy' => 'topic-tag',
    22             'labels'   => array(
     22            'taxonomy'  => 'topic-tag',
     23            'directory' => false,
     24            'labels'    => array(
    2325                'subscribed_header'      => __( 'Subscribed Topic Tags', 'wporg-forums' ),
    2426                'subscribed_user_notice' => __( 'You are not currently subscribed to any topic tags.', 'wporg-forums' ),
     
    2830        ) );
    2931
    30         $this->taxonomy = $r['taxonomy'];
    31         $this->labels   = $r['labels'];
     32        $this->taxonomy  = $r['taxonomy'];
     33        $this->labels    = $r['labels'];
     34        $this->directory = $r['directory'];
    3235
    3336        add_action( 'bbp_init', array( $this, 'bbp_init' ) );
     
    157160     * @param int $topic_author The topic author id
    158161     */
    159     public function notify_term_subscribers_of_new_topic( $topic_id, $forum_id,  $anonymous_data = false, $topic_author = 0 ) {
     162    public function notify_term_subscribers_of_new_topic( $topic_id, $forum_id, $anonymous_data = false, $topic_author = 0 ) {
    160163        $terms = get_the_terms( $topic_id, $this->taxonomy );
    161164        if ( ! $terms ) {
     
    185188        // Replace forum-specific messaging with term subscription messaging.
    186189        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 );
    187191
    188192        // Replace forum subscriber list with term subscribers, avoiding duplicates.
     
    193197
    194198        // Remove filters.
    195         remove_filter( 'bbp_forum_subscription_user_ids', array( $this, 'add_term_subscribers_to_forum' ) );
     199        remove_filter( 'bbp_forum_subscription_user_ids',     array( $this, 'add_term_subscribers_to_forum' ) );
    196200        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' ) );
     202
    197203    }
    198204
     
    236242            $topic_content,
    237243            $topic_url,
    238             $this->labels['receipt']
     244            // String may not have placeholders, ie. in the case of tags.
     245            sprintf( $this->labels['receipt'], $this->directory ? $this->directory->title() : '' )
    239246        );
    240247
    241248        return $message;
     249    }
     250
     251    /**
     252     * Replace the forum subscription subject/title with term-specific messaging.
     253     *
     254     * @param string $title The current title
     255     * @param int $topic_id The topic id
     256     */
     257    public function replace_forum_subscription_mail_title( $title, $topic_id ) {
     258        if ( $this->directory && $this->directory->title() ) {
     259            $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     260            $topic_title = strip_tags( bbp_get_topic_title( $topic_id ) );
     261
     262            // [WordPress.org] [Plugin Name] This is my threads
     263            $title = sprintf( '[%s] [%s] %s', $blog_name, $this->directory->title(), $topic_title );
     264        }
     265
     266        return $title;
    242267    }
    243268
     
    281306        // Replace topic-specific messaging with term subscription messaging.
    282307        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 );
    283309
    284310        // Replace forum subscriber list with term subscribers, avoiding duplicates.
     
    290316        // Remove filters.
    291317        remove_filter( 'bbp_topic_subscription_user_ids', array( $this, 'add_term_subscribers_to_topic' ) );
    292         remove_filter( 'bbp_subscription_mail_message', array( $this, 'replace_topic_subscription_mail_message' ), 10 );
     318        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' ) );
    293320    }
    294321
     
    331358            $reply_content,
    332359            $reply_url,
    333             $this->labels['receipt']
     360            // String may not have placeholders, ie. in the case of tags.
     361            sprintf( $this->labels['receipt'], $this->directory ? $this->directory->title() : '' )
    334362        );
    335363
    336364        return $message;
     365    }
     366
     367    /**
     368     * Replace the topic subscription subject/title with term-specific messaging.
     369     *
     370     * @param string $title    The current title
     371     * @param int    $reply_id The reply id
     372     * @param int    $topic_id The topic id
     373     */
     374    public function replace_topic_subscription_mail_title( $title, $reply_id, $topic_id ) {
     375        if ( $this->directory && $this->directory->title() ) {
     376            $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     377            $topic_title = strip_tags( bbp_get_topic_title( $topic_id ) );
     378
     379            // [WordPress.org] [Plugin Name] This is my threads
     380            $title = sprintf( '[%s] [%s] %s', $blog_name, $this->directory->title(), $topic_title );
     381        }
     382
     383        return $title;
    337384    }
    338385
Note: See TracChangeset for help on using the changeset viewer.