Example #1
0
/**
 * Echo a CPT Archive option from the options table.
 *
 * @since 2.0.0
 *
 * @uses genesis_get_cpt_option() Return a CPT Archive setting value from the options table.
 *
 * @param string $key            Option name.
 * @param string $post_type_name Post type name.
 * @param bool   $use_cache      Optional. Whether to use the Genesis cache value or not. Defaults to true.
 */
function genesis_cpt_option($key, $post_type_name, $use_cache = true)
{
    echo genesis_get_cpt_option($key, $post_type_name, $use_cache);
}
 /**
  * Add custom headline and description to relevant custom post type archive pages.
  *
  * If we're not on a post type archive page, or not on page 1, then nothing extra is displayed.
  *
  * If there's a custom headline to display, it is marked up as a level 1 heading.
  *
  * If there's a description (intro text) to display, it is run through wpautop() before being added to a div.
  *
  * @since 2.0.0
  *
  * @uses genesis_has_post_type_archive_support() Check if a post type should potentially support an archive setting page.
  * @uses genesis_get_cpt_option()                Get list of custom post types which need an archive settings page.
  *
  * @return null Return early if not on relevant post type archive.
  */
 public function do_cpt_archive_description()
 {
     if (!is_post_type_archive() || !genesis_has_post_type_archive_support()) {
         return;
     }
     if (get_query_var('paged') >= 2) {
         return;
     }
     $intro_text = apply_filters('display_featured_image_genesis_cpt_description', genesis_get_cpt_option('intro_text'));
     if ($intro_text) {
         printf('<div class="archive-description cpt-archive-description">%s</div>', wp_kses_post(wpautop($intro_text)));
     }
 }
Example #3
0
/**
 * Adds a custom class to the custom post type archive body classes.
 *
 * It accepts a value from the archive settings page.
 *
 * @since 2.0.0
 *
 * @uses genesis_has_post_type_archive_support() Check if current CPT has archive support.
 * @uses genesis_get_cpt_option()                Get CPT Archive setting.
 *
 * @param array $classes Existing classes.
 *
 * @return array Amended classes.
 */
function genesis_cpt_archive_body_class(array $classes)
{
    if (!is_post_type_archive() || !genesis_has_post_type_archive_support()) {
        return $classes;
    }
    $new_class = genesis_get_cpt_option('body_class');
    if ($new_class) {
        $classes[] = esc_attr(sanitize_html_class($new_class));
    }
    return $classes;
}
Example #4
0
/**
 * 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);
}
Example #5
0
/**
 * 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() || is_tag() || is_tax()) {
        $term = $wp_query->get_queried_object();
        $meta['noindex'] = get_term_meta($term->term_id, 'noindex', true) ? 'noindex' : $meta['noindex'];
        $meta['nofollow'] = get_term_meta($term->term_id, 'nofollow', true) ? 'nofollow' : $meta['nofollow'];
        $meta['noarchive'] = get_term_meta($term->term_id, 'noarchive', true) ? 'noarchive' : $meta['noarchive'];
        if (is_category()) {
            $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()) {
            $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_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));
    }
}
/**
 * Callback for WordPress 'pre_get_posts' action.
 *
 * Modify the number of posts on an testimony archive page if set to a custom value.
 *
 * @see https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
 * 
 * @since 0.0.1
 * 
 * @return void
 */
function cpt_as_pre_get_posts($query)
{
    //* if admin or not on the testimony archive page, exit
    if (is_admin() || !is_post_type_archive('testimony')) {
        return;
    }
    //* get the custom posts_per_page value
    $posts_per_page = (int) genesis_get_cpt_option('posts_per_page', 'testimony');
    //* if a valid posts_per_page value and on the main query, adjust the query
    if ($posts_per_page && $query->is_main_query()) {
        $query->set('posts_per_page', $posts_per_page);
    }
}
 /**
  * Add custom headline and description to relevant custom post type archive pages.
  *
  * If we're not on a post type archive page, or not on page 1, then nothing extra is displayed.
  *
  * If there's a custom headline to display, it is marked up as a level 1 heading.
  *
  * If there's a description (intro text) to display, it is run through wpautop() before being added to a div.
  *
  * @since 2.0.0
  *
  * @uses genesis_has_post_type_archive_support() Check if a post type should potentially support an archive setting page.
  * @uses genesis_get_cpt_option()                Get list of custom post types which need an archive settings page.
  *
  * @return null Return early if not on relevant post type archive.
  */
 public function do_cpt_archive_description()
 {
     if (!is_post_type_archive() || !genesis_has_post_type_archive_support()) {
         return;
     }
     if (get_query_var('paged') >= 2) {
         return;
     }
     $intro_text = apply_filters('display_featured_image_genesis_cpt_description', genesis_get_cpt_option('intro_text'));
     if ($intro_text) {
         $class = 'archive-description cpt-archive-description';
         $this->print_description($intro_text, $class);
     }
 }
