/** * Outputs custom backgrounds inline * * @author Travis Smith * * @uses $genesis_settings for custom background default image * @uses apply_filters() filters defaults * */ function gcb_do_theme_background() { $defaults = array('default_img' => genesis_get_option('cb_default', GCB_SETTINGS_FIELD), 'bgimage' => get_background_image(), 'bgcolor' => get_background_color()); $defaults = apply_filters('gcb_defaults', $defaults); extract($defaults, EXTR_SKIP); // begin output $output = "<style type='text/css'>\n"; if (!empty($bgimage)) { $bg_styles = 'background-image: url(\'' . get_theme_mod('background_image', '') . '\');' . ' background-repeat: ' . get_theme_mod('background_repeat', 'repeat') . ';' . ' background-position: top ' . get_theme_mod('background_position_x', 'left') . ';' . 'background-attachment: ' . get_theme_mod('background_attachment', 'scroll'); $output .= "body { " . $bg_styles . "; } \n"; } if (!empty($bgcolor)) { $output .= "body { background-color: #" . $bgcolor . "; } \n"; } // for child themes to set a default bg img if (!empty($default_img) && empty($bgimage)) { $output .= "body { background: url('" . gcb_setting_url($default_img) . "'); } \n"; } $output .= "</style>"; echo apply_filters('gcb_output', $output, $bgimage, $bgcolor); return $output; }
/** * Add settings to the Genesis Backgrounds metabox. * * @author Travis Smith * @version 1.0 */ function gcb_settings() { $setting = genesis_get_option('cb_default', GCB_SETTINGS_FIELD); $bg_styles = ' background-image: url(\'' . gcb_setting_url($setting) . '\');' . ' background-repeat: repeat;' . ' background-position: top left;' . ' width: 100%;' . ' float: left;' . ' margin: 0 10px 10px 0;'; ?> <h4><?php _e('Selected Default Background', GCB_DOMAIN); ?> </h4> <div id="custom-background-image" style="<?php echo $bg_styles; ?> "><?php // must be double quote, see above ?> <p style="visibility:hidden;"><?php _e('default', GCB_DOMAIN); ?> </p> <img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?> " style="visibility:hidden;" alt="" /> </div> <div class="clear"></div> <?php $imagefolders = gcb_dir_list(GCB_BG_DIR); $lights = gcb_dir_list(GCB_LIGHT_URL); foreach ($lights as $key => $folder) { $light[$folder] = gcb_file_list(GCB_BG_DIR . 'light/' . $folder); } $darks = gcb_dir_list(GCB_DARK_URL); foreach ($darks as $folder) { $dark[$folder] = gcb_file_list(GCB_BG_DIR . 'dark/' . $folder); } foreach ($imagefolders as $key => $folder) { ?> <h2><?php _e(ucfirst($folder) . ' Backgrounds', GCB_DOMAIN); ?> </h2> <?php foreach (${$folder} as $fkey => $types) { ?> <h4><?php _e(ucfirst($fkey) . ' Backgrounds', GCB_DOMAIN); ?> </h4> <?php $i = 0; foreach (${$folder}[$fkey] as $ikey => $img) { $i++; $bg_styles = ''; // background-image URL must be single quote, see below $bg_styles .= ' background-image: url(\'' . GCB_BG_URL . $folder . '/' . $fkey . '/' . $img . '\');' . ' background-repeat: repeat;' . ' background-position: top left;' . ' width: 48%;' . ' float: left;' . ' margin: 0 10px 10px 0;'; ?> <div id="custom-background-image" style="<?php echo $bg_styles; ?> "><?php // must be double quote, see above ?> <input type="radio" class="cbi-option" id="<?php echo GCB_SETTINGS_FIELD; ?> [cb_default]" name="<?php echo GCB_SETTINGS_FIELD; ?> [cb_default]" value="<?php echo $folder . '-' . $fkey . '-' . $i; ?> " <?php checked($folder . '-' . $fkey . '-' . $i, $setting); ?> > <p style="visibility:hidden;"><?php _e(ucfirst($folder) . ' ' . ucfirst($fkey), GCB_DOMAIN); ?> </p> </input> <img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?> " style="visibility:hidden;" alt="" /> </div> <?php } ?> <div class="clear"></div><?php } } }