'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_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_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_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_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_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_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_menu_font_family' => themeoo_get_mod( 'typography_menu_font_family' ), 'typography_menu_font_variant' => themeoo_get_mod( 'typography_menu_font_variant' ), '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_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_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_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_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_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_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_text_font_family' => themeoo_get_mod( 'typography_footer_text_font_family' ), 'typography_footer_text_font_variant' => themeoo_get_mod( 'typography_footer_text_font_variant' ), ]; $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 ); $variant = themeoo_get_default_mod( $settings, $fonts ); $used_fonts[ $value ] = array_key_exists( $value, $used_fonts ) ? ( strpos( $used_fonts[ $value ], $variant ) !== false ) ? $used_fonts[ $value ] : "$used_fonts[$value],$variant" : "$value:$variant"; } } $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'] = str_replace( ' ', '+', implode( '|', array_values( $used_fonts ) ) ); } $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 = esc_attr( themeoo_get_mod( $k ) ); 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 ) ) { ?>