| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * Gutenberg support |
|---|
| 5 | */ |
|---|
| 6 | |
|---|
| 7 | function sydney_editor_styles() { |
|---|
| 8 | wp_enqueue_style( 'sydney-block-editor-styles', get_theme_file_uri( '/sydney-gutenberg-editor-styles.css' ), '', '1.0', 'all' ); |
|---|
| 9 | |
|---|
| 10 | wp_enqueue_style( 'sydney-fonts', esc_url( sydney_enqueue_google_fonts() ), array(), null ); |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | //Dynamic styles |
|---|
| 14 | $custom = ''; |
|---|
| 15 | |
|---|
| 16 | //Fonts |
|---|
| 17 | $body_fonts = get_theme_mod('body_font', 'Raleway'); |
|---|
| 18 | $headings_fonts = get_theme_mod('headings_font', 'Raleway'); |
|---|
| 19 | $custom .= ".editor-block-list__layout, .editor-block-list__layout .editor-block-list__block { font-family:" . $body_fonts . ";}"."\n"; |
|---|
| 20 | $custom .= ".editor-post-title__block .editor-post-title__input, .editor-block-list__layout .editor-post-title__input, .editor-block-list__layout h1, .editor-block-list__layout h2, .editor-block-list__layout h3, .editor-block-list__layout h4, .editor-block-list__layout h5, .editor-block-list__layout h6 { font-family:" . $headings_fonts . ";}"."\n"; |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | //H1 size |
|---|
| 24 | $h1_size = get_theme_mod( 'h1_size','52' ); |
|---|
| 25 | if ($h1_size) { |
|---|
| 26 | $custom .= ".editor-block-list__layout h1 { font-size:" . intval($h1_size) . "px; }"."\n"; |
|---|
| 27 | } |
|---|
| 28 | //H2 size |
|---|
| 29 | $h2_size = get_theme_mod( 'h2_size','42' ); |
|---|
| 30 | if ($h2_size) { |
|---|
| 31 | $custom .= ".editor-block-list__layout h2 { font-size:" . intval($h2_size) . "px; }"."\n"; |
|---|
| 32 | } |
|---|
| 33 | //H3 size |
|---|
| 34 | $h3_size = get_theme_mod( 'h3_size','32' ); |
|---|
| 35 | if ($h3_size) { |
|---|
| 36 | $custom .= ".editor-block-list__layout h3 { font-size:" . intval($h3_size) . "px; }"."\n"; |
|---|
| 37 | } |
|---|
| 38 | //H4 size |
|---|
| 39 | $h4_size = get_theme_mod( 'h4_size','25' ); |
|---|
| 40 | if ($h4_size) { |
|---|
| 41 | $custom .= ".editor-block-list__layout h4 { font-size:" . intval($h4_size) . "px; }"."\n"; |
|---|
| 42 | } |
|---|
| 43 | //H5 size |
|---|
| 44 | $h5_size = get_theme_mod( 'h5_size','20' ); |
|---|
| 45 | if ($h5_size) { |
|---|
| 46 | $custom .= ".editor-block-list__layout h5 { font-size:" . intval($h5_size) . "px; }"."\n"; |
|---|
| 47 | } |
|---|
| 48 | //H6 size |
|---|
| 49 | $h6_size = get_theme_mod( 'h6_size','18' ); |
|---|
| 50 | if ($h6_size) { |
|---|
| 51 | $custom .= ".editor-block-list__layout h6 { font-size:" . intval($h6_size) . "px; }"."\n"; |
|---|
| 52 | } |
|---|
| 53 | //Body size |
|---|
| 54 | $body_size = get_theme_mod( 'body_size', '16' ); |
|---|
| 55 | if ($body_size) { |
|---|
| 56 | $custom .= ".editor-block-list__block, .editor-block-list__block p { font-size:" . intval($body_size) . "px; }"."\n"; |
|---|
| 57 | } |
|---|
| 58 | //Single post title |
|---|
| 59 | $single_post_title_size = get_theme_mod( 'single_post_title_size', '36' ); |
|---|
| 60 | if ($single_post_title_size) { |
|---|
| 61 | $custom .= ".editor-post-title__block .editor-post-title__input, .editor-block-list__layout .editor-post-title__input { font-size:" . intval($single_post_title_size) . "px; }"."\n"; |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | //__COLORS |
|---|
| 65 | //Primary color |
|---|
| 66 | $primary_color = get_theme_mod( 'primary_color', '#d65050' ); |
|---|
| 67 | $custom .= ".editor-block-list__layout blockquote.wp-block-quote, .editor-block-list__layout .wp-block-quote:not(.is-large):not(.is-style-large) { border-color:" . esc_attr($primary_color) . "}"."\n"; |
|---|
| 68 | |
|---|
| 69 | //Body |
|---|
| 70 | $body_text = get_theme_mod( 'body_text_color', '#47425d' ); |
|---|
| 71 | $custom .= ".editor-block-list__layout, .editor-block-list__layout .editor-block-list__block { color:" . esc_attr($body_text) . "}"."\n"; |
|---|
| 72 | |
|---|
| 73 | //Small screens font sizes |
|---|
| 74 | $custom .= "@media only screen and (max-width: 780px) { |
|---|
| 75 | h1 { font-size: 32px;} |
|---|
| 76 | h2 { font-size: 28px;} |
|---|
| 77 | h3 { font-size: 22px;} |
|---|
| 78 | h4 { font-size: 18px;} |
|---|
| 79 | h5 { font-size: 16px;} |
|---|
| 80 | h6 { font-size: 14px;} |
|---|
| 81 | }" . "\n"; |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | //Output all the styles |
|---|
| 85 | wp_add_inline_style( 'sydney-block-editor-styles', $custom ); |
|---|
| 86 | |
|---|
| 87 | } |
|---|
| 88 | add_action( 'enqueue_block_editor_assets', 'sydney_editor_styles' ); |
|---|