Esempio n. 1
2
function wp_ulike_prize_user($user_id, $user_score, $level)
{
    $user_ids = [$user_id];
    // Проверяем пользователя по чёрному списку
    $mail_ids = apply_filters('wp_ulike_mailing_ids', $user_ids);
    if (!in_array($user_id, $mail_ids)) {
        // Пользователь в чёрном списке?
        return;
    }
    // Оставляем только белый список
    $mail_ids = array_diff($mail_ids, $user_ids);
    $site_url = get_bloginfo('url');
    $site_name = get_bloginfo('name');
    $site_desc = get_bloginfo('description');
    // Если уровень больше 3 используем настройки уровня 3
    $settings = $level < 4 ? "wp_ulike_mailing_level_{$level}" : "wp_ulike_mailing_level_3";
    $user_id = stripslashes($user_id);
    $user_score = stripslashes($user_score);
    $user_info = get_userdata($user_id);
    if ($user_info) {
        $user_profile = bbp_get_user_profile_url($user_id);
        // url профиля пользователя
        $subject = wp_ulike_get_setting($settings, 'top_user_mail_subject');
        $subject = str_replace(['%user_name%', '%user_id%', '%user_profile%', '%user_score%', '%user_level%', '%site_url%', '%site_name%'], [mb_convert_case(rtrim($user_info->first_name), MB_CASE_TITLE, 'UTF-8'), $user_id, $user_profile, $user_score, $level, $site_url, $site_name], $subject);
        $content = wp_ulike_get_setting($settings, 'top_user_mail_template');
        $content = str_replace(['%user_name%', '%user_id%', '%user_profile%', '%user_score%', '%user_level%', '%site_url%', '%site_name%'], [mb_convert_case(rtrim($user_info->first_name), MB_CASE_TITLE, 'UTF-8'), $user_id, $user_profile, $user_score, $level, $site_url, $site_name], $content);
        $buf = ob_start();
        if ($buf) {
            include plugin_dir_path(__FILE__) . 'mail-template.php';
            // Подключаем шаблон
            $mail_body = ob_get_clean();
            if ($mail_body) {
                $from = wp_ulike_get_setting('wp_ulike_general', 'mail_from');
                if (!$from) {
                    $from = '*****@*****.**';
                }
                $headers = ['Content-Type: text/html; charset=UTF-8', 'From: ' . $from];
                // Отправляем уведомление пользователю
                if (wp_mail($user_info->user_email, $subject, $mail_body, $headers)) {
                    wp_ulike_mark_mailing_done($user_id, $level);
                }
                // Отправляем копии по белому списку
                while (list($i, $id) = each($mail_ids)) {
                    $user_info = get_userdata($id);
                    if ($user_info) {
                        wp_mail($user_info->user_email, $subject, $mail_body, $headers);
                    }
                }
            }
        }
    }
}
Esempio n. 2
0
 /**
  * replace_tags function.
  *
  * @param mixed $text
  */
 public function replace_tags($text)
 {
     if ($this->user) {
         $text = str_replace(array('%username%', '%userid%', '%firstname%', '%lastname%', '%name%'), array(ucwords($this->user->display_name), $this->user->ID, $this->user->first_name, $this->user->last_name, trim($this->user->first_name . ' ' . $this->user->last_name)), $text);
         // Buddypress
         if (function_exists('bp_loggedin_user_domain')) {
             $text = str_replace(array('%buddypress_profile_url%'), array(bp_loggedin_user_domain()), $text);
         }
         // BBpress
         if (function_exists('bbp_get_user_profile_url')) {
             $text = str_replace(array('%bbpress_profile_url%'), array(bbp_get_user_profile_url($this->user->ID)), $text);
         }
     }
     $logout_redirect = wp_logout_url(empty($this->instance['logout_redirect_url']) ? $this->current_url('nologout') : $this->instance['logout_redirect_url']);
     $text = str_replace(array('%admin_url%', '%logout_url%'), array(untrailingslashit(admin_url()), apply_filters('sidebar_login_widget_logout_redirect', $logout_redirect)), $text);
     $text = do_shortcode($text);
     return $text;
 }
Esempio n. 3
0
 $count = 1;
 foreach ($ratings as $rating) {
     $urid = $rating->urid;
     $wp_object = null;
     $excerpt = '';
     $permalink = '';
     if ('users' === $type) {
         $user_id = RatingWidgetPlugin::Urid2UserId($urid);
         $wp_object = get_user_by('id', $user_id);
         if (function_exists('is_buddypress')) {
             $title = trim(strip_tags(bp_core_get_user_displayname($user_id)));
             $permalink = bp_core_get_user_domain($user_id);
         } else {
             if (function_exists('is_bbpress')) {
                 $title = trim(strip_tags(bbp_get_user_display_name($user_id)));
                 $permalink = bbp_get_user_profile_url($user_id);
             } else {
                 $wp_object = null;
             }
         }
         // If valid WP_User object, retrieve the avatar URL
         if ($wp_object) {
             $thumbnail = ratingwidget()->get_user_avatar($user_id);
         }
     } else {
         $post_id = RatingWidgetPlugin::Urid2PostId($urid);
         $wp_object = get_post($post_id);
         $title = get_the_title($post_id);
         $excerpt = ratingwidget()->GetPostExcerpt($wp_object, 15);
         $permalink = get_permalink($post_id);
         $thumbnail = ratingwidget()->GetPostImage($wp_object);
Esempio n. 4
0
/**
 * Return the author url of the topic
 *
 * @since 2.0.0 bbPress (r2590)
 *
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_is_topic_anonymous() To check if the topic is by an anonymous
 *                                 user or not
 * @uses bbp_user_has_profile() To check if the user has a profile
 * @uses bbp_get_topic_author_id() To get topic author id
 * @uses bbp_get_user_profile_url() To get profile url
 * @uses get_post_meta() To get anonmous user's website
 * @uses apply_filters() Calls 'bbp_get_topic_author_url' with the link &
 *                        topic id
 * @return string Author URL of topic
 */
function bbp_get_topic_author_url($topic_id = 0)
{
    $topic_id = bbp_get_topic_id($topic_id);
    // Check for anonymous user or non-existant user
    if (!bbp_is_topic_anonymous($topic_id) && bbp_user_has_profile(bbp_get_topic_author_id($topic_id))) {
        $author_url = bbp_get_user_profile_url(bbp_get_topic_author_id($topic_id));
    } else {
        $author_url = get_post_meta($topic_id, '_bbp_anonymous_website', true);
        // Set empty author_url as empty string
        if (empty($author_url)) {
            $author_url = '';
        }
    }
    return apply_filters('bbp_get_topic_author_url', $author_url, $topic_id);
}
Esempio n. 5
0
/**
 * Redirect if unathorized user is attempting to edit another user
 *
 * This is hooked to 'bbp_template_redirect' and controls the conditions under
 * which a user can edit another user (or themselves.) If these conditions are
 * met. We assume a user cannot perform this task, and look for ways they can
 * earn the ability to access this template.
 * 
 * @since bbPress (r3605)
 *
 * @uses bbp_is_topic_edit()
 * @uses current_user_can()
 * @uses bbp_get_topic_id()
 * @uses wp_safe_redirect()
 * @uses bbp_get_topic_permalink()
 */
function bbp_check_user_edit()
{
    // Bail if not editing a topic
    if (!bbp_is_single_user_edit()) {
        return;
    }
    // Default to false
    $redirect = true;
    // Allow user to edit their own profile
    if (bbp_is_user_home_edit()) {
        $redirect = false;
        // Allow if current user can edit the displayed user
    } elseif (current_user_can('edit_user', bbp_get_displayed_user_id())) {
        $redirect = false;
        // Allow if user can manage network users, or edit-any is enabled
    } elseif (current_user_can('manage_network_users') || apply_filters('enable_edit_any_user_configuration', false)) {
        $redirect = false;
    }
    // Maybe redirect back to profile page
    if (true === $redirect) {
        wp_safe_redirect(bbp_get_user_profile_url(bbp_get_displayed_user_id()));
        exit;
    }
}
Esempio n. 6
0
 protected function _bbpress_items()
 {
     $item = array();
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $item[] = '<span typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '"  property="v:title" rel="v:url"><span>' . bbp_get_forum_archive_title() . '</span></a></span>';
     }
     if (bbp_is_forum_archive()) {
         $item[] = bbp_get_forum_archive_title();
     } elseif (bbp_is_topic_archive()) {
         $item[] = bbp_get_topic_archive_title();
     } elseif (bbp_is_single_view()) {
         $item[] = bbp_get_view_title();
     } elseif (bbp_is_single_topic()) {
         $topic_id = get_queried_object_id();
         $item = array_merge($item, $this->_get_parents(bbp_get_topic_forum_id($topic_id)));
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_topic_permalink($topic_id) . '"  property="v:title" rel="v:url"><span>' . bbp_get_topic_title($topic_id) . '</span></a></span>';
         } else {
             $item[] = bbp_get_topic_title($topic_id);
         }
         if (bbp_is_topic_split()) {
             $item[] = __('Split', DH_DOMAIN);
         } elseif (bbp_is_topic_merge()) {
             $item[] = __('Merge', DH_DOMAIN);
         } elseif (bbp_is_topic_edit()) {
             $item[] = __('Edit', DH_DOMAIN);
         }
     } elseif (bbp_is_single_reply()) {
         $reply_id = get_queried_object_id();
         $item = array_merge($item, $this->_get_parents(bbp_get_reply_topic_id($reply_id)));
         if (!bbp_is_reply_edit()) {
             $item[] = bbp_get_reply_title($reply_id);
         } else {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_reply_url($reply_id) . '"  property="v:title" rel="v:url"><span>' . bbp_get_reply_title($reply_id) . '</span></a></span>';
             $item[] = __('Edit', DH_DOMAIN);
         }
     } elseif (bbp_is_single_forum()) {
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         if (0 !== $forum_parent_id) {
             $item = array_merge($item, $this->_get_parents($forum_parent_id));
         }
         $item[] = bbp_get_forum_title($forum_id);
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_user_profile_url() . '"  property="v:title" rel="v:url" ><span>' . bbp_get_displayed_user_field('display_name') . '</span></a></span>';
             $item[] = __('Edit', DH_DOMAIN);
         } else {
             $item[] = bbp_get_displayed_user_field('display_name');
         }
     }
     return $item;
 }
Esempio n. 7
0
    /**
     * Adds a 'Switch To' link to each member's profile page in bbPress.
     */
    public function action_bbpress_button()
    {
        if (!($user = get_userdata(bbp_get_user_id()))) {
            return;
        }
        if (!($link = self::maybe_switch_url($user))) {
            return;
        }
        $link = add_query_arg(array('redirect_to' => urlencode(bbp_get_user_profile_url($user->ID))), $link);
        ?>
		<ul id="user_switching_switch_to">
			<li><a href="<?php 
        echo esc_url($link);
        ?>
"><?php 
        esc_html_e('Switch&nbsp;To', 'user-switching');
        ?>
</a></li>
		</ul>
		<?php 
    }
Esempio n. 8
0
 function mk_theme_breadcrumbs()
 {
     global $mk_options, $post;
     $post_id = global_get_post_id();
     if ($post_id) {
         $local_skining = get_post_meta($post_id, '_enable_local_backgrounds', true);
         $breadcrumb_skin = get_post_meta($post_id, '_breadcrumb_skin', true);
         if ($local_skining == 'true' && !empty($breadcrumb_skin)) {
             $breadcrumb_skin_class = $breadcrumb_skin;
         } else {
             $breadcrumb_skin_class = $mk_options['breadcrumb_skin'];
         }
     } else {
         $breadcrumb_skin_class = $mk_options['breadcrumb_skin'];
     }
     $delimiter = ' &#47; ';
     echo '<div id="mk-breadcrumbs"><div class="mk-breadcrumbs-inner ' . $breadcrumb_skin_class . '-skin">';
     if (!is_front_page()) {
         echo '<a href="';
         echo home_url();
         echo '">' . __('Home', 'mk_framework');
         echo "</a>" . $delimiter;
     }
     if (function_exists('is_woocommerce') && is_woocommerce() && is_archive()) {
         $shop_page_id = wc_get_page_id('shop');
         $shop_page = get_post($shop_page_id);
         $permalinks = get_option('woocommerce_permalinks');
         if ($shop_page_id && $shop_page && get_option('page_on_front') !== $shop_page_id) {
             echo '<a href="' . get_permalink($shop_page) . '">' . $shop_page->post_title . '</a> ';
         }
     }
     if (is_category() && !is_singular('portfolio')) {
         $category = get_the_category();
         $ID = $category[0]->cat_ID;
         echo is_wp_error($cat_parents = get_category_parents($ID, TRUE, '', FALSE)) ? '' : '<span>' . $cat_parents . '</span>';
     } else {
         if (is_singular('news')) {
             echo '<span>' . get_the_title() . '</span>';
         } else {
             if (is_single() && !is_attachment()) {
                 if (get_post_type() == 'product') {
                     if ($terms = wc_get_product_terms($post->ID, 'product_cat', array('orderby' => 'parent', 'order' => 'DESC'))) {
                         $main_term = $terms[0];
                         $ancestors = get_ancestors($main_term->term_id, 'product_cat');
                         $ancestors = array_reverse($ancestors);
                         foreach ($ancestors as $ancestor) {
                             $ancestor = get_term($ancestor, 'product_cat');
                             if (!is_wp_error($ancestor) && $ancestor) {
                                 echo '<a href="' . get_term_link($ancestor->slug, 'product_cat') . '">' . $ancestor->name . '</a>' . $delimiter;
                             }
                         }
                         echo '<a href="' . get_term_link($main_term->slug, 'product_cat') . '">' . $main_term->name . '</a>' . $delimiter;
                     }
                     echo get_the_title();
                 } elseif (is_singular('portfolio')) {
                     $portfolio_category = get_the_term_list($post->ID, 'portfolio_category', '', ' / ');
                     if (!empty($portfolio_category)) {
                         echo $portfolio_category . $delimiter;
                     }
                     echo '<span>' . get_the_title() . '</span>';
                 } elseif (get_post_type() != 'post') {
                     if (function_exists('is_bbpress') && is_bbpress()) {
                     } else {
                         $post_type = get_post_type_object(get_post_type());
                         $slug = $post_type->rewrite;
                         echo '<a href="' . get_post_type_archive_link(get_post_type()) . '">' . $post_type->labels->singular_name . '</a>' . $delimiter;
                         echo get_the_title();
                     }
                 } else {
                     $cat = current(get_the_category());
                     echo get_category_parents($cat, true, $delimiter);
                     echo get_the_title();
                 }
             } elseif (is_page() && !$post->post_parent) {
                 echo get_the_title();
             } elseif (is_page() && $post->post_parent) {
                 $parent_id = $post->post_parent;
                 $breadcrumbs = array();
                 while ($parent_id) {
                     $page = get_page($parent_id);
                     $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
                     $parent_id = $page->post_parent;
                 }
                 $breadcrumbs = array_reverse($breadcrumbs);
                 foreach ($breadcrumbs as $crumb) {
                     echo $crumb . '' . $delimiter;
                 }
                 echo get_the_title();
             } elseif (is_attachment()) {
                 $parent = get_post($post->post_parent);
                 $cat = get_the_category($parent->ID);
                 $cat = $cat[0];
                 /* admin@innodron.com patch:
                 			   Fix for Catchable fatal error: Object of class WP_Error could not be converted to string
                 			   ref: https://wordpress.org/support/topic/catchable-fatal-error-object-of-class-wp_error-could-not-be-converted-to-string-11
                 			*/
                 echo is_wp_error($cat_parents = get_category_parents($cat, TRUE, '' . $delimiter . '')) ? '' : $cat_parents;
                 /* end admin@innodron.com patch */
                 echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>' . $delimiter;
                 echo get_the_title();
             } elseif (is_search()) {
                 echo __('Search results for &ldquo;', 'mk_framework') . get_search_query() . '&rdquo;';
             } elseif (is_tag()) {
                 echo __('Tag &ldquo;', 'mk_framework') . single_tag_title('', false) . '&rdquo;';
             } elseif (is_author()) {
                 $userdata = get_userdata(get_the_author_meta('ID'));
                 echo __('Author:', 'mk_framework') . ' ' . $userdata->display_name;
             } elseif (is_day()) {
                 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter;
                 echo '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a>' . $delimiter;
                 echo get_the_time('d');
             } elseif (is_month()) {
                 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter;
                 echo get_the_time('F');
             } elseif (is_year()) {
                 echo get_the_time('Y');
             }
         }
     }
     if (get_query_var('paged')) {
         echo ' (' . __('Page', 'mk_framework') . ' ' . get_query_var('paged') . ')';
     }
     if (is_tax()) {
         $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
         if (function_exists('is_woocommerce') && is_woocommerce() && is_archive()) {
             echo $delimiter;
         }
         echo '<span>' . $term->name . '</span>';
     }
     if (function_exists('is_bbpress') && is_bbpress()) {
         $item = array();
         $post_type_object = get_post_type_object(bbp_get_forum_post_type());
         if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
             $item[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
         }
         if (bbp_is_forum_archive()) {
             $item[] = bbp_get_forum_archive_title();
         } elseif (bbp_is_topic_archive()) {
             $item[] = bbp_get_topic_archive_title();
         } elseif (bbp_is_single_view()) {
             $item[] = bbp_get_view_title();
         } elseif (bbp_is_single_topic()) {
             $topic_id = get_queried_object_id();
             $item = array_merge($item, mk_breadcrumbs_get_parents(bbp_get_topic_forum_id($topic_id)));
             if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
                 $item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
             } else {
                 $item[] = bbp_get_topic_title($topic_id);
             }
             if (bbp_is_topic_split()) {
                 $item[] = __('Split', 'mk_framework');
             } elseif (bbp_is_topic_merge()) {
                 $item[] = __('Merge', 'mk_framework');
             } elseif (bbp_is_topic_edit()) {
                 $item[] = __('Edit', 'mk_framework');
             }
         } elseif (bbp_is_single_reply()) {
             $reply_id = get_queried_object_id();
             $item = array_merge($item, mk_breadcrumbs_get_parents(bbp_get_reply_topic_id($reply_id)));
             if (!bbp_is_reply_edit()) {
                 $item[] = bbp_get_reply_title($reply_id);
             } else {
                 $item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
                 $item[] = __('Edit', 'mk_framework');
             }
         } elseif (bbp_is_single_forum()) {
             $forum_id = get_queried_object_id();
             $forum_parent_id = bbp_get_forum_parent_id($forum_id);
             if (0 !== $forum_parent_id) {
                 $item = array_merge($item, mk_breadcrumbs_get_parents($forum_parent_id));
             }
             $item[] = bbp_get_forum_title($forum_id);
         } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
             if (bbp_is_single_user_edit()) {
                 $item[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
                 $item[] = __('Edit', 'mk_framework');
             } else {
                 $item[] = bbp_get_displayed_user_field('display_name');
             }
         }
         echo implode($delimiter, $item);
     }
     echo "</div></div>";
 }
function tehnik_bbp_has_topics($args = '')
{
    global $wp_rewrite;
    /** Defaults ************************************************************* */
    // Other defaults
    $default_topic_search = !empty($_REQUEST['ts']) ? $_REQUEST['ts'] : false;
    $default_show_stickies = (bool) (bbp_is_single_forum() || bbp_is_topic_archive()) && false === $default_topic_search;
    $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
    // Default argument array
    $default = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $default_post_parent, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'posts_per_page' => bbp_get_topics_per_page(), 'paged' => bbp_get_paged(), 's' => $default_topic_search, 'show_stickies' => $default_show_stickies, 'max_num_pages' => false);
    //Get an array of IDs which the current user has permissions to view
    $allowed_forums = tehnik_bpp_get_permitted_post_ids(new WP_Query($default));
    // The default forum query with allowed forum ids array added
    $default['post__in'] = $allowed_forums;
    // What are the default allowed statuses (based on user caps)
    if (bbp_get_view_all()) {
        // Default view=all statuses
        $post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id());
        // Add support for private status
        if (current_user_can('read_private_topics')) {
            $post_statuses[] = bbp_get_private_status_id();
        }
        // Join post statuses together
        $default['post_status'] = join(',', $post_statuses);
        // Lean on the 'perm' query var value of 'readable' to provide statuses
    } else {
        $default['perm'] = 'readable';
    }
    // Maybe query for topic tags
    if (bbp_is_topic_tag()) {
        $default['term'] = bbp_get_topic_tag_slug();
        $default['taxonomy'] = bbp_get_topic_tag_tax_id();
    }
    /** Setup **************************************************************** */
    // Parse arguments against default values
    $r = bbp_parse_args($args, $default, 'has_topics');
    // Get bbPress
    $bbp = bbpress();
    // Call the query
    $bbp->topic_query = new WP_Query($r);
    // Set post_parent back to 0 if originally set to 'any'
    if ('any' == $r['post_parent']) {
        $r['post_parent'] = 0;
    }
    // Limited the number of pages shown
    if (!empty($r['max_num_pages'])) {
        $bbp->topic_query->max_num_pages = $r['max_num_pages'];
    }
    /** Stickies ************************************************************* */
    // Put sticky posts at the top of the posts array
    if (!empty($r['show_stickies']) && $r['paged'] <= 1) {
        // Get super stickies and stickies in this forum
        $stickies = bbp_get_super_stickies();
        // Get stickies for current forum
        if (!empty($r['post_parent'])) {
            $stickies = array_merge($stickies, bbp_get_stickies($r['post_parent']));
        }
        // Remove any duplicate stickies
        $stickies = array_unique($stickies);
        // We have stickies
        if (is_array($stickies) && !empty($stickies)) {
            // Start the offset at -1 so first sticky is at correct 0 offset
            $sticky_offset = -1;
            // Loop over topics and relocate stickies to the front.
            foreach ($stickies as $sticky_index => $sticky_ID) {
                // Get the post offset from the posts array
                $post_offsets = wp_filter_object_list($bbp->topic_query->posts, array('ID' => $sticky_ID), 'OR', 'ID');
                // Continue if no post offsets
                if (empty($post_offsets)) {
                    continue;
                }
                // Loop over posts in current query and splice them into position
                foreach (array_keys($post_offsets) as $post_offset) {
                    $sticky_offset++;
                    $sticky = $bbp->topic_query->posts[$post_offset];
                    // Remove sticky from current position
                    array_splice($bbp->topic_query->posts, $post_offset, 1);
                    // Move to front, after other stickies
                    array_splice($bbp->topic_query->posts, $sticky_offset, 0, array($sticky));
                    // Cleanup
                    unset($stickies[$sticky_index]);
                    unset($sticky);
                }
                // Cleanup
                unset($post_offsets);
            }
            // Cleanup
            unset($sticky_offset);
            // If any posts have been excluded specifically, Ignore those that are sticky.
            if (!empty($stickies) && !empty($r['post__not_in'])) {
                $stickies = array_diff($stickies, $r['post__not_in']);
            }
            // Fetch sticky posts that weren't in the query results
            if (!empty($stickies)) {
                // Query to use in get_posts to get sticky posts
                $sticky_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => 'any', 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies);
                //Get an array of IDs which the current user has permissions to view
                $allowed_forums = tehnik_bpp_get_permitted_post_ids(new WP_Query($sticky_query));
                // The default forum query with allowed forum ids array added
                $sticky_query['post__in'] = $allowed_forums;
                // Cleanup
                unset($stickies);
                // What are the default allowed statuses (based on user caps)
                if (bbp_get_view_all()) {
                    $sticky_query['post_status'] = $r['post_status'];
                    // Lean on the 'perm' query var value of 'readable' to provide statuses
                } else {
                    $sticky_query['post_status'] = $r['perm'];
                }
                // Get all stickies
                $sticky_posts = get_posts($sticky_query);
                if (!empty($sticky_posts)) {
                    // Get a count of the visible stickies
                    $sticky_count = count($sticky_posts);
                    // Merge the stickies topics with the query topics .
                    $bbp->topic_query->posts = array_merge($sticky_posts, $bbp->topic_query->posts);
                    // Adjust loop and counts for new sticky positions
                    $bbp->topic_query->found_posts = (int) $bbp->topic_query->found_posts + (int) $sticky_count;
                    $bbp->topic_query->post_count = (int) $bbp->topic_query->post_count + (int) $sticky_count;
                    // Cleanup
                    unset($sticky_posts);
                }
            }
        }
    }
    // If no limit to posts per page, set it to the current post_count
    if (-1 == $r['posts_per_page']) {
        $r['posts_per_page'] = $bbp->topic_query->post_count;
    }
    // Add pagination values to query object
    $bbp->topic_query->posts_per_page = $r['posts_per_page'];
    $bbp->topic_query->paged = $r['paged'];
    // Only add pagination if query returned results
    if (((int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts) && (int) $bbp->topic_query->posts_per_page) {
        // Limit the number of topics shown based on maximum allowed pages
        if (!empty($r['max_num_pages']) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count) {
            $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
        }
        // If pretty permalinks are enabled, make our pagination pretty
        if ($wp_rewrite->using_permalinks()) {
            // User's topics
            if (bbp_is_single_user_topics()) {
                $base = bbp_get_user_topics_created_url(bbp_get_displayed_user_id());
                // User's favorites
            } elseif (bbp_is_favorites()) {
                $base = bbp_get_favorites_permalink(bbp_get_displayed_user_id());
                // User's subscriptions
            } elseif (bbp_is_subscriptions()) {
                $base = bbp_get_subscriptions_permalink(bbp_get_displayed_user_id());
                // Root profile page
            } elseif (bbp_is_single_user()) {
                $base = bbp_get_user_profile_url(bbp_get_displayed_user_id());
                // View
            } elseif (bbp_is_single_view()) {
                $base = bbp_get_view_url();
                // Topic tag
            } elseif (bbp_is_topic_tag()) {
                $base = bbp_get_topic_tag_link();
                // Page or single post
            } elseif (is_page() || is_single()) {
                $base = get_permalink();
                // Topic archive
            } elseif (bbp_is_topic_archive()) {
                $base = bbp_get_topics_url();
                // Default
            } else {
                $base = get_permalink((int) $r['post_parent']);
            }
            // Use pagination base
            $base = trailingslashit($base) . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
            // Unpretty pagination
        } else {
            $base = add_query_arg('paged', '%#%');
        }
        // Pagination settings with filter
        $bbp_topic_pagination = apply_filters('bbp_topic_pagination', array('base' => $base, 'format' => '', 'total' => $r['posts_per_page'] == $bbp->topic_query->found_posts ? 1 : ceil((int) $bbp->topic_query->found_posts / (int) $r['posts_per_page']), 'current' => (int) $bbp->topic_query->paged, 'prev_text' => is_rtl() ? '&rarr;' : '&larr;', 'next_text' => is_rtl() ? '&larr;' : '&rarr;', 'mid_size' => 1));
        // Add pagination to query object
        $bbp->topic_query->pagination_links = paginate_links($bbp_topic_pagination);
        // Remove first page from pagination
        $bbp->topic_query->pagination_links = str_replace($wp_rewrite->pagination_base . "/1/'", "'", $bbp->topic_query->pagination_links);
    }
    // Return object
    return array($bbp->topic_query->have_posts(), $bbp->topic_query);
}
<?php

global $current_user;
get_currentuserinfo();
$cb_author_id = $current_user->ID;
$cb_author_posts = count_user_posts($cb_author_id);
$cb_author_profile_url = get_edit_user_link($cb_author_id);
if (class_exists('bbpress')) {
    $cb_author_profile_url = bbp_get_user_profile_url($cb_author_id);
}
if (class_exists('buddypress')) {
    global $bp;
    $cb_buddypress_user_profile_link = $cb_buddypress_user_profile_link = NULL;
    $cb_buddypress_current_user_id = $bp->loggedin_user->id;
    if (function_exists('bp_loggedin_user_domain')) {
        $cb_buddypress_user_profile_link = bp_loggedin_user_domain();
    }
    if (isset($bp->profile->slug)) {
        $cb_author_profile_url = $cb_buddypress_user_profile_link . $bp->profile->slug;
    }
    if (function_exists('bp_get_groups_root_slug')) {
        $cb_buddypress_user_group_link = $cb_buddypress_user_profile_link . bp_get_groups_root_slug();
    }
    if (function_exists('bp_get_messages_slug')) {
        $cb_buddypress_user_message_link = $cb_buddypress_user_profile_link . bp_get_messages_slug();
    }
    if (function_exists('bp_get_activity_slug')) {
        $cb_buddypress_user_activity_link = $cb_buddypress_user_profile_link . bp_get_activity_slug();
    }
    $cb_buddypress_user_avatar = bp_core_fetch_avatar(array('item_id' => $cb_buddypress_current_user_id, 'type' => 'full', 'width' => 120, 'height' => 120, 'class' => 'cb-circle'));
    $cb_buddypress_mystery_man = 'mystery-man.jpg';
Esempio n. 11
0
/**
 * Return the author link of the post
 *
 * @since bbPress (r2875)
 *
 * @param mixed $args Optional. If an integer, it is used as reply id.
 * @uses bbp_is_topic() To check if it's a topic page
 * @uses bbp_get_topic_author_link() To get the topic author link
 * @uses bbp_is_reply() To check if it's a reply page
 * @uses bbp_get_reply_author_link() To get the reply author link
 * @uses get_post_field() To get the post author
 * @uses bbp_is_reply_anonymous() To check if the reply is by an
 *                                 anonymous user
 * @uses get_the_author_meta() To get the author name
 * @uses bbp_get_user_profile_url() To get the author profile url
 * @uses get_avatar() To get the author avatar
 * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the
 *                        author link and args
 * @return string Author link of reply
 */
function bbp_get_author_link($args = '')
{
    // Default arguments
    $defaults = array('post_id' => 0, 'link_title' => '', 'type' => 'both', 'size' => 80);
    $r = bbp_parse_args($args, $defaults, 'get_author_link');
    extract($r);
    // Used as reply_id
    if (is_numeric($args)) {
        $post_id = $args;
    }
    // Confirmed topic
    if (bbp_is_topic($post_id)) {
        return bbp_get_topic_author_link($args);
    } elseif (bbp_is_reply($post_id)) {
        return bbp_get_reply_author_link($args);
    } else {
        $user_id = get_post_field('post_author', $post_id);
    }
    // Neither a reply nor a topic, so could be a revision
    if (!empty($post_id)) {
        // Generate title with the display name of the author
        if (empty($link_title)) {
            $link_title = sprintf(!bbp_is_reply_anonymous($post_id) ? __('View %s\'s profile', 'bbpress') : __('Visit %s\'s website', 'bbpress'), get_the_author_meta('display_name', $user_id));
        }
        // Assemble some link bits
        $link_title = !empty($link_title) ? ' title="' . $link_title . '"' : '';
        $author_url = bbp_get_user_profile_url($user_id);
        $anonymous = bbp_is_reply_anonymous($post_id);
        // Get avatar
        if ('avatar' == $type || 'both' == $type) {
            $author_links[] = get_avatar($user_id, $size);
        }
        // Get display name
        if ('name' == $type || 'both' == $type) {
            $author_links[] = get_the_author_meta('display_name', $user_id);
        }
        // Add links if not anonymous
        if (empty($anonymous)) {
            foreach ($author_links as $link_text) {
                $author_link[] = sprintf('<a href="%1$s"%2$s>%3$s</a>', $author_url, $link_title, $link_text);
            }
            $author_link = join('&nbsp;', $author_link);
            // No links if anonymous
        } else {
            $author_link = join('&nbsp;', $author_links);
        }
        // No post so link is empty
    } else {
        $author_link = '';
    }
    return apply_filters('bbp_get_author_link', $author_link, $args);
}
Esempio n. 12
0
 /**
  * Submit a post for spamming or hamming
  *
  * @since bbPress (r3277)
  *
  * @param int $post_id
  *
  * @global WP_Query $wpdb
  * @global string $akismet_api_host
  * @global string $akismet_api_port
  * @global object $current_user
  * @global object $current_site
  *
  * @uses current_filter() To get the reply_id
  * @uses get_post() To get the post object
  * @uses get_the_author_meta() To get the author meta
  * @uses get_post_meta() To get the post meta
  * @uses bbp_get_user_profile_url() To get a user's profile url
  * @uses get_permalink() To get the permalink of the post_parent
  * @uses akismet_get_user_roles() To get the role(s) of the post_author
  * @uses bbp_current_author_ip() To get the IP address of the current user
  * @uses BBP_Akismet::maybe_spam() To submit the post as ham or spam
  * @uses update_post_meta() To update the post meta with some Akismet data
  * @uses do_action() To call the 'bbp_akismet_submit_spam_post' and 'bbp_akismet_submit_ham_post' hooks
  *
  * @return array Array of existing topic terms
  */
 public function submit_post($post_id = 0)
 {
     global $current_user, $current_site;
     // Innocent until proven guilty
     $request_type = 'ham';
     $current_filter = current_filter();
     // Check this filter and adjust the $request_type accordingly
     switch ($current_filter) {
         // Mysterious, and straight from the can
         case 'bbp_spammed_topic':
         case 'bbp_spammed_reply':
             $request_type = 'spam';
             break;
             // Honey-glazed, a straight off the bone
         // Honey-glazed, a straight off the bone
         case 'bbp_unspammed_topic':
         case 'bbp_unspammed_reply':
             $request_type = 'ham';
             break;
             // Possibly poison...
         // Possibly poison...
         default:
             return;
     }
     // Setup some variables
     $post_id = (int) $post_id;
     // Make sure we have a post
     $_post = get_post($post_id);
     // Bail if get_post() fails
     if (empty($_post)) {
         return;
     }
     // Bail if we're spamming, but the post_status isn't spam
     if ('spam' == $request_type && bbp_get_spam_status_id() != $_post->post_status) {
         return;
     }
     // Set some default post_data
     $post_data = array('comment_approved' => $_post->post_status, 'comment_author' => $_post->post_author ? get_the_author_meta('display_name', $_post->post_author) : get_post_meta($post_id, '_bbp_anonymous_name', true), 'comment_author_email' => $_post->post_author ? get_the_author_meta('email', $_post->post_author) : get_post_meta($post_id, '_bbp_anonymous_email', true), 'comment_author_url' => $_post->post_author ? bbp_get_user_profile_url($_post->post_author) : get_post_meta($post_id, '_bbp_anonymous_website', true), 'comment_content' => $_post->post_content, 'comment_date' => $_post->post_date, 'comment_ID' => $post_id, 'comment_post_ID' => $_post->post_parent, 'comment_type' => $_post->post_type, 'permalink' => get_permalink($post_id), 'user_ID' => $_post->post_author, 'user_ip' => get_post_meta($post_id, '_bbp_author_ip', true), 'user_role' => akismet_get_user_roles($_post->post_author));
     // Use the original version stored in post_meta if available
     $as_submitted = get_post_meta($post_id, '_bbp_akismet_as_submitted', true);
     if ($as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content'])) {
         $post_data = array_merge($post_data, $as_submitted);
     }
     // Add the reporter IP address
     $post_data['reporter_ip'] = bbp_current_author_ip();
     // Add some reporter info
     if (is_object($current_user)) {
         $post_data['reporter'] = $current_user->user_login;
     }
     // Add the current site domain
     if (is_object($current_site)) {
         $post_data['site_domain'] = $current_site->domain;
     }
     // Place your slide beneath the microscope
     $post_data = $this->maybe_spam($post_data, 'submit', $request_type);
     // Manual user action
     if (isset($post_data['reporter'])) {
         // What kind of action
         switch ($request_type) {
             // Spammy
             case 'spam':
                 $this->update_post_history($post_id, sprintf(__('%1$s reported this %2$s as spam', 'bbpress'), $post_data['reporter'], $post_data['comment_type']), 'report-spam');
                 update_post_meta($post_id, '_bbp_akismet_user_result', 'true');
                 update_post_meta($post_id, '_bbp_akismet_user', $post_data['reporter']);
                 break;
                 // Hammy
             // Hammy
             case 'ham':
                 $this->update_post_history($post_id, sprintf(__('%1$s reported this %2$s as not spam', 'bbpress'), $post_data['reporter'], $post_data['comment_type']), 'report-ham');
                 update_post_meta($post_id, '_bbp_akismet_user_result', 'false');
                 update_post_meta($post_id, '_bbp_akismet_user', $post_data['reporter']);
                 // @todo Topic term revision history
                 break;
                 // Possible other actions
             // Possible other actions
             default:
                 break;
         }
     }
     do_action('bbp_akismet_submit_' . $request_type . '_post', $post_id, $post_data['bbp_akismet_result']);
 }
Esempio n. 13
0
/**
 * User Details
 *
 * @package bbPress
 * @subpackage Theme
 */
?>

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

	<span class="page-title author">

		<?php 
printf(__('Profile: %s', 'bbpress'), "<span class='vcard'><a class='url fn n' href='" . bbp_get_user_profile_url() . "' title='" . esc_attr(bbp_get_displayed_user_field('display_name')) . "' rel='me'>" . bbp_get_displayed_user_field('display_name') . "</a></span>");
?>

		<?php 
if (bbp_is_user_home() || current_user_can('edit_users')) {
    ?>

			<span class="edit_user_link"><a href="<?php 
    bbp_user_profile_edit_url();
    ?>
" title="<?php 
    printf(__('Edit Profile of User %s', 'bbpress'), esc_attr(bbp_get_displayed_user_field('display_name')));
    ?>
"><?php 
    _e('(Edit)', 'bbpress');
    ?>
 /**
  * Formats the given user as html.
  *
  * @param WP_User $user The user to format (object of type WP_User).
  *
  * @uses apply_filters() Calls 'aa_user_template' hook
  * @return String html
  */
 function format_user($user)
 {
     $tpl_vars = array('{class}' => '', '{user}' => '');
     $avatar_size = intval($this->avatar_size);
     if (!$avatar_size) {
         $avatar_size = false;
     }
     $name = "";
     if ($this->show_name) {
         $name = $user->display_name;
     }
     $alt = $title = $name;
     $divcss = array('user');
     if ($this->show_name) {
         $divcss[] = 'with-name';
     }
     $link = false;
     $link_type = $this->user_link;
     // always use 'website' for commentators
     $type = isset($user->type) ? $user->type : null;
     if ($user->user_id == -1 && "guest-author" != $type) {
         $link_type = 'website';
     }
     switch ($link_type) {
         case 'authorpage':
             if ("guest-author" == $type) {
                 $link = get_author_posts_url($user->user_id, $user->user_nicename);
             } else {
                 $link = get_author_posts_url($user->user_id);
             }
             break;
         case 'website':
             if ("guest-author" == $type) {
                 $link = get_the_author_meta('url', $user->ID);
             } else {
                 $link = $user->user_url;
                 if (empty($link) || $link == 'http://') {
                     $link = false;
                 }
             }
             break;
         case 'blog':
             if (AA_is_wpmu()) {
                 $blog = get_active_blog_for_user($user->user_id);
                 if (!empty($blog->siteurl)) {
                     $link = $blog->siteurl;
                 }
             }
             break;
         case 'bp_memberpage':
             if (function_exists('bp_core_get_user_domain')) {
                 $link = bp_core_get_user_domain($user->user_id);
             } elseif (function_exists('bp_core_get_userurl')) {
                 // BP versions < 1.1
                 $link = bp_core_get_userurl($user->user_id);
             }
             break;
         case 'bbpress_memberpage':
             if (function_exists('bbp_get_user_profile_url')) {
                 $link = bbp_get_user_profile_url($user->user_id);
             }
             if (empty($link) || $link == 'http://') {
                 $link = false;
             }
             break;
         case 'last_post':
             $recent = get_posts(array('author' => $user->user_id, 'orderby' => 'date', 'order' => 'desc', 'numberposts' => 1));
             $link = get_permalink($recent[0]->ID);
             break;
         case 'last_post_all':
             $last_post = get_most_recent_post_of_user($user->user_id);
             $link = get_permalink($last_post['post_id']);
             break;
     }
     if ($this->show_postcount) {
         $postcount = 0;
         if ($user->user_id == -1 && "guest-author" != $type) {
             $postcount = $this->get_comment_count($user->user_email);
             $title .= ' (' . sprintf(_n("%d comment", "%d comments", $postcount, 'author-avatars'), $postcount) . ')';
         } else {
             // this is passing 1 for coauthors
             if ("guest-author" == $type && $user->linked_account) {
                 $linked_user = get_user_by('login', $user->linked_account);
                 // fetch the linked account and show thats count
                 $postcount = $this->get_user_postcount($linked_user->ID);
             } else {
                 $postcount = $this->get_user_postcount($user->user_id);
             }
             $title .= ' (' . sprintf(_n("%d post", "%d posts", $postcount, 'author-avatars'), $postcount) . ')';
         }
         $name .= sprintf(apply_filters('aa_post_count', ' (%d)', $postcount), $postcount);
     }
     if ($this->show_bbpress_post_count && AA_is_bbpress()) {
         $BBPRESS_postcount = 0;
         if (function_exists('bbp_get_user_topic_count_raw')) {
             $BBPRESS_postcount = bbp_get_user_topic_count_raw($user->user_id) + bbp_get_user_reply_count_raw($user->user_id);
             $title .= ' (' . sprintf(_n("%d BBPress post", "%d BBPress posts", $BBPRESS_postcount, 'author-avatars'), $BBPRESS_postcount) . ')';
         }
         $name .= sprintf(' (%d)', $BBPRESS_postcount);
     }
     $biography = false;
     if ($this->show_biography) {
         if ("guest-author" != $type && $user->user_id > 0) {
             $biography = get_the_author_meta('description', $user->user_id);
         } else {
             $biography = isset($user->description) ? $user->description : '';
         }
         $biography = apply_filters('aa_user_biography_filter', $biography);
         // trim $biography to bio_length
         if (0 < $this->bio_length) {
             $biography = $this->truncate_html(wpautop($biography, true), apply_filters('aa_user_bio_length', $this->bio_length));
         } else {
             $biography = wpautop($biography, true);
         }
         $divcss[] = 'with-biography bio-length-' . $this->bio_length;
         $name = '<strong>' . $name . '</strong>';
         if (empty($biography)) {
             $divcss[] = 'biography-missing';
         }
     }
     $show_last_post = false;
     if ($this->show_last_post) {
         $show_last_post = $this->aa_get_last_post($user->user_id);
         /**
          * Filter the users last post.
          *
          * @since 1.8.6.0
          *
          * @param string $show_last_post    The HTML link to users last post.
          * @param object					The Current user object.
          */
         $show_last_post = apply_filters('aa_user_show_last_post_filter', $show_last_post, $user);
         $divcss[] = 'with-last-post';
         if (empty($show_last_post)) {
             $divcss[] = 'last-post-missing';
         }
     }
     $email = false;
     if ($this->show_email && $user->user_email) {
         $userEmail = $user->user_email;
         /**
          * Filter the title tag content for an admin page.
          *
          * @since 1.8.6.0
          *
          * @param string 				The mailto href for sprintf the $1$s is where the email is inserted.
          * @param string $userEmail     The Email to be inserted.
          * @param object				The Current user object.
          */
         $email = sprintf(apply_filters('aa_user_email_url_template', '<a href="mailto:%1$s">%1$s</a>', $userEmail, $user), $userEmail);
         $divcss[] = 'with-email';
         if (empty($email)) {
             $divcss[] = 'email-missing';
         }
     }
     if ($user->user_id == -1) {
         // use email for commentators
         $avatar = get_avatar($user->user_email, $avatar_size);
     } else {
         // if on buddypress install use BP function
         if (function_exists('bp_core_fetch_avatar')) {
             $avatar = bp_core_fetch_avatar(array('item_id' => $user->user_id, 'width' => $avatar_size, 'height' => $avatar_size, 'type' => 'full', 'alt' => $alt, 'title' => $title));
         } else {
             // call the standard avatar function
             $avatar = get_avatar($user->user_id, $avatar_size);
         }
     }
     /* Strip all existing links (a tags) from the get_avatar() code to
      * remove e.g. the link which is added by the add-local-avatar plugin
      * @see http://wordpress.org/support/topic/309878 */
     if (!empty($link)) {
         $avatar = preg_replace('@<\\s*\\/?\\s*[aA]\\s*.*?>@', '', $avatar);
     }
     // the buddypress code
     if (!function_exists('bp_core_fetch_avatar')) {
         /* strip alt and title parameter */
         $avatar = preg_replace('@alt=["\'][\\w]*["\'] ?@', '', $avatar);
         $avatar = preg_replace('@title=["\'][\\w]*["\'] ?@', '', $avatar);
         /* insert alt and title parameters */
         if (!stripos($avatar, 'title=')) {
             $avatar = preg_replace('@ ?\\/>@', ' title="' . $title . '" />', $avatar);
         }
         if (!stripos($avatar, 'alt=')) {
             $avatar = preg_replace('@ ?\\/>@', ' alt="' . $alt . '"  />', $avatar);
         }
     }
     $html = '';
     /**
      * filter the span that holds the avatar
      *
      * @param string 			The sprintf template.
      * @param string @title  	The value passed to the title attr in span.
      * @param string @avatar	The HTML returned from get_avatar() etc.
      * @param object $user		The user object
      */
     $html .= sprintf(apply_filters('aa_user_avatar_template', '<span class="avatar" title="%s">%s</span>', $title, $avatar, $user), $title, $avatar);
     if ($this->show_name || $this->show_bbpress_post_count || $this->show_postcount) {
         /**
          * filter the span that contains the users name
          *
          * @param string 			The sprintf template.
          * @param string $name		The value (users name) passed into the span
          * @param object $user		The user object
          */
         $html .= sprintf(apply_filters('aa_user_name_template', '<span class="name">%s</span>', $name, $user), $name);
     }
     if ($link) {
         /**
          * filter the href that wrap's avatar and users name
          *
          * @param string 			The sprintf template.
          * @param string $link		The href value.
          * @param string $title		The value for the href title
          * @param string $html 		The HTML with avatar and name
          * @param object $user		The user object
          */
         $html = sprintf(apply_filters('aa_user_link_template', '<a href="%s" title="%s">%s</a>', $link, $title, $html, $user), $link, $title, $html);
     }
     if ($email) {
         /**
          * filter that wrap's the email link in a div
          *
          * @param string 			The sprintf template.
          * @param string $email		The HTML containing the mailto href and email string.
          * @param object $user		The user object
          */
         $html .= sprintf(apply_filters('aa_user_email_template', '<div class="email">%s</div>', $email, $user), $email);
     }
     if ($biography) {
         /**
          * filter that wrap's the BIO text in a div
          *
          * @param string 			The sprintf template.
          * @param string $biography	The Bio text.
          * @param object $user		The user object
          */
         $html .= sprintf(apply_filters('aa_user_biography_template', '<div class="biography">%s</div>', $biography, $user), $biography);
     }
     if ($show_last_post) {
         /**
          * filter that wrap's the last post link in a div
          *
          * @param string 					The sprintf template.
          * @param string $show_last_post	The last post link.
          * @param object $user		The user object
          */
         $html .= sprintf(apply_filters('aa_user_last_post_template', '<div class="show_last_post">%s</div>', $show_last_post, $user), $show_last_post);
     }
     if (!empty($this->display_extra)) {
         /**
          * filter the extra HTML block before its appended
          *
          * @param string $extra		extra HTML / string.
          * @param object $user		The user object
          */
         $html .= apply_filters('aa_user_display_extra', $this->display_extra, $user);
     }
     $tpl_vars['{class}'] = implode($divcss, ' ');
     /**
      * filter on the complete HTML for the user
      *
      * @param string $html	The generated HTML.
      * @param object $user	the user object
      */
     $tpl_vars['{user}'] = apply_filters('aa_user_final_content', $html, $user);
     /**
      * filter the outer HTML template
      *
      * @param string $html	The outer user template.
      * @param object $user	the user object
      */
     return str_replace(array_keys($tpl_vars), $tpl_vars, apply_filters('aa_user_template', $this->user_template, $user));
 }
Esempio n. 15
0
 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;
 }
Esempio n. 16
0
/**
 * Gets the items for the breadcrumb item if bbPress is installed.
 *
 * @since 0.4
 *
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the item.
 */
function breadcrumbs_plus_get_bbpress_items($args = array())
{
    $item = array();
    $post_type_object = get_post_type_object(bbp_get_forum_post_type());
    if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
        if (function_exists('bp_is_active')) {
            global $bp;
            // we're outside the loop!
            // Assign some variables here
            $page1 = isset($bp->members->root_slug) ? $bp->members->root_slug : '';
            // slug for the Members page. The BuddyPress default is 'members'.
            $page2 = isset($bp->groups->root_slug) ? $bp->groups->root_slug : '';
            // slug for the Groups page. The BuddyPress default is 'groups'.
            $page3 = isset($bp->activity->root_slug) ? $bp->activity->root_slug : '';
            // slug for the Activity page. The BuddyPress default is 'activity'.
            $page4 = isset($bp->forums->root_slug) ? $bp->forums->root_slug : '';
            // slug for the Forums page. The BuddyPress default is 'forums'.
            $page5 = isset($bp->achievements->root_slug) ? $bp->achievements->root_slug : '';
            // slug for the Achievements page. The BuddyPress default is 'achievements'.
            if (!bp_is_blog_page() && (is_page() || is_page($page1) || is_page($page2) || is_page($page3) || is_page($page4) || is_page($page5)) && !bp_is_user() && !bp_is_single_item() && !bp_is_register_page()) {
                $item[] = '';
            }
            if (bp_is_user() && !bp_is_register_page()) {
                $item[] = '';
            }
        } else {
            //$item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link( bbp_get_forum_post_type() ) . '" rel="v:url" property="v:title">' . bbp_get_forum_archive_title() . '</a></div>';
        }
    }
    if (bbp_is_forum_archive()) {
        $item[] = bbp_get_forum_archive_title();
    } else {
        $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '" rel="v:url" property="v:title">' . bbp_get_forum_archive_title() . '</a></div>';
    }
    if (bbp_is_topic_archive()) {
        $item[] = bbp_get_topic_archive_title();
    } elseif (bbp_is_single_view()) {
        $item[] = bbp_get_view_title();
    } elseif (bbp_is_single_topic()) {
        $topic_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_topic_permalink($topic_id) . '" rel="v:url" property="v:title">' . bbp_get_topic_title($topic_id) . '</a></div>';
        } else {
            $item[] = '';
        }
        if (bbp_is_topic_split()) {
            $item[] = __('Split', 'framework');
        } elseif (bbp_is_topic_merge()) {
            $item[] = __('Merge', 'framework');
        } elseif (bbp_is_topic_edit()) {
            $item[] = __('Edit', 'framework');
        }
    } elseif (bbp_is_single_reply()) {
        $reply_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
        if (!bbp_is_reply_edit()) {
            $item[] = bbp_get_reply_title($reply_id);
        } else {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_reply_url($reply_id) . '" rel="v:url" property="v:title">' . bbp_get_reply_title($reply_id) . '</a></div>';
            $item[] = __('Edit', 'framework');
        }
    } elseif (bbp_is_single_forum()) {
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent_id($forum_id);
        if (0 !== $forum_parent_id) {
            $item = array_merge($item, breadcrumbs_plus_get_parents($forum_parent_id));
        }
        $item[] = bbp_get_forum_title($forum_id);
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_user_profile_url() . '" rel="v:url" property="v:title">' . bbp_get_displayed_user_field('display_name') . '</a></div>';
            $item[] = __('Edit', 'framework');
        } else {
            $item[] = bbp_get_displayed_user_field('display_name');
        }
    }
    return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
 function amr_get_href_link($field, $v, $u, $linktype)
 {
     switch ($linktype) {
         case 'none':
             return '';
         case 'mailto':
             if (!empty($u->user_email)) {
                 return 'mailto:' . $u->user_email;
             } else {
                 return '';
             }
         case 'postsbyauthor':
             // figure out which post type ?
             if (empty($v) or !current_user_can('edit_others_posts')) {
                 return '';
             } else {
                 $href = network_admin_url('edit.php?author=' . $u->ID);
                 if (stristr($field, '_count')) {
                     // it is a item count thing, but not a post count
                     if (is_object($u) and isset($u->ID)) {
                         $ctype = str_replace('_count', '', $field);
                         $href = add_query_arg(array('post_type' => $ctype), $href);
                     }
                     // end if
                 }
                 // end if stristr
                 return $href;
             }
             return '';
         case 'edituser':
             if (current_user_can('edit_users') and is_object($u) and isset($u->ID)) {
                 if (is_network_admin()) {
                     return network_admin_url('user-edit.php?user_id=' . $u->ID);
                 } else {
                     return admin_url('user-edit.php?user_id=' . $u->ID);
                 }
             } else {
                 return '';
             }
         case 'authorarchive':
             // should do on a post count only else may not be an author template ?
             if (is_object($u) and isset($u->ID)) {
                 //return(add_query_arg('author', $u->ID, home_url())); // 201401
                 return get_author_posts_url($u->ID);
             } else {
                 return '';
             }
         case 'commentsbyauthor':
             //20140722
             if (empty($v)) {
                 return '';
             } else {
                 return add_query_arg('s', $u->user_email, admin_url('edit-comments.php'));
             }
         case 'url':
             if (!empty($u->user_url)) {
                 return $u->user_url;
             }
         case 'wplist':
             // for multisite
             if (current_user_can('edit_users') and is_object($u) and isset($u->user_login)) {
                 return network_admin_url('users.php?s=' . $u->user_login);
             }
         case 'bbpressprofile':
             if (function_exists('bbp_get_user_profile_url')) {
                 return bbp_get_user_profile_url($u->ID);
             } else {
                 return '';
             }
         default:
             return apply_filters('amr-users-linktype-function', $linktype, $u, $field);
             // all the user values
     }
 }
