Skip to content

Instantly share code, notes, and snippets.

@timkinnane
Forked from MikeNGarrett/wp-3-8-replace-open-sans
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timkinnane/30809524e8525a5d92b8 to your computer and use it in GitHub Desktop.
Save timkinnane/30809524e8525a5d92b8 to your computer and use it in GitHub Desktop.
Replace WP dashboard and admin bar font with your own (optional) locally hosted font. NOTE: I've used Roboto to match my theme, but called it Open Sans. This prevents error for admin plugin dependencies that expect an Open Sans style to be registered. WHY: If I'm doing local development offline page loads were always delayed by the Google Fonts …
<?php
// Reregister Open-sans as Roboto.
function replace_open_sans() {
// Replace the URL with your local or remote css
$roboto_open_sans_url = get_template_directory_uri().'/assets/fonts/roboto-hack.css';
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', $roboto_open_sans_url );
}
add_action( 'admin_enqueue_scripts', 'replace_open_sans' );
add_action( 'wp_enqueue_scripts', 'replace_open_sans' );
/* Using http://www.fontsquirrel.com/tools/webfont-generato */
@font-face {
font-family: 'Open Sans';
src: url('roboto-light-webfont.eot');
src: url('roboto-light-webfont.eot?#iefix') format('embedded-opentype'),
url('roboto-light-webfont.woff2') format('woff2'),
url('roboto-light-webfont.woff') format('woff'),
url('roboto-light-webfont.ttf') format('truetype'),
url('roboto-light-webfont.svg#robotolight') format('svg');
font-weight: normal;
font-style: normal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment