Exemplo n.º 1
0
/**
 * Gets the footer of an idea
 *
 * @package WP Idea Stream
 * @subpackage ideas/tags
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream() to get plugin's main instance
 * @uses   wp_idea_stream_ideas_get_the_term_list() to get the taxonomy term list
 * @uses   wp_idea_stream_get_category() to get the category taxonomy identifier
 * @uses   wp_idea_stream_get_tag() to get the tag taxonomy identifier
 * @uses   mysql2date() to format the date
 * @uses   wp_idea_stream_is_single_idea() to check if the idea is displayed on its single template
 * @uses   wp_idea_stream_user_can() to check for user's capability
 * @uses   esc_url() to sanitize url
 * @uses   get_edit_post_link() to get the edit link of an idea
 * @uses   wp_idea_stream_users_get_user_data() to get user's attribute
 * @uses   wp_idea_stream_users_get_user_profile_url() to get user's profile link
 * @uses   get_avatar() to get user's avatar
 * @uses   esc_html() to sanitize the output
 * @uses   apply_filters() call 'wp_idea_stream_ideas_get_idea_footer' to override the output
 * @return string  output for the footer
 */
function wp_idea_stream_ideas_get_idea_footer()
{
    $idea = wp_idea_stream()->query_loop->idea;
    $retarray = array('start' => __('This idea', 'wp-idea-stream'));
    $category_list = wp_idea_stream_ideas_get_the_term_list($idea->ID, wp_idea_stream_get_category());
    if (!empty($category_list)) {
        $retarray['category'] = sprintf(_x('was posted in %s', 'idea categories comma separated list', 'wp-idea-stream'), $category_list);
    }
    $tag_list = wp_idea_stream_ideas_get_the_term_list($idea->ID, wp_idea_stream_get_tag());
    if (!empty($tag_list)) {
        $in = _x('and tagged', 'idea tags join words', 'wp-idea-stream');
        if (empty($category_list)) {
            $in = _x('was tagged', 'idea tags join words no category', 'wp-idea-stream');
        }
        $retarray['tag'] = sprintf(_x('%1$s %2$s', 'idea tags comma separated list', 'wp-idea-stream'), $in, $tag_list);
    }
    if (empty($retarray['category']) && empty($retarray['tag'])) {
        $retarray['posted'] = _x('was posted', 'idea footer empty tags and categories', 'wp-idea-stream');
    }
    $date = apply_filters('get_the_date', mysql2date(get_option('date_format'), $idea->post_date));
    if (!wp_idea_stream_is_single_idea()) {
        // point at the end
        $retarray['date'] = sprintf(_x('on %s.', 'idea date of publication point', 'wp-idea-stream'), $date);
    } else {
        // no point at the end
        $retarray['date'] = sprintf(_x('on %s', 'idea date of publication no point', 'wp-idea-stream'), $date);
        $user = wp_idea_stream_users_get_user_data('id', $idea->post_author);
        $user_link = '<a class="idea-author" href="' . esc_url(wp_idea_stream_users_get_user_profile_url($idea->post_author, $user->user_nicename)) . '" title="' . esc_attr($user->display_name) . '">';
        $user_link .= get_avatar($idea->post_author, 20) . esc_html($user->display_name) . '</a>';
        $retarray['author'] = sprintf(_x('by %s.', 'single idea author link', 'wp-idea-stream'), $user_link);
    }
    // Init edit url
    $edit_url = '';
    // Super admin will use the IdeaStream Administration screens
    if (wp_idea_stream_user_can('wp_idea_stream_ideas_admin')) {
        $edit_url = get_edit_post_link($idea->ID);
        // The author will use the front end edit form
    } else {
        if (wp_idea_stream_ideas_can_edit($idea)) {
            $edit_url = wp_idea_stream_get_form_url(wp_idea_stream_edit_slug(), $idea->post_name);
        }
    }
    if (!empty($edit_url)) {
        $retarray['edit'] = '<a href="' . esc_url($edit_url) . '" title="' . esc_attr__('Edit Idea', 'wp-idea-stream') . '">' . esc_html__('Edit Idea', 'wp-idea-stream') . '</a>';
    }
    /**
     * @param  string  the footer to output
     * @param  array   $retarray the parts of the footer organized in an associative array
     * @param  WP_Post $idea the idea object
     */
    return apply_filters('wp_idea_stream_ideas_get_idea_footer', join(' ', $retarray), $retarray, $idea);
}
Exemplo n.º 2
0
/**
 * Replace or Add the user's profile link to the comment authors
 *
 * @package WP Idea Stream
 * @subpackage comments/functions
 *
 * @since 2.0.0
 *
 * @param  array   $comments the list of comments in an array
 * @param  int     $idea_id  the ID of the idea
 * @uses   wp_idea_stream_is_single_idea() to make sure the single template of an idea is displayed
 * @uses   esc_url() to sanitize the url
 * @uses   wp_idea_stream_users_get_user_profile_url() to build the link to user's profile
 * @return array             the list of comments, author links replaced by their IdeaStream profile if needed
 */