Esempio n. 18
0
 /**
  * @covers ::bbp_user_profile_url
  * @covers ::bbp_get_user_profile_url
  */
 public function test_bbp_get_user_profile_url()
 {
     // Pretty permalinks
     $this->set_permalink_structure('/%postname%/');
     $profile_url = 'http://' . WP_TESTS_DOMAIN . '/forums/users/' . $this->keymaster_userdata->user_nicename . '/';
     $user_profile_url = bbp_get_user_profile_url($this->keymaster_id);
     // String.
     $this->assertSame($profile_url, $user_profile_url);
     // Output.
     $this->expectOutputString($profile_url);
     bbp_user_profile_url($this->keymaster_id);
     ob_clean();
     // Ugly permalinks
     $this->set_permalink_structure();
     $profile_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id;
     $user_profile_url = bbp_get_user_profile_url($this->keymaster_id);
     // String.
     $this->assertSame($profile_url, $user_profile_url);
     // Output.
     $this->expectOutputString($profile_url);
     bbp_user_profile_url($this->keymaster_id);
 }
 public function bbp_get_user_profile_url($user_id = 0, $user_nicename = '')
 {
     return bbp_get_user_profile_url($user_id, $user_nicename);
 }
Esempio n. 20
0
 function x_bbpress_navbar_menu($items, $args)
 {
     if (X_BBPRESS_IS_ACTIVE && x_get_option('x_bbpress_header_menu_enable', '') == '1') {
         $submenu_items = '';
         $submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . bbp_get_search_url() . '" class="cf"><i class="x-icon-search" data-x-icon="&#xf002;"></i> <span>' . __('Forums Search', '__x__') . '</span></a></li>';
         if (is_user_logged_in()) {
             $submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . bbp_get_favorites_permalink(get_current_user_id()) . '" class="cf"><i class="x-icon-star" data-x-icon="&#xf005;"></i> <span>' . __('Favorites', '__x__') . '</span></a></li>';
             $submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . bbp_get_subscriptions_permalink(get_current_user_id()) . '" class="cf"><i class="x-icon-bookmark" data-x-icon="&#xf02e;"></i> <span>' . __('Subscriptions', '__x__') . '</span></a></li>';
         }
         if (!X_BUDDYPRESS_IS_ACTIVE || X_BUDDYPRESS_IS_ACTIVE && x_get_option('x_buddypress_header_menu_enable', '') == '') {
             if (!is_user_logged_in()) {
                 $submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . wp_login_url() . '" class="cf"><i class="x-icon-sign-in" data-x-icon="&#xf090;"></i> <span>' . __('Log in', '__x__') . '</span></a></li>';
             } else {
                 $submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . bbp_get_user_profile_url(get_current_user_id()) . '" class="cf"><i class="x-icon-cog" data-x-icon="&#xf013;"></i> <span>' . __('Profile', '__x__') . '</span></a></li>';
             }
         }
         if ($args->theme_location == 'primary') {
             $items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-bbpress">' . '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '" class="x-btn-navbar-bbpress">' . '<span><i class="x-icon-comment" data-x-icon="&#xf075;"></i><span class="x-hidden-desktop"> ' . __('Forums', '__x__') . '</span></span>' . '</a>' . '<ul class="sub-menu">' . $submenu_items . '</ul>' . '</li>';
         }
     }
     return $items;
 }
