コード例 #1
0
					<span class='bbp-user-replies-created-link'>
						<a href="<?php 
bbp_user_replies_created_url();
?>
" title="<?php 
printf(esc_attr__("%s's Replies Created", 'bbpress'), bbp_get_displayed_user_field('display_name'));
?>
"><?php 
_e('Replies Created', 'bbpress');
?>
</a>
					</span>
				</li>

				<?php 
if (bbp_is_favorites_active()) {
    ?>
					<li class="<?php 
    if (bbp_is_favorites()) {
        ?>
current<?php 
    }
    ?>
">
						<span class="bbp-user-favorites-link">
							<a href="<?php 
    bbp_favorites_permalink();
    ?>
" title="<?php 
    printf(esc_attr__("%s's Favorites", 'bbpress'), bbp_get_displayed_user_field('display_name'));
    ?>
コード例 #2
0
/**
 * User favorites link
 *
 * Return the link to make a topic favorite/remove a topic from
 * favorites
 *
 * @since bbPress (r2652)
 *
 * @param mixed $args This function supports these arguments:
 *  - subscribe: Favorite text
 *  - unsubscribe: Unfavorite text
 *  - user_id: User id
 *  - topic_id: Topic id
 *  - before: Before the link
 *  - after: After the link
 * @param int $user_id Optional. User id
 * @param int $topic_id Optional. Topic id
 * @param bool $wrap Optional. If you want to wrap the link in <span id="favorite-toggle">. See ajax_favorite()
 * @uses bbp_get_user_id() To get the user id
 * @uses current_user_can() If the current user can edit the user
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_is_user_favorite() To check if the topic is user's favorite
 * @uses bbp_get_favorites_permalink() To get the favorites permalink
 * @uses bbp_get_topic_permalink() To get the topic permalink
 * @uses bbp_is_favorites() Is it the favorites page?
 * @uses apply_filters() Calls 'bbp_get_user_favorites_link' with the
 *                        html, add args, remove args, user & topic id
 * @return string User favorites link
 */
function stachestack_bbp_get_user_favorites_link($args = '', $user_id = 0, $wrap = true)
{
    if (!bbp_is_favorites_active()) {
        return false;
    }
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('favorite' => __('Favorite', 'bbpress'), 'favorited' => __('Favorited', 'bbpress'), 'user_id' => 0, 'topic_id' => 0, 'before' => '', 'after' => ''), 'get_user_favorites_link');
    // Validate user and topic ID's
    $user_id = bbp_get_user_id($r['user_id'], true, true);
    $topic_id = bbp_get_topic_id($r['topic_id']);
    if (empty($user_id) || empty($topic_id)) {
        return false;
    }
    // No link if you can't edit yourself
    if (!current_user_can('edit_user', (int) $user_id)) {
        return false;
    }
    // Decide which link to show
    $is_fav = bbp_is_user_favorite($user_id, $topic_id);
    if (!empty($is_fav)) {
        $text = $r['favorited'];
        $query_args = array('action' => 'bbp_favorite_remove', 'topic_id' => $topic_id);
    } else {
        $text = $r['favorite'];
        $query_args = array('action' => 'bbp_favorite_add', 'topic_id' => $topic_id);
    }
    // Create the link based where the user is and if the topic is
    // already the user's favorite
    if (bbp_is_favorites()) {
        $permalink = bbp_get_favorites_permalink($user_id);
    } elseif (bbp_is_single_topic() || bbp_is_single_reply()) {
        $permalink = bbp_get_topic_permalink($topic_id);
    } else {
        $permalink = get_permalink();
    }
    $url = esc_url(wp_nonce_url(add_query_arg($query_args, $permalink), 'toggle-favorite_' . $topic_id));
    $sub = $is_fav ? ' class="is-favorite"' : '';
    $html = sprintf('%s<span id="favorite-%d"  %s><a href="%s" class="btn btn-success btn-xs favorite-toggle" data-topic="%d">%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, $text, $r['after']);
    // Initial output is wrapped in a span, ajax output is hooked to this
    if (!empty($wrap)) {
        $html = '<span id="favorite-toggle">' . $html . '</span>';
    }
    // Return the link
    return apply_filters('bbp_get_user_favorites_link', $html, $r, $user_id, $topic_id);
}
コード例 #3
0
ファイル: functions.php プロジェクト: besimhu/legacy
 /**
  * Load localizations for topic script.
  *
  * These localizations require information that may not be loaded even by init.
  *
  * @since bbPress (r2652)
  *
  * @uses bbp_is_single_topic() To check if it's the topic page
  * @uses bbp_get_current_user_id() To get the current user id
  * @uses bbp_get_topic_id() To get the topic id
  * @uses bbp_get_favorites_permalink() To get the favorites permalink
  * @uses bbp_is_user_favorite() To check if the topic is in user's favorites
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
  * @uses bbp_is_user_subscribed() To check if the user is subscribed to topic
  * @uses bbp_get_topic_permalink() To get the topic permalink
  * @uses wp_localize_script() To localize the script
 */
 function bbp_skeleton_topic_script_localization()
 {
     if (!bbp_is_single_topic()) {
         return;
     }
     $user_id = bbp_get_current_user_id();
     $localizations = array('currentUserId' => $user_id, 'topicId' => bbp_get_topic_id());
     // Favorites
     if (bbp_is_favorites_active()) {
         $localizations['favoritesActive'] = 1;
         $localizations['favoritesLink'] = bbp_get_favorites_permalink($user_id);
         $localizations['isFav'] = (int) bbp_is_user_favorite($user_id);
         $localizations['favLinkYes'] = __('favorites', 'bbpress');
         $localizations['favLinkNo'] = __('?', 'bbpress');
         $localizations['favYes'] = __('This topic is one of your %favLinkYes% [%favDel%]', 'bbpress');
         $localizations['favNo'] = __('%favAdd% (%favLinkNo%)', 'bbpress');
         $localizations['favDel'] = __('&times;', 'bbpress');
         $localizations['favAdd'] = __('Add this topic to your favorites', 'bbpress');
     } else {
         $localizations['favoritesActive'] = 0;
     }
     // Subscriptions
     if (bbp_is_subscriptions_active()) {
         $localizations['subsActive'] = 1;
         $localizations['isSubscribed'] = (int) bbp_is_user_subscribed($user_id);
         $localizations['subsSub'] = __('Subscribe', 'bbpress');
         $localizations['subsUns'] = __('Unsubscribe', 'bbpress');
         $localizations['subsLink'] = bbp_get_topic_permalink();
     } else {
         $localizations['subsActive'] = 0;
     }
     wp_localize_script('bbp_topic', 'bbpTopicJS', $localizations);
 }
コード例 #4
0
ファイル: functions.php プロジェクト: hscale/webento
/**
 * Handles the front end adding and removing of favorite topics
 *
 * @uses bbp_get_user_id() To get the user id
 * @uses bbp_verify_nonce_request() To verify the nonce and check the request
 * @uses current_user_can() To check if the current user can edit the user
 * @uses bbPress:errors:add() To log the error messages
 * @uses bbp_is_user_favorite() To check if the topic is in user's favorites
 * @uses bbp_remove_user_favorite() To remove the user favorite
 * @uses bbp_add_user_favorite() To add the user favorite
 * @uses do_action() Calls 'bbp_favorites_handler' with success, user id, topic
 *                    id and action
 * @uses bbp_is_favorites() To check if it's the favorites page
 * @uses bbp_get_favorites_link() To get the favorites page link
 * @uses bbp_get_topic_permalink() To get the topic permalink
 * @uses wp_safe_redirect() To redirect to the url
 */
function bbp_favorites_handler()
{
    if (!bbp_is_favorites_active()) {
        return false;
    }
    // Bail if not a GET action
    if ('GET' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if required GET actions aren't passed
    if (empty($_GET['topic_id']) || empty($_GET['action'])) {
        return;
    }
    // Setup possible get actions
    $possible_actions = array('bbp_favorite_add', 'bbp_favorite_remove');
    // Bail if actions aren't meant for this function
    if (!in_array($_GET['action'], $possible_actions)) {
        return;
    }
    // What action is taking place?
    $action = $_GET['action'];
    $topic_id = intval($_GET['topic_id']);
    $user_id = bbp_get_user_id(0, true, true);
    // Check for empty topic
    if (empty($topic_id)) {
        bbp_add_error('bbp_favorite_topic_id', __('<strong>ERROR</strong>: No topic was found! Which topic are you marking/unmarking as favorite?', 'bbpress'));
        // Check nonce
    } elseif (!bbp_verify_nonce_request('toggle-favorite_' . $topic_id)) {
        bbp_add_error('bbp_favorite_nonce', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress'));
        // Check current user's ability to edit the user
    } elseif (!current_user_can('edit_user', $user_id)) {
        bbp_add_error('bbp_favorite_permissions', __('<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress'));
    }
    // Bail if errors
    if (bbp_has_errors()) {
        return;
    }
    /** No errors *************************************************************/
    $is_favorite = bbp_is_user_favorite($user_id, $topic_id);
    $success = false;
    if (true == $is_favorite && 'bbp_favorite_remove' == $action) {
        $success = bbp_remove_user_favorite($user_id, $topic_id);
    } elseif (false == $is_favorite && 'bbp_favorite_add' == $action) {
        $success = bbp_add_user_favorite($user_id, $topic_id);
    }
    // Do additional favorites actions
    do_action('bbp_favorites_handler', $success, $user_id, $topic_id, $action);
    // Success!
    if (true == $success) {
        // Redirect back from whence we came
        if (bbp_is_favorites()) {
            $redirect = bbp_get_favorites_permalink($user_id);
        } elseif (bbp_is_single_user()) {
            $redirect = bbp_get_user_profile_url();
        } elseif (is_singular(bbp_get_topic_post_type())) {
            $redirect = bbp_get_topic_permalink($topic_id);
        } elseif (is_single() || is_page()) {
            $redirect = get_permalink();
        }
        wp_safe_redirect($redirect);
        // For good measure
        exit;
        // Fail! Handle errors
    } elseif (true == $is_favorite && 'bbp_favorite_remove' == $action) {
        bbp_add_error('bbp_favorite_remove', __('<strong>ERROR</strong>: There was a problem removing that topic from favorites!', 'bbpress'));
    } elseif (false == $is_favorite && 'bbp_favorite_add' == $action) {
        bbp_add_error('bbp_favorite_add', __('<strong>ERROR</strong>: There was a problem favoriting that topic!', 'bbpress'));
    }
}
    /**
     * Displays the output, the login form
     *
     * @since bbPress (r2827)
     *
     * @param mixed $args Arguments
     * @param array $instance Instance
     * @uses apply_filters() Calls 'bbp_login_widget_title' with the title
     * @uses get_template_part() To get the login/logged in form
     */
    public function widget($args = array(), $instance = array())
    {
        // Get widget settings
        $settings = $this->parse_settings($instance);
        // Typical WordPress filter
        $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base);
        // bbPress filters
        $settings['title'] = apply_filters('bbp_login_widget_title', $settings['title'], $instance, $this->id_base);
        $settings['register'] = apply_filters('bbp_login_widget_register', $settings['register'], $instance, $this->id_base);
        $settings['lostpass'] = apply_filters('bbp_login_widget_lostpass', $settings['lostpass'], $instance, $this->id_base);
        echo $args['before_widget'];
        if (!empty($settings['title'])) {
            echo $args['before_title'] . $settings['title'] . $args['after_title'];
        }
        if (!is_user_logged_in()) {
            ?>
			<form method="post" action="<?php 
            bbp_wp_login_action(array('context' => 'login_post'));
            ?>
" class="bbp-login-form">
				<fieldset>
					<legend><?php 
            _e('Log In', 'bbpress');
            ?>
</legend>

					<div class="bbp-username form-group">
						<label for="user_login" class="sr-only"><?php 
            _e('Username', 'bbpress');
            ?>
: </label>
						<div class="input-group">
							<span class="input-group-addon">
								<span class="glyphicon ipt-icomoon-user"></span>
							</span>
							<input placeholder="<?php 
            _e('Username', 'bbpress');
            ?>
" class="form-control" type="text" name="log" value="<?php 
            bbp_sanitize_val('user_login', 'text');
            ?>
" size="20" id="user_login" tabindex="<?php 
            bbp_tab_index();
            ?>
" />
						</div>
					</div>

					<div class="bbp-password form-group">
						<label for="user_pass" class="sr-only"><?php 
            _e('Password', 'bbpress');
            ?>
: </label>
						<div class="input-group">
							<span class="input-group-addon">
								<span class="glyphicon ipt-icomoon-console"></span>
							</span>
							<input placeholder="<?php 
            _e('Password', 'bbpress');
            ?>
" class="form-control" type="password" name="pwd" value="<?php 
            bbp_sanitize_val('user_pass', 'password');
            ?>
" size="20" id="user_pass" tabindex="<?php 
            bbp_tab_index();
            ?>
" />
						</div>
					</div>

					<?php 
            do_action('login_form');
            ?>

					<div class="bbp-remember-me checkbox">
						<input type="checkbox" name="rememberme" value="forever" <?php 
            checked(bbp_get_sanitize_val('rememberme', 'checkbox'), true, true);
            ?>
 id="rememberme" tabindex="<?php 
            bbp_tab_index();
            ?>
" />
						<label for="rememberme"><?php 
            _e('Remember Me', 'bbpress');
            ?>
</label>
					</div>

					<div class="bbp-submit-wrapper btn-group">
						<?php 
            if (!empty($settings['lostpass'])) {
                ?>
							<a href="<?php 
                echo esc_url($settings['lostpass']);
                ?>
" title="<?php 
                esc_attr_e('Lost Password', 'bbpress');
                ?>
" class="bbp-lostpass-link btn btn-default"><span class="glyphicon ipt-icomoon-info"></span></a>
						<?php 
            }
            ?>
						<?php 
            if (!empty($settings['register'])) {
                ?>
							<a href="<?php 
                echo esc_url($settings['register']);
                ?>
" title="<?php 
                esc_attr_e('Register', 'bbpress');
                ?>
" class="bbp-register-link btn btn-default"><span class="glyphicon ipt-icomoon-signup"></span> <?php 
                _e('Register', 'bbpress');
                ?>
</a>
						<?php 
            }
            ?>
						<button class="btn btn-primary" type="submit" name="user-submit" id="user-submit" tabindex="<?php 
            bbp_tab_index();
            ?>
" class="button submit user-submit"><span class="glyphicon ipt-icomoon-switch"></span> <?php 
            _e('Log In', 'bbpress');
            ?>
</button>
					</div>
					<?php 
            bbp_user_login_fields();
            ?>
				</fieldset>
			</form>

		<?php 
        } else {
            ?>

			<div class="bbp-logged-in">
				<a href="<?php 
            bbp_user_profile_url(bbp_get_current_user_id());
            ?>
" class="submit user-submit thumbnail pull-left"><?php 
            echo get_avatar(bbp_get_current_user_id(), '64');
            ?>
</a>
				<h4><?php 
            bbp_user_profile_link(bbp_get_current_user_id());
            ?>
</h4>
				<div class="btn-group">
					<a class="btn btn-default btn-sm" href="<?php 
            bbp_user_profile_edit_url(bbp_get_current_user_id());
            ?>
" title="<?php 
            printf(esc_attr__("Edit Your Profile", 'ipt_kb'));
            ?>
"><span class="glyphicon glyphicon-edit"></span> <?php 
            _e('Edit', 'bbpress');
            ?>
</a>
					<?php 
            bbp_logout_link();
            ?>
				</div>

				<div class="clearfix"></div>

				<div class="list-group">
					<a href="<?php 
            bbp_user_profile_url(bbp_get_current_user_id());
            ?>
" class="list-group-item bbp-user-forum-role <?php 
            if (bbp_is_user_home() && bbp_is_single_user_profile()) {
                echo 'active';
            }
            ?>
">
						<span class="glyphicon ipt-icomoon-user4"></span> <?php 
            printf(__('%s Forum Role', 'ipt_kb'), '<span class="badge">' . bbp_get_user_display_role(bbp_get_current_user_id()) . '</span>');
            ?>
					</a>
					<a href="<?php 
            bbp_user_topics_created_url(bbp_get_current_user_id());
            ?>
" class="list-group-item bbp-user-topic-count <?php 
            if (bbp_is_user_home() && bbp_is_single_user_topics()) {
                echo 'active';
            }
            ?>
">
						<span class="glyphicon ipt-icomoon-bubbles4"></span> <?php 
            printf(__('%s Topics Started', 'ipt_kb'), '<span class="badge">' . bbp_get_user_topic_count_raw(bbp_get_current_user_id()) . '</span>');
            ?>
					</a>
					<a href="<?php 
            bbp_user_replies_created_url(bbp_get_current_user_id());
            ?>
" class="list-group-item bbp-user-reply-count <?php 
            if (bbp_is_user_home() && bbp_is_single_user_replies()) {
                echo 'active';
            }
            ?>
">
						<span class="glyphicon ipt-icomoon-reply"></span> <?php 
            printf(__('%s Replies Created', 'ipt_kb'), '<span class="badge">' . bbp_get_user_reply_count_raw(bbp_get_current_user_id()) . '</span>');
            ?>
					</a>
					<?php 
            if (bbp_is_favorites_active()) {
                ?>
					<a href="<?php 
                bbp_favorites_permalink(bbp_get_current_user_id());
                ?>
" class="list-group-item bbp-user-favorite-count <?php 
                if (bbp_is_user_home() && bbp_is_favorites()) {
                    echo 'active';
                }
                ?>
" title="<?php 
                printf(esc_attr__("Your Favorites", 'ipt_kb'));
                ?>
">
						<span class="glyphicon ipt-icomoon-heart"></span> <?php 
                printf(__('%s Favorites', 'ipt_kb'), '<span class="badge">' . count(bbp_get_user_favorites_topic_ids(bbp_get_current_user_id())) . '</span>');
                ?>
					</a>
					<?php 
            }
            ?>
					<?php 
            if (bbp_is_subscriptions_active()) {
                ?>
					<a href="<?php 
                bbp_subscriptions_permalink(bbp_get_current_user_id());
                ?>
" class="list-group-item bbp-user-subscribe-count <?php 
                if (bbp_is_user_home() && bbp_is_subscriptions()) {
                    echo 'active';
                }
                ?>
" title="<?php 
                printf(esc_attr__("Your Subscriptions", 'ipt_kb'));
                ?>
">
						<span class="glyphicon ipt-icomoon-bookmarks"></span> <?php 
                printf(__('%s Subscriptions', 'ipt_kb'), '<span class="badge">' . count(bbp_get_user_subscribed_topic_ids(bbp_get_current_user_id())) . '</span>');
                ?>
					</a>
					<?php 
            }
            ?>
				</div>
			</div>

		<?php 
        }
        echo $args['after_widget'];
    }
コード例 #6
0
 /**
  * AJAX handler to add or remove a topic from a user's favorites
  *
  * @since bbPress (r3732)
  *
  * @uses bbp_is_favorites_active() To check if favorites are active
  * @uses bbp_is_user_logged_in() To check if user is logged in
  * @uses bbp_get_current_user_id() To get the current user id
  * @uses current_user_can() To check if the current user can edit the user
  * @uses bbp_get_topic() To get the topic
  * @uses wp_verify_nonce() To verify the nonce & check the referer
  * @uses bbp_is_user_favorite() To check if the topic is user's favorite
  * @uses bbp_remove_user_favorite() To remove the topic from user's favorites
  * @uses bbp_add_user_favorite() To add the topic from user's favorites
  * @uses bbp_ajax_response() To return JSON
  */
 public function ajax_favorite()
 {
     // Bail if favorites are not active
     if (!bbp_is_favorites_active()) {
         bbp_ajax_response(false, __('Favorites are no longer active.', 'bbpress'), 300);
     }
     // Bail if user is not logged in
     if (!is_user_logged_in()) {
         bbp_ajax_response(false, __('Please login to make this topic a favorite.', 'bbpress'), 301);
     }
     // Get user and topic data
     $user_id = bbp_get_current_user_id();
     $id = !empty($_POST['id']) ? intval($_POST['id']) : 0;
     // Bail if user cannot add favorites for this user
     if (!current_user_can('edit_user', $user_id)) {
         bbp_ajax_response(false, __('You do not have permission to do this.', 'bbpress'), 302);
     }
     // Get the topic
     $topic = bbp_get_topic($id);
     // Bail if topic cannot be found
     if (empty($topic)) {
         bbp_ajax_response(false, __('The topic could not be found.', 'bbpress'), 303);
     }
     // Bail if user did not take this action
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'toggle-favorite_' . $topic->ID)) {
         bbp_ajax_response(false, __('Are you sure you meant to do that?', 'bbpress'), 304);
     }
     // Take action
     $status = bbp_is_user_favorite($user_id, $topic->ID) ? bbp_remove_user_favorite($user_id, $topic->ID) : bbp_add_user_favorite($user_id, $topic->ID);
     // Bail if action failed
     if (empty($status)) {
         bbp_ajax_response(false, __('The request was unsuccessful. Please try again.', 'bbpress'), 305);
     }
     // Put subscription attributes in convenient array
     $attrs = array('topic_id' => $topic->ID, 'user_id' => $user_id);
     // Action succeeded
     bbp_ajax_response(true, bbp_get_user_favorites_link($attrs, $user_id, false), 200);
 }