function wp_idea_stream_comments_append_profile_url($comments = array(), $idea_id = 0)
{
    // Only filter comments arry if on a single idea
    if (!wp_idea_stream_is_single_idea() || empty($comments) || empty($idea_id)) {
        return $comments;
    }
    foreach ($comments as $key => $comment) {
        if (empty($comment->user_id)) {
            continue;
        }
        $comments[$key]->comment_author_url = esc_url(wp_idea_stream_users_get_user_profile_url($comment->user_id));
    }
    return $comments;
}
/**
 * Adds oEmbed discovery links in the website <head> for the IdeaStream user's profile root page.
 *
 * @since 2.3.0
 */
function wp_idea_stream_oembed_add_discovery_links()
{
    if (!wp_idea_stream_is_user_profile_ideas() || !wp_idea_stream_is_embed_profile()) {
        return;
    }
    $user_link = wp_idea_stream_users_get_user_profile_url(wp_idea_stream_users_displayed_user_id(), '', true);
    $output = '<link rel="alternate" type="application/json+oembed" href="' . esc_url(get_oembed_endpoint_url($user_link)) . '" />' . "\n";
    if (class_exists('SimpleXMLElement')) {
        $output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url(get_oembed_endpoint_url($user_link, 'xml')) . '" />' . "\n";
    }
    /**
     * Filter the oEmbed discovery links HTML.
     *
     * @since 2.3.0
     *
     * @param string $output HTML of the discovery links.
     */
    echo apply_filters('wp_idea_stream_users_oembed_add_discovery_links', $output);
}
Exemplo n.º 4
0
/**
 * About screen
 *
 * @package WP Idea Stream
 * @subpackage admin/thanks
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_get_version() to get plugin's version
 * @uses   add_query_arg() to add query vars to an url
 * @uses   admin_url() to build a link inside the current blog's Administration
 * @uses   get_transient() to get the value of a transient
 * @uses   delete_transient() to delete a transient
 * @uses   wp_oembed_get() to get the vidéo démo of the plugin
 * @return string HTML output
 */