Esempio n. 21
0
 function cupid_breadcrumb_get_bbpress_items()
 {
     $item = array();
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a></li>';
     }
     if (bbp_is_forum_archive()) {
         $item['last'] = bbp_get_forum_archive_title();
     } elseif (bbp_is_topic_archive()) {
         $item['last'] = bbp_get_topic_archive_title();
     } elseif (bbp_is_single_view()) {
         $item['last'] = bbp_get_view_title();
     } elseif (bbp_is_single_topic()) {
         $topic_id = get_queried_object_id();
         $item = array_merge($item, cupid_breadcrumb_get_parents(bbp_get_topic_forum_id($topic_id)));
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a></li>';
         } else {
             $item['last'] = bbp_get_topic_title($topic_id);
         }
         if (bbp_is_topic_split()) {
             $item['last'] = __('Split', 'cupid');
         } elseif (bbp_is_topic_merge()) {
             $item['last'] = __('Merge', 'cupid');
         } elseif (bbp_is_topic_edit()) {
             $item['last'] = __('Edit', 'cupid');
         }
     } elseif (bbp_is_single_reply()) {
         $reply_id = get_queried_object_id();
         $item = array_merge($item, cupid_breadcrumb_get_parents(bbp_get_reply_topic_id($reply_id)));
         if (!bbp_is_reply_edit()) {
             $item['last'] = bbp_get_reply_title($reply_id);
         } else {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a></li>';
             $item['last'] = __('Edit', 'cupid');
         }
     } elseif (bbp_is_single_forum()) {
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         if (0 !== $forum_parent_id) {
             $item = array_merge($item, cupid_breadcrumb_get_parents($forum_parent_id));
         }
         $item['last'] = bbp_get_forum_title($forum_id);
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a></li>';
             $item['last'] = __('Edit', 'cupid');
         } else {
             $item['last'] = bbp_get_displayed_user_field('display_name');
         }
     }
     return apply_filters('cupid_breadcrumb_get_bbpress_items', $item);
 }
/**
 * Gets the items for the breadcrumb item if bbPress is installed.
 *
 * @since 0.4
 *
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the item.
 */
function breadcrumbs_plus_get_bbpress_items($args = array())
{
    $item = array();
    $post_type_object = get_post_type_object(bbp_get_forum_post_type());
    if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
        $item[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
    }
    if (bbp_is_forum_archive()) {
        $item[] = bbp_get_forum_archive_title();
    } elseif (bbp_is_topic_archive()) {
        $item[] = bbp_get_topic_archive_title();
    } elseif (bbp_is_single_view()) {
        $item[] = bbp_get_view_title();
    } elseif (bbp_is_single_topic()) {
        $topic_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
        } else {
            $item[] = bbp_get_topic_title($topic_id);
        }
        if (bbp_is_topic_split()) {
            $item[] = __('Split', 'theme_front');
        } elseif (bbp_is_topic_merge()) {
            $item[] = __('Merge', 'theme_front');
        } elseif (bbp_is_topic_edit()) {
            $item[] = __('Edit', 'theme_front');
        }
    } elseif (bbp_is_single_reply()) {
        $reply_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
        if (!bbp_is_reply_edit()) {
            $item[] = bbp_get_reply_title($reply_id);
        } else {
            $item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
            $item[] = __('Edit', 'theme_front');
        }
    } elseif (bbp_is_single_forum()) {
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent($forum_id);
        if (0 !== $forum_parent_id) {
            $item = array_merge($item, breadcrumbs_plus_get_parents($forum_parent_id));
        }
        $item[] = bbp_get_forum_title($forum_id);
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $item[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
            $item[] = __('Edit');
        } else {
            $item[] = bbp_get_displayed_user_field('display_name');
        }
    }
    return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
Esempio n. 23
0
/**
 * Finds and links @-mentioned users in the content
 *
 * @since 2.2.0 bbPress (r4323)
 *
 * @uses bbp_find_mentions() To get usernames in content areas
 * @return string $content Content filtered for mentions
 */
