[wp-trac] [WordPress Trac] #18005: mixed http/https installation and add_custom_background / body_class

WordPress Trac wp-trac at lists.automattic.com
Wed Jul 6 15:47:46 UTC 2011


#18005: mixed http/https installation and add_custom_background / body_class
---------------------------+------------------------------
 Reporter:  rfc1437        |       Owner:
     Type:  defect (bug)   |      Status:  reopened
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Bundled Theme  |     Version:
 Severity:  trivial        |  Resolution:
 Keywords:  2nd-opinion    |
---------------------------+------------------------------

Comment (by rfc1437):

 Well, I did some more digging and the problem is in the theme_mod
 background_image handling - when setting a custom background image in
 twentyten (or actually any other theme that supports custom backgrounds,
 since that part of the admin interface comes from WP core), that custom
 background image is stored in the theme_mods_twentyten option (or in my
 case in theme_mods_rfc1437) value as an URI and that URI directly includes
 the protocol. That value is put into the body styling directly without any
 change. On option storage the value of course uses the site URI to
 construct the background image URI and so stores it with http: (and the
 fully qualified URI for images in url() CSS specs is a requirement).

 header_image does show the same value structure, but it is handled by
 get_header_image that actually contains code that checks is_ssl and
 replaces http:// with https:// (and vice versa). get_background_image is
 missing that code to handle is_ssl situations. I changed
 get_background_image to the following code in wp-includes/theme.php and
 the problem was fixed:

 {{{
 function get_background_image() {
         $default = defined('BACKGROUND_IMAGE') ? BACKGROUND_IMAGE : '';

         $url = get_theme_mod('background_image', $default);
         if ( is_ssl() )
                 $url = str_replace( 'http://', 'https://', $url );
         else
                 $url = str_replace( 'https://', 'http://', $url );
         return $url;
 }
 }}}

 my theme_mods_rfc1437 option value:


 a:8:{s:12:"header_image";s:80:"http://hugo.rfc1437.de/wp-
 content/themes/rfc1437/images/headers/enigma-
 dark.jpeg";s:16:"background_color";s:3:"fff";s:16:"background_image";s:68:"http://hugo.rfc1437.de
 /wp-content/uploads/2011/02/steam-
 invers5.jpeg";s:22:"background_image_thumb";s:75:"http://hugo.rfc1437.de
 /wp-content/uploads/2011/02/steam-
 invers5-150x150.jpg";s:17:"background_repeat";s:9:"no-
 repeat";s:21:"background_position_x";s:4:"left";s:21:"background_attachment";s:6:"scroll";s:18:"nav_menu_locations";a:1:{s:7:"primary";i:78;}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18005#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list