Example #1
0
/**
 * Gets a message in case no idea was found
 *
 * @package WP Idea Stream
 * @subpackage ideas/tags
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_is_user_profile() to check if on a user's profile
 * @uses   wp_idea_stream_is_user_profile_rates() to check if the rates part of a user's profile
 * @uses   wp_idea_stream_users_get_displayed_user_displayname() to get the displayed user's display name
 * @uses   wp_idea_stream_is_category() to check if a category is displayed
 * @uses   wp_idea_stream_is_tag() to check if a tag is displayed
 * @uses   wp_idea_stream_is_search() to check if a search is being performed
 * @uses   wp_idea_stream_is_orderby() to check if a specific order is being requested
 * @uses   wp_idea_stream_user_can() to check for user's capability
 * @uses   wp_idea_stream_get_form_url() to get the form url to add new ideas
 * @uses   apply_filters() call 'wp_idea_stream_ideas_get_not_found' to override the output
 * @return string the message to output
 */
function wp_idea_stream_ideas_get_not_found()
{
    // general feedback
    $output = esc_html__('It looks like no idea has been submitted yet, please sign in or sign up to add yours!', 'wp-idea-stream');
    if (wp_idea_stream_is_user_profile()) {
        if (!wp_idea_stream_is_user_profile_rates()) {
            $output = sprintf(__('It looks like %s has not submitted any idea yet', 'wp-idea-stream'), wp_idea_stream_users_get_displayed_user_displayname());
            // We're viewing the idea the user rated
        } else {
            $output = sprintf(__('It looks like %s has not rated any idea yet', 'wp-idea-stream'), wp_idea_stream_users_get_displayed_user_displayname());
        }
    } else {
        if (wp_idea_stream_is_category()) {
            $output = __('It looks like no idea has been published in this category yet', 'wp-idea-stream');
        } else {
            if (wp_idea_stream_is_tag()) {
                $output = __('It looks like no idea has been marked with this tag yet', 'wp-idea-stream');
            } else {
                if (wp_idea_stream_is_search()) {
                    $output = __('It looks like no idea match your search terms.', 'wp-idea-stream');
                } else {
                    if (wp_idea_stream_is_search()) {
                        $output = __('It looks like no idea match your search terms.', 'wp-idea-stream');
                    } else {
                        if (wp_idea_stream_is_orderby('rates_count')) {
                            $output = __('It looks like no idea has been rated yet.', 'wp-idea-stream');
                        } else {
                            if (wp_idea_stream_user_can('publish_ideas')) {
                                $output = sprintf(__('It looks like no idea has been submitted yet, <a href="%s" title="Submit your idea">add yours</a>', 'wp-idea-stream'), esc_url(wp_idea_stream_get_form_url()));
                            }
                        }
                    }
                }
            }
        }
    }
    /**
     * @param  string $output the message to output
     */
    return apply_filters('wp_idea_stream_ideas_get_not_found', $output);
}
Example #2
0
/**
 * Gets a message if no comments were found
 *
 * @package WP Idea Stream
 * @subpackage comments/tags
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_users_get_displayed_user_displayname() to get the message
 * @uses   apply_filters() call 'wp_idea_stream_comments_get_no_comment_found' to override the output
 * @return string the message if no comments were found
 */
function wp_idea_stream_comments_get_no_comment_found()
{
    $output = sprintf(__('It looks like %s has not commented any idea yet', 'wp-idea-stream'), wp_idea_stream_users_get_displayed_user_displayname());
    /**
     * @param  string $output the message if no comments were found
     */
    return apply_filters('wp_idea_stream_comments_get_no_comment_found', $output);
}
/**
 * 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);
}
Example #4
0
/**
 * Gets user's profile description
 *
 * @package WP Idea Stream
 * @subpackage users/tags
 *
 * @since 2.0.0
 *
 * @uses wp_idea_stream_users_get_displayed_user_displayname() get displayed user display name
 * @uses wp_idea_stream_is_current_user_profile() to check current user is viewing his profile
 * @uses wp_idea_stream_users_get_displayed_user_description() to get user's descripton
 * @uses wp_kses_allowed_html() to get allowed tags for user's description
 * @uses wp_kses to sanitize user's descripton
 * @uses apply_filters() call 'wp_idea_stream_users_get_{$self}user_profile_description' to override output
 */
function wp_idea_stream_users_get_user_profile_description()
{
    $display_name = wp_idea_stream_users_get_displayed_user_displayname();
    $self = '';
    $is_self_profile = wp_idea_stream_is_current_user_profile();
    $user_description = sprintf(esc_html__('%s has not created his description yet', 'wp-idea-stream'), $display_name);
    if (!empty($is_self_profile)) {
        $user_description = esc_html__('Replace this text with your description, then hit the Edit button to save it.', 'wp-idea-stream');
    }
    $description = wp_idea_stream_users_get_displayed_user_description();
    if (!empty($description)) {
        $allowed_html = wp_kses_allowed_html('user_description');
        $user_description = wp_kses($description, $allowed_html);
    }
    $output = '<div class="user-description">';
    if (!empty($is_self_profile)) {
        $output .= '<form action="" method="post" id="wp_idea_stream_profile_form" class="user-profile-form">';
    }
    $output .= '<blockquote>';
    if (!empty($is_self_profile)) {
        $self = 'self_';
        $output .= '<div id="wp_idea_stream_profile_description" contenteditable="true">';
    }
    /**
     * Use 'wp_idea_stream_users_get_user_profile_description' to filter description when the current user
     * is viewing someone else profile
     * Use 'wp_idea_stream_users_get_self_user_profile_description' to filter description when the current user
     * is viewing his profile
     *
     * @param string $user_description User description
     */
    $user_description = apply_filters("wp_idea_stream_users_get_{$self}user_profile_description", $user_description);
    // Add desciption to the output
    $output .= $user_description;
    if (!empty($is_self_profile)) {
        $output .= '</div>';
    }
    $output .= '</blockquote>';
    // Fall back is javscript's going wild
    if (!empty($is_self_profile)) {
        $output .= '<textarea name="wp_idea_stream_profile[description]">' . $user_description . '</textarea>';
        $output .= wp_nonce_field('wp_idea_stream_update_description', '_wpis_nonce', true, false);
        $output .= '<input type="submit" name="wp_idea_stream_profile[save]" value="' . esc_attr_x('Edit', 'User profile description edit', 'wp-idea-stream') . '"/></form>';
    }
    $output .= '</div>';
    return $output;
}