Last active
August 29, 2015 14:20
-
-
Save vajrasar/8e5d3bdfde744ad7d6a0 to your computer and use it in GitHub Desktop.
For Tut: Adding Inline logo via Theme Options in Genesis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //* Add the theme-opt.php file | |
| require_once('theme-opt.php'); | |
| /********************************** | |
| * | |
| * Replace Header Site Title with Inline Logo | |
| * | |
| * Fixes Genesis bug - when using static front page and blog page (admin reading settings) Home page is <p> tag and Blog page is <h1> tag | |
| * | |
| * Replaces "is_home" with "is_front_page" to correctly display Home page wit <h1> tag and Blog page with <p> tag | |
| * | |
| * @author AlphaBlossom / Tony Eppright | |
| * @link http://www.alphablossom.com/a-better-wordpress-genesis-responsive-logo-header/ | |
| * | |
| * @edited by Sridhar Katakam | |
| * @link http://www.sridharkatakam.com/use-inline-logo-instead-background-image-genesis/ | |
| * | |
| ************************************/ | |
| add_filter( 'genesis_seo_title', 'custom_header_inline_logo', 10, 3 ); | |
| function custom_header_inline_logo( $title, $inside, $wrap ) { | |
| $logo = '<img src="' . genesis_get_option( 'logo_url' ) . '" alt="' . esc_attr( get_bloginfo( 'name' ) ) . '" title="' . esc_attr( get_bloginfo( 'name' ) ) . '">'; | |
| $inside = sprintf( '<a href="%s" title="%s">%s</a>', trailingslashit( home_url() ), esc_attr( get_bloginfo( 'name' ) ), $logo ); | |
| //* Determine which wrapping tags to use - changed is_home to is_front_page to fix Genesis bug | |
| $wrap = is_front_page() && 'title' === genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : 'p'; | |
| //* A little fallback, in case an SEO plugin is active - changed is_home to is_front_page to fix Genesis bug | |
| $wrap = is_front_page() && ! genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : $wrap; | |
| //* And finally, $wrap in h1 if HTML5 & semantic headings enabled | |
| $wrap = genesis_html5() && genesis_get_seo_option( 'semantic_headings' ) ? 'h1' : $wrap; | |
| return sprintf( '<%1$s %2$s>%3$s</%1$s>', $wrap, genesis_attr( 'site-title' ), $inside ); | |
| } | |
| //* Remove the site description | |
| remove_action( 'genesis_site_description', 'genesis_seo_site_description' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .header-image .site-title > a { | |
| background: transparent; | |
| } | |
| .header-image .site-title { | |
| text-indent: 0; | |
| } | |
| .site-title img { | |
| vertical-align: top; | |
| } | |
| .title-area { | |
| padding: 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| Template Name: Genesis Theme Options | |
| Template Description: Adding additional options in Genesis Theme Settings page | |
| **/ | |
| /** | |
| * Step 1: Register Defaults | |
| * @author Bill Erickson | |
| * @link http://www.billerickson.net/genesis-theme-options/ | |
| * | |
| * @param array $defaults | |
| * @return array modified defaults | |
| * | |
| */ | |
| function vg_options_defaults( $defaults ) { | |
| $defaults['logo_url'] = ''; | |
| return $defaults; | |
| } | |
| add_filter( 'genesis_theme_settings_defaults', 'vg_options_defaults' ); | |
| /** | |
| * Step 2: Sanitization | |
| * Register our option values with the no_html sanitization type defined within Genesis. | |
| * | |
| * @author Bill Erickson | |
| * @link http://www.billerickson.net/genesis-theme-options/ | |
| * | |
| */ | |
| function vg_register_option_sanitization_filters() { | |
| genesis_add_option_filter( | |
| 'no_html', | |
| GENESIS_SETTINGS_FIELD, | |
| array( | |
| 'logo_url', | |
| ) | |
| ); | |
| } | |
| add_action( 'genesis_settings_sanitizer_init', 'vg_register_option_sanitization_filters' ); | |
| /** | |
| * Step 3: Register additional metaboxes to Genesis > Theme Settings | |
| * @author Bill Erickson | |
| * @link http://www.billerickson.net/genesis-theme-options/ | |
| * | |
| * @param string $_genesis_theme_settings_pagehook | |
| */ | |
| function vg_register_option_settings_box( $_genesis_theme_settings_pagehook ) { | |
| add_meta_box( 'vg-option-settings', 'Site Logo', 'vg_option_settings_box', $_genesis_theme_settings_pagehook, 'main', 'high' ); | |
| } | |
| add_action( 'genesis_theme_settings_metaboxes', 'vg_register_option_settings_box' ); | |
| /** | |
| * Step 4: Option Settings Metabox Callback | |
| * @see vg_register_option_settings_box() | |
| * @author Bill Erickson | |
| * @link http://www.billerickson.net/genesis-theme-options/ | |
| * | |
| */ | |
| function vg_option_settings_box() { | |
| ?> | |
| <p><?php _e( 'Logo URL:', 'be-genesis-child' );?><br /> | |
| <input type="text" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[logo_url]" value="<?php echo esc_url( genesis_get_option('logo_url') ); ?>" size="50" /> </p> | |
| <?php | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment