enqueue_google_fonts(array()); if ( empty( $all_google_fonts ) ) { return false; } $unique_google_fonts = array(); if( !empty( $all_google_fonts )){ foreach( $all_google_fonts as $single_google_font ){ $font_family = str_replace( ' ', '+', $single_google_font['family'] ); if( isset( $single_google_font['font-weight']) ){ $unique_google_fonts[$font_family]['font-weight'][] = $single_google_font['font-weight']; } } } $google_font_family = ''; if( !empty( $unique_google_fonts )){ foreach( $unique_google_fonts as $font_family => $unique_google_font ){ if ( $google_font_family ) { $google_font_family .= '|'; } $google_font_family .= $font_family; if( isset( $unique_google_font['font-weight']) ){ $unique_font_weights = array_unique( $unique_google_font['font-weight'] ); $google_font_family .= ':' . join( ',', $unique_font_weights ); } } } if ($google_font_family) { $google_font_family = str_replace( 'italic', 'i', $google_font_family ); $fonts_url = add_query_arg(array( 'family' => $google_font_family ), '//fonts.googleapis.com/css'); /*// For the Block Editor. add_theme_support( 'editor-styles' ); add_editor_style( $fonts_url );*/ return $fonts_url; } return false; } /** * Call back function for cosmoswp_column_elements * Change Post/Page builder layout * * @since 1.0.0 * @access public * * @return array */ public function add_editor_dynamic_styles( ){ $getCSS = ''; $dynamic_css = $this->dynamic_css(); if (is_array($dynamic_css)) { foreach ($dynamic_css as $screen => $css) { if ($screen == "all") { if (is_array($css)) { $getCSS .= implode(" ", $css); } else { $getCSS .= $css; } } elseif ($screen == "tablet") { $getCSS .= '@media (min-width: 720px) {'; if (is_array($css)) { $getCSS .= implode(" ", $css); } else { $getCSS .= $css; } $getCSS .= "}"; } elseif ($screen == "desktop") { $getCSS .= '@media (min-width: 992px) {'; if (is_array($css)) { $getCSS .= implode(" ", $css); } else { $getCSS .= $css; } $getCSS .= "}"; } } } //$output = cosmoswp_dynamic_css()->minify_css( $getCSS ); $styles = $getCSS; if( $this->add_editor_google_fonts()){ wp_enqueue_style( 'cosmmoswp-block-google-fonts', $this->add_editor_google_fonts(), false, '1.0' ); /** * Styles from the customizer */ wp_add_inline_style( 'cosmmoswp-block-google-fonts', $styles ); } } } endif; /** * Create Instance for CosmosWP_Editor_Style * * @since 1.0.0 * @access public * * @param * * @return object */ if ( ! function_exists( 'cosmoswp_editor_style' ) ) { function cosmoswp_editor_style() { return CosmosWP_Editor_Style::instance(); } cosmoswp_editor_style()->run(); }