', esc_url( get_bloginfo( 'pingback_url' ) ) ); } } add_action( 'wp_head', 'azure_news_pingback_header' ); /*---------------------------- Enqueue style and scripts -------------------------------------------------------------*/ if ( ! function_exists( 'azure_news_admin_scripts' ) ) : /** * Enqueue admin scripts and styles. */ function azure_news_admin_scripts( $hook ) { // Only needed on these admin screens if ( $hook != 'edit.php' && $hook != 'post.php' && $hook != 'post-new.php' && 'widgets.php' != $hook ) { return; } wp_enqueue_style( 'azure-news-widget-style', get_template_directory_uri() . '/inc/widgets/assets/css/widget-admin-style.css', array(), AZURE_NEWS_VERSION ); wp_enqueue_script( 'azure-news-widget-script', get_template_directory_uri() . '/inc/widgets/assets/js/widget-admin-script.js', array( 'jquery' ), AZURE_NEWS_VERSION, true ); } endif; add_action( 'admin_enqueue_scripts', 'azure_news_admin_scripts' ); if ( ! function_exists( 'azure_news_scripts' ) ) : /** * Enqueue scripts and styles. */ function azure_news_scripts() { wp_enqueue_style( 'azure-news-fonts', azure_news_google_font_callback(), array(), null ); wp_enqueue_style( 'lightslider', get_template_directory_uri() . '/assets/library/lightslider/css/lightslider.min.css', array(), AZURE_NEWS_VERSION ); wp_enqueue_style( 'box-icons', get_template_directory_uri() . '/assets/library/box-icons/css/boxicons.min.css', null, '2.1.4' ); wp_enqueue_style( 'azure-news-style', get_stylesheet_uri(), array(), AZURE_NEWS_VERSION ); wp_enqueue_style( 'azure-news-responsive-style', get_template_directory_uri() . '/assets/css/azure-news-responsive.css', array(), AZURE_NEWS_VERSION ); $azure_news_preloader_enable = azure_news_get_customizer_option_value( 'azure_news_preloader_enable' ); if ( false !== $azure_news_preloader_enable ) { wp_enqueue_style( 'azure-news-preloader', get_template_directory_uri(). '/assets/css/azure-news-preloader.css', array(), AZURE_NEWS_VERSION ); } wp_enqueue_script( 'jquery-ui-tabs' ); wp_enqueue_script( 'jquery-cookie', get_template_directory_uri() . '/assets/library/jquery-cookie/jquery.cookie.js', array(), AZURE_NEWS_VERSION, true ); wp_enqueue_script( 'lightslider', get_template_directory_uri() . '/assets/library/lightslider/js/lightslider.min.js', array(), AZURE_NEWS_VERSION, true ); wp_enqueue_script( 'jquery-marquee', get_template_directory_uri() . '/assets/library/js-marquee/jquery.marquee.js', array(), AZURE_NEWS_VERSION, true ); wp_enqueue_script( 'jquery-header-sticky', get_template_directory_uri() . '/assets/library/sticky/jquery.sticky.min.js', array(), AZURE_NEWS_VERSION, true ); wp_enqueue_script( 'jquery-sticky-sidebar', get_template_directory_uri() . '/assets/library/sticky-sidebar/theia-sticky-sidebar.min.js', array(), AZURE_NEWS_VERSION, true ); wp_enqueue_script( 'azure-news-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), AZURE_NEWS_VERSION, true ); wp_enqueue_script( 'azure-news-main-scripts', get_template_directory_uri() . '/assets/js/main-scripts.js', array( 'jquery' ), AZURE_NEWS_VERSION, true ); wp_enqueue_script( 'azure-news-keyboard-accessibility', get_template_directory_uri() . '/assets/js/keyboard-accessibility.js', array( 'jquery' ), AZURE_NEWS_VERSION, true ); $azure_news_header_sticky_enable = azure_news_get_customizer_option_value( 'azure_news_header_sticky_enable' ); $azure_news_sidebar_sticky_enable = azure_news_get_customizer_option_value( 'azure_news_sidebar_sticky_enable' ); $header_sticky = $azure_news_header_sticky_enable ? 'true' : 'false'; $sidebar_sticky = $azure_news_sidebar_sticky_enable ? 'true' : 'false'; wp_localize_script( 'azure-news-main-scripts', 'OG_JSObject', array( 'sidebar_sticky' => $sidebar_sticky, 'header_sticky' => $header_sticky ) ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } endif; add_action( 'wp_enqueue_scripts', 'azure_news_scripts' ); if ( ! function_exists( 'azure_news_social_icons_array' ) ) : /** * List of box icons * * @return array(); * @since 1.0.0 */ function azure_news_social_icons_array() { return array( "bx bxl-facebook", "bx bxl-facebook-circle", "bx bxl-facebook-square", "bx bxl-twitter", "bx bxl-google", "bx bxl-google-plus", "bx bxl-google-plus-circle", "bx bxl-google-cloud", "bx bxl-instagram", "bx bxl-instagram-alt", "bx bxl-skype", "bx bxl-whatsapp", "bx bxl-whatsapp-square", "bx bxl-tiktok", "bx bxl-airbnb", "bx bxl-deviantart", "bx bxl-linkedin", "bx bxl-linkedin-square", "bx bxl-pinterest", "bx bxl-pinterest-alt", "bx bxl-adobe", "bx bxl-flickr", "bx bxl-flickr-square", "bx bxl-tumblr", "bx bxl-slack", "bx bxl-reddit", "bx bxl-messenger", "bx bxl-wordpress", "bx bxl-behance", "bx bxl-dribbble", "bx bxl-yahoo", "bx bxl-blogger", "bx bxl-snapchat", "bx bxl-wix", "bx bxl-meta", "bx bxl-baidu", "bx bxl-discord", "bx bxl-twitch", "bx bxl-discord-alt", "bx bxl-vk", "bx bxl-trip-advisor", "bx bxl-telegram", "bx bxl-quora", "bx bxl-ok-ru", "bx bxl-microsoft-teams", "bx bxl-foursquare", "bx bxl-soundcloud", "bx bxl-vimeo", "bx bxl-digg", "bx bxl-periscope", "bx bxl-xing", "bx bxl-youtube", "bx bxl-imdb", ); } endif; if ( ! function_exists( 'azure_news_get_date_format_args' ) ) : /** * Generate date format array for query arguments * * @return array * @since 1.0.0 */ function azure_news_get_date_format_args( $format ) { switch( $format ) { case 'today': $today_date = getdate(); $get_args = array( 'year' => $today_date['year'], 'month' => $today_date['mon'], 'day' => $today_date['mday'], ); return $get_args ; break; case 'this-week': $get_args = array( 'year' => date( 'Y' ), 'week' => date( 'W' ) ); return $get_args; break; case 'last-week': $this_week = date( 'W' ); if ( $this_week != 1 ) { $last_week = $this_week - 1; } else { $last_week = 52; } $this_year = date( 'Y' ); if ( $last_week != 52 ) { $this_year = date( 'Y' ); } else { $this_year = date( 'Y' ) -1; } $get_args = array( 'year' => $this_year, 'week' => $last_week ); return $get_args; break; case 'this-month': $today_date = getdate(); $get_args = array( 'month' => $today_date['mon'] ); return $get_args; break; case 'last-month': $this_date = getdate(); if ( $this_date['mon'] != 1 ) { $last_month = $this_date['mon'] - 1; } else { $last_month = 12; } $this_year = date( 'Y' ); if ( $last_month != 12 ) { $this_year = date('Y'); } else { $this_year = date('Y') - 1; } $get_args = array( 'year' => $this_year, 'month' => $last_month ); return $get_args; break; default: return []; } } endif; if ( ! function_exists( 'azure_news_render_tab_posts' ) ) : /** * function to output the tab posts. * * @since 1.0.0 */ function azure_news_render_tab_posts( $azure_news_tab_type ) { $azure_news_tab_args = array( 'posts_per_page' => apply_filters( 'azure_news_banner_tab_post_count', 3 ), 'ignore_sticky_posts' => true ); switch ( $azure_news_tab_type ) { case 'popular': $azure_news_tab_args['orderby'] = 'comment_count'; break; case 'trending': $azure_news_trending_category = azure_news_get_customizer_option_value( 'azure_news_banner_tab_trending_category' ); if ( 'all' !== $azure_news_trending_category ) { $azure_news_tab_args['category_name'] = $azure_news_trending_category; } break; default: break; } ?>
$css = preg_replace( '/(,|:|;|\{|}|\*\/|>) /', '$1', $css ); // Remove space before , ; { } $css = preg_replace( '/ (,|;|\{|})/', '$1', $css ); // Strips leading 0 on decimal values (converts 0.5px into .5px) $css = preg_replace( '/(:| )0\.([0-9]+)(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}.${2}${3}', $css ); // Strips units if value is 0 (converts 0px to 0) $css = preg_replace( '/(:| )(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}0', $css ); // Trim $css = trim( $css ); // Return minified CSS return $css; } } /*----------------------------- Google fonts ---------------------------------------------*/ if ( ! function_exists( 'azure_news_get_google_font_variants' ) ) : /** * get Google font variants * * @since 1.0.0 */ function azure_news_get_google_font_variants() { $azure_news_font_list = get_option( 'azure_news_google_font' ); $font_family = $_REQUEST['font_family']; $variants_array = $azure_news_font_list[$font_family]['0']; $options_array = ''; foreach ( $variants_array as $variant ) { $variant_html = azure_news_convert_font_variants( $variant ); $options_array .= ''; } echo $options_array; die(); } endif; add_action( "wp_ajax_get_google_font_variants", "azure_news_get_google_font_variants" ); if ( ! function_exists( 'azure_news_convert_font_variants' ) ) : /** * function to manage the variant name according to their value. * * @param $value - string * @return string - variant name * @since 1.0.0 */ function azure_news_convert_font_variants( $value ) { switch ( $value ) { case '100': return __( 'Thin 100', 'azure-news' ); break; case '200': return __( 'Extra-Light 200', 'azure-news' ); break; case '300': return __( 'Light 300', 'azure-news' ); break; case '400': return __( 'Normal 400', 'azure-news' ); break; case '500': return __( 'Medium 500', 'azure-news' ); break; case '600': return __( 'Semi-Bold 600', 'azure-news' ); break; case '700': return __( 'Bold 700', 'azure-news' ); break; case '800': return __( 'Extra-Bold 800', 'azure-news' ); break; case '900': return __( 'Ultra-Bold 900', 'azure-news' ); break; case 'inherit': return __( 'Inherit', 'azure-news' ); break; default: break; } } endif; if ( ! function_exists( 'azure_news_google_font_callback' ) ) : /** * Load google fonts api link * * @since 1.0.0 */ function azure_news_google_font_callback() { $azure_news_get_font_list = get_option( 'azure_news_google_font' ); $azure_news_body_font_family = azure_news_get_customizer_option_value( 'azure_news_body_font_family' ); $azure_news_body_font_weight = implode( ',', $azure_news_get_font_list[$azure_news_body_font_family]['0'] ); $body_typo_combo = $azure_news_body_font_family.":".$azure_news_body_font_weight; $azure_news_heading_font_family = azure_news_get_customizer_option_value( 'azure_news_heading_font_family' ); $azure_news_heading_font_weight = implode( ',', $azure_news_get_font_list[$azure_news_heading_font_family]['0'] ); $heading_typo_combo = $azure_news_heading_font_family.":".$azure_news_heading_font_weight; $get_fonts = array( $body_typo_combo, $heading_typo_combo ); $final_font_string = implode( '|', $get_fonts ); $google_fonts_url = ''; if ( $final_font_string ) { $query_args = array( 'family' => urlencode( $final_font_string ), 'subset' => urlencode( 'latin,cyrillic-ext,greek-ext,greek,vietnamese,latin-ext,cyrillic,khmer,devanagari,arabic,hebrew,telugu' ) ); $google_fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); } return $google_fonts_url; } endif; /*----------------------------- Schema Markup ---------------------------------------------*/ if ( ! function_exists( 'azure_news_get_schema_markup' ) ) : /** * Return correct schema markup * * @since 1.0.0 */ function azure_news_get_schema_markup( $location ) { // Default $schema = $itemprop = $itemtype = ''; // HTML if ( 'html' == $location ) { if ( is_home() || is_front_page() ) { $schema = 'itemscope=itemscope itemtype=https://schema.org/WebPage'; } elseif ( is_category() || is_tag() || is_singular( 'post') ) { $schema = 'itemscope=itemscope itemtype=https://schema.org/Blog'; } elseif ( is_page() ) { $schema = 'itemscope=itemscope itemtype=https://schema.org/WebPage'; } else { $schema = 'itemscope=itemscope itemtype=https://schema.org/WebPage'; } } // Creative work if ( 'creative_work' == $location ) { if ( is_single() ) { $schema = 'itemscope=itemscope itemtype=https://schema.org/creative_work'; } elseif ( is_home() || is_archive() ) { $schema = 'itemscope=itemscope itemtype=https://schema.org/creative_work'; } } // Header if ( 'header' == $location ) { $schema = 'itemscope=itemscope itemtype=https://schema.org/WPHeader'; } // Logo if ( 'logo' == $location ) { $schema = 'itemscope itemtype=https://schema.org/Organization'; } // Navigation if ( 'site_navigation' == $location ) { $schema = 'itemscope=itemscope itemtype=https://schema.org/SiteNavigationElement'; } // Main if ( 'main' == $location ) { $itemtype = 'https://schema.org/WebPageElement'; $itemprop = 'mainContentOfPage'; } // Sidebar if ( 'sidebar' == $location ) { $schema = 'itemscope=itemscope itemtype=https://schema.org/WPSideBar'; } // Footer widgets if ( 'footer' == $location ) { $schema = 'itemscope=itemscope itemtype=https://schema.org/WPFooter'; } // Headings if ( 'headline' == $location ) { $schema = 'itemprop=headline'; } // Posts if ( 'entry_content' == $location ) { $schema = 'itemprop=text'; } // Publish date if ( 'publish_date' == $location ) { $schema = 'itemprop=datePublished'; } // Modified date if ( 'modified_date' == $location ) { $schema = 'itemprop=dateModified'; } // Author name if ( 'author_name' == $location ) { $schema = 'itemprop=name'; } // Author link if ( 'author_link' == $location ) { $schema = 'itemprop=author itemscope=itemscope itemtype=https://schema.org/Person'; } // Item if ( 'item' == $location ) { $schema = 'itemprop=item'; } // Url if ( 'url' == $location ) { $schema = 'itemprop=url'; } // Position if ( 'position' == $location ) { $schema = 'itemprop=position'; } // Image if ( 'image' == $location ) { $schema = 'itemprop=image'; } // Avatar if ( 'avatar' == $location ) { $schema = 'itemprop=avatar'; } // Description if ( 'description' == $location ) { $schema = 'itemprop=description'; } return ' ' . apply_filters( 'azure_news_schema_markup_items', $schema ); } endif; if ( ! function_exists( 'azure_news_schema_markup' ) ) : /** * Outputs correct schema markup * * @since 1.0.0 */ function azure_news_schema_markup( $location ) { $azure_news_site_schema_enable = azure_news_get_customizer_option_value( 'azure_news_site_schema_enable' ); if ( false === $azure_news_site_schema_enable ) { return; } echo azure_news_get_schema_markup( $location ); } endif; /*------------------------ Primary Menu Settings --------------------------*/ /** * Menu items - Add "Custom sub-menu" in menu item render output * if menu item has class "menu-item-target" */ add_filter( 'walker_nav_menu_start_el', 'azure_news_nav_description', 10, 4 ); if ( ! function_exists( 'azure_news_nav_description' ) ) : function azure_news_nav_description( $item_output, $item, $depth, $args ) { $azure_news_primary_menu_description_enable = azure_news_get_customizer_option_value( 'azure_news_primary_menu_description_enable' ); if ( ! empty( $item->description ) && false !== $azure_news_primary_menu_description_enable ) { $item_output = str_replace( $args->link_after . '', '' . $args->link_after . '', $item_output ); } return $item_output; } endif; /*------------------------ Generate darker color --------------------------*/ if ( ! function_exists( 'azure_news_darker_color' ) ) : /** * Generate darker color * * @since 1.0.0 */ function azure_news_darker_color( $hex, $steps ) { // Steps should be between -255 and 255. Negative = darker, positive = lighter $steps = max( -255, min( 255, $steps ) ); if ( ! str_contains( $hex, '#' ) ) { $hex = azure_news_rgba2hex( $hex ); } // 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( 'azure_news_rgba2hex' ) ) : function azure_news_rgba2hex( $string ) { $rgba = array(); $hex = ''; $regex = '#\((([^()]+|(?R))*)\)#'; if (preg_match_all($regex, $string ,$matches)) { $rgba = explode(',', implode(' ', $matches[1])); } else { $rgba = explode(',', $string); } $rr = dechex($rgba['0']); $gg = dechex($rgba['1']); $bb = dechex($rgba['2']); $aa = ''; if (array_key_exists('3', $rgba)) { $aa = dechex($rgba['3'] * 255); } return strtoupper("#$aa$rr$gg$bb"); } endif;