示例#1
0
/**
 * Echo the site description into the header.
 *
 * Depending on the SEO option set by the user, this will either be wrapped in an `h1` or `p` element.
 *
 * Applies the `genesis_seo_description` filter before echoing.
 *
 * @since 1.1.0
 *
 * @uses genesis_get_seo_option() Get SEO setting value.
 * uses genesis_html5()           Check for HTML5 support.
 */
function genesis_seo_site_description()
{
    //* Set what goes inside the wrapping tags
    $inside = esc_html(get_bloginfo('description'));
    //* Determine which wrapping tags to use
    $wrap = genesis_is_root_page() && 'description' === genesis_get_seo_option('home_h1_on') ? 'h1' : 'p';
    //* Wrap homepage site description in p tags if static front page
    $wrap = is_front_page() && !is_home() ? 'p' : $wrap;
    //* And finally, $wrap in h2 if HTML5 & semantic headings enabled
    $wrap = genesis_html5() && genesis_get_seo_option('semantic_headings') ? 'h2' : $wrap;
    /**
     * Site description wrapping element
     *
     * The wrapping element for the site description.
     *
     * @since 2.2.3
     *
     * @param string $wrap The wrapping element (h1, h2, p, etc.).
     */
    $wrap = apply_filters('genesis_site_description_wrap', $wrap);
    //* Build the description
    $description = genesis_html5() ? sprintf("<{$wrap} %s>", genesis_attr('site-description')) : sprintf('<%s id="description">%s</%s>', $wrap, $inside, $wrap);
    $description .= genesis_html5() ? "{$inside}</{$wrap}>" : '';
    //* Output (filtered)
    $output = $inside ? apply_filters('genesis_seo_description', $description, $inside, $wrap) : '';
    echo $output;
}
示例#2
0
function custom_header_inline_logo($title, $inside, $wrap)
{
    if (get_header_image()) {
        $logo = '<img  src="' . get_header_image() . '" width="' . esc_attr(get_custom_header()->width) . '" height="' . esc_attr(get_custom_header()->height) . '" alt="' . esc_attr(get_bloginfo('name')) . ' Homepage">';
    } else {
        $logo = get_bloginfo('name');
    }
    $inside = sprintf('<a href="%s">%s<span class="screen-reader-text">%s</span></a>', trailingslashit(home_url()), $logo, get_bloginfo('name'));
    // Determine which wrapping tags to use
    $wrap = genesis_is_root_page() && 'title' === genesis_get_seo_option('home_h1_on') ? 'h1' : 'p';
    // A little fallback, in case an SEO plugin is active
    $wrap = genesis_is_root_page() && !genesis_get_seo_option('home_h1_on') ? 'h1' : $wrap;
    // And finally, $wrap in h1 if HTML5 & semantic headings enabled
    $wrap = genesis_html5() && genesis_get_seo_option('semantic_headings') ? 'h1' : $wrap;
    return sprintf('<%1$s %2$s>%3$s</%1$s>', $wrap, genesis_attr('site-title'), $inside);
}
示例#3
0
/**
 * Echo the site title into the header.
 *
 * Depending on the SEO option set by the user, this will either be wrapped in an `h1` or `p` element.
 *
 * Applies the `genesis_seo_title` filter before echoing.
 *
 * @since 1.1.0
 *
 * @uses genesis_get_seo_option() Get SEO setting value.
 * @uses genesis_html5()          Check or HTML5 support.
 */
