[wp-hackers] Prepend blog name in comment feed's title

Frank Bueltge frank at bueltge.de
Sat Oct 10 09:07:24 UTC 2009


Hello Thoscho,
great idea.

Hello Peter,
nice idea for filter with mutlilanguage support!
only the script has two small bugs on the script ( ) and ; ):

if ( !function_exists('rss_title_prefix') ) {
    function rss_title_prefix($translation, $original, $domain) {
           if ( ( 'default' == $domain ) && ( 'Comments on: %s' ==
$original ) ) {
                   return get_bloginfo('name') . ' - ' . $translation;
           }
           return $translation;
    }
    add_filter('gettext', 'rss_title_prefix', 10, 3);
}

Steuernr: 204/5756/0999 Steueridentnr.: DE263849534
Geschäftsführender Gesellschafter: Heinz Rohé HRB 65224 Amtsgericht Köln

http://inpsyde.com
http://pressthis.de



On Sat, Oct 10, 2009 at 9:59 AM, Peter Westwood
<peter.westwood at ftwr.co.uk> wrote:
>
> On 10 Oct 2009, at 01:17, Thomas Scholz wrote:
>
>> Peter Westwood:
>>
>>> There is a filter on the "Comments on" bit.
>>>
>>> If you dig into the translation functions there are filters to let
>>> plugins modify the translated string which can be used to prepend something
>>> here.
>>
>> Thanks, that was it!
>>
>> Here's my code (replace 'Kommentare zu:' with 'Comments on:' in english
>> blogs):
>>
>> // functions.php
>> add_filter('gettext', 'rss_title_prefix');
>>
>> function rss_title_prefix($str)
>> {
>>        if ( is_feed() AND is_singular() )
>>        {
>>                return str_replace('Kommentare zu:', get_bloginfo('name') .
>> ' - Kommentare zu:', $str);
>>        }
>>        return $str;
>> }
>>
>> I've updated my blog post at
>> <http://toscho.de/2009/wordpress-kommentarfeed-blogname/>.
>
> This is really good... but you can do even better.
>
> The filter passes in a lot more useful info.
>
> (follow code is untested even by a php interpreter)
>
> add_filter('gettext', 'rss_title_prefix', 10, 3)
>
> function rss_title_prefix($translation, $original, $domain) {
>        if ( ( 'default' == $domain ) && ('Comments on: %s' == $original) {
>                return get_bloginfo('name') . ' - ' . $translation;
>        }
>        return $translation;
> }
>
>
> This will ensure you match the exact string (and it works for any language.
>
> Peter
> --
> Peter Westwood
> http://blog.ftwr.co.uk | http://westi.wordpress.com
> C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list