'', 'default-image' => '', ); return $args; } add_filter( 'eighties_custom_background_args', 'together_custom_background_args' ); /* * Register our styles */ function together_scripts() { wp_register_style( 'eighties', get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'together-fonts', together_google_fonts_url(), array(), null ); wp_enqueue_style( 'together-style', get_stylesheet_uri(), array( 'eighties' ) ); if ( together_header_image() ) { wp_enqueue_script( 'together-header', get_stylesheet_directory_uri() . '/js/together-header.js', array( 'backstretch' ), '20141125', true ); } } add_action( 'wp_enqueue_scripts', 'together_scripts' ); /* * Styles and scripts with Eighties no longer needed */ function together_dequeue_scripts() { wp_dequeue_style( 'eighties-header' ); wp_dequeue_style( 'eighties-headings' ); wp_dequeue_script( 'eighties-customizer-preview' ); wp_dequeue_script( 'eighties-header' ); } add_action( 'wp_enqueue_scripts', 'together_dequeue_scripts', 20 ); /* * Go get our Google Fonts */ function together_google_fonts_url() { $fonts_url = ''; /* Translators: If there are characters in your language that are not * supported by Gentium Book Basic, translate this to 'off'. Do not translate * into your own language. */ $gentium = _x( 'on', 'Gentium Book Basic font: on or off', 'together' ); if ( 'off' !== $gentium ) { $font_families = array(); if ( 'off' !== $gentium ) { $font_families[] = 'Gentium Book Basic:400italic,700,400,700italic'; } $query_args = array( 'family' => urlencode( implode( '|', $font_families ) ), 'subset' => urlencode( 'latin,latin-ext' ), ); $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); } return $fonts_url; } /* * Load Google Fonts on Custom Header page */ function together_custom_header_fonts() { wp_enqueue_style( 'together-fonts', together_google_fonts_url(), array(), null ); } add_action( 'admin_print_styles-appearance_page_custom-header', 'together_custom_header_fonts' ); /** * Together Header Image * * Template tag for getting the Together header image * based on the custom setting for featured image or * header image. * * @return bool|string */ function together_header_image() { // If the current them does not support custom header, return false. if ( ! get_theme_support( 'custom-header' ) ) { return false; } // If is singular, has post thumbnail and is set to display the featured image, return the image. if ( is_singular() && has_post_thumbnail( get_the_ID() ) && 'featured_image' === get_theme_mod( 'eighties_singular_header_image', 'header' ) ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); return $image[0]; } // If has the header image, return the header image. $header_image = get_header_image(); if ( ! empty ( $header_image ) ) { return get_header_image(); } return false; } /** * Add a new default custom header image * This replaces the default from our parent theme */ function together_custom_header_setup( $args ) { $args = array( 'default-image' => get_stylesheet_directory_uri() . '/img/together-header.png', 'default-text-color' => 'ffffff', 'height' => 600, 'width' => 1200, 'flex-height' => true, 'flex-width' => true, 'wp-head-callback' => 'together_header_style', 'admin-head-callback' => 'together_admin_header_style', 'admin-preview-callback' => 'together_admin_header_image', ); add_theme_support( 'custom-header', $args ); // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. register_default_headers( array( 'together' => array( 'url' => '%2$s/img/together-header.png', 'thumbnail_url' => '%2$s/img/together-header-thumbnail.png', 'description' => _x( 'Together', 'header image description', 'together' ) ), ) ); } add_action( 'after_setup_theme', 'together_custom_header_setup' ); if ( ! function_exists( 'together_header_style' ) ) : /** * Styles the header image and text displayed on the blog * * @see together_custom_header_setup(). */ function together_header_style() { $header_text_color = get_header_textcolor(); $header_image = together_header_image(); $header = get_custom_header(); // If no custom options for text are set, let's bail // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value if ( ( HEADER_TEXTCOLOR == $header_text_color ) && ! $header_image ) { return; } // If we get this far, we have custom styles. Let's do this. ?> Header admin panel. * * @see together_custom_header_setup(). */ function together_admin_header_style() { $header = get_custom_header(); ?> Header admin panel. * * @see together_custom_header_setup(). */ function together_admin_header_image() { $style = sprintf( 'style="color:#%s;"', get_header_textcolor() ); ?>