leac / kamoha_2015

Wordpress theme
1 stars 0 forks source link

Hardcoded item: Styles #2

Closed emiluzelac closed 9 years ago

emiluzelac commented 9 years ago

../header.php


We want to avoid hardcoding styles:

        <link href='http://fonts.googleapis.com/css?family=Alef:400,700&subset=latin,hebrew' rel='stylesheet' type='text/css'>
        <style type="text/css">
            @font-face {font-family: 'icomoon';src:url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/icomoon.eot?-416wh5');src:url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/icomoon.eot?#iefix-416wh5') format('embedded-opentype'),url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/icomoon.woff?-416wh5') format('woff'),url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/icomoon.ttf?-416wh5') format('truetype'),url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/icomoon.svg?-416wh5#icomoon') format('svg');font-weight: normal;font-style: normal;}
        </style>

and wp_enqueue_style them from functions file instead.

Here's an example how to add Google fonts and also one for inline styles.

justintadlock commented 9 years ago

Also, make sure to either use https: or leave off the http: or https: off entirely.

leac commented 9 years ago

Thanks. I managed to add it the Google fonts to the frontend, but not to the editor, event though I followed the method from the article you linked to. What could the problem be?

emiluzelac commented 9 years ago

Awesome! For the editor, please see: https://github.com/WordPress/WordPress/blob/master/wp-content/themes/twentyfourteen/functions.php#L71