function bbp_mention_filter($content = '')
{
    // Get Usernames and bail if none exist
    $usernames = bbp_find_mentions($content);
    if (empty($usernames)) {
        return $content;
    }
    // Loop through usernames and link to profiles
    foreach ((array) $usernames as $username) {
        // Skip if username does not exist or user is not active
        $user = get_user_by('slug', $username);
        if (empty($user->ID) || bbp_is_user_inactive($user->ID)) {
            continue;
        }
        // Replace name in content
        $content = preg_replace('/(@' . $username . '\\b)/', sprintf('<a href="%1$s" rel="nofollow">@%2$s</a>', bbp_get_user_profile_url($user->ID), $username), $content);
    }
    // Return modified content
    return $content;
}
        function widget($args, $instance)
        {
            if (RWLogger::IsOn()) {
                $params = func_get_args();
                RWLogger::LogEnterence("RatingWidgetPlugin_TopRatedWidget.widget", $params, true);
            }
            if (!defined("WP_RW__SITE_PUBLIC_KEY") || false === WP_RW__SITE_PUBLIC_KEY) {
                return;
            }
            if (RatingWidgetPlugin::$WP_RW__HIDE_RATINGS) {
                return;
            }
            extract($args, EXTR_SKIP);
            $bpInstalled = ratingwidget()->IsBuddyPressInstalled();
            $bbInstalled = ratingwidget()->IsBBPressInstalled();
            $types = $this->GetTypesInfo();
            $show_any = false;
            foreach ($types as $type => $data) {
                if (false !== $instance["show_{$type}"]) {
                    $show_any = true;
                    break;
                }
            }
            if (RWLogger::IsOn()) {
                RWLogger::Log('RatingWidgetPlugin_TopRatedWidget', 'show_any = ' . ($show_any ? 'TRUE' : 'FALSE'));
            }
            if (false === $show_any) {
                // Nothing to show.
                return;
            }
            $details = array("uid" => WP_RW__SITE_PUBLIC_KEY);
            $queries = array();
            foreach ($types as $type => $type_data) {
                if (isset($instance["show_{$type}"]) && $instance["show_{$type}"] && $instance["{$type}_count"] > 0) {
                    $options = ratingwidget()->GetOption($type_data["options"]);
                    $queries[$type] = array("rclasses" => $type_data["classes"], "votes" => max(1, (int) $instance["{$type}_min_votes"]), "orderby" => $instance["{$type}_orderby"], "order" => $instance["{$type}_order"], "limit" => (int) $instance["{$type}_count"], "types" => isset($options->type) ? $options->type : "star");
                    $since_created = isset($instance["{$type}_since_created"]) ? (int) $instance["{$type}_since_created"] : WP_RW__TIME_ALL_TIME;
                    // since_created should be at least 24 hours (86400 seconds), skip otherwise.
                    if ($since_created >= WP_RW__TIME_24_HOURS_IN_SEC) {
                        $time = current_time('timestamp', true) - $since_created;
                        // c: ISO 8601 full date/time, e.g.: 2004-02-12T15:19:21+00:00
                        $queries[$type]['since_created'] = date('c', $time);
                    }
                }
            }
            $details["queries"] = urlencode(json_encode($queries));
            $rw_ret_obj = ratingwidget()->RemoteCall("action/query/ratings.php", $details, WP_RW__CACHE_TIMEOUT_TOP_RATED);
            if (false === $rw_ret_obj) {
                return;
            }
            $rw_ret_obj = json_decode($rw_ret_obj);
            if (null === $rw_ret_obj || true !== $rw_ret_obj->success) {
                return;
            }
            $title = empty($instance['title']) ? __('Top Rated', WP_RW__ID) : apply_filters('widget_title', $instance['title']);
            $titleMaxLength = isset($instance['title_max_length']) && is_numeric($instance['title_max_length']) ? (int) $instance['title_max_length'] : 30;
            $empty = true;
            $toprated_data = new stdClass();
            $toprated_data->id = rand(1, 100);
            $toprated_data->title = array('label' => $title, 'show' => true, 'before' => $this->EncodeHtml($before_title), 'after' => $this->EncodeHtml($after_title));
            $toprated_data->options = array('align' => 'vertical', 'direction' => 'ltr', 'html' => array('before' => $this->EncodeHtml($before_widget), 'after' => $this->EncodeHtml($after_widget)));
            $toprated_data->site = array('id' => WP_RW__SITE_ID, 'domain' => $_SERVER['HTTP_HOST'], 'type' => 'WordPress');
            $toprated_data->itemGroups = array();
            if (count($rw_ret_obj->data) > 0) {
                foreach ($rw_ret_obj->data as $type => $ratings) {
                    if (is_array($ratings) && count($ratings) > 0) {
                        $item_group = new stdClass();
                        $item_group->type = $type;
                        $item_group->title = $instance["{$type}_title"];
                        $item_group->showTitle = 1 === $instance["show_{$type}_title"] && '' !== trim($item_group->title);
                        if (is_numeric($instance["{$type}_style"])) {
                            switch ($instance["{$type}_style"]) {
                                case 0:
                                    $instance["{$type}_style"] = 'legacy';
                                    break;
                                case 1:
                                default:
                                    $instance["{$type}_style"] = 'thumbs';
                                    break;
                            }
                        }
                        $item_group->style = $instance["{$type}_style"];
                        $item_group->options = array('title' => array('maxLen' => $titleMaxLength));
                        $item_group->items = array();
                        $has_thumb = strtolower($instance["{$type}_style"]) !== 'legacy';
                        $thumb_width = 160;
                        $thumb_height = 100;
                        if ($has_thumb) {
                            switch ($instance["{$type}_style"]) {
                                case '2':
                                case 'compact_thumbs':
                                    $thumb_width = 50;
                                    $thumb_height = 40;
                                    break;
                                case '1':
                                case 'thumbs':
                                default:
                                    $thumb_width = 160;
                                    $thumb_height = 100;
                                    break;
                            }
                            $item_group->options['thumb'] = array('width' => $thumb_width, 'height' => $thumb_height);
                        }
                        $cell = 0;
                        foreach ($ratings as $rating) {
                            $urid = $rating->urid;
                            $rclass = $types[$type]["rclass"];
                            $rclasses[$rclass] = true;
                            $extension_type = false;
                            if (RWLogger::IsOn()) {
                                RWLogger::Log('HANDLED_ITEM', 'Urid = ' . $urid . '; Class = ' . $rclass . ';');
                            }
                            if ('posts' === $type || 'pages' === $type) {
                                $post = null;
                                $id = RatingWidgetPlugin::Urid2PostId($urid);
                                $status = @get_post_status($id);
                                if (false === $status) {
                                    if (RWLogger::IsOn()) {
                                        RWLogger::Log('POST_NOT_EXIST', $id);
                                    }
                                    // Post not exist.
                                    continue;
                                } else {
                                    if ('publish' !== $status && 'private' !== $status) {
                                        if (RWLogger::IsOn()) {
                                            RWLogger::Log('POST_NOT_VISIBLE', 'status = ' . $status);
                                        }
                                        // Post not yet published.
                                        continue;
                                    } else {
                                        if ('private' === $status && !is_user_logged_in()) {
                                            if (RWLogger::IsOn()) {
                                                RWLogger::Log('RatingWidgetPlugin_TopRatedWidget::widget', 'POST_PRIVATE && USER_LOGGED_OUT');
                                            }
                                            // Private post but user is not logged in.
                                            continue;
                                        }
                                    }
                                }
                                $post = @get_post($id);
                                $title = trim(strip_tags($post->post_title));
                                $permalink = get_permalink($post->ID);
                            } else {
                                if ('comments' === $type) {
                                    $comment = null;
                                    $id = RatingWidgetPlugin::Urid2CommentId($urid);
                                    $status = @wp_get_comment_status($id);
                                    if (false === $status) {
                                        if (RWLogger::IsOn()) {
                                            RWLogger::Log('COMMENT_NOT_EXIST', $id);
                                        }
                                        // Comment not exist.
                                        continue;
                                    } else {
                                        if ('approved' !== $status) {
                                            if (RWLogger::IsOn()) {
                                                RWLogger::Log('COMMENT_NOT_VISIBLE', 'status = ' . $status);
                                            }
                                            // Comment not approved.
                                            continue;
                                        }
                                    }
                                    $comment = @get_comment($id);
                                    $title = trim(strip_tags($comment->comment_content));
                                    $permalink = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
                                } else {
                                    if ('activity_updates' === $type || 'activity_comments' === $type) {
                                        $id = RatingWidgetPlugin::Urid2ActivityId($urid);
                                        $activity = new bp_activity_activity($id);
                                        if (!is_object($activity)) {
                                            if (RWLogger::IsOn()) {
                                                RWLogger::Log('BP_ACTIVITY_NOT_EXIST', $id);
                                            }
                                            // Activity not exist.
                                            continue;
                                        } else {
                                            if (!empty($activity->is_spam)) {
                                                if (RWLogger::IsOn()) {
                                                    RWLogger::Log('BP_ACTIVITY_NOT_VISIBLE (SPAM or TRASH)');
                                                }
                                                // Activity marked as SPAM or TRASH.
                                                continue;
                                            } else {
                                                if (!empty($activity->hide_sitewide)) {
                                                    if (RWLogger::IsOn()) {
                                                        RWLogger::Log('BP_ACTIVITY_HIDE_SITEWIDE');
                                                    }
                                                    // Activity marked as hidden in site.
                                                    continue;
                                                }
                                            }
                                        }
                                        $title = trim(strip_tags($activity->content));
                                        $permalink = bp_activity_get_permalink($id);
                                    } else {
                                        if ('users' === $type) {
                                            $id = RatingWidgetPlugin::Urid2UserId($urid);
                                            if ($bpInstalled) {
                                                $title = trim(strip_tags(bp_core_get_user_displayname($id)));
                                                $permalink = bp_core_get_user_domain($id);
                                            } else {
                                                if ($bbInstalled) {
                                                    $title = trim(strip_tags(bbp_get_user_display_name($id)));
                                                    $permalink = bbp_get_user_profile_url($id);
                                                } else {
                                                    continue;
                                                }
                                            }
                                        } else {
                                            if ('forum_posts' === $type || 'forum_replies' === $type) {
                                                $id = RatingWidgetPlugin::Urid2ForumPostId($urid);
                                                if (function_exists('bp_forums_get_post')) {
                                                    $forum_post = @bp_forums_get_post($id);
                                                    if (!is_object($forum_post)) {
                                                        continue;
                                                    }
                                                    $title = trim(strip_tags($forum_post->post_text));
                                                    $page = bb_get_page_number($forum_post->post_position);
                                                    $permalink = get_topic_link($id, $page) . "#post-{$id}";
                                                } else {
                                                    if (function_exists('bbp_get_reply_id')) {
                                                        $forum_item = bbp_get_topic();
                                                        if (is_object($forum_item)) {
                                                            $is_topic = true;
                                                        } else {
                                                            $is_topic = false;
                                                            $forum_item = bbp_get_reply($id);
                                                            if (!is_object($forum_item)) {
                                                                if (RWLogger::IsOn()) {
                                                                    RWLogger::Log('BBP_FORUM_ITEM_NOT_EXIST', $id);
                                                                }
                                                                // Invalid id (no topic nor reply).
                                                                continue;
                                                            }
                                                            if (RWLogger::IsOn()) {
                                                                RWLogger::Log('BBP_IS_TOPIC_REPLY', $is_topic ? 'FALSE' : 'TRUE');
                                                            }
                                                        }
                                                        // Visible statueses: Public or Closed.
                                                        $visible_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id());
                                                        if (!in_array($forum_item->post_status, $visible_statuses)) {
                                                            if (RWLogger::IsOn()) {
                                                                RWLogger::Log('BBP_FORUM_ITEM_HIDDEN', $forum_item->post_status);
                                                            }
                                                            // Item is not public nor closed.
                                                            continue;
                                                        }
                                                        $is_reply = !$is_topic;
                                                        if ($is_reply) {
                                                            // Get parent topic.
                                                            $forum_topic = bbp_get_topic($forum_post->post_parent);
                                                            if (!in_array($forum_topic->post_status, $visible_statuses)) {
                                                                if (RWLogger::IsOn()) {
                                                                    RWLogger::Log('BBP_PARENT_FORUM_TOPIC_IS_HIDDEN', 'TRUE');
                                                                }
                                                                // Parent topic is not public nor closed.
                                                                continue;
                                                            }
                                                        }
                                                        $title = trim(strip_tags($forum_post->post_title));
                                                        $permalink = get_permalink($forum_post->ID);
                                                    } else {
                                                        continue;
                                                    }
                                                }
                                                $types[$type]['handler']->GetElementInfoByRating();
                                            } else {
                                                $found_handler = false;
                                                $extensions = ratingwidget()->GetExtensions();
                                                foreach ($extensions as $ext) {
                                                    $result = $ext->GetElementInfoByRating($type, $rating);
                                                    if (false !== $result) {
                                                        $found_handler = true;
                                                        break;
                                                    }
                                                }
                                                if ($found_handler) {
                                                    $id = $result['id'];
                                                    $title = $result['title'];
                                                    $permalink = $result['permalink'];
                                                    $img = rw_get_thumb_url($result['img'], $thumb_width, $thumb_height, $result['permalink']);
                                                    $extension_type = true;
                                                } else {
                                                    continue;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            $queued = ratingwidget()->QueueRatingData($urid, "", "", $rclass);
                            // Override rating class in case the same rating has already been queued with a different rclass.
                            $rclass = $queued['rclass'];
                            $short = mb_strlen($title) > $titleMaxLength ? trim(mb_substr($title, 0, $titleMaxLength)) . "..." : $title;
                            $item = array('site' => array('id' => WP_RW__SITE_ID, 'domain' => $_SERVER['HTTP_HOST']), 'page' => array('externalID' => $id, 'url' => $permalink, 'title' => $short), 'rating' => array('localID' => $urid, 'options' => array('rclass' => $rclass)));
                            // Add thumb url.
                            if ($extension_type && is_string($img)) {
                                $item['page']['img'] = $img;
                            } else {
                                if ($has_thumb && in_array($type, array('posts', 'pages'))) {
                                    $item['page']['img'] = rw_get_post_thumb_url($post, $thumb_width, $thumb_height);
                                }
                            }
                            $item_group->items[] = $item;
                            $cell++;
                            $empty = false;
                        }
                        $toprated_data->itemGroups[] = $item_group;
                    }
                }
            }
            if (true === $empty) {
                //            echo '<p style="margin: 0;">There are no rated items for this period.</p>';
                //        echo $before_widget;
                //        echo $after_widget;
            } else {
                // Set a flag that the widget is loaded.
                ratingwidget()->TopRatedWidgetLoaded();
                ?>
					<b class="rw-ui-recommendations" data-id="<?php 
                echo $toprated_data->id;
                ?>
"></b>
					<script type="text/javascript">
						var _rwq = _rwq || [];
						_rwq.push(['_setRecommendations', <?php 
                echo json_encode($toprated_data);
                ?>
]);
					</script>
				<?php 
            }
        }
Esempio n. 25
0
    ?>
    <div class="fullwidth">
			<a id="author-avatar" href="<?php 
    bbp_user_profile_url(bbp_get_current_user_id());
    ?>
">
				<?php 
    echo get_avatar(bbp_get_current_user_id(), '64');
    ?>
			</a>
			<h4>Welcome back, <?php 
    bbp_user_profile_link(bbp_get_current_user_id());
    ?>
!</h4>
				<a href="<?php 
    echo bbp_get_user_profile_url(bbp_get_current_user_id());
    ?>
">Your Profile</a>
				 | 
				<a href="<?php 
    echo wp_logout_url();
    ?>
" title="Log Out">Logout</a>
			<div class="clear"></div>
		</div>
		
		<?php 
} else {
    ?>
			
    <div class="one_third">
Esempio n. 26
0
 /**
  * @group bbp_make_clickable_misses
  * @group bbp_make_clickable_multiple
  * @covers ::bbp_make_clickable
  */
 public function test_bbp_make_clickable_multiple_mention_misses()
 {
     $u1 = $this->factory->user->create(array('user_login' => 'foobarbaz', 'user_nicename' => 'foobarbaz'));
     $u2 = $this->factory->user->create(array('user_login' => 'foo2', 'user_nicename' => 'foo2'));
     // Create the link to the user's profile
     $user_1 = get_userdata($u1);
     $url_1 = bbp_get_user_profile_url($user_1->ID);
     $anchor_1 = '<a href="%1$s" rel="nofollow">@%2$s</a>';
     $name_1 = $user_1->user_nicename;
     $link_1 = sprintf($anchor_1, esc_url($url_1), esc_html($name_1));
     $user_2 = get_userdata($u2);
     $url_2 = bbp_get_user_profile_url($user_2->ID);
     $anchor_2 = '<a href="%1$s" rel="nofollow">@%2$s</a>';
     $name_2 = $user_2->user_nicename;
     $link_2 = sprintf($anchor_2, esc_url($url_2), esc_html($name_2));
     // Multiples
     $at_name_in_mailto = sprintf("Send messages to @%s, @non1, @%s, @non2.", $link_1, $link_2);
     $at_name_in_mailto_final = sprintf("Send messages to @%s, @non1, @%s, @non2.", $link_1, $link_2);
     $this->assertEquals($at_name_in_mailto_final, bbp_make_clickable($at_name_in_mailto));
 }
Esempio n. 27
0
 /**
  * Runs through the various bbPress conditional tags to check the current page being viewed.  Once
  * a condition is met, add items to the $items array.
  *
  * @since  0.6.0
  * @access public
  * @return void
  */
 public function do_trail_items()
 {
     /* Add the network and site home links. */
     $this->do_network_home_link();
     $this->do_site_home_link();
     /* Get the forum post type object. */
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     /* If not viewing the forum root/archive page and a forum archive exists, add it. */
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $this->items[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
     }
     /* If viewing the forum root/archive. */
     if (bbp_is_forum_archive()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_forum_archive_title();
         }
     } elseif (bbp_is_topic_archive()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_archive_title();
         }
     } elseif (bbp_is_topic_tag()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_tag_name();
         }
     } elseif (bbp_is_topic_tag_edit()) {
         $this->items[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
         if (true === $this->args['show_title']) {
             $this->items[] = __('Edit', 'breadcrumb-trail');
         }
     } elseif (bbp_is_single_view()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_view_title();
         }
     } elseif (bbp_is_single_topic()) {
         /* Get the queried topic. */
         $topic_id = get_queried_object_id();
         /* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
         $this->do_post_parents(bbp_get_topic_forum_id($topic_id));
         /* If viewing a split, merge, or edit topic page, show the link back to the topic.  Else, display topic title. */
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $this->items[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_title($topic_id);
         }
         /* If viewing a topic split page. */
         if (bbp_is_topic_split() && true === $this->args['show_title']) {
             $this->items[] = __('Split', 'breadcrumb-trail');
         } elseif (bbp_is_topic_merge() && true === $this->args['show_title']) {
             $this->items[] = __('Merge', 'breadcrumb-trail');
         } elseif (bbp_is_topic_edit() && true === $this->args['show_title']) {
             $this->items[] = __('Edit', 'breadcrumb-trail');
         }
     } elseif (bbp_is_single_reply()) {
         /* Get the queried reply object ID. */
         $reply_id = get_queried_object_id();
         /* Get the parent items for the reply, which should be its topic. */
         $this->do_post_parents(bbp_get_reply_topic_id($reply_id));
         /* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
         if (bbp_is_reply_edit()) {
             $this->items[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
             if (true === $this->args['show_title']) {
                 $this->items[] = __('Edit', 'breadcrumb-trail');
             }
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_reply_title($reply_id);
         }
     } elseif (bbp_is_single_forum()) {
         /* Get the queried forum ID and its parent forum ID. */
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         /* If the forum has a parent forum, get its parent(s). */
         if (0 !== $forum_parent_id) {
             $this->do_post_parents($forum_parent_id);
         }
         /* Add the forum title to the end of the trail. */
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_forum_title($forum_id);
         }
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $this->items[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
             if (true === $this->args['show_title']) {
                 $this->items[] = __('Edit', 'breadcrumb-trail');
             }
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_displayed_user_field('display_name');
         }
     }
     /* Return the bbPress breadcrumb trail items. */
     $this->items = apply_filters('breadcrumb_trail_get_bbpress_items', $this->items, $this->args);
 }
 /**
  * The shortcode handler for the [show_avatar] shortcode.
  *
  * Example: [show_avatar id=pbearne@tycoelectronics.com avatar_size=30 align=right]
  */
 function shortcode_handler($atts, $content = null)
 {
     $extraClass = "";
     $hrefStart = "";
     $name = "";
     $bio = "";
     $style = "";
     $email = "";
     $link = "";
     $id = '';
     // get id or email
     if (!empty($atts['id'])) {
         $id = preg_replace('[^\\w\\.\\@\\-]', '', $atts['id']);
     }
     if (empty($id) && !empty($atts['email'])) {
         $id = preg_replace('[^\\w\\.\\@\\-]', '', $atts['email']);
     }
     // get avatar size
     $avatar_size = false;
     if (!empty($atts['avatar_size'])) {
         $avatar_size = intval($atts['avatar_size']);
     }
     // get alignment
     if (!empty($atts['align'])) {
         switch ($atts['align']) {
             case 'left':
                 $style = "float: left; margin-right: 10px;";
                 break;
             case 'right':
                 $style = "float: right; margin-left: 10px;";
                 break;
             case 'center':
                 $style = "text-align: center; width: 100%;";
                 break;
         }
     }
     if (!empty($id)) {
         $avatar = get_avatar($id, $avatar_size);
     } else {
         $avatar = __("[show_author shortcode: please set id/email attribute]");
     }
     // is there an user link request
     if (!empty($atts['user_link']) || !empty($atts['show_biography']) || !empty($atts['show_postcount']) || !empty($atts['show_name']) || !empty($atts['show_email'])) {
         // try to fetch user profile
         $isUser = true;
         if (!is_numeric($id)) {
             if (email_exists($id)) {
                 $id = email_exists($id);
             } else {
                 $isUser = false;
             }
         }
         if ($isUser) {
             $all_meta_for_user = get_user_meta($id);
             if (count($all_meta_for_user) == 0) {
                 $isUser = false;
             }
         }
         if ($isUser) {
             if (!empty($atts['user_link'])) {
                 switch ($atts['user_link']) {
                     case 'authorpage':
                         $link = get_author_posts_url($id);
                         break;
                     case 'website':
                         $link = get_the_author_meta('user_url', $id);
                         if (empty($link) || $link == 'http://') {
                             $link = false;
                         }
                         break;
                     case 'blog':
                         if (AA_is_wpmu()) {
                             $blog = get_active_blog_for_user($id);
                             if (!empty($blog->siteurl)) {
                                 $link = $blog->siteurl;
                             }
                         }
                         break;
                     case 'bp_memberpage':
                         if (function_exists('bp_core_get_user_domain')) {
                             $link = bp_core_get_user_domain($id);
                         } elseif (function_exists('bp_core_get_userurl')) {
                             // BP versions < 1.1
                             $link = bp_core_get_userurl($id);
                         }
                         break;
                     case 'bbpress_memberpage':
                         if (function_exists('bbp_get_user_profile_url')) {
                             $link = bbp_get_user_profile_url($id);
                         }
                         if (empty($link) || $link == 'http://') {
                             $link = false;
                         }
                         break;
                 }
                 if ($link) {
                     $hrefStart = '<a href="' . $link . '">';
                 }
             }
             if (!empty($atts['show_name'])) {
                 $name = '<br />' . get_the_author_meta('display_name', $id);
                 $extraClass .= ' with-name';
             }
             if (!empty($atts['show_email'])) {
                 $userEmail = get_the_author_meta('user_email', $id);
                 $email = "<div class='email'><a href='mailto:" . $userEmail . "''>" . $userEmail . "</a></div>";
                 if (empty($email)) {
                     $extraClass .= 'email-missing';
                 } else {
                     $extraClass .= ' with-email';
                 }
             }
             if (!empty($atts['show_postcount'])) {
                 require_once 'UserList.class.php';
                 $this->userlist = new UserList();
                 $name .= ' (' . ($postcount = $this->userlist->get_user_postcount($id) . ')');
             }
             if (!empty($atts['show_bbpress_post_count'])) {
                 if (function_exists('bbp_get_user_topic_count_raw')) {
                     $BBPRESS_postcount = bbp_get_user_topic_count_raw($id) + bbp_get_user_reply_count_raw($id);
                     $name .= ' (' . ($postcount = $BBPRESS_postcount . ')');
                 }
             }
             if (!empty($atts['show_biography'])) {
                 $bio = get_the_author_meta('description', $id);
                 if (!empty($atts['show_name'])) {
                     $bio = '<div class="bio">' . $bio . '</div>';
                 }
                 if (empty($bio)) {
                     $extraClass .= 'biography-missing';
                 } else {
                     $extraClass .= ' with-biography';
                 }
             }
         }
     }
     $hrefend = '';
     if (!empty($hrefStart)) {
         $hrefend = '</a>';
     }
     if (!empty($style)) {
         $style = ' style="' . $style . '"';
     }
     return '<div class="shortcode-show-avatar ' . $extraClass . '"' . $style . '>' . $hrefStart . $avatar . $name . $hrefend . $bio . $email . '</div>' . $content;
 }
Esempio n. 29
0
function kleo_bp_replace_placeholders($output)
{
    $initial_output = $output;
    if (strpos($output, '##profile_link##') !== false) {
        if (!is_user_logged_in()) {
            return '';
        }
        if (function_exists('bp_is_active')) {
            $logged_in_link = bp_loggedin_user_domain('/');
            $output = str_replace('##profile_link##', $logged_in_link, $output);
        } elseif (class_exists('bbPress')) {
            //$logged_in_link = bb_get_profile_link();
            $logged_in_link = bbp_get_user_profile_url(bbp_get_current_user_id());
            $output = str_replace('##profile_link##', $logged_in_link, $output);
        }
    }
    if (strpos($output, '##member_name##') !== false) {
        if (!is_user_logged_in()) {
            return '';
        }
        if (function_exists('bp_is_active')) {
            $logged_in_username = bp_get_loggedin_user_fullname();
            $output = str_replace('##member_name##', $logged_in_username, $output);
        } elseif (class_exists('bbPress')) {
            $logged_in_username = bbp_get_user_nicename(bbp_get_current_user_id());
            $output = str_replace('##member_name##', $logged_in_username, $output);
        }
    }
    $output = apply_filters('kleo_bp_replace_placeholders', $output, $initial_output);
    return $output;
}
Esempio n. 30
0
/**
 * Return the author link of the post
 *
 * @since 2.0.0 bbPress (r2875)
 *
 * @param array $args Optional. If an integer, it is used as reply id.
 * @uses bbp_is_topic() To check if it's a topic page
 * @uses bbp_get_topic_author_link() To get the topic author link
 * @uses bbp_is_reply() To check if it's a reply page
 * @uses bbp_get_reply_author_link() To get the reply author link
 * @uses get_post_field() To get the post author
 * @uses bbp_is_reply_anonymous() To check if the reply is by an
 *                                 anonymous user
 * @uses get_the_author_meta() To get the author name
 * @uses bbp_get_user_profile_url() To get the author profile url
 * @uses get_avatar() To get the author avatar
 * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the
 *                        author link and args
 * @return string Author link of reply
 */
function bbp_get_author_link($args = array())
{
    $post_id = is_numeric($args) ? (int) $args : 0;
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('post_id' => $post_id, 'link_title' => '', 'type' => 'both', 'size' => 80), 'get_author_link');
    // Confirmed topic
    if (bbp_is_topic($r['post_id'])) {
        return bbp_get_topic_author_link($r);
        // Confirmed reply
    } elseif (bbp_is_reply($r['post_id'])) {
        return bbp_get_reply_author_link($r);
    }
    // Get the post author and proceed
    $user_id = get_post_field('post_author', $r['post_id']);
    // Neither a reply nor a topic, so could be a revision
    if (!empty($r['post_id'])) {
        // Generate title with the display name of the author
        if (empty($r['link_title'])) {
            $r['link_title'] = sprintf(!bbp_is_reply_anonymous($r['post_id']) ? __('View %s\'s profile', 'bbpress') : __('Visit %s\'s website', 'bbpress'), get_the_author_meta('display_name', $user_id));
        }
        // Assemble some link bits
        $link_title = !empty($r['link_title']) ? ' title="' . esc_attr($r['link_title']) . '"' : '';
        $anonymous = bbp_is_reply_anonymous($r['post_id']);
        // Declare empty array
        $author_links = array();
        // Get avatar
        if ('avatar' === $r['type'] || 'both' === $r['type']) {
            $author_links[] = get_avatar($user_id, $r['size']);
        }
        // Get display name
        if ('name' === $r['type'] || 'both' === $r['type']) {
            $author_links[] = esc_html(get_the_author_meta('display_name', $user_id));
        }
        // Add links if not anonymous
        if (empty($anonymous) && bbp_user_has_profile($user_id)) {
            $author_url = bbp_get_user_profile_url($user_id);
            foreach ($author_links as $link_text) {
                $author_link[] = sprintf('<a href="%1$s"%2$s>%3$s</a>', esc_url($author_url), $link_title, $link_text);
            }
            $author_link = implode('&nbsp;', $author_link);
            // No links if anonymous
        } else {
            $author_link = implode('&nbsp;', $author_links);
        }
        // No post so link is empty
    } else {
        $author_link = '';
    }
    return apply_filters('bbp_get_author_link', $author_link, $r);
}