function wp_idea_stream_admin_about()
{
    $display_version = wp_idea_stream_get_version();
    $settings_url = add_query_arg('page', 'ideastream', admin_url('options-general.php'));
    $has_upgraded = get_transient('_ideastream_reactivated_upgrade');
    $upgraded = __('activating', 'wp-idea-stream');
    if (!empty($has_upgraded)) {
        $upgraded = __('upgrading to', 'wp-idea-stream');
        delete_transient('_ideastream_reactivated_upgrade');
    }
    if (wp_idea_stream_is_embed_profile()) {
        $admin_profile = wp_oembed_get(wp_idea_stream_users_get_user_profile_url(get_current_user_id(), '', true));
    }
    ?>
	<div class="wrap about-wrap">
		<h1><?php 
    printf(esc_html_x('WP Idea Stream %s', 'about screen title', 'wp-idea-stream'), $display_version);
    ?>
</h1>
		<div class="about-text"><?php 
    printf(esc_html__('Thank you for %1$s the latest version of WP Idea Stream! %2$s brings some really cool new features!', 'wp-idea-stream'), $upgraded, $display_version);
    ?>
</div>
		<div class="wp-idea-stream-badge"></div>

		<h2 class="nav-tab-wrapper">
			<a class="nav-tab nav-tab-active" href="<?php 
    echo esc_url(admin_url(add_query_arg(array('page' => 'about-ideastream'), 'index.php')));
    ?>
">
				<?php 
    esc_html_e('About', 'wp-idea-stream');
    ?>
			</a>
			<a class="nav-tab" href="<?php 
    echo esc_url(admin_url(add_query_arg(array('page' => 'credits-ideastream'), 'index.php')));
    ?>
">
				<?php 
    _e('Credits', 'wp-idea-stream');
    ?>
			</a>
		</h2>

		<div class="headline-feature">
			<h2 style="text-align:center"><?php 
    echo esc_html_x('Share ideas, great ones will rise to the top!', 'IdeaStream Headline', 'wp-idea-stream');
    ?>
</h2>

			<div class="feature-section">
				<p>
					<?php 
    esc_html_e('WP Idea Stream is a WordPress plugin to power idea management for your site. Your members will be able to easily create, share and rate ideas.', 'wp-idea-stream');
    ?>
				</p>

				<?php 
    if (!empty($has_upgraded)) {
        ?>
					<h4><?php 
        esc_html_e('Important: these features are not supported anymore.', 'wp-idea-stream');
        ?>
</h4>
					<ul>
						<li><?php 
        esc_html_e('Set the list of ideas as the front page of the blog.', 'wp-idea-stream');
        ?>
</li>
						<li><?php 
        esc_html_e('Sharing options (twitter or email).', 'wp-idea-stream');
        ?>
</li>
						<li><?php 
        esc_html_e('Disabling the built-in rating system.', 'wp-idea-stream');
        ?>
</li>
					</ul>
				<?php 
    }
    ?>
			</div>
		</div>

		<hr />

		<div class="headline-feature">
			<h2 style="text-align:center"><?php 
    esc_html_e('Embed your users profiles', 'wp-idea-stream');
    ?>
</h2>

			<?php 
    if (!empty($admin_profile)) {
        ?>
				<style>blockquote.wp-embedded-content{display:none;}iframe.wp-embedded-content{display:block!important;margin:0 auto;max-height:228px!important;}</style>
				<div class="embed-container" id="#embed-admin-profile">
					<?php 
        echo $admin_profile;
        ?>
				</div>
			<?php 
    } else {
        ?>
				<div class="feature-image" style="text-align:center">
					<img src="https://cldup.com/4t2V1bvOMR.png" alt="<?php 
        esc_attr_e('Embed profile', 'wp-idea-stream');
        ?>
">
				</div>
			<?php 
    }
    ?>

			<div class="feature-section" style="margin-top:1em">
				<h3 style="text-align:center"><?php 
    esc_html_e('Great ideas are found by awesome people!', 'wp-idea-stream');
    ?>
</h3>
				<p><?php 
    esc_html_e('Use the powerful WordPress Embeds provider feature introduced in WordPress 4.4 to let your users show off their lovely profile and statistics about their contributions.', 'wp-idea-stream');
    ?>
</p>
				<p><?php 
    esc_html_e('WP Idea Stream embed profiles are even greater when BuddyPress 2.4 is activated thanks to its new Cover Images feature, check this out!', 'wp-idea-stream');
    ?>
</p>
			</div>

			<div class="feature-image" style="padding-bottom:1.5em;width:600px;margin:0 auto">
				<img src="https://cldup.com/liERrg_WJJ.png" alt="<?php 
    esc_attr_e('Embed profile when BuddyPress is active', 'wp-idea-stream');
    ?>
">
			</div>

			<div class="clear"></div>
		</div>

		<hr />

		<div class="feature-section two-col">
			<div class="col">
				<div class="media-container">
					<img src="https://cldup.com/QOitsGKqou.png" alt=""/>
				</div>
			</div>
			<div class="col">
				<h3><?php 
    esc_html_e('Featured images for ideas.', 'wp-idea-stream');
    ?>
</h3>
				<p><?php 
    esc_html_e('When a user adds an image to the idea, it will now be listed into a list of inserted images from which he will be able to choose the one he wishes to use as featured image.', 'wp-idea-stream');
    ?>
</p>
			</div>
		</div>

		<hr />

		<div class="feature-section two-col">
			<div class="col">
				<div class="media-container">
					<img src="https://cldup.com/GglZMhKiLG.png" alt=""/>
				</div>
			</div>
			<div class="col">
				<h3><?php 
    esc_html_e('Embeds, embeds, embeds!', 'wp-idea-stream');
    ?>
</h3>
				<p>
					<?php 
    esc_html_e('You can share ideas into your WordPress posts, or anyone can do it from everywhere on the internet just like regular posts. Ideas will include one more information: the average rating they got!', 'wp-idea-stream');
    ?>
				</p>
				<p>
					<?php 
    esc_html_e('The way the plugin deal with embeds has been greatly improved and every embed code should be displayed just fine in every single view of ideas (including the one in BuddyPress Groups).', 'wp-idea-stream');
    ?>
				</p>
			</div>
		</div>

		<div class="changelog feature-list">
			<h2 class="about-headline-callout"><?php 
    esc_html_e('The finer points..', 'wp-idea-stream');
    ?>
</h2>
			<div class="feature-section col one-col">
				<div class="col-1">
					<h4><?php 
    esc_html_e('TwentySixteen', 'wp-idea-stream');
    ?>
</h4>
					<p>
						<?php 
    esc_html_e('WP Idea Stream will look really nice into the new WordPress default theme. Its style has been optimized for it.', 'wp-idea-stream');
    ?>
					</p>
					<h4><?php 
    esc_html_e('Bug fixes', 'wp-idea-stream');
    ?>
</h4>
					<ul>
						<li><?php 
    esc_html_e('In users profiles, the issue with the title of commented private ideas is now fixed.', 'wp-idea-stream');
    ?>
</li>
						<li><?php 
    esc_html_e('In users profiles, user rates are now consistent meaning only ideas the displayed user rated will be displayed.', 'wp-idea-stream');
    ?>
</li>
						<li><?php 
    esc_html_e('Spammed users on multisite configs or configs where BuddyPress is activated, will not be displayed anymore. Unless you unspam them :)', 'wp-idea-stream');
    ?>
</li>
						<li><?php 
    esc_html_e('More links on archive pages are now using the link of the idea.', 'wp-idea-stream');
    ?>
</li>
						<li><?php 
    esc_html_e('The Ideas pagination is now completely independant of the Posts one.', 'wp-idea-stream');
    ?>
</li>
					</ul>
				</div>
			</div>
		</div>

		<div class="changelog">
			<div class="return-to-dashboard">
				<a href="<?php 
    echo esc_url($settings_url);
    ?>
" title="<?php 
    _e('Configure WP Idea Stream', 'wp-idea-stream');
    ?>
"><?php 
    _e('Go to the IdeaStream Settings page', 'wp-idea-stream');
    ?>
</a>
			</div>
		</div>

	</div>
	<?php 
}
Exemplo n.º 5
0
        /**
         * Displays the ratings metabox
         *
         * @package WP Idea Stream
         * @subpackage admin/admin
         *
         * @since 2.0.0
         *
         * @param  WP_Post $idea the idea object
         * @uses   wp_idea_stream_count_ratings() to get the rating stats for the idea
         * @uses   get_edit_post_link() to get the idea edit link
         * @uses   wp_idea_stream_get_hint_list() to get the captions for the rates
         * @uses   esc_html() to sanitize output
         * @uses   number_format_i18n() to format numbers
         * @uses   wp_idea_stream_users_get_user_profile_url() to get a user's IdeaStream profile url
         * @uses   esc_url() to sanitize url
         * @uses   get_avatar() to get user's avatar
         * @uses   wp_nonce_url() to add a security token to check upon once the link clicked
         * @uses   add_query_arg() to add query vars to an url
         * @return string HTML output
         */
        public function ratings_do_metabox($idea = null)
        {
            $id = $idea->ID;
            $ratings_stats = wp_idea_stream_count_ratings($id, 0, true);
            $users_count = count($ratings_stats['users']);
            $edit_link = get_edit_post_link($id);
            if (empty($users_count)) {
                esc_html_e('Not rated yet', 'wp-idea-stream');
            } else {
                $hintlabels = wp_idea_stream_get_hint_list();
                $hintlist = array_keys($hintlabels);
                ?>
			<p class="description">
				<?php 
                echo esc_html(sprintf(_n('%1$s member rated the idea. Its Average rating is: %2$s', '%1$s members rated the idea. Its Average rating is: %2$s', $users_count, 'wp-idea-stream'), number_format_i18n($users_count), number_format_i18n($ratings_stats['average'], 1)));
                ?>
			</p>
			<ul class="admin-idea-rates">
				<?php 
                foreach ($hintlist as $hintlabel) {
                    $hint = $hintlabel + 1;
                    ?>
				<li>
					<div class="admin-idea-rates-star"><?php 
                    echo esc_html(ucfirst($hintlabels[$hintlabel]));
                    ?>
</div>
					<div class="admin-idea-rates-users">
						<?php 
                    if (empty($ratings_stats['details'][$hint])) {
                        ?>
							&#8212;
						<?php 
                    } else {
                        foreach ($ratings_stats['details'][$hint] as $user_id) {
                            ?>
							<span class="user-rated">
								<a href="<?php 
                            echo esc_url(wp_idea_stream_users_get_user_profile_url($user_id));
                            ?>
"><?php 
                            echo get_avatar($user_id, 40);
                            ?>
</a>

								<?php 
                            $edit_user_link = wp_nonce_url(add_query_arg('remove_vote', $user_id, $edit_link), 'idea_remove_vote_' . $user_id);
                            ?>

								<a href="<?php 
                            echo esc_url($edit_user_link);
                            ?>
" class="del-rate" title="<?php 
                            esc_attr_e('Delete this rating', 'wp-idea-stream');
                            ?>
" data-userid="<?php 
                            echo $user_id;
                            ?>
">
									<div class="dashicons dashicons-trash"></div>
								</a>
							</span>
						<?php 
                        }
                    }
                    ?>
					</div>
				</li>
				<?php 
                }
                ?>
			</ul>
			<?php 
            }
        }
