[wp-hackers] Hook boginfo_url

Frank Bueltge frank at bueltge.de
Wed Aug 11 10:11:49 UTC 2010


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
>


More information about the wp-hackers mailing list