コード例 #7
0
ファイル: settings.php プロジェクト: joeyblake/bbpress
/**
 * Allow favorites setting field
 *
 * @since 2.0.0 bbPress (r2786)
 *
 * @uses checked() To display the checked attribute
 */
function bbp_admin_setting_callback_favorites()
{
    ?>

	<input name="_bbp_enable_favorites" id="_bbp_enable_favorites" type="checkbox" value="1" <?php 
    checked(bbp_is_favorites_active(true));
    bbp_maybe_admin_setting_disabled('_bbp_enable_favorites');
    ?>
 />
	<label for="_bbp_enable_favorites"><?php 
    esc_html_e('Allow users to mark topics as favorites', 'bbpress');
    ?>
</label>

<?php 
}
コード例 #8
0
ファイル: bbp-user-template.php プロジェクト: rmccue/bbPress
/**
 * User favorites link
 *
 * Return the link to make a topic favorite/remove a topic from
 * favorites
 *
 * @since bbPress (r2652)
 *
 * @param array $add Optional. Add to favorites args
 * @param array $rem Optional. Remove from favorites args
 * @param int $user_id Optional. User id
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_user_id() To get the user id
 * @uses current_user_can() If the current user can edit the user
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_is_user_favorite() To check if the topic is user's favorite
 * @uses bbp_get_favorites_permalink() To get the favorites permalink
 * @uses bbp_get_topic_permalink() To get the topic permalink
 * @uses bbp_is_favorites() Is it the favorites page?
 * @uses apply_filters() Calls 'bbp_get_user_favorites_link' with the
 *                        html, add args, remove args, user & topic id
 * @return string User favorites link
 */
