@@ -193,30 +193,48 @@ function render() {
193193
194194 /* Font Family */
195195 if ($ this ->field ['font-family ' ] === true ) {
196+
197+ //if (filter_var($this->value['google'], FILTER_VALIDATE_BOOLEAN)) {
196198 if (filter_var ($ this ->value ['google ' ], FILTER_VALIDATE_BOOLEAN )) {
199+
200+ // Divide and conquer
197201 $ fontFamily = explode (', ' , $ this ->value ['font-family ' ], 2 );
202+
203+ // If array 0 is empty and array 1 is not
198204 if (empty ($ fontFamily [0 ]) && !empty ($ fontFamily [1 ])) {
205+
206+ // Make array 0 = array 1
199207 $ fontFamily [0 ] = $ fontFamily [1 ];
208+
209+ // Clear array 1
200210 $ fontFamily [1 ] = "" ;
201211 }
202212 }
203213
214+ // If no fontFamily array exists, create one and set array 0
215+ // with font value
204216 if (!isset ($ fontFamily )) {
205217 $ fontFamily = array ();
206218 $ fontFamily [0 ] = $ this ->value ['font-family ' ];
207219 $ fontFamily [1 ] = "" ;
208220 }
221+
222+ // Is selected font a Google font
223+ $ isGoogleFont = '0 ' ;
224+ if (isset ($ this ->parent ->fonts ['google ' ][$ fontFamily [0 ]])) {
225+ $ isGoogleFont = '1 ' ;
226+ }
227+
228+ // If not a Google font, show all font families
229+ if ($ isGoogleFont != '1 ' ) {
230+ $ fontFamily [0 ] = $ this ->value ['font-family ' ];
231+ }
209232
210233 $ userFonts = '0 ' ;
211234 if (true == $ this ->user_fonts ) {
212235 $ userFonts = '1 ' ;
213236 }
214237
215- $ isGoogleFont = '0 ' ;
216- if (isset ($ this ->parent ->fonts ['google ' ][$ fontFamily [0 ]])) {
217- $ isGoogleFont = '1 ' ;
218- }
219-
220238 echo '<input type="hidden" class="redux-typography-font-family ' . $ this ->field ['class ' ] . '" data-user-fonts=" ' . $ userFonts . '" name=" ' . $ this ->field ['name ' ] . '[font-family] ' . $ this ->field ['name_suffix ' ] . '" value=" ' . $ this ->value ['font-family ' ] . '" data-id=" ' . $ this ->field ['id ' ] . '" /> ' ;
221239 echo '<input type="hidden" class="redux-typography-font-options ' . $ this ->field ['class ' ] . '" name=" ' . $ this ->field ['name ' ] . '[font-options] ' . $ this ->field ['name_suffix ' ] . '" value=" ' . $ this ->value ['font-options ' ] . '" data-id=" ' . $ this ->field ['id ' ] . '" /> ' ;
222240
@@ -233,6 +251,7 @@ function render() {
233251
234252 $ googleSet = false ;
235253 if ($ this ->field ['google ' ] === true ) {
254+
236255 // Set a flag so we know to set a header style or not
237256 echo '<input type="hidden" class="redux-typography-google ' . $ this ->field ['class ' ] . '" id=" ' . $ this ->field ['id ' ] . '-google" name=" ' . $ this ->field ['name ' ] . '[google] ' . $ this ->field ['name_suffix ' ] . '" type="text" value=" ' . $ this ->field ['google ' ] . '" data-id=" ' . $ this ->field ['id ' ] . '" /> ' ;
238257 $ googleSet = true ;
@@ -475,19 +494,20 @@ function render() {
475494 $ style = '' ;
476495 if (isset ($ this ->field ['preview ' ]['always_display ' ])) {
477496 if (true === filter_var ( $ this ->field ['preview ' ]['always_display ' ], FILTER_VALIDATE_BOOLEAN )) {
478-
479- $ this ->parent ->typography_preview [$ fontFamily [0 ]] = array (
480- 'font-style ' => array ($ this ->value ['font-weight ' ] . $ this ->value ['font-style ' ]),
481- 'subset ' => array ($ this ->value ['subset ' ])
482- );
497+ if ( $ isGoogleFont == true ) {
498+ $ this ->parent ->typography_preview [$ fontFamily [0 ]] = array (
499+ 'font-style ' => array ($ this ->value ['font-weight ' ] . $ this ->value ['font-style ' ]),
500+ 'subset ' => array ($ this ->value ['subset ' ])
501+ );
483502
484- $ protocol = ( ! empty ( $ _SERVER ['HTTPS ' ] ) && $ _SERVER ['HTTPS ' ] !== 'off ' || $ _SERVER ['SERVER_PORT ' ] == 443 ) ? "https: " : "http: " ;
485-
486- wp_deregister_style ('redux-typography-preview ' );
487- wp_dequeue_style ('redux-typography-preview ' );
488-
489- wp_register_style ( 'redux-typography-preview ' , $ protocol . $ this ->makeGoogleWebfontLink ( $ this ->parent ->typography_preview ), '' , time () );
490- wp_enqueue_style ( 'redux-typography-preview ' );
503+ $ protocol = ( ! empty ( $ _SERVER ['HTTPS ' ] ) && $ _SERVER ['HTTPS ' ] !== 'off ' || $ _SERVER ['SERVER_PORT ' ] == 443 ) ? "https: " : "http: " ;
504+
505+ wp_deregister_style ('redux-typography-preview ' );
506+ wp_dequeue_style ('redux-typography-preview ' );
507+
508+ wp_register_style ( 'redux-typography-preview ' , $ protocol . $ this ->makeGoogleWebfontLink ( $ this ->parent ->typography_preview ), '' , time () );
509+ wp_enqueue_style ( 'redux-typography-preview ' );
510+ }
491511
492512 $ style = 'display: block; font-family: ' . $ this ->value ['font-family ' ] . '; font-weight: ' . $ this ->value ['font-weight ' ] . '; ' ;
493513 }
0 commit comments