/**
 * Filters the <title> content
 *
 * Inspired by bbPress's bbp_title()
 *
 * @package WP Idea Stream
 * @subpackage core/template-functions
 *
 * @since 2.0.0
 *
 * @param array $title the title parts
 * @uses  wp_idea_stream_is_ideastream() to make sure it's plugin's territory
 * @uses  wp_idea_stream_is_addnew() to check the submit form is displayed
 * @uses  wp_idea_stream_is_user_profile() to check if a user's profile is displayed
 * @uses  wp_idea_stream_users_get_displayed_user_displayname() to get the display name of the user being viewed
 * @uses  wp_idea_stream_is_single_idea() to check whether page is displaying the single idea template
 * @uses  is_tax() to check if a taxonomy is in queried objects
 * @uses  wp_idea_stream_get_current_term() to get the current term
 * @uses  get_taxonomy() to get the taxonomy
 * @uses  wp_idea_stream_set_idea_var() to globalize the current term
 * @uses  wp_idea_stream_is_signup() to check if on the signup page
 * @uses  apply_filters() call 'wp_idea_stream_title' to override the title meta tag of the page
 * @return string the page title meta tag
 */
function wp_idea_stream_title($title_array = array())
{
    if (!wp_idea_stream_is_ideastream()) {
        return $title_array;
    }
    $new_title = array();
    if (wp_idea_stream_is_addnew()) {
        $new_title[] = esc_attr__('New idea', 'wp-idea-stream');
    } elseif (wp_idea_stream_is_edit()) {
        $new_title[] = esc_attr__('Edit idea', 'wp-idea-stream');
    } elseif (wp_idea_stream_is_user_profile()) {
        $new_title[] = sprintf(esc_html__('%s&#39;s profile', 'wp-idea-stream'), wp_idea_stream_users_get_displayed_user_displayname());
    } elseif (wp_idea_stream_is_single_idea()) {
        $new_title[] = single_post_title('', false);
    } elseif (is_tax()) {
        $term = wp_idea_stream_get_current_term();
        if ($term) {
            $tax = get_taxonomy($term->taxonomy);
            // Catch the term for later use
            wp_idea_stream_set_idea_var('current_term', $term);
            $new_title[] = single_term_title('', false);
            $new_title[] = $tax->labels->name;
        }
    } elseif (wp_idea_stream_is_signup()) {
        $new_title[] = esc_html__('Create an account', 'wp-idea-stream');
    } else {
        $new_title[] = esc_html__('Ideas', 'wp-idea-stream');
    }
    // Compare new title with original title
    if (empty($new_title)) {
        return $title_array;
    }
    $title_array = array_diff($title_array, $new_title);
    $new_title_array = array_merge($title_array, $new_title);
    /**
     * @param  string $new_title the filtered title
     * @param  string $sep
     * @param  string $seplocation
     * @param  string $title the original title meta tag
     */
    return apply_filters('wp_idea_stream_title', $new_title_array, $title_array, $new_title);
}
Пример #2
0
/**
 * Displays the current term description if it exists
 *
 * @package WP Idea Stream
 * @subpackage ideas/tags
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_is_category() to check if a category about ideas is displayed
 * @uses   wp_idea_stream_is_tag() to check if a tag about ideas is displayed
 * @uses   wp_idea_stream_get_current_term() to get the current term in the displayed taxonomy
 * @return string Output for the current term description.
 */
function wp_idea_stream_ideas_taxonomy_description()
{
    if (wp_idea_stream_is_category() || wp_idea_stream_is_tag()) {
        $term = wp_idea_stream_get_current_term();
        if (!empty($term->description)) {
            ?>
			<p class="idea-term-description"><?php 
            echo esc_html($term->description);
            ?>
</p>
			<?php 
        }
    }
}
Пример #3
0
/**
 * Gets a specific "tag" term url
 *
 * @package WP Idea Stream
 * @subpackage core/functions
 *
 * @since 2.0.0
 *
 * @param  object $tag the term to build the url for
 * @uses   wp_idea_stream_get_current_term() to get the current term thanks to queried object
 * @uses   get_term_link() to build the link
 * @uses   wp_idea_stream_get_tag() to get the taxonomy identifier
 * @uses   apply_filters() call 'wp_idea_stream_get_tag_url' to customize post type term url
 * @return string          url to reach all ideas tagged with the requested term
 */
function wp_idea_stream_get_tag_url($tag = '')
{
    if (empty($tag)) {
        $tag = wp_idea_stream_get_current_term();
    }
    $term_link = get_term_link($tag, wp_idea_stream_get_tag());
    /**
     * @param  string $term_link url to reach the ideas tagged with the term
     * @param  object $tag the term for this taxonomy
     */
    return apply_filters('wp_idea_stream_get_tag_url', $term_link, $tag);
}