function genesis_seo_site_title()
{
    //* Set what goes inside the wrapping tags
    $inside = sprintf('<a href="%s">%s</a>', trailingslashit(home_url()), get_bloginfo('name'));
    //* Determine which wrapping tags to use
    $wrap = genesis_is_root_page() && 'title' === genesis_get_seo_option('home_h1_on') ? 'h1' : 'p';
    //* A little fallback, in case an SEO plugin is active
    $wrap = genesis_is_root_page() && !genesis_get_seo_option('home_h1_on') ? 'h1' : $wrap;
    //* And finally, $wrap in h1 if HTML5 & semantic headings enabled
    $wrap = genesis_html5() && genesis_get_seo_option('semantic_headings') ? 'h1' : $wrap;
    //* Build the title
    $title = genesis_html5() ? sprintf("<{$wrap} %s>", genesis_attr('site-title')) : sprintf('<%s id="title">%s</%s>', $wrap, $inside, $wrap);
    $title .= genesis_html5() ? "{$inside}</{$wrap}>" : '';
    //* Echo (filtered)
    echo apply_filters('genesis_seo_title', $title, $inside, $wrap);
}
示例#4
0
文件: layout.php 项目: nkeat12/dv
/**
 * Return the site layout for different contexts.
 *
 * Checks both the custom field and the theme option to find the user-selected site layout, and returns it.
 *
 * Applies `genesis_site_layout` filter early to allow shortcutting of function.
 *
 * @since 0.2.2
 *
 * @uses genesis_get_custom_field()              Get per-post layout value.
 * @uses genesis_get_option()                    Get theme setting layout value.
 * @uses genesis_get_default_layout()            Get default from registered layouts.
 * @uses genesis_has_post_type_archive_support() Check if a post type supports an archive setting page.
 *
 * @global WP_Query $wp_query Query object.
 *
 * @param boolean $use_cache Conditional to use cache or get fresh.
 *
 * @return string Key of layout.
 */
function genesis_site_layout($use_cache = true)
{
    //* Allow child theme to short-circuit this function
    $pre = apply_filters('genesis_site_layout', null);
    if (null !== $pre) {
        return $pre;
    }
    //* If we're supposed to use the cache, setup cache. Use if value exists.
    if ($use_cache) {
        //* Setup cache
        static $layout_cache = '';
        //* If cache is populated, return value
        if ('' !== $layout_cache) {
            return esc_attr($layout_cache);
        }
    }
    global $wp_query;
    //* If viewing a singular page or post, or the posts page, but not the front page
    if (is_singular() || is_home() && !genesis_is_root_page()) {
        $post_id = is_home() ? get_option('page_for_posts') : null;
        $custom_field = genesis_get_custom_field('_genesis_layout', $post_id);
        $site_layout = $custom_field ? $custom_field : genesis_get_option('site_layout');
    } elseif (is_category() || is_tag() || is_tax()) {
        $term = $wp_query->get_queried_object();
        $site_layout = $term && isset($term->meta['layout']) && $term->meta['layout'] ? $term->meta['layout'] : genesis_get_option('site_layout');
    } elseif (is_post_type_archive() && genesis_has_post_type_archive_support()) {
        $site_layout = genesis_get_cpt_option('layout') ? genesis_get_cpt_option('layout') : genesis_get_option('site_layout');
    } elseif (is_author()) {
        $site_layout = get_the_author_meta('layout', (int) get_query_var('author')) ? get_the_author_meta('layout', (int) get_query_var('author')) : genesis_get_option('site_layout');
    } else {
        $site_layout = genesis_get_option('site_layout');
    }
    //* Use default layout as a fallback, if necessary
    if (!genesis_get_layout($site_layout)) {
        $site_layout = genesis_get_default_layout();
    }
    //* Push layout into cache, if caching turned on
    if ($use_cache) {
        $layout_cache = $site_layout;
    }
    //* Return site layout
    return esc_attr($site_layout);
}
示例#5
0
/**
 * Determine the `noindex`, `nofollow`, `noodp`, `noydir`, `noarchive` robots meta code for the current context.
 *
 * @since 2.4.0
 *
 * @global WP_Query $wp_query Query object.
 *
 * @return string String for `content` attribute of `robots` meta tag.
 */