Example #8
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);
}
Example #9
0
/**
 * 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;
    //* 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 home page SEO settings, set noindex, nofollow and noarchive
    if (is_front_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'];
        //* noindex paged archives, if canonical archives is off
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        $meta['noindex'] = $paged > 1 && !genesis_get_seo_option('canonical_archives') ? 'noindex' : $meta['noindex'];
    }
    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'];
        //* noindex paged archives, if canonical archives is off
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        $meta['noindex'] = $paged > 1 && !genesis_get_seo_option('canonical_archives') ? 'noindex' : $meta['noindex'];
    }
    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'];
        //* noindex paged archives, if canonical archives is off
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        $meta['noindex'] = $paged > 1 && !genesis_get_seo_option('canonical_archives') ? 'noindex' : $meta['noindex'];
    }
    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'];
        //* noindex paged archives, if canonical archives is off
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        $meta['noindex'] = $paged > 1 && !genesis_get_seo_option('canonical_archives') ? 'noindex' : $meta['noindex'];
    }
    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'];
        //* noindex paged archives, if canonical archives is off
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        $meta['noindex'] = $paged > 1 && !genesis_get_seo_option('canonical_archives') ? 'noindex' : $meta['noindex'];
    }
    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'];
    }
    if (is_singular()) {
        $meta['noindex'] = genesis_get_custom_field('_genesis_noindex') ? 'noindex' : $meta['noindex'];
        $meta['nofollow'] = genesis_get_custom_field('_genesis_nofollow') ? 'nofollow' : $meta['nofollow'];
        $meta['noarchive'] = genesis_get_custom_field('_genesis_noarchive') ? '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));
    }
}
/**
 * Add custom headline and description to relevant custom post type archive pages.
 *
 * If we're not on a post type archive page, or not on page 1, then nothing extra is displayed.
 *
 * If there's a custom headline to display, it is marked up as a level 1 heading.
 *
 * If there's a description (intro text) to display, it is run through wpautop() before being added to a div.
 *
 * @since 2.0.0
 *
 * @uses genesis_has_post_type_archive_support() Check if a post type should potentially support an archive setting page.
 * @uses genesis_get_cpt_option()                Get list of custom post types which need an archive settings page.
 *
 * @return null Return early if not on relevant post type archive.
 */
function msdlab_do_cpt_archive_title_description()
{
    if (!is_post_type_archive() || !genesis_has_post_type_archive_support()) {
        return;
    }
    if (get_query_var('paged') >= 2) {
        return;
    }
    $headline = genesis_get_cpt_option('headline');
    $intro_text = genesis_get_cpt_option('intro_text');
    $headline = $headline ? sprintf('<h1 class="archive-title">%s</h1>', $headline) : '';
    $intro_text = $intro_text ? apply_filters('genesis_cpt_archive_intro_text_output', $intro_text) : '';
    if ($headline || $intro_text) {
        printf('<div class="archive-description cpt-archive-description"><div class="wrap">%s</div></div>', $headline . '<div class="sep"></div>' . $intro_text);
    }
}
/**
 * Add custom headline and description to relevant custom post type archive pages.
 *
 * If we're not on a post type archive page, then nothing extra is displayed.
 *
 * If there's a custom headline to display, it is marked up as a level 1 heading.
 *
 * If there's a description (intro text) to display, it is run through wpautop() before being added to a div.
 *
 * @since 2.0.0
 *
 * @uses genesis_has_post_type_archive_support() Check if a post type should potentially support an archive setting page.
 * @uses genesis_get_cpt_option()                Get list of custom post types which need an archive settings page.
 *
 * @return null Return early if not on relevant post type archive.
 */
