and *
elements too, along with the proper attributes. * * It would be beneficial to also include the tag for content type. * * The default doctype is XHTML v1.0 Transitional, unless HTML support os present in the child theme. * * @since 1.3.0 */ function genesis_do_doctype() { if ( genesis_html5() ) { genesis_html5_doctype(); } else { genesis_xhtml_doctype(); } } /** * XHTML 1.0 Transitional doctype markup. * * @since 2.0.0 */ function genesis_xhtml_doctype() { ?> > > > get_parts( $parts ); } add_filter( 'document_title_separator', 'genesis_document_title_separator' ); /** * Filter Document title parts separator based on SEO setting value. * * @since 2.6.0 * * @return string Return modified title parts separator. */ function genesis_document_title_separator( $sep ) { $sep = genesis_get_seo_option( 'doctitle_sep' ); return $sep ? $sep : '-'; } add_action( 'get_header', 'genesis_doc_head_control' ); /** * Remove unnecessary code that WordPress puts in the `head`. * * @since 1.3.0 */ function genesis_doc_head_control() { remove_action( 'wp_head', 'wp_generator' ); if ( ! genesis_get_seo_option( 'head_adjacent_posts_rel_link' ) ) { remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); } if ( ! genesis_get_seo_option( 'head_wlwmanifest_link' ) ) { remove_action( 'wp_head', 'wlwmanifest_link' ); } if ( ! genesis_get_seo_option( 'head_shortlink' ) ) { remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); } if ( is_single() && ! genesis_get_option( 'comments_posts' ) ) { remove_action( 'wp_head', 'feed_links_extra', 3 ); } if ( is_page() && ! genesis_get_option( 'comments_pages' ) ) { remove_action( 'wp_head', 'feed_links_extra', 3 ); } } add_action( 'genesis_meta', 'genesis_seo_meta_description' ); /** * Output the meta description based on contextual criteria. * * Output nothing if description isn't present. * * @since 1.2.0 * @since 2.4.0 Logic moved to `genesis_get_seo_meta_description()` * * @see genesis_get_seo_meta_description() */ function genesis_seo_meta_description() { $description = genesis_get_seo_meta_description(); // Add the description if one exists. if ( $description ) { echo '' . "\n"; } } add_action( 'genesis_meta', 'genesis_seo_meta_keywords' ); /** * Output the meta keywords based on contextual criteria. * * Outputs nothing if keywords are not present. * * @since 1.2.0 * @since 2.4.0 Logic moved to `genesis_get_seo_meta_keywords()` * * @see genesis_get_seo_meta_keywords() */ function genesis_seo_meta_keywords() { $keywords = genesis_get_seo_meta_keywords(); // Add the keywords if they exist. if ( $keywords ) { echo '' . "\n"; } } add_action( 'genesis_meta', 'genesis_robots_meta' ); /** * Output the robots meta code in the document `head`. * * @since 1.0.0 * @since 2.4.0 Logic moved to `genesis_get_robots_meta_content()` * * @see genesis_get_robots_meta_content() * * @return void Return early if blog is not public. */ function genesis_robots_meta() { // If the blog is private, then following logic is unnecessary as WP will insert noindex and nofollow. if ( ! get_option( 'blog_public' ) ) { return; } $meta = genesis_get_robots_meta_content(); // Add meta if any exist. if ( $meta ) { ?> ' . "\n", esc_attr( $viewport_value ) ); } add_action( 'wp_head', 'genesis_load_favicon' ); /** * Echo favicon link. * * @since 1.0.0 * @since 2.4.0 Logic moved to `genesis_get_favicon_url()`. * * @see genesis_get_favicon_url() * * @return void Return early if WP Site Icon is used. */ function genesis_load_favicon() { // Use WP site icon, if available. if ( function_exists( 'has_site_icon' ) && has_site_icon() ) { return; } $favicon = genesis_get_favicon_url(); if ( $favicon ) { echo '' . "\n"; } } add_action( 'wp_head', 'genesis_do_meta_pingback' ); /** * Adds the pingback meta tag to the head so that other sites can know how to send a pingback to our site. * * @since 1.3.0 */ function genesis_do_meta_pingback() { if ( 'open' === get_option( 'default_ping_status' ) ) { echo '' . "\n"; } } add_action( 'wp_head', 'genesis_paged_rel' ); /** * Output rel links in the head to indicate previous and next pages in paginated archives and posts. * * @link https://webmasters.googleblog.com/2011/09/pagination-with-relnext-and-relprev.html * * @since 2.2.0 * * @return void Return early if doing a Customizer preview. */ function genesis_paged_rel() { global $wp_query; $prev = $next = ''; $paged = (int) get_query_var( 'paged' ); $page = (int) get_query_var( 'page' ); if ( ! is_singular() ) { $prev = $paged > 1 ? get_previous_posts_page_link() : $prev; $next = $paged < $wp_query->max_num_pages ? get_next_posts_page_link( $wp_query->max_num_pages ) : $next; } else { // No need for this on previews. if ( is_preview() ) { return; } $numpages = substr_count( $wp_query->post->post_content, '' ) + 1; if ( $numpages && ! $page ) { $page = 1; } if ( $page > 1 ) { $prev = genesis_paged_post_url( $page - 1 ); } if ( $page < $numpages ) { $next = genesis_paged_post_url( $page + 1 ); } } if ( $prev ) { printf( '' . "\n", esc_url( $prev ) ); } if ( $next ) { printf( '' . "\n", esc_url( $next ) ); } } add_action( 'wp_head', 'genesis_meta_name' ); /** * Output meta tag for site name. * * @since 2.2.0 * * @return void Return early if not HTML5 or not front page. */ function genesis_meta_name() { if ( ! genesis_html5() || ! is_front_page() ) { return; } printf( '' . "\n", get_bloginfo( 'name' ) ); } add_action( 'wp_head', 'genesis_meta_url' ); /** * Output meta tag for site URL. * * @since 2.2.0 * * @return void Return early if not HTML5 or not front page. */ function genesis_meta_url() { if ( ! genesis_html5() || ! is_front_page() ) { return; } printf( '' . "\n", trailingslashit( home_url() ) ); } add_action( 'wp_head', 'genesis_canonical', 5 ); /** * Echo custom canonical link tag. * * Remove the default WordPress canonical tag, and use our custom * one. Gives us more flexibility and effectiveness. * * @since 1.0.0 */ function genesis_canonical() { // Remove the WordPress canonical. remove_action( 'wp_head', 'rel_canonical' ); $canonical = genesis_canonical_url(); if ( $canonical ) { printf( '' . "\n", esc_url( apply_filters( 'genesis_canonical', $canonical ) ) ); } } add_filter( 'genesis_header_scripts', 'do_shortcode' ); add_action( 'wp_head', 'genesis_header_scripts' ); /** * Echo header scripts in to wp_head(). * * Allows shortcodes. * * Applies `genesis_header_scripts` filter on value stored in header_scripts setting. * * Also echoes scripts from the post's custom field. * * @since 1.0.0 */ function genesis_header_scripts() { echo apply_filters( 'genesis_header_scripts', genesis_get_option( 'header_scripts' ) ); // If singular, echo scripts from custom field. if ( is_singular() ) { genesis_custom_field( '_genesis_scripts' ); } } add_action( 'genesis_before', 'genesis_page_specific_body_scripts' ); /** * Output page-specific body scripts if their position is set to 'top'. * * If the position is 'bottom' or null, output occurs in genesis_footer_scripts() instead. * * @since 2.5.0 */ function genesis_page_specific_body_scripts() { if ( ! is_singular() ) { return; } if ( 'top' === genesis_get_custom_field( '_genesis_scripts_body_position' ) ) { genesis_custom_field( '_genesis_scripts_body' ); } } add_action( 'after_setup_theme', 'genesis_custom_header' ); /** * Activate the custom header feature. * * It gets arguments passed through add_theme_support(), defines the constants, and calls `add_custom_image_header()`. * * Applies `genesis_custom_header_defaults` filter. * * @since 1.6.0 * * @return void Return early if `custom-header` or `genesis-custom-header` are not supported in the theme. */ function genesis_custom_header() { $wp_custom_header = get_theme_support( 'custom-header' ); // If WP custom header is active, no need to continue. if ( $wp_custom_header ) { return; } $genesis_custom_header = get_theme_support( 'genesis-custom-header' ); // If Genesis custom is not active, do nothing. if ( ! $genesis_custom_header ) { return; } // Blog title option is obsolete when custom header is active. add_filter( 'genesis_pre_get_option_blog_title', '__return_empty_array' ); // Cast, if necessary. $genesis_custom_header = isset( $genesis_custom_header[0] ) && is_array( $genesis_custom_header[0] ) ? $genesis_custom_header[0] : array(); // Merge defaults with passed arguments. $args = wp_parse_args( $genesis_custom_header, apply_filters( 'genesis_custom_header_defaults', array( 'width' => 960, 'height' => 80, 'textcolor' => '333333', 'no_header_text' => false, 'header_image' => '%s/images/header.png', 'header_callback' => '', 'admin_header_callback' => '', ) ) ); // Push $args into theme support array. add_theme_support( 'custom-header', array( 'default-image' => sprintf( $args['header_image'], get_stylesheet_directory_uri() ), 'header-text' => $args['no_header_text'] ? false : true, 'default-text-color' => $args['textcolor'], 'width' => $args['width'], 'height' => $args['height'], 'random-default' => false, 'header-selector' => genesis_html5() ? '.site-header' : '#header', 'wp-head-callback' => $args['header_callback'], 'admin-head-callback' => $args['admin_header_callback'], ) ); } add_action( 'wp_head', 'genesis_custom_header_style' ); /** * Custom header callback. * * It outputs special CSS to the document head, modifying the look of the header based on user input. * * @since 1.6.0 * * @return void Return early if `custom-header` not supported, user specified own callback, or no options set. */ function genesis_custom_header_style() { // Do nothing if custom header not supported. if ( ! current_theme_supports( 'custom-header' ) ) { return; } // Do nothing if user specifies their own callback. if ( get_theme_support( 'custom-header', 'wp-head-callback' ) ) { return; } $output = ''; $header_image = get_header_image(); $text_color = get_header_textcolor(); // If no options set, don't waste the output. Do nothing. if ( empty( $header_image ) && ! display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) ) { return; } $header_selector = get_theme_support( 'custom-header', 'header-selector' ); $title_selector = genesis_html5() ? '.custom-header .site-title' : '.custom-header #title'; $desc_selector = genesis_html5() ? '.custom-header .site-description' : '.custom-header #description'; // Header selector fallback. if ( ! $header_selector ) { $header_selector = genesis_html5() ? '.custom-header .site-header' : '.custom-header #header'; } // Header image CSS, if exists. if ( $header_image ) { $output .= sprintf( '%s { background: url(%s) no-repeat !important; }', $header_selector, esc_url( $header_image ) ); } // Header text color CSS, if showing text. if ( display_header_text() && $text_color !== get_theme_support( 'custom-header', 'default-text-color' ) ) { $output .= sprintf( '%2$s a, %2$s a:hover, %3$s { color: #%1$s !important; }', esc_html( $text_color ), esc_html( $title_selector ), esc_html( $desc_selector ) ); } if ( $output ) { printf( '' . "\n", $output ); } } add_action( 'genesis_header', 'genesis_header_markup_open', 5 ); /** * Echo the opening structural markup for the header. * * @since 1.2.0 */ function genesis_header_markup_open() { genesis_markup( array( 'open' => '