ID, 'sophia_after_dark_post_sidebar_layout', true ); if ( 'layout--default-sidebar' !== $single_post_sidebar_layout && ! empty( $single_post_sidebar_layout ) ) { $classes[] = esc_attr( $single_post_sidebar_layout ); } else { $posts_sidebar_layout = get_theme_mod( 'sophia_after_dark_posts_sidebar_layout', 'right-sidebar' ); $classes[] = esc_attr( $posts_sidebar_layout ); } } elseif ( is_page() ) { $single_page_sidebar_layout = get_post_meta( $post->ID, 'sophia_after_dark_post_sidebar_layout', true ); if ( 'layout--default-sidebar' !== $single_page_sidebar_layout && ! empty( $single_page_sidebar_layout ) ) { $classes[] = esc_attr( $single_page_sidebar_layout ); } else { $pages_sidebar_layout = get_theme_mod( 'sophia_after_dark_pages_sidebar_layout', 'right-sidebar' ); $classes[] = esc_attr( $pages_sidebar_layout ); } } return $classes; } add_filter( 'body_class', 'sophia_after_dark_body_classes' ); /** * Add a pingback url auto-discovery header for single posts, pages, or attachments. */ function sophia_after_dark_pingback_header() { if ( is_singular() && pings_open() ) { echo ''; } } add_action( 'wp_head', 'sophia_after_dark_pingback_header' ); /*-----------------------------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'sophia_after_dark_fonts_url' ) ) : /** * Register Bunny fonts for Sophia After Dark. * * @return string Bunny fonts URL for the theme. * @since 1.0.0 */ function sophia_after_dark_fonts_url() { $fonts_url = ''; $font_families = array(); /* * Translators: If there are characters in your language that are not supported * byJosefin Sans translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Josefin Sans font: on or off', 'sophia-after-dark' ) ) { $font_families[] = 'Josefin Sans:400,700'; } /* * Translators: If there are characters in your language that are not supported * by Poppins, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Poppins font: on or off', 'sophia-after-dark' ) ) { $font_families[] = 'Poppins:300,400,400i,500,700'; } if ( $font_families ) { $query_args = array( 'family' => urlencode( implode( '|', $font_families ) ), 'subset' => urlencode( 'latin,latin-ext' ), ); $fonts_url = add_query_arg( $query_args, 'https://fonts.bunny.net/css' ); } return $fonts_url; } endif; /*-----------------------------------------------------------------------------------------------------------------------*/ /** * Enqueue scripts and styles for only admin * * @since 1.0.0 */ add_action( 'admin_enqueue_scripts', 'sophia_after_dark_admin_scripts' ); function sophia_after_dark_admin_scripts( $hook ) { global $sophia_after_dark_theme_version; if ( 'widgets.php' != $hook && 'customize.php' != $hook && 'edit.php' != $hook && 'post.php' != $hook && 'post-new.php' != $hook ) { return; } wp_enqueue_script( 'jquery-ui-button' ); wp_enqueue_script( 'sophia-after-dark--admin-script', get_template_directory_uri() . '/assets/js/sad-admin-scripts.js', array( 'jquery' ), esc_attr( $sophia_after_dark_theme_version ), true ); wp_enqueue_style( 'sophia-after-dark--admin-style', get_template_directory_uri() . '/assets/css/sad-admin-styles.css', array(), esc_attr( $sophia_after_dark_theme_version ) ); } /*----------------------------------------------------------------------------------------------------------------------------------------*/ /** * Enqueue scripts and styles. */ function sophia_after_dark_scripts(): void { $v = wp_get_theme()->get( 'Version' ); $dir = get_template_directory_uri(); wp_enqueue_style( 'sophia-after-dark-fonts', sophia_after_dark_fonts_url(), array(), null ); wp_enqueue_style( 'lightslider-style', "$dir/assets/library/lightslider/css/lightslider.min.css", array(), null ); wp_enqueue_style( 'animate', "$dir/assets/library/animate/animate.min.css", array(), '3.5.1' ); wp_enqueue_style( 'sophia-after-dark-style', get_stylesheet_uri(), array(), $v ); wp_enqueue_style( 'sophia-after-dark-responsive-style', "$dir/assets/css/sad-responsive.css", array(), $v ); wp_enqueue_script( 'sophia-after-dark-combine-scripts', "$dir/assets/js/sad-combine-scripts.js", array( 'jquery' ), $v, true ); wp_enqueue_script( 'sophia-after-dark-navigation', "$dir/assets/js/navigation.js", array(), $v, true ); wp_enqueue_script( 'sophia-after-dark-skip-link-focus-fix', "$dir/assets/js/skip-link-focus-fix.js", array(), $v, true ); wp_enqueue_script( 'sophia-after-dark-custom-scripts', "$dir/assets/js/sad-custom-scripts.js", array( 'jquery' ), $v, true ); wp_localize_script( 'sophia-after-dark-custom-scripts', 'sophia_after_darkObject', array( 'menu_sticky' => get_theme_mod( 'sophia_after_dark_enable_sticky_menu', true ) ? 'on' : 'off', 'wow_effect' => get_theme_mod( 'sophia_after_dark_enable_wow_animation', true ) ? 'on' : 'off', ) ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'sophia_after_dark_scripts' ); /*----------------------------------------------------------------------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'sophia_after_dark_fork_awesome_social_icon_array' ) ) : /** * Define fork awesome social media icons * * @return array(); * @since 1.0.0 */ function sophia_after_dark_fork_awesome_social_icon_array() { return array( 'fa fa-facebook-square', 'fa fa-facebook-f', 'fa fa-facebook', 'fa fa-facebook-official', 'fa fa-twitter-square', 'fa fa-twitter', 'fa fa-yahoo', 'fa fa-google', 'fa fa-google-wallet', 'fa fa-google-plus-circle', 'fa fa-google-plus-official', 'fa fa-instagram', 'fa fa-linkedin-square', 'fa fa-linkedin', 'fa fa-pinterest-p', 'fa fa-pinterest', 'fa fa-pinterest-square', 'fa fa-google-plus-square', 'fa fa-google-plus', 'fa fa-youtube-square', 'fa fa-youtube', 'fa fa-youtube-play', 'fa fa-vimeo', 'fa fa-vimeo-square', ); } endif; /*----------------------------------------------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'sophia_after_dark_social_media_content' ) ) : /** * function to display the social icons */ function sophia_after_dark_social_media_content() { $defaults_icons = json_encode( array( array( 'social_icon' => 'fa fa-twitter', 'social_url' => '#', ), array( 'social_icon' => 'fa fa-pinterest', 'social_url' => '#', ), ) ); $sophia_after_dark_social_icons = get_theme_mod( 'sophia_after_dark_social_icons', $defaults_icons ); $social_icons = json_decode( $sophia_after_dark_social_icons ); if ( ! empty( $social_icons ) ) { ?>
0 ) ); $sophia_after_dark_categories_list[''] = __( 'Select Category', 'sophia-after-dark' ); foreach ( $sophia_after_dark_get_categories as $category ) { $sophia_after_dark_categories_list[ esc_attr( $category->slug ) ] = esc_html( $category->cat_name ); } return $sophia_after_dark_categories_list; } endif; /*----------------------------------------------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'sophia_after_dark_is_sidebar_layout' ) ) : /** * Checks if the current page matches the given layout * * @return string $layout layout of current page. */ function sophia_after_dark_is_sidebar_layout() { global $post; $layout = ''; if ( is_archive() || is_home() ) { $layout = get_theme_mod( 'sophia_after_dark_archive_sidebar_layout', 'no-sidebar' ); } elseif ( is_single() ) { $single_post_layout = get_post_meta( $post->ID, 'sophia_after_dark_post_sidebar_layout', true ); if ( 'layout--default-sidebar' !== $single_post_layout ) { $layout = $single_post_layout; } else { $layout = get_theme_mod( 'sophia_after_dark_posts_sidebar_layout', 'right-sidebar' ); } } elseif ( is_page() ) { $single_page_layout = get_post_meta( $post->ID, 'sophia_after_dark_post_sidebar_layout', true ); if ( 'layout--default-sidebar' !== $single_page_layout ) { $layout = $single_page_layout; } else { $layout = get_theme_mod( 'sophia_after_dark_pages_sidebar_layout', 'right-sidebar' ); } } return $layout; } endif; /*----------------------------------------------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'sophia_after_dark_inner_header_bg_image' ) ) : /** * Background image for inner page header * * @since 1.0.0 */ function sophia_after_dark_inner_header_bg_image( $input ) { $image_attr = array(); if ( empty( $image_attr ) ) { // Fetch from Custom Header Image. $image = get_header_image(); if ( ! empty( $image ) ) { $image_attr['url'] = $image; $image_attr['width'] = get_custom_header()->width; $image_attr['height'] = get_custom_header()->height; } } if ( ! empty( $image_attr ) ) { $input .= 'background-image:url(' . esc_url( $image_attr['url'] ) . ');'; $input .= 'background-size:cover;'; } return $input; } endif; add_filter( 'sophia_after_dark_inner_header_style_attribute', 'sophia_after_dark_inner_header_bg_image' ); /*-----------------------------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'sophia_after_dark_css_strip_whitespace' ) ) : /** * Get minified css and removed space * * @since 1.0.0 */ function sophia_after_dark_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 ); } endif; /*-----------------------------------------------------------------------------------------------------------------------*/ /** * Archive title prefix */ $archive_title_prefix_option = get_theme_mod( 'sophia_after_dark_enable_archive_title_prefix', true ); if ( false === $archive_title_prefix_option ) { add_filter( 'get_the_archive_title', 'sophia_after_dark_archive_title_prefix' ); } if ( ! function_exists( 'sophia_after_dark_archive_title_prefix' ) ) : function sophia_after_dark_archive_title_prefix( $title ) { return preg_replace( '/^\w+: /', '', $title ); } endif;