function genesis_get_robots_meta_content()
{
    global $wp_query;
    $post_id = null;
    // Defaults.
    $directives = array('noindex' => '', 'nofollow' => '', 'noarchive' => genesis_get_seo_option('noarchive') ? 'noarchive' : '', 'noodp' => genesis_get_seo_option('noodp') ? 'noodp' : '', 'noydir' => genesis_get_seo_option('noydir') ? 'noydir' : '');
    // Check root page SEO settings, set noindex, nofollow and noarchive.
    if (genesis_is_root_page()) {
        $directives['noindex'] = genesis_get_seo_option('home_noindex') ? 'noindex' : $directives['noindex'];
        $directives['nofollow'] = genesis_get_seo_option('home_nofollow') ? 'nofollow' : $directives['nofollow'];
        $directives['noarchive'] = genesis_get_seo_option('home_noarchive') ? 'noarchive' : $directives['noarchive'];
    }
    // When the page is set as the Posts Page in WordPress core, use the $post_id of the page when loading SEO values.
    if (is_home() && get_option('page_for_posts') && get_queried_object_id()) {
        $post_id = get_option('page_for_posts');
    }
    if (is_singular() || null !== $post_id) {
        $directives['noindex'] = genesis_get_custom_field('_genesis_noindex', $post_id) ? 'noindex' : $directives['noindex'];
        $directives['nofollow'] = genesis_get_custom_field('_genesis_nofollow', $post_id) ? 'nofollow' : $directives['nofollow'];
        $directives['noarchive'] = genesis_get_custom_field('_genesis_noarchive', $post_id) ? 'noarchive' : $directives['noarchive'];
    } elseif (is_category() || is_tag() || is_tax()) {
        $term = $wp_query->get_queried_object();
        $directives['noindex'] = get_term_meta($term->term_id, 'noindex', true) ? 'noindex' : $directives['noindex'];
        $directives['nofollow'] = get_term_meta($term->term_id, 'nofollow', true) ? 'nofollow' : $directives['nofollow'];
        $directives['noarchive'] = get_term_meta($term->term_id, 'noarchive', true) ? 'noarchive' : $directives['noarchive'];
        if (is_category()) {
            $directives['noindex'] = genesis_get_seo_option('noindex_cat_archive') ? 'noindex' : $directives['noindex'];
            $directives['noarchive'] = genesis_get_seo_option('noarchive_cat_archive') ? 'noarchive' : $directives['noarchive'];
        } elseif (is_tag()) {
            $directives['noindex'] = genesis_get_seo_option('noindex_tag_archive') ? 'noindex' : $directives['noindex'];
            $directives['noarchive'] = genesis_get_seo_option('noarchive_tag_archive') ? 'noarchive' : $directives['noarchive'];
        }
    } elseif (is_post_type_archive() && genesis_has_post_type_archive_support()) {
        $directives['noindex'] = genesis_get_cpt_option('noindex') ? 'noindex' : $directives['noindex'];
        $directives['nofollow'] = genesis_get_cpt_option('nofollow') ? 'nofollow' : $directives['nofollow'];
        $directives['noarchive'] = genesis_get_cpt_option('noarchive') ? 'noarchive' : $directives['noarchive'];
    } elseif (is_author()) {
        $directives['noindex'] = get_the_author_meta('noindex', (int) get_query_var('author')) ? 'noindex' : $directives['noindex'];
        $directives['nofollow'] = get_the_author_meta('nofollow', (int) get_query_var('author')) ? 'nofollow' : $directives['nofollow'];
        $directives['noarchive'] = get_the_author_meta('noarchive', (int) get_query_var('author')) ? 'noarchive' : $directives['noarchive'];
        $directives['noindex'] = genesis_get_seo_option('noindex_author_archive') ? 'noindex' : $directives['noindex'];
        $directives['noarchive'] = genesis_get_seo_option('noarchive_author_archive') ? 'noarchive' : $directives['noarchive'];
    } elseif (is_date()) {
        $directives['noindex'] = genesis_get_seo_option('noindex_date_archive') ? 'noindex' : $directives['noindex'];
        $directives['noarchive'] = genesis_get_seo_option('noarchive_date_archive') ? 'noarchive' : $directives['noarchive'];
    } elseif (is_search()) {
        $directives['noindex'] = genesis_get_seo_option('noindex_search_archive') ? 'noindex' : $directives['noindex'];
        $directives['noarchive'] = genesis_get_seo_option('noarchive_search_archive') ? 'noarchive' : $directives['noarchive'];
    }
    /**
     * Filter the array of directives for the robots meta tag.
     *
     * @since 2.4.0
     *
     * @param array $directives May contain keys for `noindex`, `nofollow`, `noodp`, `noydir`, `noarchive`.
     */
    $directives = apply_filters('genesis_get_robots_meta_content', $directives);
    // Strip empty array items.
    $directives = array_filter($directives);
    return implode(',', $directives);
}
/**
 * Add custom headline and description to assigned posts page.
 *
 * If we're not on a posts page, then nothing extra is displayed.
 *
 * @since 2.2.1
 *
 * @uses genesis_a11y() Check if a post type should potentially support an archive setting page.
 * @uses genesis_do_post_title() Get list of custom post types which need an archive settings page.
 *
 * @return null Return early if not on relevant posts page.
 */
