/** * Validates the URL to determine if the activity item is valid. * * @since 2.6.0 * * @param string $url The URL to check. * @return int|bool Activity ID on success; boolean false on failure. */ protected function validate_url_to_item_id($url) { if (bp_core_enable_root_profiles()) { $domain = bp_get_root_domain(); } else { $domain = bp_get_members_directory_permalink(); } // Check the URL to see if this is a single activity URL. if (0 !== strpos($url, $domain)) { return false; } // Check for activity slug. if (false === strpos($url, '/' . bp_get_activity_slug() . '/')) { return false; } // Do more checks. $url = trim(untrailingslashit($url)); // Grab the activity ID. $activity_id = (int) substr($url, strrpos($url, '/') + 1); if (!empty($activity_id)) { // Check if activity item still exists. $activity = new BP_Activity_Activity($activity_id); // Okay, we're good to go! if (!empty($activity->component) && 0 === (int) $activity->is_spam) { return $activity_id; } } return false; }
function bpg_init() { require_once dirname(__FILE__) . '/includes/functions.php'; if (defined('BP_VERSION') && defined('WPGLOBUS_VERSION')) { $apply_filters = false; //TOFIX // Always on frontend if (!is_admin() || $apply_filters) { $optionLanguages = wpgl_get_option_language(); $defaultLanguage = wpgl_get_default_language($optionLanguages); $currentLanguage = wpgl_get_current_language($optionLanguages); if ($currentLanguage != $defaultLanguage) { apply_filters('bp_get_groups_directory_permalink', trailingslashit(bp_get_groups_directory_permalink() . $currentLanguage . '/')); apply_filters('bp_get_activity_directory_permalink', trailingslashit(bp_get_activity_directory_permalink() . $currentLanguage . '/')); apply_filters('bp_get_blogs_directory_permalink', trailingslashit(bp_get_blogs_directory_permalink() . $currentLanguage . '/')); apply_filters('bp_get_forum_directory_permalink', trailingslashit(bp_get_forum_directory_permalink() . $currentLanguage . '/')); apply_filters('bp_get_members_directory_permalink', trailingslashit(bp_get_members_directory_permalink() . $currentLanguage . '/')); } } } else { if (is_admin()) { add_action('admin_notices', 'bpgl_admin_notice_required_plugins'); } } }
function kleo_bp_member_types_tabs() { if (!bp_get_current_member_type()) { $member_types = bp_get_member_types(array(), 'objects'); if ($member_types) { foreach ($member_types as $member_type) { if ($member_type->has_directory == 1) { echo '<li id="members-' . esc_attr($member_type->name) . '" class="bp-member-type-filter">'; echo '<a href="' . bp_get_members_directory_permalink() . 'type/' . $member_type->directory_slug . '/">' . sprintf('%s <span>%d</span>', $member_type->labels['name'], kleo_bp_count_member_types($member_type->name)) . '</a>'; echo '</li>'; } } } } }
/** * Output member directory permalink * * @package BuddyPress * @subpackage Members Template * @since 1.5 * @uses bp_get_members_directory_permalink() */ function bp_members_directory_permalink() { echo bp_get_members_directory_permalink(); }
function x_buddypress_navbar_menu($items, $args) { if (X_BUDDYPRESS_IS_ACTIVE && x_get_option('x_buddypress_header_menu_enable', '') == '1') { $top_level_link = is_user_logged_in() ? bp_loggedin_user_domain() : bp_get_activity_directory_permalink(); $submenu_items = ''; if (bp_is_active('activity')) { $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activity_directory_permalink() . '" class="cf"><i class="x-icon-thumbs-up" data-x-icon=""></i> <span>' . x_get_option('x_buddypress_activity_title', __('Activity', '__x__')) . '</span></a></li>'; } if (bp_is_active('groups')) { $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_groups_directory_permalink() . '" class="cf"><i class="x-icon-sitemap" data-x-icon=""></i> <span>' . x_get_option('x_buddypress_groups_title', __('Groups', '__x__')) . '</span></a></li>'; } if (is_multisite() && bp_is_active('blogs')) { $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_blogs_directory_permalink() . '" class="cf"><i class="x-icon-file" data-x-icon=""></i> <span>' . x_get_option('x_buddypress_blogs_title', __('Blogs', '__x__')) . '</span></a></li>'; } $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_members_directory_permalink() . '" class="cf"><i class="x-icon-male" data-x-icon=""></i> <span>' . x_get_option('x_buddypress_members_title', __('Members', '__x__')) . '</span></a></li>'; if (!is_user_logged_in()) { if (bp_get_signup_allowed()) { $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_signup_page() . '" class="cf"><i class="x-icon-pencil" data-x-icon=""></i> <span>' . x_get_option('x_buddypress_register_title', __('Create an Account', '__x__')) . '</span></a></li>'; $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activation_page() . '" class="cf"><i class="x-icon-key" data-x-icon=""></i> <span>' . x_get_option('x_buddypress_activate_title', __('Activate Your Account', '__x__')) . '</span></a></li>'; } $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . wp_login_url() . '" class="cf"><i class="x-icon-sign-in" data-x-icon=""></i> <span>' . __('Log in', '__x__') . '</span></a></li>'; } else { $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_loggedin_user_domain() . '" class="cf"><i class="x-icon-cog" data-x-icon=""></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-buddypress">' . '<a href="' . $top_level_link . '" class="x-btn-navbar-buddypress">' . '<span><i class="x-icon-user" data-x-icon=""></i><span class="x-hidden-desktop"> ' . __('Social', '__x__') . '</span></span>' . '</a>' . '<ul class="sub-menu">' . $submenu_items . '</ul>' . '</li>'; } } return $items; }
/** * Runs through the various buddyPress 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() { global $bp; /* Add the network and site home links. */ $this->do_network_home_link(); $this->do_site_home_link(); $trail_end = ''; if (!empty($bp->displayed_user->fullname)) { // looking at a user or self $this->items[] = '<a href="' . bp_get_members_directory_permalink() . '">' . get_the_title($bp->pages->members->id) . '</a>'; $this->items[] = '<a href="' . $bp->displayed_user->domain . '" title="' . strip_tags($bp->displayed_user->userdata->display_name) . '">' . strip_tags($bp->displayed_user->userdata->display_name) . '</a>'; } else { if ($bp->is_single_item) { // we're on a single item page $this->items[] = '<a href="' . get_permalink($bp->pages->{$bp->current_component}->id) . '" title="' . esc_attr(strip_tags(get_the_title($bp->pages->{$bp->current_component}->id))) . '">' . get_the_title($bp->pages->{$bp->current_component}->id) . '</a>'; $this->items[] = '<a href="' . get_permalink() . '" title="' . esc_attr($bp->bp_options_title) . '">' . $bp->bp_options_title . '</a>'; } else { if ($bp->is_directory) { // this is a top level directory page $trail_end = get_the_title($bp->pages->{$bp->current_component}->id); } else { if (bp_is_register_page()) { $trail_end = __('Create an Account', 'buddypress'); } else { if (bp_is_activation_page()) { $trail_end = __('Activate your Account', 'buddypress'); } else { if (bp_is_group_create()) { $this->items[] = '<a href="' . get_permalink($bp->pages->groups->id) . '" title="' . esc_attr(get_the_title($bp->pages->groups->id)) . '">' . get_the_title($bp->pages->groups->id) . '</a>'; $trail_end = __('Create a Group', 'buddypress'); } else { if (bp_is_create_blog()) { $this->items[] = '<a href="' . home_url() . '/' . $bp->current_component . '" title="' . ucwords($bp->current_component) . '">' . ucwords($bp->current_component) . '</a>'; $trail_end = __('Create a Blog', 'buddypress'); } } } } } } } if ($trail_end) { $this->items[] = $trail_end; } /* Return the bbPress breadcrumb trail items. */ $this->items = apply_filters('breadcrumb_trail_get_buddypress_items', $this->items, $this->args); }
/** * Return the linked name of the user who last posted to the current topic in the loop. * * @since 1.0.0 * * @return string HTML link to the profile of the user who last posted * to the current topic. */ function bp_get_the_topic_last_poster_name() { global $forum_template; $domain = bp_core_get_user_domain($forum_template->topic->topic_last_poster, $forum_template->topic->topic_last_poster_nicename, $forum_template->topic->topic_last_poster_login); // In the case where no user is found, bp_core_get_user_domain() may return the URL // of the Members directory. if (empty($domain) || bp_get_members_directory_permalink() === $domain) { return __('Deleted User', 'buddypress'); } /** * Filters the linked name of the user who last posted to the current topic in the loop. * * @since 1.0.0 * * @param string $value HTML link to the profile of the user who last posted. */ return apply_filters('bp_get_the_topic_last_poster_name', '<a href="' . $domain . '">' . $forum_template->topic->topic_last_poster_displayname . '</a>'); }
/** * Display the Members widget. * * @since 1.0.3 * * @see WP_Widget::widget() for description of parameters. * * @param array $args Widget arguments. * @param array $instance Widget settings, as saved by the user. */ public function widget($args, $instance) { global $members_template; // Get widget settings. $settings = $this->parse_settings($instance); /** * Filters the title of the Members widget. * * @since 1.8.0 * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter. * * @param string $title The widget title. * @param array $settings The settings for the particular instance of the widget. * @param string $id_base Root ID for all widgets of this type. */ $title = apply_filters('widget_title', $settings['title'], $settings, $this->id_base); $title = $settings['link_title'] ? '<a href="' . bp_get_members_directory_permalink() . '">' . $title . '</a>' : $title; /** * Filters the separator of the member widget links. * * @since 2.4.0 * * @param string $separator Separator string. Default '|'. */ $separator = apply_filters('bp_members_widget_separator', '|'); // Output before widget HTMl, title (and maybe content before & after it). echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title']; // Setup args for querying members. $members_args = array('user_id' => 0, 'type' => $settings['member_default'], 'per_page' => $settings['max_members'], 'max' => $settings['max_members'], 'populate_extras' => true, 'search_terms' => false); // Back up the global. $old_members_template = $members_template; ?> <?php if (bp_has_members($members_args)) { ?> <div class="item-options" id="members-list-options"> <a href="<?php bp_members_directory_permalink(); ?> " id="newest-members" <?php if ('newest' === $settings['member_default']) { ?> class="selected"<?php } ?> ><?php esc_html_e('Newest', 'buddypress'); ?> </a> <span class="bp-separator" role="separator"><?php echo esc_html($separator); ?> </span> <a href="<?php bp_members_directory_permalink(); ?> " id="recently-active-members" <?php if ('active' === $settings['member_default']) { ?> class="selected"<?php } ?> ><?php esc_html_e('Active', 'buddypress'); ?> </a> <?php if (bp_is_active('friends')) { ?> <span class="bp-separator" role="separator"><?php echo esc_html($separator); ?> </span> <a href="<?php bp_members_directory_permalink(); ?> " id="popular-members" <?php if ('popular' === $settings['member_default']) { ?> class="selected"<?php } ?> ><?php esc_html_e('Popular', 'buddypress'); ?> </a> <?php } ?> </div> <ul id="members-list" class="item-list" aria-live="polite" aria-relevant="all" aria-atomic="true"> <?php while (bp_members()) { bp_the_member(); ?> <li class="vcard"> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_avatar(); ?> </a> </div> <div class="item"> <div class="item-title fn"><a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_name(); ?> </a></div> <div class="item-meta"> <?php if ('newest' == $settings['member_default']) { ?> <span class="activity" data-livestamp="<?php bp_core_iso8601_date(bp_get_member_registered(array('relative' => false))); ?> "><?php bp_member_registered(); ?> </span> <?php } elseif ('active' == $settings['member_default']) { ?> <span class="activity" data-livestamp="<?php bp_core_iso8601_date(bp_get_member_last_active(array('relative' => false))); ?> "><?php bp_member_last_active(); ?> </span> <?php } else { ?> <span class="activity"><?php bp_member_total_friend_count(); ?> </span> <?php } ?> </div> </div> </li> <?php } ?> </ul> <?php wp_nonce_field('bp_core_widget_members', '_wpnonce-members', false); ?> <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr($settings['max_members']); ?> " /> <?php } else { ?> <div class="widget-error"> <?php esc_html_e('No one has signed up yet!', 'buddypress'); ?> </div> <?php } ?> <?php echo $args['after_widget']; // Restore the global. $members_template = $old_members_template; }
/** * Handle the loading of the Activate screen. * * @todo Move the actual activation process into an action in bp-members-actions.php */ function bp_core_screen_activation() { // Bail if not viewing the activation page. if (!bp_is_current_component('activate')) { return false; } // If the user is already logged in, redirect away from here. if (is_user_logged_in()) { // If activation page is also front page, set to members directory to // avoid an infinite loop. Otherwise, set to root domain. $redirect_to = bp_is_component_front_page('activate') ? bp_get_members_directory_permalink() : bp_get_root_domain(); // Trailing slash it, as we expect these URL's to be. $redirect_to = trailingslashit($redirect_to); /** * Filters the URL to redirect logged in users to when visiting activation page. * * @since 1.9.0 * * @param string $redirect_to URL to redirect user to. */ $redirect_to = apply_filters('bp_loggedin_activate_page_redirect_to', $redirect_to); // Redirect away from the activation page. bp_core_redirect($redirect_to); } // Grab the key (the old way). $key = isset($_GET['key']) ? $_GET['key'] : ''; // Grab the key (the new way). if (empty($key)) { $key = bp_current_action(); } // Get BuddyPress. $bp = buddypress(); // We've got a key; let's attempt to activate the signup. if (!empty($key)) { /** * Filters the activation signup. * * @since 1.1.0 * * @param bool|int $value Value returned by activation. * Integer on success, boolean on failure. */ $user = apply_filters('bp_core_activate_account', bp_core_activate_signup($key)); // If there were errors, add a message and redirect. if (!empty($user->errors)) { bp_core_add_message($user->get_error_message(), 'error'); bp_core_redirect(trailingslashit(bp_get_root_domain() . '/' . $bp->pages->activate->slug)); } $hashed_key = wp_hash($key); // Check if the signup avatar folder exists. If it does, move the folder to // the BP user avatars directory. if (file_exists(bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key)) { @rename(bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user); } bp_core_add_message(__('Your account is now active!', 'buddypress')); $bp->activation_complete = true; } /** * Filters the template to load for the Member activation page screen. * * @since 1.1.1 * * @param string $value Path to the Member activation template to load. */ bp_core_load_template(apply_filters('bp_core_template_activate', array('activate', 'registration/activate'))); }
function bp_aps_wrap_value_in_link($value) { return '<a href="' . bp_get_members_directory_permalink() . '?s=' . urlencode($value) . '">' . $value . '</a>'; }
function x_breadcrumbs() { if (x_get_option('x_breadcrumb_display')) { global $post; $is_ltr = !is_rtl(); $stack = x_get_stack(); $delimiter = x_get_breadcrumb_delimiter(); $home_text = x_get_breadcrumb_home_text(); $home_link = home_url(); $current_before = x_get_breadcrumb_current_before(); $current_after = x_get_breadcrumb_current_after(); $page_title = get_the_title(); $blog_title = get_the_title(get_option('page_for_posts', true)); if (!is_404()) { $post_parent = $post->post_parent; } else { $post_parent = ''; } if (X_WOOCOMMERCE_IS_ACTIVE) { $shop_url = x_get_shop_link(); $shop_title = x_get_option('x_' . $stack . '_shop_title'); $shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>'; } echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter; if (is_home()) { echo $current_before . $blog_title . $current_after; } elseif (is_category()) { $the_cat = get_category(get_query_var('cat'), false); if ($the_cat->parent != 0) { echo get_category_parents($the_cat->parent, TRUE, $delimiter); } echo $current_before . single_cat_title('', false) . $current_after; } elseif (x_is_product_category()) { if ($is_ltr) { echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after; } else { echo $current_before . single_cat_title('', false) . $current_after . $delimiter . $shop_link; } } elseif (x_is_product_tag()) { if ($is_ltr) { echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after; } else { echo $current_before . single_tag_title('', false) . $current_after . $delimiter . $shop_link; } } elseif (is_search()) { echo $current_before . __('Search Results for ', '__x__') . '“' . get_search_query() . '”' . $current_after; } elseif (is_singular('post')) { if (get_option('page_for_posts') == is_front_page()) { echo $current_before . $page_title . $current_after; } else { if ($is_ltr) { echo '<a href="' . get_permalink(get_option('page_for_posts')) . '">' . $blog_title . '</a>' . $delimiter . $current_before . $page_title . $current_after; } else { echo $current_before . $page_title . $current_after . $delimiter . '<a href="' . get_permalink(get_option('page_for_posts')) . '">' . $blog_title . '</a>'; } } } elseif (x_is_portfolio()) { echo $current_before . get_the_title() . $current_after; } elseif (x_is_portfolio_item()) { $link = x_get_parent_portfolio_link(); $title = x_get_parent_portfolio_title(); if ($is_ltr) { echo '<a href="' . $link . '">' . $title . '</a>' . $delimiter . $current_before . $page_title . $current_after; } else { echo $current_before . $page_title . $current_after . $delimiter . '<a href="' . $link . '">' . $title . '</a>'; } } elseif (x_is_product()) { if ($is_ltr) { echo $shop_link . $delimiter . $current_before . $page_title . $current_after; } else { echo $current_before . $page_title . $current_after . $delimiter . $shop_link; } } elseif (x_is_buddypress()) { if (bp_is_group()) { echo '<a href="' . bp_get_groups_directory_permalink() . '">' . x_get_option('x_buddypress_groups_title') . '</a>' . $delimiter . $current_before . x_buddypress_get_the_title() . $current_after; } elseif (bp_is_user()) { echo '<a href="' . bp_get_members_directory_permalink() . '">' . x_get_option('x_buddypress_members_title') . '</a>' . $delimiter . $current_before . x_buddypress_get_the_title() . $current_after; } else { echo $current_before . x_buddypress_get_the_title() . $current_after; } } elseif (x_is_bbpress()) { remove_filter('bbp_no_breadcrumb', '__return_true'); if (bbp_is_forum_archive()) { echo $current_before . bbp_get_forum_archive_title() . $current_after; } else { echo bbp_get_breadcrumb(); } add_filter('bbp_no_breadcrumb', '__return_true'); } elseif (is_page() && !$post_parent) { echo $current_before . $page_title . $current_after; } elseif (is_page() && $post_parent) { $parent_id = $post_parent; $breadcrumbs = array(); if (is_rtl()) { echo $current_before . $page_title . $current_after . $delimiter; } 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; } if ($is_ltr) { $breadcrumbs = array_reverse($breadcrumbs); } for ($i = 0; $i < count($breadcrumbs); $i++) { echo $breadcrumbs[$i]; if ($i != count($breadcrumbs) - 1) { echo $delimiter; } } if ($is_ltr) { echo $delimiter . $current_before . $page_title . $current_after; } } elseif (is_tag()) { echo $current_before . single_tag_title('', false) . $current_after; } elseif (is_author()) { global $author; $userdata = get_userdata($author); echo $current_before . __('Posts by ', '__x__') . '“' . $userdata->display_name . $current_after . '”'; } elseif (is_404()) { echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after; } elseif (is_archive()) { if (x_is_shop()) { echo $current_before . $shop_title . $current_after; } else { echo $current_before . __('Archives ', '__x__') . $current_after; } } echo '</div>'; } }
function build_html() { // Get the total member count global $members_template; $total = $members_template->total_member_count; // Add everything to an array $members = array(); while (bp_members()) { bp_the_member(); $members[] = sprintf('<a href="%1$s" title="%2$s User Profile">%2$s</a>', bp_get_member_permalink(), bp_get_member_name()); } if ($total > $this->number) { $members[] = sprintf('<a href="%1$s" title="View all online members">%2$d More</a>', bp_get_members_directory_permalink(), $total - $this->number); } // Implode the members with separator $members = implode(" | ", $members); // Store everything in an output buffer ob_start(); ?> <div id="sidebar-members-widget" class="widget"> <header class="widget-header"> <h3 class="widget-title">Online Members</h3> </header> <p class="online-members"><i class="fa fa-users"></i> <?php if ($total > 1) { printf('There are currently <span class="activity-count">%d</span> members online:', $total); } elseif ($total == 1) { printf('There is currently <span class="activity-count">%d</span> member online:', $total); } else { echo 'There are currently no members online:'; } ?> </p> <p class="online-members"><?php echo $members; ?> </p> </div><?php // Get the contents of the buffer $html = ob_get_contents(); ob_end_clean(); // Return the html to the class return $html; }
/** * Remove the anchor tag autogenerated for at-mentions when forum topics and posts are edited. * * Prevents embedded anchor tags. * * @param string $content Edited post content. * @return string $content Sanitized post content. */ function bp_forums_strip_mentions_on_post_edit($content) { $content = htmlspecialchars_decode($content); $directory = bp_get_members_directory_permalink(); $pattern = "|<a href='{$directory}[A-Za-z0-9-_\\.]+/' rel='nofollow'>(@[A-Za-z0-9-_\\.@]+)</a>|"; $content = preg_replace($pattern, "\$1", $content); return $content; }
function cb_breadcrumbs($cb_padding = 'padding-on') { $cb_breadcrumb = NULL; $cb_post_type = get_post_type(); if ($cb_padding == 'padding-off') { $cb_padding_type = ' cb-padding-off'; } else { $cb_padding_type = NULL; } if (is_page() == false) { $cb_breadcrumb = '<div class="cb-breadcrumbs wrap' . $cb_padding_type . '">'; $cb_icon = '<i class="icon-angle-right"></i>'; $cb_breadcrumb .= '<a href="' . home_url() . '">' . __("Home", "cubell") . '</a>' . $cb_icon; if (is_category()) { $cb_cat_id = get_query_var('cat'); $cb_current_category = get_category($cb_cat_id); if ($cb_current_category->category_parent == '0') { $cb_breadcrumb .= '<a href="' . get_category_link($cb_current_category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $cb_current_category->name)) . '">' . $cb_current_category->name . '</a>'; } else { $cb_breadcrumb .= '<a href="' . get_category_link($cb_current_category->category_parent) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), get_the_category_by_ID($cb_current_category->category_parent))) . '">' . get_the_category_by_ID($cb_current_category->category_parent) . '</a>' . $cb_icon; $cb_breadcrumb .= '<a href="' . get_category_link($cb_current_category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $cb_current_category->name)) . '">' . $cb_current_category->name . '</a>'; } } elseif (function_exists('buddypress') && is_buddypress() == true) { global $bp; $cb_bp_output = NULL; $cb_bp_current_component = bp_current_component(); $cb_bp_current_action = bp_current_action(); if ($cb_bp_current_action != 'my-groups' && $cb_bp_current_component == 'groups') { $cb_bp_group = $bp->groups->current_group; if (!is_numeric($cb_bp_group)) { $cb_bp_group_id = $cb_bp_group->id; $cb_bp_group_name = $cb_bp_group->name; $cb_bp_group_link = bp_get_group_permalink($cb_bp_group); $cb_bp_output = '<a href="' . trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug()) . '">' . __('Groups', 'cubell') . '</a>' . $cb_icon . $cb_bp_group_name; } else { $cb_bp_output = __('Groups', 'cubell'); } $cb_breadcrumb .= $cb_bp_output; } if ($cb_bp_current_component == 'activity' || $cb_bp_current_action == 'my-groups' || $cb_bp_current_action == 'public' || $cb_bp_current_component == 'settings' || $cb_bp_current_component == 'forums' || $cb_bp_current_component == 'friends') { $cb_activity_title = get_the_title(); $cb_bp_activity = $bp->activity->current_id; $cb_bp_activity_link = bp_get_members_directory_permalink(); $cb_bp_output .= '<a href="' . $cb_bp_activity_link . '">' . __('Members', 'cubell') . '</a>' . $cb_icon . $cb_activity_title; if ($cb_bp_activity != NULL) { $cb_bp_output .= __('Members', 'cubell'); } $cb_breadcrumb .= $cb_bp_output; } if ($cb_bp_current_component == 'messages') { $cb_breadcrumb .= __('Messages', 'cubell'); } if (bp_is_directory() == true) { $cb_breadcrumb = '<div>'; } } elseif ($cb_post_type == 'post') { $cb_categories = get_the_category(); if ($cb_categories[0]->category_parent == '0') { $cb_breadcrumb .= '<a href="' . get_category_link($cb_categories[0]->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $cb_categories[0]->name)) . '">' . $cb_categories[0]->name . '</a>'; } else { $cb_breadcrumb .= '<a href="' . get_category_link($cb_categories[0]->category_parent) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), get_the_category_by_ID($cb_categories[0]->category_parent))) . '">' . get_the_category_by_ID($cb_categories[0]->category_parent) . '</a>' . $cb_icon; $cb_breadcrumb .= '<a href="' . get_category_link($cb_categories[0]->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $cb_categories[0]->name)) . '">' . $cb_categories[0]->name . '</a>'; } } $cb_breadcrumb .= '</div>'; } return $cb_breadcrumb; }
/** * Get the page context * @version 2.0 */ function get_context() { // Setup placeholders $title = SITENAME; $desc = get_bloginfo('description'); $classes = get_body_class(); $crumbs = array(); // Get some data $id = $this->queried_object_id; $object = $this->queried_object; $sep = " • "; /*-------------------------------------------- DEFAULT CONTEXT ---------------------------------------------*/ $classes[] = 0 == get_current_user_id() ? 'logged-out' : 'logged-in'; $crumbs[] = '<a href="' . SITEURL . '" title="' . SITENAME . '" rel="home" class="trail-home">Home</a>'; // Homepage if (is_home()) { $title = SITENAME . $sep . 'Home'; $classes[] = 'home'; $classes[] = 'sidebar'; $classes[] = 'archive'; /*-------------------------------------------- BUDDYPRESS CONTEXT ---------------------------------------------*/ } elseif (class_exists('BuddyPress') && is_buddypress()) { // BuddyPress Defaults $title = "BuddyPress Page"; $desc = "This is a BuddyPress page."; $classes[] = 'buddypress'; // User Profiles if (bp_is_user()) { $title = bp_get_displayed_user_fullname() . $sep . "User Profile"; $desc = SITENAME . " user profile for member " . bp_get_displayed_user_fullname(); // Your own profile if (bp_is_my_profile()) { $crumbs[] = 'Your Profile'; } else { $crumbs[] = '<a href="' . bp_get_members_directory_permalink() . '" title="Members Directory">Members</a>'; $crumbs[] = '<a href="' . bp_displayed_user_domain() . '" title="' . bp_get_displayed_user_fullname() . '">' . bp_get_displayed_user_fullname() . '</a>'; } // Display the profile component if it isnt the profile home if (!bp_is_user_profile()) { $crumbs[] = ucfirst(bp_current_component()); } // Display the current action if it is not the default public profile if (!in_array(bp_current_action(), array('public', 'just-me', 'my-friends'))) { $crumbs[] = ucfirst(bp_current_action()); } // Single Group } elseif (bp_is_group() || bp_is_group_create()) { // Group Creation if (bp_is_group_create()) { $title = 'Submit New Group'; $desc = 'Submit a new user group for listing on the ' . SITENAME . ' community groups directory.'; $crumbs[] = '<a href="' . SITEURL . '/' . bp_get_groups_root_slug() . '" title="Groups Directory">Groups</a>'; $crumbs[] = 'Create Group'; } elseif (bp_is_group()) { // Default entries $title = bp_get_group_name(); $desc = SITENAME . ' guild profile for ' . bp_get_group_name(); $classes = array_diff($classes, array('page', 'page-template-default')); $crumbs[] = '<a href="' . bp_get_groups_directory_permalink() . '" title="Groups Directory">Groups</a>'; // Group Profile Home if (bp_is_group_home()) { $title = $title . $sep . 'Profile'; $crumbs[] = bp_get_group_name(); // Advanced Component } else { // Link back to group profile $crumbs[] = '<a href="' . bp_get_group_permalink() . '" title="Return to Group Profile">' . bp_get_group_name() . '</a>'; // Members if (bp_is_group_members()) { $title = $title . $sep . 'Members'; $crumbs[] = 'Members'; // Activity } elseif (bp_is_group_activity()) { $title = $title . $sep . 'Activity'; $crumbs[] = 'Activity'; // Invites } elseif (bp_is_group_invites()) { $title = $title . $sep . 'Invitations'; $crumbs[] = 'Invitations'; // Admin } elseif (bp_is_group_admin_page()) { $title = $title . $sep . 'Admin'; $crumbs[] = 'Admin'; // Forum } else { // Forum Root if (NULL == bp_action_variable()) { $title = $title . $sep . 'Forum'; $crumbs[] = 'Forum'; // Sub-Component } else { $crumbs[] = '<a href="' . bp_get_group_permalink() . 'forum/" title="Group Forum">Forum</a>'; // Retrieve topic information from the database global $bp; global $wpdb; // Single Topic if (bp_is_action_variable('topic', 0)) { // Get the topic $topic = $wpdb->get_row($wpdb->prepare("SELECT post_title AS title, post_name AS url\n\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts} \n\t\t\t\t\t\t\t\t\t\tWHERE post_name = %s", $bp->action_variables[1])); $title = $topic->title; $crumbs[] = $topic->title; // Replies } elseif (bp_is_action_variable('reply', 0)) { // Get the reply parent topic $topic = $wpdb->get_row($wpdb->prepare("SELECT post_title AS title, post_name AS url\n\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts} \n\t\t\t\t\t\t\t\t\t\tWHERE ID = ( \n\t\t\t\t\t\t\t\t\t\t\tSELECT post_parent\n\t\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts}\n\t\t\t\t\t\t\t\t\t\t\tWHERE post_name = %s \n\t\t\t\t\t\t\t\t\t\t)", $bp->action_variables[1])); $title = $topic->title; $crumbs[] = $topic->title; } // Topic and Reply Edits if (bp_is_action_variable('edit', 2)) { $crumbs[] = 'Edit'; } } } } } // Directories } elseif (bp_is_directory()) { // Sitewide Activity if (bp_is_activity_component()) { $title = SITENAME . ' Sitewide Activity Feed'; $desc = 'A listing of all recent activity happening throughout the ' . SITENAME . ' community.'; $crumbs[] = 'Sitewide Activity'; // Members Directory } elseif (bp_is_members_component()) { $title = SITENAME . ' Members Directory'; $desc = 'A listing of all registered members in the ' . SITENAME . ' community.'; $crumbs[] = 'Members Directory'; // Groups Directory } elseif (bp_is_groups_component()) { $title = SITENAME . ' Guilds Directory'; $desc = 'A directory listing of guilds active within in the ' . SITENAME . ' community.'; $crumbs[] = 'Guilds Directory'; } // Registration } elseif (bp_is_register_page()) { $title = SITENAME . ' User Registration'; $desc = "Register to join the " . SITENAME . " community."; $crumbs[] = "User Registration"; // Activation } elseif (bp_is_activation_page()) { $title = SITENAME . ' Account Activation'; $desc = "Activate a pending " . SITENAME . " user account."; $crumbs[] = "Account Activation"; } /*-------------------------------------------- BBPRESS CONTEXT ---------------------------------------------*/ } elseif (class_exists('bbPress') && is_bbpress()) { // bbPress Defaults $classes[] = 'bbpress'; $classes[] = 'forums'; $crumbs[] = bbp_is_forum_archive() ? "Forums" : '<a href="' . get_post_type_archive_link('forum') . '">Forums</a>'; // Main Forum Archive if (bbp_is_forum_archive()) { $title = SITENAME . " Forums"; $desc = "Get involved in the community on the " . SITENAME . " forums."; // Recent Topics } elseif (bbp_is_topic_archive()) { $title = "Recent Topics in the " . SITENAME . " Forums"; $desc = "Browse a list of the most recent topics in the " . SITENAME . " Forums."; $crumbs[] = "Recent Topics"; // Single Forum } elseif (bbp_is_single_forum()) { $title = $object->post_title; $desc = $object->post_content; // Loop through parent forums $parent_id = bbp_get_forum_parent_id($id); if (0 != $parent_id) { $crumbs = array_merge($crumbs, $this->parent_crumbs($parent_id)); } $crumbs[] = $object->post_title; // Single Topic } elseif (bbp_is_single_topic()) { $title = $object->post_title; $desc = bbp_get_topic_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs(bbp_get_topic_forum_id($id))); $crumbs[] = $object->post_title; // Edit Topic } elseif (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) { $title = 'Edit Topic' . $sep . $object->post_title; $desc = bbp_get_topic_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs($id)); // Tag the specific task if (bbp_is_topic_split()) { $crumbs[] = 'Split Topic'; } elseif (bbp_is_topic_merge()) { $crumbs[] = 'Merge Topic'; } elseif (bbp_is_topic_edit()) { $crumbs[] = 'Edit Topic'; } // Edit Reply } elseif (bbp_is_reply_edit()) { $title = 'Edit Reply' . $sep . bbp_get_reply_topic_title($id); $desc = bbp_get_reply_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs(bbp_get_reply_topic_id($id))); $crumbs[] = 'Edit Reply'; } /*-------------------------------------------- WORDPRESS CONTEXT ---------------------------------------------*/ } else { // Singular Posts and Pages if (is_singular()) { $title = $object->post_title; $desc = get_post_meta($id, 'description', true); // If no description is found, use an excerpt if (empty($desc)) { $desc = get_post_field('post_excerpt', $id); } // Check for custom template $template = get_post_meta($id, "_wp_{$object->post_type}_template", true); if ('' != $template) { $template = str_replace(array("{$object->post_type}-template-", "{$object->post_type}-"), '', basename($template, '.php')); $classes[] = "{$template}-template"; } // Generate breadcrumbs by post type switch ($object->post_type) { // Single Posts case 'post': // Is the post in a category? $categories = get_the_category(); if ($categories) { // Start with the first category $term = $categories[0]; // If the category has a parent, add it to the trail. if (0 != $term->parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($term->parent, 'category')); } // Add the category archive link to the trail. $crumbs[] = '<a href="' . get_term_link($term) . '" title="' . esc_attr($term->name) . '">' . $term->name . '</a>'; } // Does the post have an ancestor? if ($object->post_parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($object->post_parent)); } // Editing a comment on this post if (is_comment_edit()) { $crumbs[] = '<a href="' . get_permalink() . '" title="Return to article">' . get_the_title() . '</a>'; $crumbs[] = 'Edit Comment'; // Reading the post } else { $crumbs[] = get_the_title(); } break; // Pages // Pages case 'page': // Does the page have an ancestor? if ($object->post_parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($object->post_parent)); } // Otherwise, viewing the page $crumbs[] = get_the_title(); break; // Events // Events case 'event': // Get the calendar the event belongs to $calendar = get_the_terms($object->ID, 'calendar'); $calendar = array_shift($calendar); $desc = 'Upcoming event on the ' . $calendar->name . ' calendar.'; $crumbs[] = '<a href="' . SITEURL . '/calendar/' . $calendar->slug . '" title="' . $calendar->name . ' Calendar">' . $calendar->name . ' Calendar</a>'; $crumbs[] = get_the_title(); break; } // Archives } elseif (is_archive()) { // Category Archives if (is_category()) { $crumbs[] = 'Category'; // If the category has a parent, add it to the trail. if ($object->parent != 0) { $crumbs = array_merge($crumbs, $this->trail_parents($object->parent)); } // Finish up with the term name $crumbs[] = $object->name; // Author Archive } elseif (is_author()) { $title = 'Author Archive' . $sep . $object->display_name; $desc = 'An archive of articles written by ' . $object->display_name; $crumbs[] = 'Author'; $crumbs[] = $object->display_name; // Advanced Search Page } elseif (is_search()) { $title = SITENAME . " Advanced Search"; $desc = "Search for a variety of content types throughout " . SITENAME; $crumbs[] = 'Advanced Search'; $classes[] = 'page'; // Calendar } elseif (is_calendar()) { $title = $object->name . " Calendar"; $desc = "Upcoming events on the " . $object->name . " calendar."; $crumbs[] = $object->name . " Calendar"; } // 404 } elseif (is_404()) { $title = "Error" . $sep . "Page Not Found"; $desc = "Sorry, but this page does not exist, or is not accessible at this time."; $classes[] = 'page'; $crumbs[] = '404 Page Not Found'; } } /*-------------------------------------------- RETURN DATA ---------------------------------------------*/ $this->title = html_entity_decode($title); $this->description = html_entity_decode($desc); $this->classes = $classes; $this->crumbs = $crumbs; }
/** * @ticket BP6325 */ function test_members_shortlink_redirector() { $shortlink_member_slug = 'me'; $this->go_to(bp_get_members_directory_permalink() . $shortlink_member_slug); $this->assertSame(get_current_user_id(), bp_displayed_user_id()); }
/** * @ticket BP6286 * @group member_types */ public function test_member_directory_should_404_for_member_types_that_have_no_directory() { bp_register_member_type('foo', array('has_directory' => false)); $this->go_to(bp_get_members_directory_permalink() . 'type/foo/'); $this->assertTrue(is_404()); }
/** * Output member directory permalink. * * @since 1.5.0 * * @uses bp_get_members_directory_permalink() */ function bp_members_directory_permalink() { echo esc_url(bp_get_members_directory_permalink()); }
function kleo_search_form_func($atts, $content = null) { $form_style = $type = $placeholder = $context = $el_class = ''; extract(shortcode_atts(array('form_style' => 'default', 'type' => 'both', 'context' => '', 'placeholder' => '', 'el_class' => ''), $atts)); global $kleo_config; $class = ''; if ($el_class != '') { $class = ' ' . $el_class; } $class .= ' search-style-' . $form_style; //Defaults $action = home_url('/'); $hidden = ''; $input_name = 's'; $ajax_results = 'yes'; $search_page = 'yes'; if ($type == 'ajax') { $search_page = 'no'; } elseif ($type == 'form_submit') { $ajax_results = 'no'; } if (function_exists('bp_is_active') && $context == 'members') { //Buddypress members form link $action = bp_get_members_directory_permalink(); } elseif (function_exists('bp_is_active') && bp_is_active('groups') && $context == 'groups') { //Buddypress group directory link $action = bp_get_groups_directory_permalink(); } elseif (class_exists('bbPress') && $context == 'forum') { $action = bbp_get_search_url(); $input_name = 'bbp_search'; } elseif ($context == 'product') { $hidden .= '<input type="hidden" name="post_type" value="product">'; } $output = '<div class="kleo-search-wrap kleo-search-form' . $class . '">'; $output .= '<form role="search" method="get" id="searchform" ' . ($search_page == 'no' ? ' onsubmit="return false;"' : '') . ' action="' . $action . '" data-context="' . $context . '"> <div class="input-group"> <input name="' . $input_name . '" id="' . $input_name . '" autocomplete="off" type="text" class="ajax_s form-control input-lg" value="" placeholder="' . $placeholder . '">'; if ($search_page == 'yes') { $output .= '<span class="input-group-btn">' . '<input type="submit" value="' . __("Search") . '" id="searchsubmit" class="button">' . '</span>'; } $output .= '</div>' . $hidden . '</form>'; if ($ajax_results == 'yes') { $output .= '<span class="kleo-ajax-search-loading"><span class="kleo-loading-icon"></span></span><div class="kleo_ajax_results"></div>'; } $output .= '</div>'; return $output; }
/** * Get the canonical URL of the current page. * * @since 1.6.0 * * @uses apply_filters() Filter bp_get_canonical_url to modify return value. * * @param array $args { * Optional array of arguments. * @type bool $include_query_args Whether to include current URL arguments * in the canonical URL returned from the function. * } * @return string Canonical URL for the current page. */ function bp_get_canonical_url($args = array()) { // For non-BP content, return the requested url, and let WP do the work. if (bp_is_blog_page()) { return bp_get_requested_url(); } $bp = buddypress(); $defaults = array('include_query_args' => false); $r = wp_parse_args($args, $defaults); extract($r); // Special case: when a BuddyPress directory (eg example.com/members) // is set to be the front page, ensure that the current canonical URL // is the home page URL. if ('page' == get_option('show_on_front') && ($page_on_front = (int) get_option('page_on_front'))) { $front_page_component = array_search($page_on_front, bp_core_get_directory_page_ids()); // If requesting the front page component directory, canonical // URL is the front page. We detect whether we're detecting a // component *directory* by checking that bp_current_action() // is empty - ie, this not a single item or a feed. if (false !== $front_page_component && bp_is_current_component($front_page_component) && !bp_current_action()) { $bp->canonical_stack['canonical_url'] = trailingslashit(bp_get_root_domain()); // Except when the front page is set to the registration page // and the current user is logged in. In this case we send to // the members directory to avoid redirect loops. } elseif (bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in()) { /** * Filters the logged in register page redirect URL. * * @since 1.5.1 * * @param string $value URL to redirect logged in members to. */ $bp->canonical_stack['canonical_url'] = apply_filters('bp_loggedin_register_page_redirect_to', bp_get_members_directory_permalink()); } } if (empty($bp->canonical_stack['canonical_url'])) { // Build the URL in the address bar. $requested_url = bp_get_requested_url(); // Stash query args. $url_stack = explode('?', $requested_url); // Build the canonical URL out of the redirect stack. if (isset($bp->canonical_stack['base_url'])) { $url_stack[0] = $bp->canonical_stack['base_url']; } if (isset($bp->canonical_stack['component'])) { $url_stack[0] = trailingslashit($url_stack[0] . $bp->canonical_stack['component']); } if (isset($bp->canonical_stack['action'])) { $url_stack[0] = trailingslashit($url_stack[0] . $bp->canonical_stack['action']); } if (!empty($bp->canonical_stack['action_variables'])) { foreach ((array) $bp->canonical_stack['action_variables'] as $av) { $url_stack[0] = trailingslashit($url_stack[0] . $av); } } // Add trailing slash. $url_stack[0] = trailingslashit($url_stack[0]); // Stash in the $bp global. $bp->canonical_stack['canonical_url'] = implode('?', $url_stack); } $canonical_url = $bp->canonical_stack['canonical_url']; if (!$include_query_args) { $canonical_url = array_reverse(explode('?', $canonical_url)); $canonical_url = array_pop($canonical_url); } /** * Filters the canonical url of the current page. * * @since 1.6.0 * * @param string $canonical_url Canonical URL of the current page. * @param array $args Array of arguments to help determine canonical URL. */ return apply_filters('bp_get_canonical_url', $canonical_url, $args); }
/** * Return member type directory permalink. * * @since 2.5.0 * * @param string $member_type Optional. Member type. Defaults to current member type. * @return string Member type directory URL on success, an empty string on failure. */ function bp_get_member_type_directory_permalink($member_type = '') { if ($member_type) { $_member_type = $member_type; } else { // Fall back on the current member type. $_member_type = bp_get_current_member_type(); } $type = bp_get_member_type_object($_member_type); // Bail when member type is not found or has no directory. if (!$type || !$type->has_directory) { return ''; } /** * Filters the member type directory permalink. * * @since 2.5.0 * * @param string $value Member type directory permalink. * @param object $type Member type object. * @param string $member_type Member type name, as passed to the function. */ return apply_filters('bp_get_member_type_directory_permalink', trailingslashit(bp_get_members_directory_permalink() . bp_get_members_member_type_base() . '/' . $type->directory_slug), $type, $member_type); }
/** * Filter an Extended Profile field value, and attempt to make clickable links * to members search results out of them. * * - Not run on datebox field types. * - Not run on values without commas with less than 5 words. * - URL's are made clickable. * - To disable: remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 ); * * @since 1.1.0 * * @param string $field_value Profile field data value. * @param string $field_type Profile field type. * @return string */ function xprofile_filter_link_profile_data($field_value, $field_type = 'textbox') { if ('datebox' === $field_type) { return $field_value; } if (!strpos($field_value, ',') && count(explode(' ', $field_value)) > 5) { return $field_value; } $values = explode(',', $field_value); if (!empty($values)) { foreach ((array) $values as $value) { $value = trim($value); // If the value is a URL, skip it and just make it clickable. if (preg_match('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', $value)) { $new_values[] = make_clickable($value); // Is not clickable. } else { // More than 5 spaces. if (count(explode(' ', $value)) > 5) { $new_values[] = $value; // Less than 5 spaces. } else { $query_arg = bp_core_get_component_search_query_arg('members'); $search_url = add_query_arg(array($query_arg => urlencode($value)), bp_get_members_directory_permalink()); $new_values[] = '<a href="' . esc_url($search_url) . '" rel="nofollow">' . $value . '</a>'; } } } $values = implode(', ', $new_values); } return $values; }
function cb_breadcrumbs($cb_padding = 'padding-on') { $cb_breadcrumb = NULL; $cb_post_type = get_post_type(); $cb_cpt = cb_get_custom_post_types(); if ($cb_padding == 'padding-off') { $cb_padding_type = ' cb-padding-off'; } else { $cb_padding_type = NULL; } if (is_page() == true) { global $post; if ($post->post_parent == 0) { return; } } $cb_breadcrumb = '<div class="cb-breadcrumbs wrap' . $cb_padding_type . '">'; $cb_icon = '<i class="fa fa-angle-right"></i>'; $cb_breadcrumb .= '<a href="' . home_url() . '">' . __("Home", "cubell") . '</a>' . $cb_icon; if (is_tag()) { $cb_tag_id = get_query_var('tag_id'); $cb_breadcrumb .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_tag_link($cb_tag_id) . '" itemprop="url"><span itemprop="title">' . single_tag_title("", false) . '</span></a></div>'; } elseif (is_category()) { $cb_cat_id = get_query_var('cat'); $cb_current_category = get_category($cb_cat_id); if ($cb_current_category->category_parent == '0') { $cb_breadcrumb .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_category_link($cb_current_category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $cb_current_category->name)) . '" itemprop="url"><span itemprop="title">' . $cb_current_category->name . '</span></a></div>'; } else { $cb_breadcrumb .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_category_link($cb_current_category->category_parent) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), get_the_category_by_ID($cb_current_category->category_parent))) . '"><span itemprop="title">' . get_the_category_by_ID($cb_current_category->category_parent) . '</span></a></div>' . $cb_icon; $cb_breadcrumb .= '<div itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_category_link($cb_current_category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $cb_current_category->name)) . '" itemprop="url"><span itemprop="title">' . $cb_current_category->name . '</span></a></div>'; } } elseif (function_exists('buddypress') && is_buddypress() == true) { global $bp; $cb_bp_output = NULL; $cb_bp_current_component = bp_current_component(); $cb_bp_current_action = bp_current_action(); if ($cb_bp_current_action != 'my-groups' && $cb_bp_current_component == 'groups') { $cb_bp_group = $bp->groups->current_group; if (!is_numeric($cb_bp_group)) { $cb_bp_group_id = $cb_bp_group->id; $cb_bp_group_name = $cb_bp_group->name; $cb_bp_group_link = bp_get_group_permalink($cb_bp_group); $cb_bp_output = '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug()) . '" itemprop="url"><span itemprop="title">' . __('Groups', 'cubell') . '</span></a></div>' . $cb_icon . $cb_bp_group_name; } else { $cb_bp_output = __('Groups', 'cubell'); } $cb_breadcrumb .= $cb_bp_output; } if ($cb_bp_current_component == 'activity' || $cb_bp_current_action == 'my-groups' || $cb_bp_current_action == 'public' || $cb_bp_current_component == 'settings' || $cb_bp_current_component == 'forums' || $cb_bp_current_component == 'friends') { if (isset($bp->activity->current_id)) { $cb_bp_activity = $bp->activity->current_id; } else { $cb_bp_activity = NULL; } $cb_activity_title = get_the_title(); $cb_bp_activity_link = bp_get_members_directory_permalink(); $cb_bp_output .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . esc_url($cb_bp_activity_link) . '" itemprop="url"><span itemprop="title">' . __('Members', 'cubell') . '</span></a></div>' . $cb_icon . $cb_activity_title; if ($cb_bp_activity != NULL) { $cb_bp_output .= __('Members', 'cubell'); } $cb_breadcrumb .= $cb_bp_output; } if ($cb_bp_current_component == 'messages') { $cb_breadcrumb .= __('Messages', 'cubell'); } if ($cb_bp_current_component == 'register') { $cb_breadcrumb .= __('Register', 'cubell'); } if (bp_is_directory() == true) { $cb_breadcrumb = '<div>'; } } elseif (in_array($cb_post_type, $cb_cpt) == true || $cb_post_type == 'post') { $cb_categories = get_the_category(); if ($cb_categories[0]->category_parent == '0') { $cb_breadcrumb .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_category_link($cb_categories[0]->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $cb_categories[0]->name)) . '" itemprop="url"><span itemprop="title">' . $cb_categories[0]->name . '</span></a></div>'; } else { $cb_breadcrumb_output = '<a href="' . get_category_link($cb_categories[0]->category_parent) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), get_the_category_by_ID($cb_categories[0]->category_parent))) . '" itemprop="url"><span itemprop="title">' . get_the_category_by_ID($cb_categories[0]->category_parent) . '</span></a>' . $cb_icon; $cb_breadcrumb_output .= '<a href="' . get_category_link($cb_categories[0]->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $cb_categories[0]->name)) . '" itemprop="url"><span itemprop="title">' . $cb_categories[0]->name . '</span></a>'; $cb_current_cat = get_category($cb_categories[0]->category_parent); if ($cb_current_cat->category_parent != '0') { $cb_breadcrumb_output = '<a href="' . get_category_link($cb_current_cat->category_parent) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), get_the_category_by_ID($cb_current_cat->category_parent))) . '" itemprop="url"><span itemprop="title">' . get_the_category_by_ID($cb_current_cat->category_parent) . '</span></a>' . $cb_icon . $cb_breadcrumb_output; $cb_current_cat = get_category($cb_current_cat->category_parent); if ($cb_current_cat->category_parent != '0') { $cb_breadcrumb_output = '<a href="' . get_category_link($cb_current_cat->category_parent) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), get_the_category_by_ID($cb_current_cat->category_parent))) . '" itemprop="url"><span itemprop="title">' . get_the_category_by_ID($cb_current_cat->category_parent) . '</span></a>' . $cb_icon . $cb_breadcrumb_output; $cb_current_cat = get_category($cb_current_cat->category_parent); if ($cb_current_cat->category_parent != '0') { $cb_breadcrumb_output = '<a href="' . get_category_link($cb_current_cat->category_parent) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), get_the_category_by_ID($cb_current_cat->category_parent))) . '" itemprop="url"><span itemprop="title">' . get_the_category_by_ID($cb_current_cat->category_parent) . '</span></a>' . $cb_icon . $cb_breadcrumb_output; } } } $cb_breadcrumb .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . $cb_breadcrumb_output . '</div>'; } } elseif (class_exists('Woocommerce') && is_woocommerce() == true) { $cb_breadcrumb = NULL; woocommerce_breadcrumb(array('delimiter' => $cb_icon, 'wrap_before' => '<div class="cb-breadcrumbs wrap" ' . (is_single() ? 'itemprop="breadcrumb"' : '') . '>', 'wrap_after' => ' ', 'before' => '', 'after' => '', 'home' => _x('Home', 'breadcrumb', 'woocommerce'))); } elseif (is_page() == true) { $cb_parent_page = get_post($post->post_parent); $cb_parent_page_title = $cb_parent_page->post_title; $cb_breadcrumb .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($cb_parent_page->ID) . '"><span itemprop="title">' . $cb_parent_page_title . '</span></a></div>'; } $cb_breadcrumb .= apply_filters('cb_breadcrumbs_output', ''); $cb_breadcrumb .= '</div>'; return $cb_breadcrumb; }
function kleo_ajax_search() { //if "s" input is missing exit if (empty($_REQUEST['s']) && empty($_REQUEST['bbp_search'])) { die; } if (!empty($_REQUEST['bbp_search'])) { $search_string = $_REQUEST['bbp_search']; } else { $search_string = $_REQUEST['s']; } $output = ""; $context = "any"; $defaults = array('numberposts' => 4, 'posts_per_page' => 20, 'post_type' => 'any', 'post_status' => 'publish', 'post_password' => '', 'suppress_filters' => false, 's' => $_REQUEST['s']); if (isset($_REQUEST['context']) && $_REQUEST['context'] != '') { $context = explode(",", $_REQUEST['context']); $defaults['post_type'] = $context; } $defaults = apply_filters('kleo_ajax_query_args', $defaults); $the_query = new WP_Query($defaults); $posts = $the_query->get_posts(); $members = array(); $members['total'] = 0; $groups = array(); $groups['total'] = 0; $forums = FALSE; if (function_exists('bp_is_active') && ($context == "any" || in_array("members", $context))) { $members = bp_core_get_users(array('search_terms' => $search_string, 'per_page' => $defaults['numberposts'], 'populate_extras' => false)); } if (function_exists('bp_is_active') && bp_is_active("groups") && ($context == "any" || in_array("groups", $context))) { $groups = groups_get_groups(array('search_terms' => $search_string, 'per_page' => $defaults['numberposts'], 'populate_extras' => false)); } if (class_exists('bbPress') && ($context == "any" || in_array("forum", $context))) { $forums = kleo_bbp_get_replies($search_string); } //if there are no posts, groups nor members if (empty($posts) && $members['total'] == 0 && $groups['total'] == 0 && !$forums) { $output = "<div class='kleo_ajax_entry ajax_not_found'>"; $output .= "<div class='ajax_search_content'>"; $output .= "<i class='icon icon-exclamation-sign'></i> "; $output .= __("Sorry, we haven't found anything based on your criteria.", 'kleo_framework'); $output .= "<br>"; $output .= __("Please try searching by different terms.", 'kleo_framework'); $output .= "</div>"; $output .= "</div>"; echo $output; die; } //if there are members if ($members['total'] != 0) { $output .= '<div class="kleo-ajax-part kleo-ajax-type-members">'; $output .= '<h4><span>' . __("Members", 'kleo_framework') . '</span></h4>'; foreach ((array) $members['users'] as $member) { $image = '<img src="' . bp_core_fetch_avatar(array('item_id' => $member->ID, 'width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">'; if ($update = bp_get_user_meta($member->ID, 'bp_latest_update', true)) { $latest_activity = char_trim(trim(strip_tags(bp_create_excerpt($update['content'], 50, "...")))); } else { $latest_activity = ''; } $output .= "<div class ='kleo_ajax_entry'>"; $output .= "<div class='ajax_search_image'>{$image}</div>"; $output .= "<div class='ajax_search_content'>"; $output .= "<a href='" . bp_core_get_user_domain($member->ID) . "' class='search_title'>"; $output .= $member->display_name; $output .= "</a>"; $output .= "<span class='search_excerpt'>"; $output .= $latest_activity; $output .= "</span>"; $output .= "</div>"; $output .= "</div>"; } $output .= "<a class='ajax_view_all' href='" . bp_get_members_directory_permalink() . "?s=" . $search_string . "'>" . __('View member results', 'kleo_framework') . "</a>"; $output .= "</div>"; } //if there are groups if ($groups['total'] != 0) { $output .= '<div class="kleo-ajax-part kleo-ajax-type-groups">'; $output .= '<h4><span>' . __("Groups", 'kleo_framework') . '</span></h4>'; foreach ((array) $groups['groups'] as $group) { $image = '<img src="' . bp_core_fetch_avatar(array('item_id' => $group->id, 'object' => 'group', 'width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">'; $output .= "<div class ='kleo_ajax_entry'>"; $output .= "<div class='ajax_search_image'>{$image}</div>"; $output .= "<div class='ajax_search_content'>"; $output .= "<a href='" . bp_get_group_permalink($group) . "' class='search_title'>"; $output .= $group->name; $output .= "</a>"; $output .= "</div>"; $output .= "</div>"; } $output .= "<a class='ajax_view_all' href='" . bp_get_groups_directory_permalink() . "?s=" . $search_string . "'>" . __('View group results', 'kleo_framework') . "</a>"; $output .= "</div>"; } //if there are posts if (!empty($posts)) { $post_types = array(); $post_type_obj = array(); foreach ($posts as $post) { $post_types[$post->post_type][] = $post; if (empty($post_type_obj[$post->post_type])) { $post_type_obj[$post->post_type] = get_post_type_object($post->post_type); } } foreach ($post_types as $ptype => $post_type) { $output .= '<div class="kleo-ajax-part kleo-ajax-type-' . esc_attr($post_type_obj[$ptype]->name) . '">'; if (isset($post_type_obj[$ptype]->labels->name)) { $output .= "<h4><span>" . $post_type_obj[$ptype]->labels->name . "</span></h4>"; } else { $output .= "<hr>"; } $count = 0; foreach ($post_type as $post) { $count++; if ($count > 4) { continue; } $format = get_post_format($post->ID); if ($img_url = kleo_get_post_thumbnail_url($post->ID)) { $image = aq_resize($img_url, 44, 44, true, true, true); if (!$image) { $image = $img_url; } $image = '<img src="' . $image . '" class="kleo-rounded">'; } else { if ($format == 'video') { $image = "<i class='icon icon-video'></i>"; } elseif ($format == 'image' || $format == 'gallery') { $image = "<i class='icon icon-picture'></i>"; } else { $image = "<i class='icon icon-link'></i>"; } } $excerpt = ""; if (!empty($post->post_content)) { $excerpt = char_trim(trim(strip_tags(strip_shortcodes($post->post_content))), 40, "..."); } $link = apply_filters('kleo_custom_url', get_permalink($post->ID)); $classes = "format-" . $format; $output .= "<div class ='kleo_ajax_entry {$classes}'>"; $output .= "<div class='ajax_search_image'>{$image}</div>"; $output .= "<div class='ajax_search_content'>"; $output .= "<a href='{$link}' class='search_title'>"; $output .= get_the_title($post->ID); $output .= "</a>"; $output .= "<span class='search_excerpt'>"; $output .= $excerpt; $output .= "</span>"; $output .= "</div>"; $output .= "</div>"; } $output .= '</div>'; } $output .= "<a class='ajax_view_all' href='" . home_url('/') . '?s=' . $search_string . "'>" . __('View all results', 'kleo_framework') . "</a>"; } /* Forums topics search */ if (!empty($forums)) { $output .= '<div class="kleo-ajax-part kleo-ajax-type-forums">'; $output .= '<h4><span>' . __("Forums", 'kleo_framework') . '</span></h4>'; $i = 0; foreach ($forums as $fk => $forum) { $i++; if ($i <= 4) { $image = "<i class='icon icon-chat-1'></i>"; $output .= "<div class ='kleo_ajax_entry'>"; $output .= "<div class='ajax_search_image'>{$image}</div>"; $output .= "<div class='ajax_search_content'>"; $output .= "<a href='" . $forum['url'] . "' class='search_title'>"; $output .= $forum['name']; $output .= "</a>"; //$output .= "<span class='search_excerpt'>"; //$output .= $latest_activity; //$output .= "</span>"; $output .= "</div>"; $output .= "</div>"; } } $output .= "<a class='ajax_view_all' href='" . bbp_get_search_url() . "?bbp_search=" . $search_string . "'>" . __('View forum results', 'kleo_framework') . "</a>"; $output .= "</div>"; } echo $output; die; }
/** * @ticket BP6840 */ public function test_successful_format() { bp_register_member_type('foo', array('has_directory' => true)); $expected = bp_get_members_directory_permalink() . 'type/foo/'; $this->assertSame($expected, bp_get_member_type_directory_permalink('foo')); }