From f0935052c2266ff55f73ba0eb50bfa12f626f07d Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 29 Jul 2015 19:37:06 +0000 Subject: [PATCH] Press This: properly add Open Sans to the editor, using the `mce_css` filter. See #26072. Fixes #33189. git-svn-id: https://develop.svn.wordpress.org/trunk@33497 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/css/press-this-editor.css | 1 - src/wp-admin/includes/class-wp-press-this.php | 31 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/css/press-this-editor.css b/src/wp-admin/css/press-this-editor.css index 098921f94d..96ff426168 100644 --- a/src/wp-admin/css/press-this-editor.css +++ b/src/wp-admin/css/press-this-editor.css @@ -6,7 +6,6 @@ Press This TinyMCE editor styles :) /** * Links */ -@import url("https://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,600,700"); a { color: #0073aa; } diff --git a/src/wp-admin/includes/class-wp-press-this.php b/src/wp-admin/includes/class-wp-press-this.php index 48e7f2dddf..58ed28661a 100644 --- a/src/wp-admin/includes/class-wp-press-this.php +++ b/src/wp-admin/includes/class-wp-press-this.php @@ -783,7 +783,36 @@ class WP_Press_This { $press_this = str_replace( '.css', '-rtl.css', $press_this ); } - return $styles . $press_this; + $open_sans_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' ) ) { + $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)' ); + + if ( 'cyrillic' == $subset ) { + $subsets .= ',cyrillic,cyrillic-ext'; + } elseif ( 'greek' == $subset ) { + $subsets .= ',greek,greek-ext'; + } elseif ( 'vietnamese' == $subset ) { + $subsets .= ',vietnamese'; + } + + $query_args = array( + 'family' => urlencode( 'Open Sans:400italic,700italic,400,600,700' ), + 'subset' => urlencode( $subsets ), + ); + + $open_sans_font_url = ',' . add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); + } + + return $styles . $press_this . $open_sans_font_url; } /**