fonts_url(), [], Constants::get_version() ); wp_register_style( 'bigshop-fontello', bigshop_get_file('/assets/vendor/fontello.css'), [], Constants::get_version() ); wp_register_script( 'rt-parallex', bigshop_get_js( 'parallex' ), [ 'jquery' ], Constants::get_version(), true ); wp_register_script( 'rt-countdown', bigshop_get_js( 'countdown' ), [ 'jquery' ], Constants::get_version(), true ); wp_register_script( 'rt-headroom', bigshop_get_js( 'headroom' ), [ 'jquery' ], Constants::get_version(), true ); } /** * Enqueue all necessary scripts and styles for the theme * @return void */ public function enqueue_scripts() { // CSS wp_enqueue_style( 'bigshop-gfonts' ); wp_enqueue_style( 'bigshop-fontello' ); wp_enqueue_style( 'bigshop-main', bigshop_get_css( 'style', true ), [], Constants::get_version() ); // JS wp_enqueue_script('rt-headroom'); wp_enqueue_script('rt-countdown'); wp_enqueue_script( 'bigshop-main', bigshop_get_js( 'scripts' ), [ 'jquery' ], Constants::get_version(), true ); // localize script $bigshop_localize_data = array( // Ajax 'ajaxURL' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce( 'bigshop-nonce' ) ); wp_localize_script( 'bigshop-main', 'bigshopObj', $bigshop_localize_data ); // Extra if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } public function enqueue_admin_scripts( ) { wp_register_style( 'bigshop-fontello', bigshop_get_file('/assets/vendor/fontello.css'), [], Constants::get_version() ); wp_enqueue_style( 'bigshop-fontello' ); } public function fonts_url() { if ( 'off' === _x( 'on', 'Google font: on or off', 'bigshop' ) ) { return ''; } //Default variable. $subsets = ''; $body_font = json_decode( bigshop_option( 'rt_body_typo' ), true ); $menu_font = json_decode( bigshop_option( 'rt_menu_typo' ), true ); $h_font = json_decode( bigshop_option( 'rt_all_heading_typo' ), true ); $bodyFont = $body_font['font'] ?? 'Inter'; // Body Font $menuFont = $menu_font['font'] ?? $bodyFont; // Menu Font $hFont = $h_font['font'] ?? $body_font; // Heading Font $hFontW = $h_font['regularweight'] ?? null; $heading_fonts = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ]; foreach ( $heading_fonts as $heading ) { $heading_font = json_decode( bigshop_option( "rt_heading_{$heading}_typo" ), true ); ${$heading . '_font'} = $heading_font; ${$heading . 'Font'} = ''; //Assign default value if not exist the value if ( ! empty( $heading_font['font'] ) ) { ${$heading . 'Font'} = $heading_font['font'] == 'Inherit' ? $hFont : $heading_font['font']; ${$heading . 'FontW'} = $heading_font['font'] == 'Inherit' ? $hFontW : $heading_font['regularweight']; } } $check_families = []; $font_families = []; // Body Font $font_families[] = $bodyFont . ':300,400,500,600,700'; $check_families[] = $bodyFont; // Menu Font if ( ! in_array( $menuFont, $check_families ) ) { $font_families[] = $menuFont . ':300,400,500,600,700'; $check_families[] = $menuFont; } // Heading Font if ( ! in_array( $hFont, $check_families ) ) { $font_families[] = $hFont . ':300,400,500,600,700,800'; $check_families[] = $hFont; } //Check all heading fonts foreach ( $heading_fonts as $heading ) { $hDynamic = ${$heading . '_font'}; if ( ! empty( $hDynamic['font'] ) ) { if ( ! in_array( ${$heading . 'Font'}, $check_families ) ) { $font_families[] = ${$heading . 'Font'} . ':' . ${$heading . 'FontW'}; $check_families[] = ${$heading . 'Font'}; } } } $final_fonts = array_unique( $font_families ); $query_args = [ 'family' => urlencode( implode( '|', $final_fonts ) ), 'display' => urlencode( 'fallback' ), ]; $fonts_url = add_query_arg( $query_args, "//fonts.googleapis.com/css" ); return esc_url_raw( $fonts_url ); } }