Exemplo n.º 6
0
/**
 * Return the avatar of the author of the comment currently being iterated on.
 *
 * @package WP Idea Stream
 * @subpackage comments/tags
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream() to get plugin's main instance
 * @uses   get_avatar() to get the avatar of the author
 * @uses   wp_idea_stream_users_get_user_profile_url() to get the comment author profile url
 * @uses   apply_filters() call 'wp_idea_stream_comments_get_comment_author_avatar' to override the output
 * @return string the avatar.
 */
function wp_idea_stream_comments_get_comment_author_avatar()
{
    $author = wp_idea_stream()->comment_query_loop->comment->user_id;
    $avatar = get_avatar($author);
    $avatar_link = '<a href="' . esc_url(wp_idea_stream_users_get_user_profile_url($author)) . '" title="' . esc_attr__('User&#39;s profile', 'wp-idea-stream') . '">' . $avatar . '</a>';
    /**
     * @param  string  $avatar_link the avatar output
     * @param  int     $author the author ID
     * @param  string  $avatar the avatar
     */
    return apply_filters('wp_idea_stream_comments_get_comment_author_avatar', $avatar_link, $author, $avatar);
}
Exemplo n.º 7
0
/**
 * Gets displayed user's rating for a given idea
 *
 * @package WP Idea Stream
 * @subpackage users/tags
 *
 * @since 2.0.0
 *
 * @param int $id      the idea ID
 * @param int $user_id the user ID
 * @uses  wp_idea_stream_is_user_profile_rates() to check we're on the rates part of a user's profile
 * @uses  wp_idea_stream_get_idea_var() to get a globalized value
 * @uses  wp_idea_stream_users_displayed_user_id() to get displayed user's ID
 * @uses  wp_idea_stream_users_get_displayed_user_username() to get displayed user's username
 * @uses  wp_idea_stream_users_get_user_profile_url() to get user's profile url
 * @uses  get_avatar() to get user's avatar
 * @uses  apply_filters() call 'wp_idea_stream_users_get_user_idea_rating' to override output
 */
