[wp-trac] [WordPress Trac] #9873: enforce a consistent home and siteurl www. pref

WordPress Trac wp-trac at lists.automattic.com
Tue May 19 12:36:11 GMT 2009


#9873: enforce a consistent home and siteurl www. pref
-------------------------------+--------------------------------------------
 Reporter:  Denis-de-Bernardy  |       Owner:     
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  2.8
Component:  Users              |     Version:  2.8
 Severity:  normal             |    Keywords:     
-------------------------------+--------------------------------------------
 Seen on a few sites. home and siteurl with inconsistent www prefs prevents
 the admin user's cookie from getting picked up properly, upon logging in.

 code I currently use to prevent the issue is this:


 {{{
 add_action('login_head', 'fix_www_pref');

 function fix_www_pref() {
         $home_url = get_option('home');
         $site_url = get_option('siteurl');

         $home_www = strpos($home_url, '://www.') !== false;
         $site_www = strpos($site_url, '://www.') !== false;

         if ( $home_www != $site_www ) {
                 if ( $home_www )
                         $site_url = str_replace('://', '://www.',
 $site_url);
                 else
                         $site_url = str_replace('://www.', '://',
 $site_url);
                 update_option('site_url', $site_url);
         }
 } # fix_www_pref()
 }}}

 there's probably a better way and a better location for this.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9873>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list