[wp-hackers] Hook boginfo_url

Otto otto at ottodestruct.com
Wed Aug 11 15:52:05 UTC 2010


Instead of hooking to bloginfo, try using these filters instead:


add_filter ( 'stylesheet_uri', 'whatever' );
add_filter ( 'template_directory_uri', 'whatever' );
add_filter ( 'stylesheet_directory_uri', 'whatever' );

And so on.. Not everything uses bloginfo to get those values.

-Otto



On Wed, Aug 11, 2010 at 5:11 AM, Frank Bueltge <frank at bueltge.de> wrote:
> The function dont work for stylesheet_directory - maybe an idea - Many
> thanks.
>
> On Mon, Aug 9, 2010 at 12:45 PM, Frank Bueltge <frank at bueltge.de> wrote:
>
>> Hello,
>>
>> i will change the url for use CDN on themes and uploads of my WP install.
>> I have write a small function and im not sure, if use the hook correctl
>> for  - 9999, 2)
>>
>> Thanks for your feedback.
>>
>> Here my small function
>>
>> if ( !function_exists('fb_add_static_wpurl') ) {
>>     function fb_add_static_wpurl($info, $show) {
>>
>>         $keys = array(
>>             'wpurl',
>>             'stylesheet_url',
>>             'stylesheet_directory',
>>             'template_url',
>>             'template_directory',
>>             );
>>
>>         if ( in_array( $show, $keys ) ) {
>>
>>             $wpurl = get_bloginfo('wpurl');
>>
>>             $search = array(
>>                 $wpurl . '/wp-content/images/',
>>                 $wpurl . '/wp-content/download/',
>>                 $wpurl . '/wp-content/themes/',
>>             );
>>
>>             $replace = array(
>>                 'http://cdn1.example.com/',
>>                 'http://cdn2.example.com/',
>>                 'http://cdn3.example.com/',
>>             );
>>
>>             return str_replace( $search, $replace, $info );
>>
>>         } else {
>>             return $info;
>>         }
>>     }
>>
>>     add_filter( 'bloginfo_url', 'fb_add_static_wpurl', 9999, 2 );
>> }
>>
>> Best wishes
>> Frank
>>
> _______________________________________________
> 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