PHP problems with Twenty Twelve (custom theme)
-
I know a bit about HTML and CSS but I’m a novice when it comes to PHP.
The thing is that I’m trying to heavily modify the Twenty Twelve theme to create a good-looking theme for my site.
The test site is currently up at: https://test.techtage.com
If I were editing the parent theme’s PHP files, the task would’ve been a lot easier for me. As I’m using a child theme, I’m facing a lot of limitations.
I can’t seem to edit the function twentytwelve_fonts_url.
Original code:
function twentytwelve_get_font_url() { $font_url = ''; /* translators: If there are characters in your language that are not supported by Open Sans, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'twentytwelve' ) ) { $subsets = 'latin,latin-ext'; /* translators: To add an additional Open Sans character subset specific to your language, translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. */ $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'twentytwelve' ); if ( 'cyrillic' == $subset ) $subsets .= ',cyrillic,cyrillic-ext'; elseif ( 'greek' == $subset ) $subsets .= ',greek,greek-ext'; elseif ( 'vietnamese' == $subset ) $subsets .= ',vietnamese'; $protocol = is_ssl() ? 'https' : 'http'; $query_args = array( 'family' => 'Open+Sans:400italic,700italic,400,700', 'subset' => $subsets, ); $font_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ); } return $font_url; }
What I tried adding in child theme’s functions.php:
function twentytwelve_fonts_url() { $fonts_url = ''; /* Translators: If there are characters in your language that are not * supported by Source Sans Pro, translate this to 'off'. Do not translate * into your own language. */ $source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'twentytwelve' ); /* Translators: If there are characters in your language that are not * supported by Bitter, translate this to 'off'. Do not translate into your * own language. */ $bitter = _x( 'on', 'Bitter font: on or off', 'twentytwelve' ); if ( 'off' !== $source_sans_pro || 'off' !== $bitter ) { $font_families = array(); if ( 'off' !== $source_sans_pro ) $font_families[] = 'Source Sans Pro:300,400,700,300italic,400italic,700italic'; if ( 'off' !== $bitter ) $font_families[] = 'Bitter:400,700'; $query_args = array( 'family' => urlencode( implode( '|', $font_families ) ), 'subset' => urlencode( 'latin,latin-ext' ), ); $fonts_url = add_query_arg( $query_args, "//fonts.googleapis.com/css" ); } return $fonts_url; }
I basically wanted the heading fonts of Twenty Thirteen. The above code not only doesn’t work, but renders the site unusable.
Any idea? The other day I was messing up with Genesis child themes and I couldn’t most of the things of it as I practically have zero knowledge about PHP hooks, filters etc.
- The topic ‘PHP problems with Twenty Twelve (custom theme)’ is closed to new replies.