function genesis_do_posts_page_heading()
{
    if (!genesis_a11y('headings')) {
        return;
    }
    $posts_page = get_option('page_for_posts');
    if (is_null($posts_page)) {
        return;
    }
    if (!is_home() || genesis_is_root_page()) {
        return;
    }
    printf('<div %s>', genesis_attr('posts-page-description'));
    printf('<h1 %s>%s</h1>', genesis_attr('archive-title'), get_the_title($posts_page));
    echo '</div>';
}
示例#7
0
文件: header.php 项目: hoaint/junhee
/**
 * Output the `index`, `follow`, `noodp`, `noydir`, `noarchive` robots meta code in the document `head`.
 *
 * @since 0.1.3
 *
 * @uses genesis_get_seo_option()   Get SEO setting value.
 * @uses genesis_get_custom_field() Get custom field value.
 *
 * @global WP_Query $wp_query Query object.
 *
 * @return null Return early if blog is not public.
 */
function genesis_robots_meta()
{
    global $wp_query;
    $post_id = null;
    //* If the blog is private, then following logic is unnecessary as WP will insert noindex and nofollow
    if (!get_option('blog_public')) {
        return;
    }
    //* Defaults
    $meta = array('noindex' => '', 'nofollow' => '', 'noarchive' => genesis_get_seo_option('noarchive') ? 'noarchive' : '', 'noodp' => genesis_get_seo_option('noodp') ? 'noodp' : '', 'noydir' => genesis_get_seo_option('noydir') ? 'noydir' : '');
    //* Check root page SEO settings, set noindex, nofollow and noarchive
    if (genesis_is_root_page()) {
        $meta['noindex'] = genesis_get_seo_option('home_noindex') ? 'noindex' : $meta['noindex'];
        $meta['nofollow'] = genesis_get_seo_option('home_nofollow') ? 'nofollow' : $meta['nofollow'];
        $meta['noarchive'] = genesis_get_seo_option('home_noarchive') ? 'noarchive' : $meta['noarchive'];
    }
    if (is_category()) {
        $term = $wp_query->get_queried_object();
        $meta['noindex'] = $term->meta['noindex'] ? 'noindex' : $meta['noindex'];
        $meta['nofollow'] = $term->meta['nofollow'] ? 'nofollow' : $meta['nofollow'];
        $meta['noarchive'] = $term->meta['noarchive'] ? 'noarchive' : $meta['noarchive'];
        $meta['noindex'] = genesis_get_seo_option('noindex_cat_archive') ? 'noindex' : $meta['noindex'];
        $meta['noarchive'] = genesis_get_seo_option('noarchive_cat_archive') ? 'noarchive' : $meta['noarchive'];
    }
    if (is_tag()) {
        $term = $wp_query->get_queried_object();
        $meta['noindex'] = $term->meta['noindex'] ? 'noindex' : $meta['noindex'];
        $meta['nofollow'] = $term->meta['nofollow'] ? 'nofollow' : $meta['nofollow'];
        $meta['noarchive'] = $term->meta['noarchive'] ? 'noarchive' : $meta['noarchive'];
        $meta['noindex'] = genesis_get_seo_option('noindex_tag_archive') ? 'noindex' : $meta['noindex'];
        $meta['noarchive'] = genesis_get_seo_option('noarchive_tag_archive') ? 'noarchive' : $meta['noarchive'];
    }
    if (is_tax()) {
        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        $meta['noindex'] = $term->meta['noindex'] ? 'noindex' : $meta['noindex'];
        $meta['nofollow'] = $term->meta['nofollow'] ? 'nofollow' : $meta['nofollow'];
        $meta['noarchive'] = $term->meta['noarchive'] ? 'noarchive' : $meta['noarchive'];
    }
    if (is_post_type_archive() && genesis_has_post_type_archive_support()) {
        $meta['noindex'] = genesis_get_cpt_option('noindex') ? 'noindex' : $meta['noindex'];
        $meta['nofollow'] = genesis_get_cpt_option('nofollow') ? 'nofollow' : $meta['nofollow'];
        $meta['noarchive'] = genesis_get_cpt_option('noarchive') ? 'noarchive' : $meta['noarchive'];
    }
    if (is_author()) {
        $meta['noindex'] = get_the_author_meta('noindex', (int) get_query_var('author')) ? 'noindex' : $meta['noindex'];
        $meta['nofollow'] = get_the_author_meta('nofollow', (int) get_query_var('author')) ? 'nofollow' : $meta['nofollow'];
        $meta['noarchive'] = get_the_author_meta('noarchive', (int) get_query_var('author')) ? 'noarchive' : $meta['noarchive'];
        $meta['noindex'] = genesis_get_seo_option('noindex_author_archive') ? 'noindex' : $meta['noindex'];
        $meta['noarchive'] = genesis_get_seo_option('noarchive_author_archive') ? 'noarchive' : $meta['noarchive'];
    }
    if (is_date()) {
        $meta['noindex'] = genesis_get_seo_option('noindex_date_archive') ? 'noindex' : $meta['noindex'];
        $meta['noarchive'] = genesis_get_seo_option('noarchive_date_archive') ? 'noarchive' : $meta['noarchive'];
    }
    if (is_search()) {
        $meta['noindex'] = genesis_get_seo_option('noindex_search_archive') ? 'noindex' : $meta['noindex'];
        $meta['noarchive'] = genesis_get_seo_option('noarchive_search_archive') ? 'noarchive' : $meta['noarchive'];
    }
    //* When the page is set as the Posts Page in WordPress core, use the $post_id of the page when loading SEO values
    if (is_home() && get_option('page_for_posts') && get_queried_object_id()) {
        $post_id = get_option('page_for_posts');
    }
    if (is_singular() || null !== $post_id) {
        $meta['noindex'] = genesis_get_custom_field('_genesis_noindex', $post_id) ? 'noindex' : $meta['noindex'];
        $meta['nofollow'] = genesis_get_custom_field('_genesis_nofollow', $post_id) ? 'nofollow' : $meta['nofollow'];
        $meta['noarchive'] = genesis_get_custom_field('_genesis_noarchive', $post_id) ? 'noarchive' : $meta['noarchive'];
    }
    //* Strip empty array items
    $meta = array_filter($meta);
    //* Add meta if any exist
    if ($meta) {
        printf('<meta name="robots" content="%s" />' . "\n", implode(',', $meta));
    }
}
示例#8
0
/**
 * Echo the site description into the header.
 *
 * Depending on the SEO option set by the user, this will either be wrapped in an `h1` or `p` element.
 *
 * Applies the `genesis_seo_description` filter before echoing.
 *
 * @since 1.1.0
 */