function wp_idea_stream_users_get_user_idea_rating($id = 0, $user_id = 0)
{
    if (!wp_idea_stream_is_user_profile_rates()) {
        return;
    }
    if (empty($id)) {
        $query_loop = wp_idea_stream_get_idea_var('query_loop');
        if (!empty($query_loop->idea->ID)) {
            $id = $query_loop->idea->ID;
        }
    }
    if (empty($user_id)) {
        $user_id = wp_idea_stream_users_displayed_user_id();
    }
    if (empty($user_id) || empty($id)) {
        return;
    }
    $user_rating = wp_idea_stream_count_ratings($id, $user_id);
    if (empty($user_rating) || is_array($user_rating)) {
        return false;
    }
    $username = wp_idea_stream_users_get_displayed_user_username();
    $output = '<a class="user-rating-link" href="' . esc_url(wp_idea_stream_users_get_user_profile_url($user_id, $username)) . '" title="' . esc_attr($username) . '">';
    $output .= get_avatar($user_id, 20) . sprintf(_n('rated 1 star', 'rated %s stars', $user_rating, 'wp-idea-stream'), $user_rating) . '</a>';
    /**
     * Filter the user idea rating output
     *
     * @param string $output        the rating
     * @param int    $id            the idea ID
     * @param int    $user_id       the user ID
     */
    return apply_filters('wp_idea_stream_users_get_user_idea_rating', $output, $id, $user_id);
}
Exemplo n.º 8
0
/**
 * In case a user's profile is embed, replace the Utility page permalink with
 * the user's profile link
 *
 * @since 2.3.0
 *
 * @param  string  $permalink the link to the post
 * @param  WP_Post $post      the post object relative to the permalink
 * @return string  Unchanged link or the link to the user's profile if needed
 */