function genesis_do_cpt_archive_title_description()
{
    if (!is_post_type_archive() || !genesis_has_post_type_archive_support()) {
        return;
    }
    $headline = genesis_get_cpt_option('headline');
    if (empty($headline) && genesis_a11y('headings')) {
        $headline = post_type_archive_title('', false);
    }
    $intro_text = genesis_get_cpt_option('intro_text');
    $headline = $headline ? sprintf('<h1 %s>%s</h1>', genesis_attr('archive-title'), strip_tags($headline)) : '';
    $intro_text = $intro_text ? apply_filters('genesis_cpt_archive_intro_text_output', $intro_text) : '';
    if ($headline || $intro_text) {
        printf('<div %s>%s</div>', genesis_attr('cpt-archive-description'), $headline . $intro_text);
    }
}
 protected static function set_item_title($title = '')
 {
     $frontpage = get_option('show_on_front');
     // either 'posts' or 'page'
     $postspage = get_option('page_for_posts');
     $a11ycheck = current_theme_supports('genesis-accessibility', array('headings'));
     if (is_singular()) {
         $title = get_the_title();
     } elseif (is_home() && 'page' === $frontpage) {
         $title = get_post($postspage)->post_title;
     } elseif (is_category() || is_tag() || is_tax()) {
         $term = is_tax() ? get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')) : get_queried_object();
         if (!$term || !isset($term->meta)) {
             return;
         }
         $title = $term->meta['headline'];
         if (empty($title) && $a11ycheck) {
             $title = $term->name;
         }
     } elseif (is_author()) {
         $title = get_the_author_meta('headline', (int) get_query_var('author'));
         if (empty($title) && $a11ycheck) {
             $title = get_the_author_meta('display_name', (int) get_query_var('author'));
         }
     } elseif (is_post_type_archive() && genesis_has_post_type_archive_support()) {
         $title = genesis_get_cpt_option('headline');
         if (empty($title) && $a11ycheck) {
             $title = post_type_archive_title('', false);
         }
     }
     return $title;
 }
 /**
  * Echo the widget content.
  *
  * @since 2.0.0
  *
  *
  * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
  * @param array $instance The settings for the particular instance of the widget
  */
 function widget($args, $instance)
 {
     //* Merge with defaults
     $instance = wp_parse_args((array) $instance, $this->defaults);
     $post_type = get_post_type_object($instance['post_type']);
     $option = get_option('displayfeaturedimagegenesis');
     if ('post' === $instance['post_type']) {
         $frontpage = get_option('show_on_front');
         // either 'posts' or 'page'
         $postspage = get_option('page_for_posts');
         $postspage_image = get_post_thumbnail_id($postspage);
         $title = get_post($postspage)->post_title;
         $permalink = esc_url(get_the_permalink($postspage));
         if ('posts' === $frontpage || 'page' === $frontpage && !$postspage) {
             $postspage_image = display_featured_image_genesis_get_default_image_id();
             $title = get_bloginfo('name');
             $permalink = home_url();
         }
     } else {
         $title = $post_type->label;
         $permalink = esc_url(get_post_type_archive_link($instance['post_type']));
         if (post_type_supports($instance['post_type'], 'genesis-cpt-archives-settings')) {
             $headline = genesis_get_cpt_option('headline', $instance['post_type']);
             if (!empty($headline)) {
                 $title = $headline;
             }
         }
     }
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['after_title'];
     }
     $image = '';
     $image_id = 'post' === $instance['post_type'] ? $postspage_image : displayfeaturedimagegenesis_check_image_id($option['post_type'][$post_type->name]);
     $image_src = wp_get_attachment_image_src($image_id, $instance['image_size']);
     if ($image_src) {
         $image = '<img src="' . $image_src[0] . '" alt="' . $title . '" />';
     }
     if ($instance['show_image'] && $image) {
         $role = empty($instance['show_title']) ? '' : 'aria-hidden="true"';
         printf('<a href="%s" title="%s" class="%s" %s>%s</a>', esc_url($permalink), esc_html($title), esc_attr($instance['image_alignment']), esc_attr($role), $image);
     }
     if ($instance['show_title']) {
         if (!empty($instance['show_title'])) {
             $title_output = sprintf('<h2><a href="%s">%s</a></h2>', $permalink, esc_html($title));
             if (genesis_html5()) {
                 $title_output = sprintf('<h2 class="archive-title"><a href="%s">%s</a></h2>', $permalink, esc_html($title));
             }
             echo wp_kses_post($title_output);
         }
     }
     $intro_text = '';
     if (post_type_supports($instance['post_type'], 'genesis-cpt-archives-settings')) {
         $intro_text = genesis_get_cpt_option('intro_text', $instance['post_type']);
     } elseif ('post' === $instance['post_type']) {
         $intro_text = get_post($postspage)->post_excerpt;
         if ('posts' === $frontpage || 'page' === $frontpage && !$postspage) {
             $intro_text = get_bloginfo('description');
         }
     }
     if ($instance['show_content'] && $intro_text) {
         echo genesis_html5() ? '<div class="archive-description">' : '';
         $intro_text = apply_filters('display_featured_image_genesis_cpt_description', $intro_text);
         echo wp_kses_post(wpautop($intro_text));
         echo genesis_html5() ? '</div>' : '';
     }
     echo $args['after_widget'];
 }