function genesis_seo_site_description()
{
    // Set what goes inside the wrapping tags.
    $inside = esc_html(get_bloginfo('description'));
    // Determine which wrapping tags to use.
    $wrap = genesis_is_root_page() && 'description' === genesis_get_seo_option('home_h1_on') ? 'h1' : 'p';
    // Wrap homepage site description in p tags if static front page.
    $wrap = is_front_page() && !is_home() ? 'p' : $wrap;
    // And finally, $wrap in h2 if HTML5 & semantic headings enabled.
    $wrap = genesis_html5() && genesis_get_seo_option('semantic_headings') ? 'h2' : $wrap;
    /**
     * Site description wrapping element
     *
     * The wrapping element for the site description.
     *
     * @since 2.2.3
     *
     * @param string $wrap The wrapping element (h1, h2, p, etc.).
     */
    $wrap = apply_filters('genesis_site_description_wrap', $wrap);
    // Build the description.
    $description = genesis_markup(array('open' => sprintf("<{$wrap} %s>", genesis_attr('site-description')), 'close' => "</{$wrap}>", 'content' => $inside, 'context' => 'site-description', 'echo' => false, 'params' => array('wrap' => $wrap)));
    // Output (filtered).
    $output = $inside ? apply_filters('genesis_seo_description', $description, $inside, $wrap) : '';
    echo $output;
}