| | 131 | /** |
| | 132 | * Add plugin or theme name to view feed titles. |
| | 133 | * |
| | 134 | * bbPress uses 'All Topics' title for view feeds, which isn't useful when |
| | 135 | * dealing with plugin or theme support. |
| | 136 | * |
| | 137 | * @see https://meta.trac.wordpress.org/ticket/2078 |
| | 138 | * @see https://bbpress.trac.wordpress.org/ticket/3064 |
| | 139 | */ |
| | 140 | public function add_compat_title_to_feed() { |
| | 141 | if ( empty( $this->query['bbp_view'] ) || empty( $this->query[ $this->query_var() ] ) ) { |
| | 142 | return; |
| | 143 | } |
| | 144 | |
| | 145 | add_filter( 'gettext', array( $this, 'title_correction_for_feed' ), 10, 3 ); |
| | 146 | } |
| | 147 | |
| | 148 | /** |
| | 149 | * Replace 'All Topics' feed title with an appropriate view title |
| | 150 | * that includes the plugin or theme name. |
| | 151 | * |
| | 152 | * @see https://meta.trac.wordpress.org/ticket/2078 |
| | 153 | * @see https://bbpress.trac.wordpress.org/ticket/3064 |
| | 154 | * |
| | 155 | * @param string $translation Translated text. |
| | 156 | * @param string $text Text to translate. |
| | 157 | * @param string $domain Text domain. |
| | 158 | * @return string |
| | 159 | */ |
| | 160 | public function title_correction_for_feed( $translation, $text, $domain ) { |
| | 161 | if ( 'bbpress' !== $domain || 'All Topics' !== $text ) { |
| | 162 | return $translation; |
| | 163 | } |
| | 164 | |
| | 165 | remove_filter( 'gettext', array( $this, 'title_correction_for_feed' ), 10, 3 ); |
| | 166 | |
| | 167 | $object = $this->get_object( $this->query[ $this->query_var() ] ); |
| | 168 | if ( ! $object ) { |
| | 169 | return $translation; |
| | 170 | } |
| | 171 | |
| | 172 | $this->{$this->compat()} = $object; |
| | 173 | |
| | 174 | switch ( $this->query['bbp_view'] ) { |
| | 175 | case 'plugin': |
| | 176 | case 'theme': |
| | 177 | $translation = $this->compat_title(); |
| | 178 | break; |
| | 179 | case 'reviews': |
| | 180 | $translation = $this->reviews_title(); |
| | 181 | break; |
| | 182 | case 'active': |
| | 183 | $translation = $this->activity_title(); |
| | 184 | break; |
| | 185 | } |
| | 186 | |
| | 187 | return $translation; |
| | 188 | } |
| | 189 | |