function wp_idea_stream_users_oembed_link($permalink, $post)
{
    if (!isset($post->ID) || wp_idea_stream_is_embed_profile() !== (int) $post->ID) {
        return $permalink;
    }
    $user = wp_idea_stream_get_idea_var('embed_user_data');
    if (!is_a($user, 'WP_User')) {
        return $permalink;
    }
    return wp_idea_stream_users_get_user_profile_url($user->ID, $user->user_nicename, true);
}
Exemplo n.º 9
0
        /**
         * Display the widget on front end
         *
         * @package WP Idea Stream
         * @subpackage users/widgets
         *
         * @since 2.0.0
         *
         * @uses  apply_filters() call 'widget_title' to allow the widget title to edited
         * @uses  wp_idea_stream_users_ideas_count_by_user() to get an ordered list of top contributors
         * @uses  wp_idea_stream_users_get_user_profile_url() to get url to user's profile
         * @uses  get_avatar() to get user's avatar
         */
        public function widget($args = array(), $instance = array())
        {
            // Default is 5
            $number = 5;
            // No nav items to show !? Stop!
            if (!empty($instance['number'])) {
                $number = (int) $instance['number'];
            }
            // Ten max.
            if ($number > 10) {
                $number = 10;
            }
            // Default title is nothing
            $title = '';
            if (!empty($instance['title'])) {
                $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
            }
            echo $args['before_widget'];
            if (!empty($title)) {
                echo $args['before_title'] . $title . $args['after_title'];
            }
            // Top contributors.
            $tops = wp_idea_stream_users_ideas_count_by_user($number);
            // Display the IdeaStream Nav
            if (!empty($tops)) {
                ?>

		<ul class="wp-idea-stream-tops">

			<?php 
                foreach ($tops as $top_user) {
                    ?>

				<li>
					<a href="<?php 
                    echo esc_url(wp_idea_stream_users_get_user_profile_url($top_user->post_author, $top_user->user_nicename));
                    ?>
" title="<?php 
                    echo esc_attr($top_user->user_nicename);
                    ?>
">
						<span class="avatar">
							<?php 
                    echo get_avatar($top_user->post_author, 40);
                    ?>
						</span>
						<span class="title">
							<?php 
                    echo esc_html($top_user->user_nicename);
                    ?>
						</span>
						<span class="count">
							(<?php 
                    echo esc_html($top_user->count_ideas);
                    ?>
)
						</span>
					</a>
				</li>

		<?php 
                }
                ?>

		</ul>
		<?php 
            }
            echo $args['after_widget'];
        }