'postMessage' instead of the default 'transport' * => 'refresh' * * @return void */ public static function live_preview() { /* Live Preview using Javascript and postMessage Transport */ } /** * Enqueue customizer scripts. * * @return void */ public static function enqueue_scripts() { $deps = [ 'jquery', 'wp-color-picker' ]; wp_enqueue_script( 'chosen', get_template_directory_uri() . '/assets/plugins/chosen/chosen.jquery.min.js', $deps, '1.0.0', true ); wp_enqueue_script( 'themeoo-customizer', get_template_directory_uri() . '/inc/customizer/assets/js/customizer.min.js', array(), '1.0.0', true ); wp_localize_script( 'themeoo-customizer', 'themeooCustomizerFontsL10n', themeoo_get_all_fonts() ); wp_enqueue_style( 'chosen', get_template_directory_uri() . '/assets/plugins/chosen/chosen.min.css', array(), '1.0.0' ); wp_enqueue_style( 'themeoo-customizer', get_template_directory_uri() . '/inc/customizer/assets/css/customizer.css', array(), '1.0.0' ); } /** * Enqueue fonts. * * @return void */ public static function enqueue_fonts() { if ( false === apply_filters( 'themeoo_enqueue_google_fonts', true ) ) { return; } $fonts = [ 'typography_global_font_family' => themeoo_get_mod( 'typography_global_font_family' ), 'typography_global_font_variant' => themeoo_get_mod( 'typography_global_font_variant' ), 'typography_global_font_variant_extra' => themeoo_get_mod( 'typography_global_font_variant_extra' ), 'typography_heading_h1_font_family' => themeoo_get_mod( 'typography_heading_h1_font_family' ), 'typography_heading_h1_font_variant' => themeoo_get_mod( 'typography_heading_h1_font_variant' ), 'typography_heading_h1_font_variant_extra' => themeoo_get_mod( 'typography_heading_h1_font_variant_extra' ), 'typography_heading_h2_font_family' => themeoo_get_mod( 'typography_heading_h2_font_family' ), 'typography_heading_h2_font_variant' => themeoo_get_mod( 'typography_heading_h2_font_variant' ), 'typography_heading_h2_font_variant_extra' => themeoo_get_mod( 'typography_heading_h2_font_variant_extra' ), 'typography_heading_h3_font_family' => themeoo_get_mod( 'typography_heading_h3_font_family' ), 'typography_heading_h3_font_variant' => themeoo_get_mod( 'typography_heading_h3_font_variant' ), 'typography_heading_h3_font_variant_extra' => themeoo_get_mod( 'typography_heading_h3_font_variant_extra' ), 'typography_heading_h4_font_family' => themeoo_get_mod( 'typography_heading_h4_font_family' ), 'typography_heading_h4_font_variant' => themeoo_get_mod( 'typography_heading_h4_font_variant' ), 'typography_heading_h4_font_variant_extra' => themeoo_get_mod( 'typography_heading_h4_font_variant_extra' ), 'typography_heading_h5_font_family' => themeoo_get_mod( 'typography_heading_h5_font_family' ), 'typography_heading_h5_font_variant' => themeoo_get_mod( 'typography_heading_h5_font_variant' ), 'typography_heading_h5_font_variant_extra' => themeoo_get_mod( 'typography_heading_h5_font_variant_extra' ), 'typography_heading_h6_font_family' => themeoo_get_mod( 'typography_heading_h6_font_family' ), 'typography_heading_h6_font_variant' => themeoo_get_mod( 'typography_heading_h6_font_variant' ), 'typography_heading_h6_font_variant_extra' => themeoo_get_mod( 'typography_heading_h6_font_variant_extra' ), 'typography_menu_font_family' => themeoo_get_mod( 'typography_menu_font_family' ), 'typography_menu_font_variant' => themeoo_get_mod( 'typography_menu_font_variant' ), 'typography_menu_font_variant_extra' => themeoo_get_mod( 'typography_menu_font_variant_extra' ), 'typography_menu_sub_font_family' => themeoo_get_mod( 'typography_menu_sub_font_family' ), 'typography_menu_sub_font_variant' => themeoo_get_mod( 'typography_menu_sub_font_variant' ), 'typography_menu_sub_font_variant_extra' => themeoo_get_mod( 'typography_menu_sub_font_variant_extra' ), 'typography_menu_mobile_font_family' => themeoo_get_mod( 'typography_menu_mobile_font_family' ), 'typography_menu_mobile_font_variant' => themeoo_get_mod( 'typography_menu_mobile_font_variant' ), 'typography_menu_mobile_font_variant_extra' => themeoo_get_mod( 'typography_menu_mobile_font_variant_extra' ), 'typography_site_title_font_family' => themeoo_get_mod( 'typography_site_title_font_family' ), 'typography_site_title_font_variant' => themeoo_get_mod( 'typography_site_title_font_variant' ), 'typography_site_title_font_variant_extra' => themeoo_get_mod( 'typography_site_title_font_variant_extra' ), 'typography_site_tagline_font_family' => themeoo_get_mod( 'typography_site_tagline_font_family' ), 'typography_site_tagline_font_variant' => themeoo_get_mod( 'typography_site_tagline_font_variant' ), 'typography_site_tagline_font_variant_extra' => themeoo_get_mod( 'typography_site_tagline_font_variant_extra' ), 'typography_sidebar_title_font_family' => themeoo_get_mod( 'typography_sidebar_title_font_family' ), 'typography_sidebar_title_font_variant' => themeoo_get_mod( 'typography_sidebar_title_font_variant' ), 'typography_sidebar_title_font_variant_extra' => themeoo_get_mod( 'typography_sidebar_title_font_variant_extra' ), 'typography_sidebar_body_font_family' => themeoo_get_mod( 'typography_sidebar_body_font_family' ), 'typography_sidebar_body_font_variant' => themeoo_get_mod( 'typography_sidebar_body_font_variant' ), 'typography_sidebar_body_font_variant_extra' => themeoo_get_mod( 'typography_sidebar_body_font_variant_extra' ), 'typography_footer_title_font_family' => themeoo_get_mod( 'typography_footer_title_font_family' ), 'typography_footer_title_font_variant' => themeoo_get_mod( 'typography_footer_title_font_variant' ), 'typography_footer_title_font_variant_extra' => themeoo_get_mod( 'typography_footer_title_font_variant_extra' ), 'typography_footer_body_font_family' => themeoo_get_mod( 'typography_footer_body_font_family' ), 'typography_footer_body_font_variant' => themeoo_get_mod( 'typography_footer_body_font_variant' ), 'typography_footer_body_font_variant_extra' => themeoo_get_mod( 'typography_footer_body_font_variant_extra' ), 'typography_footer_text_font_family' => themeoo_get_mod( 'typography_footer_text_font_family' ), 'typography_footer_text_font_variant' => themeoo_get_mod( 'typography_footer_text_font_variant' ), 'typography_footer_text_font_variant_extra' => themeoo_get_mod( 'typography_footer_text_font_variant_extra' ), ]; $used_fonts = []; $defaults = array_keys( themeoo_get_standard_fonts() ); foreach ( $fonts as $key => $value ) { if ( themeoo_string_ends_with( $key, '_family' ) && ! empty( $value ) && ! in_array( $value, $defaults ) ) { $settings = str_replace( '_family', '_variant', $key ); $settings_extra = str_replace( '_family', '_variant_extra', $key ); $variant = themeoo_get_default_mod( $settings, $fonts ); $variant_extra = themeoo_get_default_mod( $settings_extra, $fonts ); if ( ! is_array( $variant ) && ! empty( $variant ) ) { $variant = [ $variant ]; } if ( ! is_array( $variant_extra ) ) { //$variant_extra = [ $variant_extra ]; } if ( ! isset( $used_fonts[ $value ] ) ) { $used_fonts[ $value ] = [ 'family' => $value, 'variants' => [], ]; } if ( ! empty( $variant ) ) { $used_fonts[ $value ]['variants'] = array_merge( $used_fonts[ $value ]['variants'], $variant ); } if ( ! empty( $variant_extra ) ) { $used_fonts[ $value ]['variants'] = array_merge( $used_fonts[ $value ]['variants'], $variant_extra ); } $used_fonts[ $value ]['variants'] = array_filter($used_fonts[ $value ]['variants']); $used_fonts[ $value ]['variants'] = array_unique($used_fonts[ $value ]['variants']); } } $query_args = []; if ( empty( $used_fonts ) ) { // Roboto:300|Raleway:700,regular $query_args['family'] = 'Roboto:300|Raleway:100,500,700,regular'; } else { $query_args['family'] = array_reduce( $used_fonts, function ( $carry, $item ) { return $item['family'] . ':' . implode( ',', $item['variants'] ) . '|' . $carry; } ); $query_args['family'] = rtrim( $query_args['family'], '|' ); } $query_args['subset'] = implode( ',', (array) themeoo_get_mod( 'typography_options_subsets' ) ); wp_enqueue_style( 'themeoo_google-fonts', add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ), array(), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion } /** * Prints Customizer Generated CSS & CSS Variables. * * @return void */ public static function generate_css() { // phpcs:disable WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound $mappings = require THEMEOO_THEME_DIR . 'inc/customizer/css-variable-mapping.php'; // phpcs:enable $vars = ''; foreach ( $mappings as $k => $v ) { $mod = themeoo_get_mod( $k ); if ( is_array( $mod ) ) { // @XXX in some case font_variant return's array (maybe for old installation/not selected). $mod = reset( $mod ); } $mod = esc_attr( (string) $mod ); if ( $mod && 'default' !== strtolower( $mod ) ) { if ( false !== strpos( $v, '-fw-' ) ) { $style = str_replace( '-fw-', '-font-style-', $v ); if ( in_array( $mod, [ 'regular', 'italic' ] ) ) { $vars .= "$v:400;"; if ( 'italic' === $mod ) { $vars .= "$style:italic;"; } continue; } if ( strpos( $mod, 'regular' ) || strpos( $mod, 'italic' ) ) { $fw = str_replace( [ 'regular', 'italic' ], '', $mod ); $vars .= "$v:$fw;"; if ( strpos( $mod, 'italic' ) ) { $vars .= "$style:italic;"; } continue; } } $vars .= "$v:{$mod}"; if ( strpos( $k, '_logo_width') || strpos( $k, '_main_menu_width') || strpos( $k, '_button_width') ) { $vars .= '%'; } elseif ( ( false !== strpos( $k, 'layout_' ) && ! ( false !== strpos( $k, 'align' ) ) ) || strpos( $k, 'font_size' ) || strpos( $k, 'letter_spacing' ) || strpos( $k, 'word_spacing' ) ) { $vars .= 'px'; } $vars .= ';'; } } if ( ! empty( $vars ) ) { ?> '.boxed', 'title_bar_title_container' => '#title-container', 'footer_top_bg_img' => '.themeoo-footer-top', ]; foreach ( $bg as $mod => $selector ) { $css .= self::background_image_mod( $mod, $selector ); } /* Container Fluid Max Width */ $mod = themeoo_get_mod( 'layout_global_content_layout_max_width' ); if ( $mod ) { $css .= '.container-fluid{max-width:' . absint( $mod ) . 'px}'; } // Print Css. if ( ! empty( $css ) ) { ?>