@@ -53,7 +53,7 @@ protected function render() {
5353}
5454endif ;
5555
56- if ( !class_exists ('SiteOrigin_Customizer_CSS_Builder ' ) ) :
56+ if ( !class_exists ( 'SiteOrigin_Customizer_CSS_Builder ' ) ) :
5757/**
5858 * This is used for building custom CSS.
5959 */
@@ -87,13 +87,15 @@ function css() {
8787 // Start by importing Google web fonts
8888 $ return = '<style type="text/css" id="customizer-css"> ' ;
8989
90- $ import = array ();
91- foreach ( $ this ->google_fonts as $ font ) {
92- $ import [ ] = urlencode ( $ font [ 0 ] ) . ': ' . $ font [ 1 ];
93- }
94- $ import = array_unique ( $ import );
95- if ( !empty ( $ import ) ) {
96- $ return .= '@import url(http ' . ( is_ssl () ? 's ' : '' ) . '://fonts.googleapis.com/css?family= ' . implode ( '| ' , $ import ) . '); ' ;
90+ if ( apply_filters ( 'origami_import_google_fonts ' , true ) ) {
91+ $ import = array ();
92+ foreach ( $ this ->google_fonts as $ font ) {
93+ $ import [ ] = urlencode ( $ font [ 0 ] ) . ': ' . $ font [ 1 ];
94+ }
95+ $ import = array_unique ( $ import );
96+ if ( !empty ( $ import ) ) {
97+ $ return .= '@import url(//fonts.googleapis.com/css?family= ' . implode ( '| ' , $ import ) . '&display=block); ' ;
98+ }
9799 }
98100
99101 foreach ( $ this ->css as $ selector => $ rules ) {
@@ -175,13 +177,16 @@ function add_web_font( $selector, $mod ) {
175177 }
176178
177179 $ this ->add_css ( $ selector , 'font-family ' , $ family );
178- if ( $ variant != 400 ) $ this ->add_css ( $ selector , 'font-weight ' , $ variant );
179-
180- $ this ->fonts [ ] = $ font ;
181-
182- if ( !empty ( $ variant ) ) {
183- if ( $ variant == 'regular ' ) $ variant = '400 ' ;
184- $ this ->css [ $ selector ][ ] = 'font-weight: ' . $ variant ;
180+ if ( ! empty ( $ variant ) ) {
181+ if ( $ variant != 400 && $ variant != 'regular ' ) {
182+ if ( ! is_numeric ( $ variant ) ) {
183+ $ variant = filter_var ( $ variant , FILTER_SANITIZE_NUMBER_INT );
184+ $ this ->add_css ( $ selector , 'font-style ' , 'italic ' );
185+ }
186+ $ this ->add_css ( $ selector , 'font-weight ' , $ variant );
187+ } else {
188+ $ this ->add_css ( $ selector , 'font-weight ' , 400 );
189+ }
185190 }
186191 }
187192
@@ -325,7 +330,7 @@ class SiteOrigin_Customizer_Helper {
325330 private $ sections ;
326331 private $ defaults ;
327332
328- function __construct ($ settings = array (), $ sections = array (), $ theme , $ root_url = false , $ make_single = true ){
333+ function __construct ($ settings = array (), $ sections = array (), $ theme = ' generic ' , $ root_url = false , $ make_single = true ){
329334 // Give child themes a chance to filter this.
330335 $ this ->theme = $ theme ;
331336 $ this ->defaults = array ();
@@ -334,11 +339,6 @@ function __construct($settings = array(), $sections = array(), $theme, $root_url
334339 $ this ->add_sections ($ sections );
335340 $ this ->add_settings ($ settings );
336341
337- if ( empty ($ root_url ) ) {
338- $ root_url = get_template_directory_uri ().'/premium/extras/customizer/ ' ;
339- }
340- $ this ->root_url = $ root_url ;
341-
342342 // Add a script that will help us with our previews
343343 add_action ( 'customize_preview_init ' , array ( $ this , 'enqueue ' ) );
344344 add_action ( 'customize_controls_enqueue_scripts ' , array ( $ this , 'admin_enqueue ' ) );
@@ -452,6 +452,11 @@ function customize_register($wp_customize){
452452 // Can't use live changes with a callback
453453 if ( !empty ($ setting ['callback ' ]) ) $ setting ['no_live ' ] = true ;
454454
455+ // Set $setting['description' ] if this setting doesn't have a description
456+ if ( ! isset ( $ setting ['description ' ] ) ) {
457+ $ setting ['description ' ] = '' ;
458+ }
459+
455460 // Now lets add a control for this setting
456461 switch ($ setting ['type ' ]) {
457462 case 'font ' :
@@ -460,6 +465,7 @@ function customize_register($wp_customize){
460465 'section ' => $ setting ['section ' ],
461466 'settings ' => $ id ,
462467 'priority ' => $ priority ++,
468+ 'description ' => esc_html ( $ setting ['description ' ] ),
463469 ) ) );
464470 break ;
465471
@@ -469,6 +475,7 @@ function customize_register($wp_customize){
469475 'section ' => $ setting ['section ' ],
470476 'settings ' => $ id ,
471477 'priority ' => $ priority ++,
478+ 'description ' => esc_html ( $ setting ['description ' ] ),
472479 ) ) );
473480 if ( empty ( $ setting ['no_live ' ] ) ) $ wp_customize ->get_setting ( $ id )->transport = 'postMessage ' ;
474481 break ;
@@ -479,6 +486,7 @@ function customize_register($wp_customize){
479486 'section ' => $ setting ['section ' ],
480487 'type ' => 'text ' ,
481488 'priority ' => $ priority ++,
489+ 'description ' => esc_html ( $ setting ['description ' ] ),
482490 ) );
483491 if ( empty ( $ setting ['no_live ' ] ) ) $ wp_customize ->get_setting ( $ id )->transport = 'postMessage ' ;
484492 break ;
@@ -489,6 +497,7 @@ function customize_register($wp_customize){
489497 'section ' => $ setting ['section ' ],
490498 'settings ' => $ id ,
491499 'priority ' => $ priority ++,
500+ 'description ' => esc_html ( $ setting ['description ' ] ),
492501 ) ) );
493502 break ;
494503
@@ -498,6 +507,7 @@ function customize_register($wp_customize){
498507 'section ' => $ setting ['section ' ],
499508 'settings ' => $ id ,
500509 'priority ' => $ priority ++,
510+ 'description ' => esc_html ( $ setting ['description ' ] ),
501511 ) ) );
502512 break ;
503513
@@ -508,6 +518,7 @@ function customize_register($wp_customize){
508518 'type ' => $ setting ['type ' ],
509519 'priority ' => $ priority ++,
510520 'choices ' => isset ($ setting ['choices ' ]) ? $ setting ['choices ' ] : null ,
521+ 'description ' => esc_html ( $ setting ['description ' ] ),
511522 ) );
512523 break ;
513524 }
@@ -559,11 +570,11 @@ function create_css_builder(){
559570 }
560571 }
561572 }
562-
563- if ( isset ($ setting ['callback ' ]) ) {
564- $ val = get_theme_mod ($ id );
565- if ( isset ( $ setting ['default ' ] ) && $ val != $ setting ['default ' ]) {
566- call_user_func ( $ setting ['callback ' ], $ builder , $ val , array_merge ( $ setting , array ('id ' => $ id ) ) );
573+
574+ if ( isset ( $ setting ['callback ' ] ) ) {
575+ $ val = get_theme_mod ( $ id );
576+ if ( isset ( $ setting ['default ' ] ) && $ val != $ setting ['default ' ] ) {
577+ call_user_func ( $ setting ['callback ' ], $ builder , $ val , array_merge ( $ setting , array ( 'id ' => $ id ) ) );
567578 }
568579 }
569580 }
@@ -598,7 +609,7 @@ function admin_enqueue( ){
598609 )
599610 ));
600611
601- wp_enqueue_style ('siteorigin-customizer-admin ' , $ this -> root_url . 'css/admin.css ' , array ( ), SITEORIGIN_THEME_VERSION );
612+ wp_enqueue_style ('siteorigin-customizer-admin ' , get_template_directory_uri () . '/inc/customizer/ css/admin.css ' , array ( ), SITEORIGIN_THEME_VERSION );
602613 }
603614
604615 /**
@@ -611,4 +622,4 @@ function reset_defaults(){
611622 }
612623}
613624
614- endif ;
625+ endif ;
0 commit comments