function bbp_get_user_favorites_link($add = array(), $rem = array(), $user_id = 0, $topic_id = 0)
{
    if (!bbp_is_favorites_active()) {
        return false;
    }
    // Validate user and topic ID's
    $user_id = bbp_get_user_id($user_id, true, true);
    $topic_id = bbp_get_topic_id($topic_id);
    if (empty($user_id) || empty($topic_id)) {
        return false;
    }
    if (!current_user_can('edit_user', (int) $user_id)) {
        return false;
    }
    if (empty($add) || !is_array($add)) {
        $add = array('mid' => __('Add this topic to your favorites', 'bbpress'), 'post' => __(' (%?%)', 'bbpress'));
    }
    if (empty($rem) || !is_array($rem)) {
        $rem = array('pre' => __('This topic is one of your %favorites% [', 'bbpress'), 'mid' => __('&times;', 'bbpress'), 'post' => __(']', 'bbpress'));
    }
    $is_fav = bbp_is_user_favorite($user_id, $topic_id);
    if (!empty($is_fav)) {
        $url = esc_url(bbp_get_favorites_permalink($user_id));
        $rem = preg_replace('|%(.+)%|', "<a href='{$url}'>\$1</a>", $rem);
        $favs = array('action' => 'bbp_favorite_remove', 'topic_id' => $topic_id);
        $pre = is_array($rem) && isset($rem['pre']) ? $rem['pre'] : '';
        $mid = is_array($rem) && isset($rem['mid']) ? $rem['mid'] : (is_string($rem) ? $rem : '');
        $_post = is_array($rem) && isset($rem['post']) ? $rem['post'] : '';
    } else {
        $url = esc_url(bbp_get_favorites_permalink($user_id));
        $add = preg_replace('|%(.+)%|', "<a href='{$url}'>\$1</a>", $add);
        $favs = array('action' => 'bbp_favorite_add', 'topic_id' => $topic_id);
        $pre = is_array($add) && isset($add['pre']) ? $add['pre'] : '';
        $mid = is_array($add) && isset($add['mid']) ? $add['mid'] : (is_string($add) ? $add : '');
        $_post = is_array($add) && isset($add['post']) ? $add['post'] : '';
    }
    // Create the link based where the user is and if the topic is
    // already the user's favorite
    if (bbp_is_favorites()) {
        $permalink = bbp_get_favorites_permalink($user_id);
    } elseif (is_singular(bbp_get_topic_post_type())) {
        $permalink = bbp_get_topic_permalink($topic_id);
    } elseif (is_singular(bbp_get_reply_post_type())) {
        $permalink = bbp_get_topic_permalink($topic_id);
    } elseif (bbp_is_query_name('bbp_single_topic')) {
        $permalink = get_permalink();
    }
    $url = esc_url(wp_nonce_url(add_query_arg($favs, $permalink), 'toggle-favorite_' . $topic_id));
    $is_fav = $is_fav ? 'is-favorite' : '';
    $html = '<span id="favorite-toggle"><span id="favorite-' . $topic_id . '" class="' . $is_fav . '">' . $pre . '<a href="' . $url . '" class="dim:favorite-toggle:favorite-' . $topic_id . ':is-favorite">' . $mid . '</a>' . $_post . '</span></span>';
    // Return the link
    return apply_filters('bbp_get_user_favorites_link', $html, $add, $rem, $user_id, $topic_id);
}
コード例 #9
0
ファイル: core.php プロジェクト: luskyj89/mt-wordpress
 function cb_bbp_author_details($cb_author_id, $cb_desc = true)
 {
     $cb_author_email = get_the_author_meta('publicemail', $cb_author_id);
     $cb_author_name = get_the_author_meta('display_name', $cb_author_id);
     $cb_author_position = get_the_author_meta('position', $cb_author_id);
     $cb_author_tw = get_the_author_meta('twitter', $cb_author_id);
     $cb_author_go = get_the_author_meta('googleplus', $cb_author_id);
     $cb_author_www = get_the_author_meta('url', $cb_author_id);
     $cb_author_desc = get_the_author_meta('description', $cb_author_id);
     $cb_author_posts = count_user_posts($cb_author_id);
     $cb_author_output = NULL;
     $cb_author_output .= '<div class="cb-author-details cb-bbp clearfix"><div class="cb-mask"><a href="' . bbp_get_user_profile_url() . '" title="' . bbp_get_displayed_user_field('display_name') . '" rel="me">' . get_avatar(bbp_get_displayed_user_field('user_email', 'raw'), apply_filters('bbp_single_user_details_avatar_size', 150)) . '</a></div><div class="cb-meta"><h3><a href="' . bbp_get_user_profile_url() . '" title="' . bbp_get_displayed_user_field('display_name') . '">' . $cb_author_name . '</a></h3>';
     if ($cb_author_position != NULL) {
         $cb_author_output .= '<div class="cb-author-position">' . $cb_author_position . '</div>';
     }
     if ($cb_author_desc != NULL && $cb_desc == true) {
         $cb_author_output .= '<p class="cb-author-bio">' . $cb_author_desc . '</p>';
     }
     if ($cb_author_email != NULL || $cb_author_www != NULL || $cb_author_tw != NULL || $cb_author_go != NULL) {
         $cb_author_output .= '<div class="cb-author-page-contact">';
     }
     if ($cb_author_email != NULL) {
         $cb_author_output .= '<a href="mailto:' . $cb_author_email . '"><i class="icon-envelope-alt cb-tip-bot" title="' . __('Email', 'cubell') . '"></i></a>';
     }
     if ($cb_author_www != NULL) {
         $cb_author_output .= ' <a href="' . $cb_author_www . '" target="_blank"><i class="icon-link cb-tip-bot" title="' . __('Website', 'cubell') . '"></i></a> ';
     }
     if ($cb_author_tw != NULL) {
         $cb_author_output .= ' <a href="//www.twitter.com/' . $cb_author_tw . '" target="_blank" ><i class="icon-twitter cb-tip-bot" title="Twitter"></i></a>';
     }
     if ($cb_author_go != NULL) {
         $cb_author_output .= ' <a href="' . $cb_author_go . '" rel="publisher" target="_top" title="Google+" class="cb-googleplus cb-tip-bot" ><img src="//ssl.gstatic.com/images/icons/gplus-32.png"  data-src-retina="//ssl.gstatic.com/images/icons/gplus-64.png" alt="Google+" ></a>';
     }
     if ($cb_author_email != NULL || $cb_author_www != NULL || $cb_author_go != NULL || $cb_author_tw != NULL) {
         $cb_author_output .= '</div>';
     }
     $cb_author_output .= '<div id="cb-user-nav"><ul>';
     if (bbp_is_single_user_replies()) {
         $cb_user_current = 'current';
     }
     $cb_author_output .= '<li class="';
     if (bbp_is_single_user_topics()) {
         $cb_author_output .= 'current';
     }
     $cb_author_output .= '"><span class="bbp-user-topics-created-link"><a href="' . bbp_get_user_topics_created_url() . '">' . __('Topics Started', 'bbpress') . '</a></span></li>';
     $cb_author_output .= '<li class="';
     if (bbp_is_single_user_replies()) {
         $cb_author_output .= 'current';
     }
     $cb_author_output .= '"><span class="bbp-user-replies-created-link"><a href="' . bbp_get_user_replies_created_url() . '">' . __('Replies Created', 'bbpress') . '</a></span></li>';
     if (bbp_is_favorites_active()) {
         $cb_author_output .= '<li class="';
         if (bbp_is_favorites()) {
             $cb_author_output .= 'current';
         }
         $cb_author_output .= '"><span class="bbp-user-favorites-link"><a href="' . bbp_get_favorites_permalink() . '">' . __('Favorites', 'bbpress') . '</a></span></li>';
     }
     if (bbp_is_user_home() || current_user_can('edit_users')) {
         if (bbp_is_subscriptions_active()) {
             $cb_author_output .= '<li class="';
             if (bbp_is_subscriptions()) {
                 $cb_author_output .= 'current';
             }
             $cb_author_output .= '"><span class="bbp-user-subscriptions-link"><a href="' . bbp_get_subscriptions_permalink() . '">' . __('Subscriptions', 'bbpress') . '</a></span></li>';
         }
         $cb_author_output .= '<li class="';
         if (bbp_is_single_user_edit()) {
             $cb_author_output .= 'current';
         }
         $cb_author_output .= '"><span class="bbp-user-edit-link"><a href="' . bbp_get_user_profile_edit_url() . '">' . __('Edit', 'bbpress') . '</a></span></li>';
     }
     $cb_author_output .= '</ul></div><!-- #cb-user-nav -->';
     $cb_author_output .= '</div></div>';
     return $cb_author_output;
 }