Example #14
0
/**
 * Return filtered post title.
 *
 * This function does 3 things:
 *  1. Pulls the values for `$sep` and `$seplocation`, uses defaults if necessary.
 *  2. Determines if the site title should be appended.
 *  3. Allows the user to set a custom title on a per-page or per-post basis.
 *
 * @since 0.1.3
 *
 * @global WP_Query $wp_query Query object.
 *
 * @param string $title       Existing page title.
 * @param string $sep         Separator character(s). Default is `–` if not set.
 * @param string $seplocation Separator location - "left" or "right". Default is "right" if not set.
 * @return string Page title, formatted depending on context.
 */
function genesis_default_title($title, $sep, $seplocation)
{
    global $wp_query;
    $post_id = null;
    if (is_feed()) {
        return $title;
    }
    $sep = genesis_get_seo_option('doctitle_sep') ? genesis_get_seo_option('doctitle_sep') : '–';
    $seplocation = genesis_get_seo_option('doctitle_seplocation') ? genesis_get_seo_option('doctitle_seplocation') : 'right';
    // If viewing the root page.
    if (genesis_is_root_page()) {
        // Determine the doctitle.
        $title = genesis_get_seo_option('home_doctitle') ? genesis_get_seo_option('home_doctitle') : get_bloginfo('name');
        // Append site description, if necessary.
        $title = genesis_get_seo_option('append_description_home') ? $title . " {$sep} " . get_bloginfo('description') : $title;
    }
    // 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 viewing a post / page / attachment.
    if (is_singular() || null !== $post_id) {
        // The User Defined Title (Genesis).
        if (genesis_get_custom_field('_genesis_title', $post_id)) {
            $title = genesis_get_custom_field('_genesis_title', $post_id);
        } elseif (genesis_get_custom_field('_aioseop_title', $post_id)) {
            $title = genesis_get_custom_field('_aioseop_title', $post_id);
        } elseif (genesis_get_custom_field('_headspace_page_title', $post_id)) {
            $title = genesis_get_custom_field('_headspace_page_title', $post_id);
        } elseif (genesis_get_custom_field('thesis_title', $post_id)) {
            $title = genesis_get_custom_field('thesis_title', $post_id);
        } elseif (genesis_get_custom_field('title_tag', $post_id)) {
            $title = genesis_get_custom_field('title_tag', $post_id);
        } elseif (genesis_get_custom_field('title', $post_id)) {
            $title = genesis_get_custom_field('title', $post_id);
        }
    }
    if (is_category() || is_tag() || is_tax()) {
        $term = get_queried_object();
        $title_meta = get_term_meta($term->term_id, 'doctitle', true);
        $title = !empty($title_meta) ? $title_meta : $title;
    }
    if (is_author()) {
        $user_title = get_the_author_meta('doctitle', (int) get_query_var('author'));
        $title = $user_title ? $user_title : $title;
    }
    if (is_post_type_archive() && genesis_has_post_type_archive_support()) {
        $title = genesis_get_cpt_option('doctitle') ? genesis_get_cpt_option('doctitle') : $title;
    }
    // If we don't want site name appended, or if we're on the home page.
    if (!genesis_get_seo_option('append_site_title') || is_front_page()) {
        return esc_html(trim($title));
    }
    // Else append the site name.
    $title = 'right' === $seplocation ? $title . " {$sep} " . get_bloginfo('name') : get_bloginfo('name') . " {$sep} " . $title;
    return esc_html(trim($title));
}