Making WordPress.org


Ignore:
Timestamp:
05/12/2020 07:17:45 AM (4 years ago)
Author:
dd32
Message:

Support Forums: Correct the RSS feed title for Reviews.

See #2078.

File:
1 edited

Legend:

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

    r9663 r9853  
    3636
    3737            // Add plugin or theme name to view feed titles.
    38             add_action( 'bbp_feed', array( $this, 'add_compat_title_to_feed' ) );
     38            add_filter( 'wp_title_rss', array( $this, 'title_correction_for_feed' ) );
    3939
    4040            // Define the taxonomy and query vars for this view.
     
    146146
    147147    /**
    148      * Add plugin or theme name to view feed titles.
    149      *
    150      * bbPress uses 'All Topics' title for view feeds, which isn't useful when
    151      * dealing with plugin or theme support.
    152      *
    153      * @see https://meta.trac.wordpress.org/ticket/2078
    154      * @see https://bbpress.trac.wordpress.org/ticket/3064
    155      */
    156     public function add_compat_title_to_feed() {
    157         if ( empty( $this->query['bbp_view'] ) || empty( $this->query[ $this->query_var() ] ) ) {
    158             return;
    159         }
    160 
    161         add_filter( 'gettext', array( $this, 'title_correction_for_feed' ), 10, 3 );
    162     }
    163 
    164     /**
    165148     * Replace 'All Topics' feed title with an appropriate view title
    166149     * that includes the plugin or theme name.
    167150     *
    168151     * @see https://meta.trac.wordpress.org/ticket/2078
    169      * @see https://bbpress.trac.wordpress.org/ticket/3064
    170      *
    171      * @param string $translation Translated text.
    172      * @param string $text        Text to translate.
    173      * @param string $domain      Text domain.
    174      * @return string New feed title.
    175      */
    176     public function title_correction_for_feed( $translation, $text, $domain ) {
    177         if ( 'bbpress' !== $domain || 'All Topics' !== $text ) {
    178             return $translation;
    179         }
    180 
    181         remove_filter( 'gettext', array( $this, 'title_correction_for_feed' ), 10, 3 );
     152     */
     153    public function title_correction_for_feed( $title ) {
     154        if ( empty( $this->query['bbp_view'] ) || empty( $this->query[ $this->query_var() ] ) ) {
     155            return $title;
     156        }
    182157
    183158        $object = $this->get_object( $this->query[ $this->query_var() ] );
    184159        if ( ! $object ) {
    185             return $translation;
     160            return $title;
    186161        }
    187162
     
    190165        switch ( $this->query['bbp_view'] ) {
    191166            case $this->compat():
    192                 $translation = $this->compat_title();
     167                $title = get_bloginfo_rss( 'name' ) . ' » ' . $this->compat_title();
    193168                break;
    194169            case 'reviews':
    195                 $translation = $this->reviews_title();
     170                $title = get_bloginfo_rss( 'name' ) . ' » ' . $this->reviews_title();
    196171                break;
    197172            case 'active':
    198                 $translation = $this->active_title();
     173                $title = get_bloginfo_rss( 'name' ) . ' » ' . $this->active_title();
    199174                break;
    200175            case 'unresolved':
    201                 $translation = $this->unresolved_title();
     176                $title = get_bloginfo_rss( 'name' ) . ' » ' . $this->unresolved_title();
    202177                break;
    203178        }
    204179
    205         return $translation;
     180        return $title;
    206181    }
    207182
Note: See TracChangeset for help on using the changeset viewer.