urlencode( implode( '|', $font_families ) ), 'subset' => urlencode( 'latin,latin-ext' ), ); $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); } return $fonts_url; } endif; /*---------------------------------------------------------------------------------------------------------------*/ /** * Social media function * * @since 1.0.0 */ if( !function_exists( 'blogmagazine_social_media' ) ): function blogmagazine_social_media() { $get_social_media_icons = get_theme_mod( 'social_media_icons', '' ); $get_decode_social_media = json_decode( $get_social_media_icons ); if( ! empty( $get_decode_social_media ) ) { echo '
'; foreach ( $get_decode_social_media as $single_icon ) { $icon_class = (isset($single_icon->icon_class)) ? $single_icon->icon_class : ''; $icon_url = (isset($single_icon->icon_url)) ? $single_icon->icon_url : ''; $icon_background = (isset($single_icon->icon_background)) ? $single_icon->icon_background : ''; if( !empty( $icon_url ) ) { echo ''; } } echo '
'; } } endif; /*-----------------------------------------------------------------------------------------------------------------------*/ /** * Category list * * @return array(); */ if( !function_exists( 'blogmagazine_categories_lists' ) ): function blogmagazine_categories_lists() { $blogmagazine_categories = get_categories( array( 'hide_empty' => false ) ); $blogmagazine_categories_lists = array(); foreach( $blogmagazine_categories as $category ) { $blogmagazine_categories_lists[$category->term_id] = $category->name . ' ('.$category->count.')'; } return $blogmagazine_categories_lists; } endif; /*-----------------------------------------------------------------------------------------------------------------------*/ /** * Category dropdown * * @return array(); */ if( !function_exists( 'blogmagazine_categories_dropdown' ) ): function blogmagazine_categories_dropdown() { $blogmagazine_categories = get_categories( array( 'hide_empty' => 1 ) ); $blogmagazine_categories_lists = array(); $blogmagazine_categories_lists['0'] = esc_html__( 'Select Category', 'blogmagazine' ); foreach( $blogmagazine_categories as $category ) { $blogmagazine_categories_lists[esc_attr( $category->term_id )] = esc_html( $category->name . ' ('.$category->count.')' ); } return $blogmagazine_categories_lists; } endif; /*-----------------------------------------------------------------------------------------------------------------------*/ /** * Get minified css and removed space * * @since 1.0.0 */ function blogmagazine_css_strip_whitespace( $css ){ $replace = array( "#/\*.*?\*/#s" => "", // Strip C style comments. "#\s\s+#" => " ", // Strip excess whitespace. ); $search = array_keys( $replace ); $css = preg_replace( $search, $replace, $css ); $replace = array( ": " => ":", "; " => ";", " {" => "{", " }" => "}", ", " => ",", "{ " => "{", ";}" => "}", // Strip optional semicolons. ",\n" => ",", // Don't wrap multiple selectors. "\n}" => "}", // Don't wrap closing braces. "} " => "}\n", // Put each rule on it's own line. ); $search = array_keys( $replace ); $css = str_replace( $search, $replace, $css ); return trim( $css ); } /*-----------------------------------------------------------------------------------------------------------------------*/ /** * Generate darker color * Source: http://stackoverflow.com/questions/3512311/how-to-generate-lighter-darker-color-with-php * * @since 1.0.0 */ if( ! function_exists( 'blogmagazine_hover_color' ) ) : function blogmagazine_hover_color( $hex, $steps ) { // Steps should be between -255 and 255. Negative = darker, positive = lighter $steps = max( -255, min( 255, $steps ) ); // Normalize into a six character long hex string $hex = str_replace( '#', '', $hex ); if ( strlen( $hex ) == 3) { $hex = str_repeat( substr( $hex,0,1 ), 2 ).str_repeat( substr( $hex, 1, 1 ), 2 ).str_repeat( substr( $hex,2,1 ), 2 ); } // Split into three parts: R, G and B $color_parts = str_split( $hex, 2 ); $return = '#'; foreach ( $color_parts as $color ) { $color = hexdec( $color ); // Convert to decimal $color = max( 0, min( 255, $color + $steps ) ); // Adjust color $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code } return $return; } endif; if(!function_exists('blogmagazine_fallback_menu')): function blogmagazine_fallback_primary_menu(){ ?>