-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 Fix broken Google Fonts URL for Roboto
Also set a single URL for both the normal and condensed versions of Roboto
- Loading branch information
Showing
1 changed file
with
53 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,109 @@ | ||
<?php | ||
if ( ! function_exists( 'ucsc_theme_setup' ) ) : | ||
/** | ||
* Sets up theme defaults and registers support for various WordPress features. | ||
* | ||
* Note that this function is hooked into the after_setup_theme hook, which runs | ||
* before the init hook. The init hook is too late for some features, such as indicating | ||
* support for post thumbnails. | ||
*/ | ||
function ucsc_theme_setup() { | ||
if (!function_exists('ucsc_theme_setup')) : | ||
/** | ||
* Sets up theme defaults and registers support for various WordPress features. | ||
* | ||
* Note that this function is hooked into the after_setup_theme hook, which runs | ||
* before the init hook. The init hook is too late for some features, such as indicating | ||
* support for post thumbnails. | ||
*/ | ||
function ucsc_theme_setup() | ||
{ | ||
|
||
add_theme_support( 'wp-block-styles' ); | ||
add_theme_support('wp-block-styles'); | ||
|
||
add_editor_style( 'build/index.css' ); | ||
add_editor_style('build/index.css'); | ||
|
||
/** | ||
* Register primary navigation menu location | ||
*/ | ||
register_nav_menus( array( | ||
'primary' => __('Primary Navigation', 'theme-ucsc'), | ||
) ); | ||
} | ||
* Register primary navigation menu location | ||
*/ | ||
register_nav_menus(array( | ||
'primary' => __('Primary Navigation', 'theme-ucsc'), | ||
)); | ||
} | ||
endif; | ||
add_action( 'after_setup_theme', 'ucsc_theme_setup' ); | ||
add_action('after_setup_theme', 'ucsc_theme_setup'); | ||
|
||
/** | ||
* Enqueue theme scripts and styles. | ||
*/ | ||
function ucsc_theme_scripts() { | ||
wp_enqueue_style( 'ucsc-theme-styles', get_stylesheet_uri() ); | ||
wp_enqueue_style('ucsc-theme-styles-scss', get_template_directory_uri(). '/build/style-index.css'); | ||
function ucsc_theme_scripts() | ||
{ | ||
wp_enqueue_style('ucsc-theme-styles', get_stylesheet_uri()); | ||
wp_enqueue_style('ucsc-theme-styles-scss', get_template_directory_uri() . '/build/style-index.css'); | ||
} | ||
add_action( 'wp_enqueue_scripts', 'ucsc_theme_scripts' ); | ||
add_action('wp_enqueue_scripts', 'ucsc_theme_scripts'); | ||
|
||
/** | ||
* Enqueue additional Google Font Scripts | ||
*/ | ||
function ucsc_googleapi_scripts(){ | ||
echo '<link rel="preconnect" href="https://fonts.googleapis.com">'; | ||
echo '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>'; | ||
function ucsc_googleapi_scripts() | ||
{ | ||
echo '<link rel="preconnect" href="https://fonts.googleapis.com">'; | ||
echo '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>'; | ||
} | ||
add_action('wp_head','ucsc_googleapi_scripts'); | ||
add_action('wp_head', 'ucsc_googleapi_scripts'); | ||
|
||
/** | ||
* Enqueue editor styles and scripts. | ||
*/ | ||
|
||
function ucsc_add_admin_scripts() { | ||
function ucsc_add_admin_scripts() | ||
{ | ||
|
||
wp_register_script( 'ucsc-admin-scripts', get_template_directory_uri() . '/build/theme.js', array(), '', true ); | ||
wp_enqueue_script( 'ucsc-admin-scripts' ); | ||
wp_register_style( 'ucsc-admin-styles', get_template_directory_uri() . '/build/index.css', array(), '', false ); | ||
wp_enqueue_style( 'ucsc-admin-styles' ); | ||
wp_register_script('ucsc-admin-scripts', get_template_directory_uri() . '/build/theme.js', array(), '', true); | ||
wp_enqueue_script('ucsc-admin-scripts'); | ||
wp_register_style('ucsc-admin-styles', get_template_directory_uri() . '/build/index.css', array(), '', false); | ||
wp_enqueue_style('ucsc-admin-styles'); | ||
} | ||
|
||
add_action( 'admin_enqueue_scripts', 'ucsc_add_admin_scripts' ); | ||
add_action('admin_enqueue_scripts', 'ucsc_add_admin_scripts'); | ||
|
||
/** | ||
* Enqueue fonts, styles and scripts. | ||
*/ | ||
|
||
function ucsc_add_scripts() { | ||
function ucsc_add_scripts() | ||
{ | ||
|
||
wp_enqueue_style( 'ucsc-google-roboto-font', 'https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,600;0,700;0,900;1,300;1,400;1,600;1,700;1,900', false ); | ||
wp_enqueue_style( 'ucsc-google-roboto-condensed-font', 'https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,600;1,600&display=swap', false ); | ||
wp_register_script( 'ucsc-front', get_template_directory_uri() . '/build/theme.js', array(), '', true ); | ||
wp_enqueue_script( 'ucsc-front' ); | ||
wp_enqueue_style('ucsc-google-roboto-font', 'https://fonts.googleapis.com/css?family=Roboto+Condensed:300,400,700|Roboto:100,300,400,500,700&display=swap', false); | ||
wp_register_script('ucsc-front', get_template_directory_uri() . '/build/theme.js', array(), '', true); | ||
wp_enqueue_script('ucsc-front'); | ||
} | ||
|
||
add_action( 'wp_enqueue_scripts', 'ucsc_add_scripts' ); | ||
add_action('wp_enqueue_scripts', 'ucsc_add_scripts'); | ||
|
||
|
||
/** | ||
* Copyright shortcode | ||
* returns copyright symbol and current year | ||
*/ | ||
function ucsc_copyright(){ | ||
function ucsc_copyright() | ||
{ | ||
$copyright = '©'; | ||
$year = date('Y'); | ||
return $copyright.$year; | ||
return $copyright . $year; | ||
} | ||
add_shortcode( 'copyright', 'ucsc_copyright' ); | ||
add_shortcode('copyright', 'ucsc_copyright'); | ||
|
||
/** | ||
* Last Modified shortcode | ||
* returns the date of the | ||
* last time the page was | ||
* updated | ||
*/ | ||
function ucsc_last_modified_helper(){ | ||
function ucsc_last_modified_helper() | ||
{ | ||
$ucsc_time = get_the_time('U'); | ||
$ucsc_modified_time = get_the_modified_time('U'); | ||
$ucsc_modified_time = get_the_modified_time('U'); | ||
if ($ucsc_modified_time >= $ucsc_time + 86400) { | ||
return the_modified_time('F jS, Y'); | ||
return the_modified_time('F jS, Y'); | ||
} | ||
} | ||
function ucsc_last_modified(){ | ||
function ucsc_last_modified() | ||
{ | ||
ob_start(); | ||
ucsc_last_modified_helper(); | ||
return ob_get_clean(); | ||
} | ||
add_shortcode( 'last-modified', 'ucsc_last_modified' ); | ||
add_shortcode('last-modified', 'ucsc_last_modified'); |