コード例 #10
0
ファイル: loader.php プロジェクト: joeyblake/bbpress
 /**
  * Setup BuddyBar navigation
  *
  * @since 2.1.0 bbPress (r3552)
  */
 public function setup_nav($main_nav = array(), $sub_nav = array())
 {
     // Stop if there is no user displayed or logged in
     if (!is_user_logged_in() && !bp_displayed_user_id()) {
         return;
     }
     // Define local variable(s)
     $user_domain = '';
     // Add 'Forums' to the main navigation
     $main_nav = array('name' => __('Forums', 'bbpress'), 'slug' => $this->slug, 'position' => 80, 'screen_function' => 'bbp_member_forums_screen_topics', 'default_subnav_slug' => bbp_get_topic_archive_slug(), 'item_css_id' => $this->id);
     // Determine user to use
     if (bp_displayed_user_id()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         return;
     }
     // User link
     $forums_link = trailingslashit($user_domain . $this->slug);
     // Topics started
     $sub_nav[] = array('name' => __('Topics Started', 'bbpress'), 'slug' => bbp_get_topic_archive_slug(), 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bbp_member_forums_screen_topics', 'position' => 20, 'item_css_id' => 'topics');
     // Replies to topics
     $sub_nav[] = array('name' => __('Replies Created', 'bbpress'), 'slug' => bbp_get_reply_archive_slug(), 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bbp_member_forums_screen_replies', 'position' => 40, 'item_css_id' => 'replies');
     // Favorite topics
     if (bbp_is_favorites_active()) {
         $sub_nav[] = array('name' => __('Favorites', 'bbpress'), 'slug' => bbp_get_user_favorites_slug(), 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bbp_member_forums_screen_favorites', 'position' => 60, 'item_css_id' => 'favorites');
     }
     // Subscribed topics (my profile only)
     if (bp_is_my_profile() && bbp_is_subscriptions_active()) {
         $sub_nav[] = array('name' => __('Subscriptions', 'bbpress'), 'slug' => bbp_get_user_subscriptions_slug(), 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bbp_member_forums_screen_subscriptions', 'position' => 60, 'item_css_id' => 'subscriptions');
     }
     parent::setup_nav($main_nav, $sub_nav);
 }
コード例 #11
0
    public static function roost_bbp_topic_subscription( $post ) {
        global $post;
        $post_id = $post->ID;

        $url = bbp_get_topic_permalink( $post_id );

        $roost_bbp_subscriptions = get_post_meta( $post_id, '_roost_bbp_subscription', true );

        echo( sprintf( "<span id='roost-subscribe-%d' style='display:none;'><a href='%s' data-post='%d' class='roost-topic-subscribe-link'></a></span>", $post_id, $url, $post_id ) );
        ?>
        <script>
            jQuery(document).ready(function($) {
                var subscribeLink = $('.roost-topic-subscribe-link');
                var subscribeWrap = $('#roost-subscribe-<?php echo( $post_id ); ?>');
                <?php
                    if ( ! empty( $roost_bbp_subscriptions ) ) {
                        $reply_bbp_subscriptions = json_encode( $roost_bbp_subscriptions );
                ?>
                        var registrations = <?php echo( $reply_bbp_subscriptions ); ?>;
                <?php
                    } else {
                ?>
                        var registrations = [];
                <?php
                    }
                ?>

                setTimeout(function(){
                    if ( window.roostEnabled ){
                        if ( 'undefined' !== typeof registrations[window.roostToken] ) {
                            if ( true === registrations[window.roostToken] ) {
                                subscribeLink.text( 'Unsubscribe from Push Notifications' );
                                subscribeLink.data( 'action', 'roost_bbp_unsubscribe' );
                            }
                        } else {
                            subscribeLink.text( 'Subscribe with Push Notifications' );
                            subscribeLink.data( 'action', 'roost_bbp_subscribe' );
                        }
                        <?php
                            if ( true === bbp_is_subscriptions_active() && true === is_user_logged_in() ) {
                        ?>
                            subscribeWrap.detach().appendTo( '#subscription-toggle' ).show();
                            subscribeWrap.prepend( ' | ' );
                        <?php
                            } else if ( true === bbp_is_favorites_active() && true === is_user_logged_in() ) {
                        ?>
                            subscribeWrap.detach();
                            subscribeWrap.appendTo( '.bbp-header .bbp-reply-content' ).append( ' | ' ).wrap( "<div id='subscription-toggle'></div>" ).show();
                        <?php
                            } else {
                        ?>
                            subscribeWrap.detach();
                            subscribeWrap.appendTo( '.bbp-header .bbp-reply-content' ).wrap( "<div id='subscription-toggle'></div>" ).show();
                        <?php
                            }
                        ?>
                    }
                }, 1500);

                subscribeLink.on( 'click', function( e ){
                    e.preventDefault();
                    var data = {
                        link: subscribeLink.attr('href'),
                        action: subscribeLink.data('action'),
                        roostToken: window.roostToken,
                        postID: subscribeLink.data('post'),
                    };
                    if ( 'roost_bbp_subscribe' === subscribeLink.data( 'action' ) ){
                        subscribeLink.text( 'Unsubscribe from Push Notifications' );
                        subscribeLink.data( 'action', 'roost_bbp_unsubscribe' );
                    } else {
                        subscribeLink.text( 'Subscribe with Push Notifications' );
                        subscribeLink.data( 'action', 'roost_bbp_subscribe' );
                    }

                    $.post( ajaxurl, data, function( response ) {

                    });
                });
            });
        </script>
        <?php
    }
コード例 #12
0
ファイル: members.php プロジェクト: danielcoats/schoolpress
 /**
  * Set favorites and subscriptions query variables if viewing member profile
  * pages.
  *
  * @since bbPress (r4615)
  *
  * @global WP_Query $wp_query
  * @return If not viewing your own profile
  */
 public function set_member_forum_query_vars()
 {
     // Special handling for forum component
     if (!bp_is_my_profile()) {
         return;
     }
     global $wp_query;
     // 'favorites' action
     if (bbp_is_favorites_active() && bp_is_current_action(bbp_get_user_favorites_slug())) {
         $wp_query->bbp_is_single_user_favs = true;
         // 'subscriptions' action
     } elseif (bbp_is_subscriptions_active() && bp_is_current_action(bbp_get_user_subscriptions_slug())) {
         $wp_query->bbp_is_single_user_subs = true;
     }
 }
コード例 #13
0
 /**
  * Override bbPress profile URL with BuddyPress profile URL
  *
  * @since bbPress (r3401)
  * @param string $url
  * @param int $user_id
  * @param string $user_nicename
  * @return string
  */
 public function user_profile_url($user_id)
 {
     // Define local variable(s)
     $profile_url = '';
     // Special handling for forum component
     if (bp_is_current_component('forums')) {
         // Empty action or 'topics' action
         if (!bp_current_action() || bp_is_current_action('topics')) {
             $profile_url = bp_core_get_user_domain($user_id) . 'forums/topics';
             // Empty action or 'topics' action
         } elseif (bp_is_current_action('replies')) {
             $profile_url = bp_core_get_user_domain($user_id) . 'forums/replies';
             // 'favorites' action
         } elseif (bbp_is_favorites_active() && bp_is_current_action('favorites')) {
             $profile_url = $this->get_favorites_permalink('', $user_id);
             // 'subscriptions' action
         } elseif (bbp_is_subscriptions_active() && bp_is_current_action('subscriptions')) {
             $profile_url = $this->get_subscriptions_permalink('', $user_id);
         }
         // Not in users' forums area
     } else {
         $profile_url = bp_core_get_user_domain($user_id);
     }
     return trailingslashit($profile_url);
 }