function porto_page_title() { global $porto_settings; $output = ''; if (!is_front_page()) { } elseif (is_home()) { $output .= $porto_settings['blog-title']; } if (is_singular()) { $output .= porto_page_title_leaf(); } else { if (is_post_type_archive()) { if (is_search()) { $output .= porto_page_title_leaf('search'); } else { $output .= porto_page_title_archive(); } } elseif (is_tax() || is_tag() || is_category()) { $html = porto_page_title_leaf('term'); if (is_tag()) { $output .= sprintf(__('Tag - %s', 'porto'), $html); } elseif (is_tax('product_tag')) { $output .= sprintf(__('Product Tag - %s', 'porto'), $html); } else { $output .= $html; } } elseif (is_date()) { if (is_year()) { $output .= porto_page_title_leaf('year'); } elseif (is_month()) { $output .= porto_page_title_leaf('month'); } elseif (is_day()) { $output .= porto_page_title_leaf('day'); } } elseif (is_author()) { $output .= porto_page_title_leaf('author'); } elseif (is_search()) { $output .= porto_page_title_leaf('search'); } elseif (is_404()) { $output .= porto_page_title_leaf('404'); } elseif (class_exists('bbPress') && is_bbpress()) { if (bbp_is_search()) { $output .= porto_page_title_leaf('bbpress_search'); } elseif (bbp_is_single_user()) { $output .= porto_page_title_leaf('bbpress_user'); } else { $output .= porto_page_title_leaf(); } } else { if (is_home() && !is_front_page()) { if (get_option('show_on_front') == 'page') { $output .= get_the_title(get_option('page_for_posts', true)); } else { $output .= $porto_settings['blog-title']; } } } } return apply_filters('porto_page_title', $output); }
/** * Possibly intercept the template being loaded * * Listens to the 'template_include' filter and waits for any bbPress specific * template condition to be met. If one is met and the template file exists, * it will be used; otherwise * * Note that the _edit() checks are ahead of their counterparts, to prevent them * from being stomped on accident. * * @since bbPress (r3032) * * @param string $template * * @uses bbp_is_single_user() To check if page is single user * @uses bbp_get_single_user_template() To get user template * @uses bbp_is_single_user_edit() To check if page is single user edit * @uses bbp_get_single_user_edit_template() To get user edit template * @uses bbp_is_single_view() To check if page is single view * @uses bbp_get_single_view_template() To get view template * @uses bbp_is_search() To check if page is search * @uses bbp_get_search_template() To get search template * @uses bbp_is_forum_edit() To check if page is forum edit * @uses bbp_get_forum_edit_template() To get forum edit template * @uses bbp_is_topic_merge() To check if page is topic merge * @uses bbp_get_topic_merge_template() To get topic merge template * @uses bbp_is_topic_split() To check if page is topic split * @uses bbp_get_topic_split_template() To get topic split template * @uses bbp_is_topic_edit() To check if page is topic edit * @uses bbp_get_topic_edit_template() To get topic edit template * @uses bbp_is_reply_move() To check if page is reply move * @uses bbp_get_reply_move_template() To get reply move template * @uses bbp_is_reply_edit() To check if page is reply edit * @uses bbp_get_reply_edit_template() To get reply edit template * @uses bbp_set_theme_compat_template() To set the global theme compat template * * @return string The path to the template file that is being used */ function bbp_template_include_theme_supports($template = '') { // Editing a user if (bbp_is_single_user_edit() && ($new_template = bbp_get_single_user_edit_template())) { // User favorites } elseif (bbp_is_favorites() && ($new_template = bbp_get_favorites_template())) { // User favorites } elseif (bbp_is_subscriptions() && ($new_template = bbp_get_subscriptions_template())) { // Viewing a user } elseif (bbp_is_single_user() && ($new_template = bbp_get_single_user_template())) { // Single View } elseif (bbp_is_single_view() && ($new_template = bbp_get_single_view_template())) { // Search } elseif (bbp_is_search() && ($new_template = bbp_get_search_template())) { // Forum edit } elseif (bbp_is_forum_edit() && ($new_template = bbp_get_forum_edit_template())) { // Single Forum } elseif (bbp_is_single_forum() && ($new_template = bbp_get_single_forum_template())) { // Forum Archive } elseif (bbp_is_forum_archive() && ($new_template = bbp_get_forum_archive_template())) { // Topic merge } elseif (bbp_is_topic_merge() && ($new_template = bbp_get_topic_merge_template())) { // Topic split } elseif (bbp_is_topic_split() && ($new_template = bbp_get_topic_split_template())) { // Topic edit } elseif (bbp_is_topic_edit() && ($new_template = bbp_get_topic_edit_template())) { // Single Topic } elseif (bbp_is_single_topic() && ($new_template = bbp_get_single_topic_template())) { // Topic Archive } elseif (bbp_is_topic_archive() && ($new_template = bbp_get_topic_archive_template())) { // Reply move } elseif (bbp_is_reply_move() && ($new_template = bbp_get_reply_move_template())) { // Editing a reply } elseif (bbp_is_reply_edit() && ($new_template = bbp_get_reply_edit_template())) { // Single Reply } elseif (bbp_is_single_reply() && ($new_template = bbp_get_single_reply_template())) { // Editing a topic tag } elseif (bbp_is_topic_tag_edit() && ($new_template = bbp_get_topic_tag_edit_template())) { // Viewing a topic tag } elseif (bbp_is_topic_tag() && ($new_template = bbp_get_topic_tag_template())) { } // A bbPress template file was located, so override the WordPress template // and use it to switch off bbPress's theme compatibility. if (!empty($new_template)) { $template = bbp_set_template_included($new_template); } return apply_filters('bbp_template_include_theme_supports', $template); }
/** * Possibly intercept the template being loaded * * Listens to the 'template_include' filter and waits for any bbPress specific * template condition to be met. If one is met and the template file exists, * it will be used; otherwise * * Note that the _edit() checks are ahead of their counterparts, to prevent them * from being stomped on accident. * * @since bbPress (r3032) * * @param string $template * * @uses bbp_is_single_user() To check if page is single user * @uses bbp_get_single_user_template() To get user template * @uses bbp_is_single_user_edit() To check if page is single user edit * @uses bbp_get_single_user_edit_template() To get user edit template * @uses bbp_is_single_view() To check if page is single view * @uses bbp_get_single_view_template() To get view template * @uses bbp_is_forum_edit() To check if page is forum edit * @uses bbp_get_forum_edit_template() To get forum edit template * @uses bbp_is_topic_merge() To check if page is topic merge * @uses bbp_get_topic_merge_template() To get topic merge template * @uses bbp_is_topic_split() To check if page is topic split * @uses bbp_get_topic_split_template() To get topic split template * @uses bbp_is_topic_edit() To check if page is topic edit * @uses bbp_get_topic_edit_template() To get topic edit template * @uses bbp_is_reply_edit() To check if page is reply edit * @uses bbp_get_reply_edit_template() To get reply edit template * @uses bbp_set_theme_compat_template() To set the global theme compat template * * @return string The path to the template file that is being used */ function bbp_template_include_theme_supports($template = '') { // Editing a user if (bbp_is_single_user_edit() && ($new_template = bbp_get_single_user_edit_template())) { // User favorites } elseif (bbp_is_favorites() && ($new_template = bbp_get_favorites_template())) { // User favorites } elseif (bbp_is_subscriptions() && ($new_template = bbp_get_subscriptions_template())) { // Viewing a user } elseif (bbp_is_single_user() && ($new_template = bbp_get_single_user_template())) { // Single View } elseif (bbp_is_single_view() && ($new_template = bbp_get_single_view_template())) { // Forum edit } elseif (bbp_is_forum_edit() && ($new_template = bbp_get_forum_edit_template())) { // Single Forum } elseif (bbp_is_single_forum() && ($new_template = bbp_get_single_forum_template())) { // Forum Archive } elseif (bbp_is_forum_archive() && ($new_template = bbp_get_forum_archive_template())) { // Topic merge } elseif (bbp_is_topic_merge() && ($new_template = bbp_get_topic_merge_template())) { // Topic split } elseif (bbp_is_topic_split() && ($new_template = bbp_get_topic_split_template())) { // Topic edit } elseif (bbp_is_topic_edit() && ($new_template = bbp_get_topic_edit_template())) { // Single Topic } elseif (bbp_is_single_topic() && ($new_template = bbp_get_single_topic_template())) { // Topic Archive } elseif (bbp_is_topic_archive() && ($new_template = bbp_get_topic_archive_template())) { // Editing a reply } elseif (bbp_is_reply_edit() && ($new_template = bbp_get_reply_edit_template())) { // Single Reply } elseif (bbp_is_single_reply() && ($new_template = bbp_get_single_reply_template())) { // Editing a topic tag } elseif (bbp_is_topic_tag_edit() && ($new_template = bbp_get_topic_tag_edit_template())) { // Viewing a topic tag } elseif (bbp_is_topic_tag() && ($new_template = bbp_get_topic_tag_template())) { } // bbPress template file exists if (!empty($new_template)) { // Override the WordPress template with a bbPress one $template = $new_template; // @see: bbp_template_include_theme_compat() bbpress()->theme_compat->bbpress_template = true; } return apply_filters('bbp_template_include_theme_supports', $template); }
function avia_bbpress_breadcrumb($trail) { global $avia_config; if (isset($avia_config['currently_viewing']) && $avia_config['currently_viewing'] == 'forum' || get_post_type() === "forum" || get_post_type() === "topic") { $bc = bbp_get_breadcrumb(); if (isset($avia_config['bbpress_trail'])) { $trail_zero = $trail[0]; $trail = $avia_config['bbpress_trail']; $trail[0] = $trail_zero; } if (bbp_is_single_user_edit() || bbp_is_single_user()) { $user_info = get_userdata(bbp_get_displayed_user_id()); $title = __("Profile for User:"******"avia_framework") . " " . $user_info->display_name; array_pop($trail); $trail[] = $title; } } return $trail; }
/** * Tweak problematic Genesis post actions * * @access private * @since 0.8 */ public function genesis_post_actions() { /** * If the current theme is a child theme of Genesis that also includes * the template files bbPress needs, we can leave things how they are. */ if (is_bbpress()) { /** Remove Actions ************************************************/ // Remove genesis breadcrumbs remove_action('genesis_before_loop', 'genesis_do_breadcrumbs'); /** * Remove post info & meta * * If you moved the info/meta from their default locations, you are * on your own. */ remove_action('genesis_before_post_content', 'genesis_post_info'); remove_action('genesis_after_post_content', 'genesis_post_meta'); /** * Remove Genesis post image and content * * bbPress heavily relies on the_content() so if Genesis is * modifying it unexpectedly, we need to un-unexpect it. */ remove_action('genesis_post_content', 'genesis_do_post_image'); remove_action('genesis_post_content', 'genesis_do_post_content'); /** * Remove authorbox * * In some odd cases the Genesis authorbox could appear */ remove_action('genesis_after_post', 'genesis_do_author_box_single'); // Remove the navigation after the post loop remove_action('genesis_after_endwhile', 'genesis_posts_nav'); // Remove post title from profile pages (as they don't work) if (bbp_is_single_user() || bbp_is_single_user_edit() || bbp_is_user_home()) { remove_action('genesis_post_title', 'genesis_do_post_title'); } /** Add Actions ***************************************************/ // Re add 'the_content' back onto 'genesis_post_content' add_action('genesis_post_content', 'the_content'); } }
function bbps_lock_to_author($bbp_t) { global $wp_query; //return if we are at a prem forum or the user is an admin or moderator and we are not looking at a users profile page! if ((bbps_is_premium_forum(bbp_get_forum_id()) == false || current_user_can('administrator') || current_user_can('bbp_moderator')) && !bbp_is_single_user()) { return $bbp_t; } // is someone looking at a user page? if they are then we want to exclude all premium posts //and change the post author to be the users who profile it is if (bbp_is_single_user()) { $premium_topics = bbps_get_all_premium_topic_ids(); $user_id = bbp_get_displayed_user_id(); $bbp_t['post_author'] = $user_id; $bbp_t['author'] = $user_id; $bbp_t['post__not_in'] = $premium_topics; $bbp_t['post_type'] = 'topic'; return $bbp_t; } else { //there is one problem with this - if the users ID is 0 then it still shows all topics //setting userid to -1 seems to do the trick .. better way perhapes? //ops no it doesnt do the trick so for lauch I will make it a huge number this will need to be revisited ASAP global $current_user; $current_user = wp_get_current_user(); $user_id = $current_user->ID; if ($user_id == 0) { $user_id = 99999999; } //create the new query we only want to display topics from that user $bbp_t['post_author'] = $user_id; $bbp_t['author'] = $user_id; $bbp_t['post_type'] = 'topic'; $bbp_t['show_stickies'] = 0; $bbp_t['posts_per_page'] = 30; // exit('<pre>'.print_r($bbp_t,1).'</pre>'); return $bbp_t; } }
/** * Replaces the_content() if the post_type being displayed is one that would * normally be handled by bbPress, but proper single page templates do not * exist in the currently active theme. * * Note that we do *not* currently use is_main_query() here. This is because so * many existing themes either use query_posts() or fail to use wp_reset_query() * when running queries before the main loop, causing theme compat to fail. * * @since bbPress (r3034) * @param string $content * @return type */ function bbp_replace_the_content($content = '') { // Bail if not inside the query loop if (!in_the_loop()) { return $content; } $bbp = bbpress(); // Define local variable(s) $new_content = ''; // Bail if shortcodes are unset somehow if (!is_a($bbp->shortcodes, 'BBP_Shortcodes')) { return $content; } // Use shortcode API to display forums/topics/replies because they are // already output buffered and ready to fit inside the_content /** Users *************************************************************/ // Profile View if (bbp_is_single_user_edit() || bbp_is_single_user()) { ob_start(); bbp_get_template_part('content', 'single-user'); $new_content = ob_get_contents(); ob_end_clean(); /** Forums ************************************************************/ // Forum archive } elseif (bbp_is_forum_archive()) { // Page exists where this archive should be $page = bbp_get_page_by_path(bbp_get_root_slug()); if (!empty($page)) { // Restore previously unset filters bbp_restore_all_filters('the_content'); // Remove 'bbp_replace_the_content' filter to prevent infinite loops remove_filter('the_content', 'bbp_replace_the_content'); // Start output buffer ob_start(); // Grab the content of this page $new_content = apply_filters('the_content', $page->post_content); // Clean up the buffer ob_end_clean(); // Add 'bbp_replace_the_content' filter back (@see $this::start()) add_filter('the_content', 'bbp_replace_the_content'); // No page so show the archive } else { $new_content = $bbp->shortcodes->display_forum_index(); } // Forum Edit } elseif (bbp_is_forum_edit()) { $new_content = $bbp->shortcodes->display_forum_form(); // Single Forum } elseif (bbp_is_single_forum()) { $new_content = $bbp->shortcodes->display_forum(array('id' => get_the_ID())); /** Topics ************************************************************/ // Topic archive } elseif (bbp_is_topic_archive()) { // Page exists where this archive should be $page = bbp_get_page_by_path(bbp_get_topic_archive_slug()); if (!empty($page)) { // Restore previously unset filters bbp_restore_all_filters('the_content'); // Remove 'bbp_replace_the_content' filter to prevent infinite loops remove_filter('the_content', 'bbp_replace_the_content'); // Start output buffer ob_start(); // Grab the content of this page $new_content = apply_filters('the_content', $page->post_content); // Clean up the buffer ob_end_clean(); // Add 'bbp_replace_the_content' filter back (@see $this::start()) add_filter('the_content', 'bbp_replace_the_content'); // No page so show the archive } else { $new_content = $bbp->shortcodes->display_topic_index(); } // Topic Edit } elseif (bbp_is_topic_edit()) { // Split if (bbp_is_topic_split()) { ob_start(); bbp_get_template_part('form', 'topic-split'); $new_content = ob_get_contents(); ob_end_clean(); // Merge } elseif (bbp_is_topic_merge()) { ob_start(); bbp_get_template_part('form', 'topic-merge'); $new_content = ob_get_contents(); ob_end_clean(); // Edit } else { $new_content = $bbp->shortcodes->display_topic_form(); } // Single Topic } elseif (bbp_is_single_topic()) { $new_content = $bbp->shortcodes->display_topic(array('id' => get_the_ID())); /** Replies ***********************************************************/ // Reply archive } elseif (is_post_type_archive(bbp_get_reply_post_type())) { //$new_content = $bbp->shortcodes->display_reply_index(); // Reply Edit } elseif (bbp_is_reply_edit()) { $new_content = $bbp->shortcodes->display_reply_form(); // Single Reply } elseif (bbp_is_single_reply()) { $new_content = $bbp->shortcodes->display_reply(array('id' => get_the_ID())); /** Views *************************************************************/ } elseif (bbp_is_single_view()) { $new_content = $bbp->shortcodes->display_view(array('id' => get_query_var('bbp_view'))); /** Topic Tags ********************************************************/ // Show topics of tag } elseif (bbp_is_topic_tag()) { $new_content = $bbp->shortcodes->display_topics_of_tag(array('id' => bbp_get_topic_tag_id())); // Edit topic tag } elseif (bbp_is_topic_tag_edit()) { $new_content = $bbp->shortcodes->display_topic_tag_form(); } // Juggle the content around and try to prevent unsightly comments if (!empty($new_content) && $new_content != $content) { // Set the content to be the new content $content = apply_filters('bbp_replace_the_content', $new_content, $content); // Clean up after ourselves unset($new_content); // Reset the $post global wp_reset_postdata(); } // Return possibly hi-jacked content return $content; }
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; }
/** * Mark a users topics and replies as spam when the user is marked as spam * * @since bbPress (r3405) * * @global WPDB $wpdb * @param int $user_id Optional. User ID to unspam. Defaults to displayed user. * * @uses bbp_is_single_user() * @uses bbp_is_user_home() * @uses bbp_get_displayed_user_id() * @uses bbp_is_user_keymaster() * @uses get_blogs_of_user() * @uses bbp_get_topic_post_type() * @uses bbp_get_reply_post_type() * @uses switch_to_blog() * @uses get_post_type() * @uses bbp_unspam_topic() * @uses bbp_unspam_reply() * @uses restore_current_blog() * * @return If no user ID passed */ function bbp_make_ham_user($user_id = 0) { // Use displayed user if it's not yourself if (empty($user_id) && bbp_is_single_user() && !bbp_is_user_home()) { $user_id = bbp_get_displayed_user_id(); } // Bail if no user ID if (empty($user_id)) { return false; } // Bail if user ID is keymaster if (bbp_is_user_keymaster($user_id)) { return false; } // Arm the torpedos global $wpdb; // Get the blog IDs of the user to mark as spam $blogs = get_blogs_of_user($user_id, true); // If user has no blogs, they are a guest on this site if (empty($blogs)) { $blogs[$wpdb->blogid] = array(); } // Make array of post types to mark as spam $post_types = array(bbp_get_topic_post_type(), bbp_get_reply_post_type()); $post_types = "'" . implode("', '", $post_types) . "'"; // Loop through blogs and remove their posts foreach ((array) array_keys($blogs) as $blog_id) { // Switch to the blog ID switch_to_blog($blog_id); // Get topics and replies $posts = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_status = '%s' AND post_type IN ( {$post_types} )", $user_id, bbp_get_spam_status_id())); // Loop through posts and spam them if (!empty($posts)) { foreach ($posts as $post_id) { // The routines for topics ang replies are different, so use the // correct one based on the post type switch (get_post_type($post_id)) { case bbp_get_topic_post_type(): bbp_unspam_topic($post_id); break; case bbp_get_reply_post_type(): bbp_unspam_reply($post_id); break; } } } // Switch back to current blog restore_current_blog(); } // Success return true; }
/** * Custom page title for bbPress pages * * @since bbPress (r2788) * * @param string $title Optional. The title (not used). * @param string $sep Optional, default is '»'. How to separate the * various items within the page title. * @param string $seplocation Optional. Direction to display title, 'right'. * @uses bbp_is_single_user() To check if it's a user profile page * @uses bbp_is_single_user_edit() To check if it's a user profile edit page * @uses bbp_is_user_home() To check if the profile page is of the current user * @uses get_query_var() To get the user id * @uses get_userdata() To get the user data * @uses bbp_is_single_forum() To check if it's a forum * @uses bbp_get_forum_title() To get the forum title * @uses bbp_is_single_topic() To check if it's a topic * @uses bbp_get_topic_title() To get the topic title * @uses bbp_is_single_reply() To check if it's a reply * @uses bbp_get_reply_title() To get the reply title * @uses is_tax() To check if it's the tag page * @uses get_queried_object() To get the queried object * @uses bbp_is_single_view() To check if it's a view * @uses bbp_get_view_title() To get the view title * @uses apply_filters() Calls 'bbp_raw_title' with the title * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title, * separator and separator location * @return string The tite */ function bbp_title($title = '', $sep = '»', $seplocation = '') { // Title array $new_title = array(); /** Archives **************************************************************/ // Forum Archive if (bbp_is_forum_archive()) { $new_title['text'] = bbp_get_forum_archive_title(); // Topic Archive } elseif (bbp_is_topic_archive()) { $new_title['text'] = bbp_get_topic_archive_title(); /** Edit ******************************************************************/ // Forum edit page } elseif (bbp_is_forum_edit()) { $new_title['text'] = bbp_get_forum_title(); $new_title['format'] = esc_attr__('Forum Edit: %s', 'bbpress'); // Topic edit page } elseif (bbp_is_topic_edit()) { $new_title['text'] = bbp_get_topic_title(); $new_title['format'] = esc_attr__('Topic Edit: %s', 'bbpress'); // Reply edit page } elseif (bbp_is_reply_edit()) { $new_title['text'] = bbp_get_reply_title(); $new_title['format'] = esc_attr__('Reply Edit: %s', 'bbpress'); // Topic tag edit page } elseif (bbp_is_topic_tag_edit()) { $new_title['text'] = bbp_get_topic_tag_name(); $new_title['format'] = esc_attr__('Topic Tag Edit: %s', 'bbpress'); /** Singles ***************************************************************/ // Forum page } elseif (bbp_is_single_forum()) { $new_title['text'] = bbp_get_forum_title(); $new_title['format'] = esc_attr__('Forum: %s', 'bbpress'); // Topic page } elseif (bbp_is_single_topic()) { $new_title['text'] = bbp_get_topic_title(); $new_title['format'] = esc_attr__('Topic: %s', 'bbpress'); // Replies } elseif (bbp_is_single_reply()) { $new_title['text'] = bbp_get_reply_title(); // Topic tag page } elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag')) { $new_title['text'] = bbp_get_topic_tag_name(); $new_title['format'] = esc_attr__('Topic Tag: %s', 'bbpress'); /** Users *****************************************************************/ // Profile page } elseif (bbp_is_single_user()) { // User is viewing their own profile if (bbp_is_user_home()) { $new_title['text'] = esc_attr_x('Your', 'User viewing his/her own profile', 'bbpress'); // User is viewing someone else's profile (so use their display name) } else { $new_title['text'] = sprintf(esc_attr_x("%s's", 'User viewing another users profile', 'bbpress'), get_userdata(bbp_get_user_id())->display_name); } // User topics created if (bbp_is_single_user_topics()) { $new_title['format'] = esc_attr__("%s Topics", 'bbpress'); // User rueplies created } elseif (bbp_is_single_user_replies()) { $new_title['format'] = esc_attr__("%s Replies", 'bbpress'); // User favorites } elseif (bbp_is_favorites()) { $new_title['format'] = esc_attr__("%s Favorites", 'bbpress'); // User subscriptions } elseif (bbp_is_subscriptions()) { $new_title['format'] = esc_attr__("%s Subscriptions", 'bbpress'); // User "home" } else { $new_title['format'] = esc_attr__("%s Profile", 'bbpress'); } // Profile edit page } elseif (bbp_is_single_user_edit()) { // Current user if (bbp_is_user_home_edit()) { $new_title['text'] = esc_attr__('Edit Your Profile', 'bbpress'); // Other user } else { $new_title['text'] = get_userdata(bbp_get_user_id())->display_name; $new_title['format'] = esc_attr__("Edit %s's Profile", 'bbpress'); } /** Views *****************************************************************/ // Views } elseif (bbp_is_single_view()) { $new_title['text'] = bbp_get_view_title(); $new_title['format'] = esc_attr__('View: %s', 'bbpress'); /** Search ****************************************************************/ // Search } elseif (bbp_is_search()) { $new_title['text'] = bbp_get_search_title(); } // This filter is deprecated. Use 'bbp_before_title_parse_args' instead. $new_title = apply_filters('bbp_raw_title_array', $new_title); // Set title array defaults $new_title = bbp_parse_args($new_title, array('text' => $title, 'format' => '%s'), 'title'); // Get the formatted raw title $new_title = sprintf($new_title['format'], $new_title['text']); // Filter the raw title $new_title = apply_filters('bbp_raw_title', $new_title, $sep, $seplocation); // Compare new title with original title if ($new_title === $title) { return $title; } // Temporary separator, for accurate flipping, if necessary $t_sep = '%WP_TITILE_SEP%'; $prefix = ''; if (!empty($new_title)) { $prefix = " {$sep} "; } // sep on right, so reverse the order if ('right' === $seplocation) { $new_title_array = array_reverse(explode($t_sep, $new_title)); $new_title = implode(" {$sep} ", $new_title_array) . $prefix; // sep on left, do not reverse } else { $new_title_array = explode($t_sep, $new_title); $new_title = $prefix . implode(" {$sep} ", $new_title_array); } // Filter and return return apply_filters('bbp_title', $new_title, $sep, $seplocation); }
<?php global $avia_config; /* * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory. */ get_header(); $title = ""; if (!is_singular()) { $title = __('Forums', "avia_framework"); } if (function_exists('bbp_is_single_user_edit') && (bbp_is_single_user_edit() || bbp_is_single_user())) { $user_info = get_userdata(bbp_get_displayed_user_id()); $title = __("Profile for User:"******"avia_framework") . " " . $user_info->display_name; if (bbp_is_single_user_edit()) { $title = __("Edit profile for User:"******"avia_framework") . " " . $user_info->display_name; } } $args = array(); if (!empty($title)) { $args['title'] = $title; } if (get_post_meta(get_the_ID(), 'header', true) != 'no') { echo avia_title($args); } ?> <div class='container_wrap main_color <?php avia_layout_class('main'); ?> '>
/** * Custom page title for bbPress pages * * @since bbPress (r2788) * * @param string $title Optional. The title (not used). * @param string $sep Optional, default is '»'. How to separate the * various items within the page title. * @param string $seplocation Optional. Direction to display title, 'right'. * @uses bbp_is_single_user() To check if it's a user profile page * @uses bbp_is_single_user_edit() To check if it's a user profile edit page * @uses bbp_is_user_home() To check if the profile page is of the current user * @uses get_query_var() To get the user id * @uses get_userdata() To get the user data * @uses bbp_is_single_forum() To check if it's a forum * @uses bbp_get_forum_title() To get the forum title * @uses bbp_is_single_topic() To check if it's a topic * @uses bbp_get_topic_title() To get the topic title * @uses bbp_is_single_reply() To check if it's a reply * @uses bbp_get_reply_title() To get the reply title * @uses is_tax() To check if it's the tag page * @uses get_queried_object() To get the queried object * @uses bbp_is_single_view() To check if it's a view * @uses bbp_get_view_title() To get the view title * @uses apply_filters() Calls 'bbp_raw_title' with the title * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title, * separator and separator location * @return string The tite */ function bbp_title($title = '', $sep = '»', $seplocation = '') { // Store original title to compare $_title = $title; /** Archives **************************************************************/ // Forum Archive if (bbp_is_forum_archive()) { $title = bbp_get_forum_archive_title(); // Topic Archive } elseif (bbp_is_topic_archive()) { $title = bbp_get_topic_archive_title(); /** Singles ***************************************************************/ // Forum page } elseif (bbp_is_single_forum()) { $title = sprintf(__('Forum: %s', 'bbpress'), bbp_get_forum_title()); // Topic page } elseif (bbp_is_single_topic()) { $title = sprintf(__('Topic: %s', 'bbpress'), bbp_get_topic_title()); // Replies } elseif (bbp_is_single_reply()) { $title = bbp_get_reply_title(); // Topic tag page (or edit) } elseif (bbp_is_topic_tag() || bbp_is_topic_tag_edit() || get_query_var('bbp_topic_tag')) { $term = get_queried_object(); $title = sprintf(__('Topic Tag: %s', 'bbpress'), $term->name); /** Users *****************************************************************/ // Profile page } elseif (bbp_is_single_user()) { // Current users profile if (bbp_is_user_home()) { $title = __('Your Profile', 'bbpress'); // Other users profile } else { $userdata = get_userdata(bbp_get_user_id()); $title = sprintf(__('%s\'s Profile', 'bbpress'), $userdata->display_name); } // Profile edit page } elseif (bbp_is_single_user_edit()) { // Current users profile if (bbp_is_user_home_edit()) { $title = __('Edit Your Profile', 'bbpress'); // Other users profile } else { $userdata = get_userdata(bbp_get_user_id()); $title = sprintf(__('Edit %s\'s Profile', 'bbpress'), $userdata->display_name); } /** Views *****************************************************************/ // Views } elseif (bbp_is_single_view()) { $title = sprintf(__('View: %s', 'bbpress'), bbp_get_view_title()); } // Filter the raw title $title = apply_filters('bbp_raw_title', $title, $sep, $seplocation); // Compare new title with original title if ($title == $_title) { return $title; } // Temporary separator, for accurate flipping, if necessary $t_sep = '%WP_TITILE_SEP%'; $prefix = ''; if (!empty($title)) { $prefix = " {$sep} "; } // sep on right, so reverse the order if ('right' == $seplocation) { $title_array = explode($t_sep, $title); $title_array = array_reverse($title_array); $title = implode(" {$sep} ", $title_array) . $prefix; // sep on left, do not reverse } else { $title_array = explode($t_sep, $title); $title = $prefix . implode(" {$sep} ", $title_array); } // Filter and return return apply_filters('bbp_title', $title, $sep, $seplocation); }
/** * 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); }
/** * The main topic loop. WordPress makes this easy for us * * @since 2.0.0 bbPress (r2485) * * @param array $args All the arguments supported by {@link WP_Query} * @uses current_user_can() To check if the current user can edit other's topics * @uses bbp_get_topic_post_type() To get the topic post type * @uses WP_Query To make query and get the topics * @uses is_page() To check if it's a page * @uses bbp_is_single_forum() To check if it's a forum * @uses bbp_get_forum_id() To get the forum id * @uses bbp_get_paged() To get the current page value * @uses bbp_get_super_stickies() To get the super stickies * @uses bbp_get_stickies() To get the forum stickies * @uses bbp_use_pretty_urls() To check if the site is using pretty URLs * @uses get_permalink() To get the permalink * @uses add_query_arg() To add custom args to the url * @uses apply_filters() Calls 'bbp_topics_pagination' with the pagination args * @uses paginate_links() To paginate the links * @uses apply_filters() Calls 'bbp_has_topics' with * bbPres::topic_query::have_posts() * and bbPres::topic_query * @return object Multidimensional array of topic information */ function bbp_has_topics($args = array()) { /** 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', 'meta_type' => 'DATETIME', 'orderby' => 'meta_value', 'order' => 'DESC', 'posts_per_page' => bbp_get_topics_per_page(), 'paged' => bbp_get_paged(), 'show_stickies' => $default_show_stickies, 'max_num_pages' => false); // Only add 's' arg if searching for topics // See https://bbpress.trac.wordpress.org/ticket/2607 if (!empty($default_topic_search)) { $default['s'] = $default_topic_search; } // 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(), bbp_get_pending_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'] = implode(',', $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', 'meta_type' => 'DATETIME', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies); // Cleanup unset($stickies); // Conditionally exclude private/hidden forum ID's $exclude_forum_ids = bbp_exclude_forum_ids('array'); if (!empty($exclude_forum_ids)) { $sticky_query['post_parent__not_in'] = $exclude_forum_ids; } // 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 (bbp_use_pretty_urls()) { // 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(); // Forum archive } elseif (bbp_is_forum_archive()) { $base = bbp_get_forums_url(); // 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(bbp_get_paged_slug() . '/%#%/'); // 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() ? '→' : '←', 'next_text' => is_rtl() ? '←' : '→', '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(bbp_get_paged_slug() . "/1/'", "'", $bbp->topic_query->pagination_links); } // Return object return apply_filters('bbp_has_topics', $bbp->topic_query->have_posts(), $bbp->topic_query); }
/** * dynWid::detectPage() Page detection * * @return string */ public function detectPage() { // First we register the Path URL $this->url = $_SERVER['REQUEST_URI']; if (is_front_page() && get_option('show_on_front') == 'posts') { return 'front-page'; } else { if (is_home() && get_option('show_on_front') == 'page') { return 'front-page'; } else { if (is_attachment()) { return 'attachment'; // must be before is_single(), otherwise detects as 'single' } else { if (is_single()) { return 'single'; } else { if (is_page()) { return 'page'; } else { if (is_author()) { return 'author'; } else { if (is_category()) { return 'category'; } else { if (is_tag()) { return 'tag'; } else { if (function_exists('is_post_type_archive') && is_post_type_archive()) { return 'cp_archive'; // must be before is_archive(), otherwise detects as 'archive' in WP 3.1.0 } else { if (function_exists('is_tax') && is_tax()) { return 'tax_archive'; } else { if (is_archive() && !is_category() && !is_author() && !is_tag()) { return 'archive'; } else { if (function_exists('bbp_is_single_user') && (bbp_is_single_user() || bbp_is_single_user_edit())) { // must be before is_404(), otherwise bbPress profile page is detected as 'e404'. return 'bbp_profile'; } else { if (is_404()) { return 'e404'; } else { if (is_search()) { return 'search'; } else { if (function_exists('is_pod_page') && is_pod_page()) { return 'pods'; } else { return 'undef'; } } } } } } } } } } } } } } } }
/** * 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); }
<?php get_header(); $cb_user_page = NULL; global $bb_current_user; $cb_breadcrumbs = ot_get_option('cb_breadcrumbs', 'on'); $cb_theme_style = ot_get_option('cb_theme_style', 'cb_boxed'); $cb_bbpress_sidebar = ot_get_option('cb_bbpress_sidebar', 'sidebar'); $cb_bbpress_global_color = ot_get_option('cb_bbpress_global_color', '#eb9812'); $cb_current_user = bbp_get_user_id(); $cb_forum_id = bbp_get_forum_id(); $cb_title = get_the_title(); if (bbp_is_single_user() == true || bbp_is_favorites() == true) { $cb_title = '<h1 id="cb-cat-title"><span>' . __('Member', 'cubell') . ' <i class="icon-long-arrow-right"></i></span> ' . get_the_title() . '</h1>'; $cb_user_page = 'cb-author-page '; } $cb_sidebar_position = NULL; if ($cb_bbpress_sidebar == 'sidebar_left') { $cb_sidebar_position = ' cb-sidebar-left '; } elseif ($cb_bbpress_sidebar == 'nosidebar') { $cb_sidebar_position = ' cb-full-width'; } ?> <div id="cb-content" class="<?php if ($cb_user_page != NULL) { echo $cb_user_page; } ?> wrap clearfix">
/** * Determine if content is relevant * * @since 1.0 * @return boolean */ public function in_context() { return function_exists('bbp_is_single_user') && bbp_is_single_user(); }
/** * Super admin privileges notice * * @since 2.0.0 bbPress (r2688) * * @uses is_multisite() To check if the blog is multisite * @uses bbp_is_single_user() To check if it's the profile page * @uses bbp_is_single_user_edit() To check if it's the profile edit page * @uses current_user_can() To check if the current user can manage network * options * @uses bbp_get_displayed_user_id() To get the displayed user id * @uses is_super_admin() To check if the user is super admin * @uses bbp_is_user_home() To check if it's the user home * @uses bbp_is_user_home_edit() To check if it's the user home edit */ function bbp_notice_edit_user_is_super_admin() { if (is_multisite() && (bbp_is_single_user() || bbp_is_single_user_edit()) && current_user_can('manage_network_options') && is_super_admin(bbp_get_displayed_user_id())) { ?> <div class="bbp-template-notice important"> <ul> <li><?php bbp_is_user_home() || bbp_is_user_home_edit() ? esc_html_e('You have super admin privileges.', 'bbpress') : esc_html_e('This user has super admin privileges.', 'bbpress'); ?> </li> </ul> </div> <?php } }
function gpbbp_profile_redirect() { if (bbp_is_single_user()) { $directory_url = '/directory/user'; $user_id = bbp_get_user_id(); $user_profile_url = home_url() . $directory_url . '/' . $user_id; wp_redirect($user_profile_url); exit; } }
/** * Handles the front end subscribing and unsubscribing topics * * @uses bbp_is_subscriptions_active() To check if the subscriptions are active * @uses bbp_get_user_id() To get the user id * @uses bbp_verify_nonce_request() To verify the nonce and check the request * @uses current_user_can() To check if the current user can edit the user * @uses bbPress:errors:add() To log the error messages * @uses bbp_is_user_subscribed() To check if the topic is in user's * subscriptions * @uses bbp_remove_user_subscription() To remove the user subscription * @uses bbp_add_user_subscription() To add the user subscription * @uses do_action() Calls 'bbp_subscriptions_handler' with success, user id, * topic id and action * @uses bbp_is_subscription() To check if it's the subscription page * @uses bbp_get_subscription_link() To get the subscription page link * @uses bbp_get_topic_permalink() To get the topic permalink * @uses wp_safe_redirect() To redirect to the url */ function bbp_subscriptions_handler() { if (!bbp_is_subscriptions_active()) { return false; } // Bail if not a GET action if ('GET' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } // Bail if required GET actions aren't passed if (empty($_GET['topic_id']) || empty($_GET['action'])) { return; } // Setup possible get actions $possible_actions = array('bbp_subscribe', 'bbp_unsubscribe'); // Bail if actions aren't meant for this function if (!in_array($_GET['action'], $possible_actions)) { return; } // Get required data $action = $_GET['action']; $user_id = bbp_get_user_id(0, true, true); $topic_id = intval($_GET['topic_id']); // Check for empty topic if (empty($topic_id)) { bbp_add_error('bbp_subscription_topic_id', __('<strong>ERROR</strong>: No topic was found! Which topic are you subscribing/unsubscribing to?', 'bbpress')); // Check nonce } elseif (!bbp_verify_nonce_request('toggle-subscription_' . $topic_id)) { bbp_add_error('bbp_subscription_topic_id', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress')); // Check current user's ability to edit the user } elseif (!current_user_can('edit_user', $user_id)) { bbp_add_error('bbp_subscription_permissions', __('<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress')); } // Bail if we have errors if (bbp_has_errors()) { return; } /** No errors *************************************************************/ $is_subscription = bbp_is_user_subscribed($user_id, $topic_id); $success = false; if (true == $is_subscription && 'bbp_unsubscribe' == $action) { $success = bbp_remove_user_subscription($user_id, $topic_id); } elseif (false == $is_subscription && 'bbp_subscribe' == $action) { $success = bbp_add_user_subscription($user_id, $topic_id); } // Do additional subscriptions actions do_action('bbp_subscriptions_handler', $success, $user_id, $topic_id, $action); // Success! if (true == $success) { // Redirect back from whence we came if (bbp_is_subscriptions()) { $redirect = bbp_get_subscriptions_permalink($user_id); } elseif (bbp_is_single_user()) { $redirect = bbp_get_user_profile_url(); } elseif (is_singular(bbp_get_topic_post_type())) { $redirect = bbp_get_topic_permalink($topic_id); } elseif (is_single() || is_page()) { $redirect = get_permalink(); } wp_safe_redirect($redirect); // For good measure exit; // Fail! Handle errors } elseif (true == $is_subscription && 'bbp_unsubscribe' == $action) { bbp_add_error('bbp_unsubscribe', __('<strong>ERROR</strong>: There was a problem unsubscribing from that topic!', 'bbpress')); } elseif (false == $is_subscription && 'bbp_subscribe' == $action) { bbp_add_error('bbp_subscribe', __('<strong>ERROR</strong>: There was a problem subscribing to that topic!', 'bbpress')); } }
/** * The main topic loop. WordPress makes this easy for us * * @since bbPress (r2485) * * @param mixed $args All the arguments supported by {@link WP_Query} * @uses current_user_can() To check if the current user can edit other's topics * @uses bbp_is_user_bozo() To add the bozo post status * @uses bbp_get_topic_post_type() To get the topic post type * @uses WP_Query To make query and get the topics * @uses is_page() To check if it's a page * @uses bbp_is_single_forum() To check if it's a forum * @uses bbp_get_forum_id() To get the forum id * @uses bbp_get_paged() To get the current page value * @uses bbp_get_super_stickies() To get the super stickies * @uses bbp_get_stickies() To get the forum stickies * @uses wpdb::get_results() To execute our query and get the results * @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks * @uses get_permalink() To get the permalink * @uses add_query_arg() To add custom args to the url * @uses apply_filters() Calls 'bbp_topics_pagination' with the pagination args * @uses paginate_links() To paginate the links * @uses apply_filters() Calls 'bbp_has_topics' with * bbPres::topic_query::have_posts() * and bbPres::topic_query * @return object Multidimensional array of topic information */ function bbp_has_topics($args = '') { global $wp_rewrite; // What are the default allowed statuses (based on user caps) if (bbp_get_view_all()) { $post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id()); } else { $post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id()); } // Add the bozo status if user is a bozo if (bbp_is_user_bozo()) { $post_statuses[] = bbp_get_bozo_status_id(); } $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_post_status = join(',', $post_statuses); // Default argument array $default = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $default_post_parent, 'post_status' => $default_post_status, '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); // 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(); } $bbp_t = bbp_parse_args($args, $default, 'has_topics'); // Extract the query variables extract($bbp_t); // Get bbPress $bbp = bbpress(); // Call the query $bbp->topic_query = new WP_Query($bbp_t); // Set post_parent back to 0 if originally set to 'any' if ('any' == $bbp_t['post_parent']) { $bbp_t['post_parent'] = $post_parent = 0; } // Limited the number of pages shown if (!empty($max_num_pages)) { $bbp->topic_query->max_num_pages = $max_num_pages; } // Put sticky posts at the top of the posts array if (!empty($show_stickies) && $paged <= 1) { // Get super stickies and stickies in this forum $stickies = bbp_get_super_stickies(); $stickies = !empty($post_parent) ? array_merge($stickies, bbp_get_stickies($post_parent)) : $stickies; $stickies = array_unique($stickies); // We have stickies if (is_array($stickies) && !empty($stickies)) { // Setup the number of stickies and reset offset to 0 $num_topics = count($bbp->topic_query->posts); $sticky_offset = 0; // Loop over topics and relocate stickies to the front. for ($i = 0; $i < $num_topics; $i++) { if (in_array($bbp->topic_query->posts[$i]->ID, $stickies)) { $sticky = $bbp->topic_query->posts[$i]; // Remove sticky from current position array_splice($bbp->topic_query->posts, $i, 1); // Move to front, after other stickies array_splice($bbp->topic_query->posts, $sticky_offset, 0, array($sticky)); // Increment the sticky offset. The next sticky will be placed at this offset. $sticky_offset++; // Remove post from sticky posts array $offset = array_search($sticky->ID, $stickies); // Cleanup unset($stickies[$offset]); unset($sticky); } } // If any posts have been excluded specifically, Ignore those that are sticky. if (!empty($stickies) && !empty($post__not_in)) { $stickies = array_diff($stickies, $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', 'post_status' => $default_post_status, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies); // 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); // Loop through stickies and add them to beginning of array foreach ($sticky_posts as $sticky) { $topics[] = $sticky; } // Loop through topics and add them to end of array foreach ($bbp->topic_query->posts as $topic) { $topics[] = $topic; } // Adjust loop and counts for new sticky positions $bbp->topic_query->posts = $topics; $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($topics); unset($stickies); unset($sticky_posts); } } } } // If no limit to posts per page, set it to the current post_count if (-1 == $posts_per_page) { $posts_per_page = $bbp->topic_query->post_count; } // Add pagination values to query object $bbp->topic_query->posts_per_page = $posts_per_page; $bbp->topic_query->paged = $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($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()) { // Profile page if (bbp_is_single_user()) { $base = bbp_get_user_profile_url(bbp_get_displayed_user_id()); } elseif (bbp_is_single_view()) { $base = bbp_get_view_url(); } elseif (bbp_is_topic_tag()) { $base = bbp_get_topic_tag_link(); } elseif (is_page() || is_single()) { $base = get_permalink(); } elseif (bbp_is_topic_archive()) { $base = bbp_get_topics_url(); } else { $base = get_permalink($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' => $posts_per_page == $bbp->topic_query->found_posts ? 1 : ceil((int) $bbp->topic_query->found_posts / (int) $posts_per_page), 'current' => (int) $bbp->topic_query->paged, 'prev_text' => '←', 'next_text' => '→', '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 apply_filters('bbp_has_topics', $bbp->topic_query->have_posts(), $bbp->topic_query); }
/** * The main reply loop. WordPress makes this easy for us * * @since bbPress (r2553) * * @param mixed $args All the arguments supported by {@link WP_Query} * @uses bbp_show_lead_topic() Are we showing the topic as a lead? * @uses bbp_get_topic_id() To get the topic id * @uses bbp_get_reply_post_type() To get the reply post type * @uses bbp_get_topic_post_type() To get the topic post type * @uses get_option() To get the replies per page option * @uses bbp_get_paged() To get the current page value * @uses current_user_can() To check if the current user is capable of editing * others' replies * @uses WP_Query To make query and get the replies * @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks * @uses get_permalink() To get the permalink * @uses add_query_arg() To add custom args to the url * @uses apply_filters() Calls 'bbp_replies_pagination' with the pagination args * @uses paginate_links() To paginate the links * @uses apply_filters() Calls 'bbp_has_replies' with * bbPres::reply_query::have_posts() * and bbPres::reply_query * @return object Multidimensional array of reply information */ function bbp_has_replies($args = '') { global $wp_rewrite; /** Defaults **************************************************************/ // Other defaults $default_reply_search = !empty($_REQUEST['rs']) ? $_REQUEST['rs'] : false; $default_post_parent = bbp_is_single_topic() ? bbp_get_topic_id() : 'any'; $default_post_type = bbp_is_single_topic() && bbp_show_lead_topic() ? bbp_get_reply_post_type() : array(bbp_get_topic_post_type(), bbp_get_reply_post_type()); $default_thread_replies = (bool) (bbp_is_single_topic() && bbp_thread_replies()); // Default query args $default = array('post_type' => $default_post_type, 'post_parent' => $default_post_parent, 'posts_per_page' => bbp_get_replies_per_page(), 'paged' => bbp_get_paged(), 'orderby' => 'date', 'order' => 'ASC', 'hierarchical' => $default_thread_replies, 'ignore_sticky_posts' => true, 's' => $default_reply_search); // 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_replies')) { $post_statuses[] = bbp_get_private_status_id(); } // Join post statuses together $default['post_status'] = implode(',', $post_statuses); // Lean on the 'perm' query var value of 'readable' to provide statuses } else { $default['perm'] = 'readable'; } /** Setup *****************************************************************/ // Parse arguments against default values $r = bbp_parse_args($args, $default, 'has_replies'); // Set posts_per_page value if replies are threaded $replies_per_page = $r['posts_per_page']; if (true === $r['hierarchical']) { $r['posts_per_page'] = -1; } // Get bbPress $bbp = bbpress(); // Call the query $bbp->reply_query = new WP_Query($r); // Add pagination values to query object $bbp->reply_query->posts_per_page = $replies_per_page; $bbp->reply_query->paged = $r['paged']; // Never home, regardless of what parse_query says $bbp->reply_query->is_home = false; // Reset is_single if single topic if (bbp_is_single_topic()) { $bbp->reply_query->is_single = true; } // Only add reply to if query returned results if ((int) $bbp->reply_query->found_posts) { // Get reply to for each reply foreach ($bbp->reply_query->posts as &$post) { // Check for reply post type if (bbp_get_reply_post_type() === $post->post_type) { $reply_to = bbp_get_reply_to($post->ID); // Make sure it's a reply to a reply if (empty($reply_to) || bbp_get_reply_topic_id($post->ID) === $reply_to) { $reply_to = 0; } // Add reply_to to the post object so we can walk it later $post->reply_to = $reply_to; } } } // Only add pagination if query returned results if ((int) $bbp->reply_query->found_posts && (int) $bbp->reply_query->posts_per_page) { // If pretty permalinks are enabled, make our pagination pretty if ($wp_rewrite->using_permalinks()) { // User's replies if (bbp_is_single_user_replies()) { $base = bbp_get_user_replies_created_url(bbp_get_displayed_user_id()); // Root profile page } elseif (bbp_is_single_user()) { $base = bbp_get_user_profile_url(bbp_get_displayed_user_id()); // Page or single post } elseif (is_page() || is_single()) { $base = get_permalink(); // Single topic } else { $base = get_permalink(bbp_get_topic_id()); } $base = trailingslashit($base) . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/'); // Unpretty permalinks } else { $base = add_query_arg('paged', '%#%'); } // Figure out total pages if (true === $r['hierarchical']) { $walker = new BBP_Walker_Reply(); $total_pages = ceil((int) $walker->get_number_of_root_elements($bbp->reply_query->posts) / (int) $replies_per_page); } else { $total_pages = ceil((int) $bbp->reply_query->found_posts / (int) $replies_per_page); // Add pagination to query object $bbp->reply_query->pagination_links = paginate_links(apply_filters('bbp_replies_pagination', array('base' => $base, 'format' => '', 'total' => $total_pages, 'current' => (int) $bbp->reply_query->paged, 'prev_text' => is_rtl() ? '→' : '←', 'next_text' => is_rtl() ? '←' : '→', 'mid_size' => 1, 'add_args' => bbp_get_view_all() ? array('view' => 'all') : false))); // Remove first page from pagination if ($wp_rewrite->using_permalinks()) { $bbp->reply_query->pagination_links = str_replace($wp_rewrite->pagination_base . '/1/', '', $bbp->reply_query->pagination_links); } else { $bbp->reply_query->pagination_links = str_replace('&paged=1', '', $bbp->reply_query->pagination_links); } } } // Return object return apply_filters('bbp_has_replies', $bbp->reply_query->have_posts(), $bbp->reply_query); }
function fix_bbp_404() { global $wp_query; if (class_exists('bbPress')) { if (bbp_is_single_user() || bbp_is_single_user_edit()) { if ($wp_query->bbp_is_single_user || $wp_query->bbp_is_single_user_edit || $wp_query->bbp_is_view) { $wp_query->is_404 = false; // Unset nocache_headers foreach (wp_get_nocache_headers() as $name => $field_value) { @header("{$name}: "); } // Set status 200 status_header(200); } } } }
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 = ' / '; 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 “', 'mk_framework') . get_search_query() . '”'; } elseif (is_tag()) { echo __('Tag “', 'mk_framework') . single_tag_title('', false) . '”'; } 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>"; }
public function InBBPressPage() { if (!$this->IsBBPressInstalled()) { return false; } if (!isset($this->_inBBPress)) { $this->_inBBPress = false; if (function_exists('bbp_is_forum')) { // $this->_inBBPress = $this->_inBBPress || ('' !== bb_get_location()); $this->_inBBPress = $this->_inBBPress || bbp_is_forum(get_the_ID()); $this->_inBBPress = $this->_inBBPress || bbp_is_single_user(); } if (RWLogger::IsOn()) { RWLogger::Log('InBBPressPage', $this->_inBuddyPress ? 'TRUE' : 'FALSE'); } } return $this->_inBBPress; }
/** * 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); }
/** * Prepare the full output of the breadcrumb path * * @return void */ private function prepare_breadcrumb_html() { // Add the path prefix $this->html_markup = $this->get_breadcrumb_prefix(); // Add the "Home" link $this->html_markup .= $this->get_breadcrumb_home(); // Woocommerce path prefix (e.g "Shop" ) if (class_exists('Woocommerce') && (is_woocommerce() && is_archive() && !is_shop() || is_cart() || is_checkout() || is_account_page())) { $this->html_markup .= $this->get_woocommerce_shop_page(); } // bbPress path prefix (e.g "Forums" ) if (class_exists('bbPress') && is_bbpress() && (bbp_is_topic_archive() || bbp_is_single_user() || bbp_is_search())) { $this->html_markup .= $this->get_bbpress_main_archive_page(); } // Single Posts and Pages (of all post types) if (is_singular()) { // If the post type of the current post has an archive link, display the archive breadcrumb if (isset($this->post->post_type) && get_post_type_archive_link($this->post->post_type) && $this->show_post_type_archive) { $this->html_markup .= $this->get_post_type_archive(); } // If the post doesn't have parents if (isset($this->post->post_parent) && $this->post->post_parent == 0) { $this->html_markup .= $this->get_post_terms(); // If there are parents; mostly for pages } else { $this->html_markup .= $this->get_post_ancestors(); } $this->html_markup .= $this->get_breadcrumb_leaf_markup(); } else { // Custom post types archives if (is_post_type_archive()) { $this->html_markup .= $this->get_post_type_archive(FALSE); // Search on custom post type (e.g. Woocommerce) if (is_search()) { $this->html_markup .= $this->get_breadcrumb_leaf_markup('search'); } // Taxonomy Archives } elseif (is_tax() || is_tag() || is_category()) { // If we have a tag archive, add the tag prefix if (is_tag()) { $this->html_markup .= $this->tag_archive_prefix; } $this->html_markup .= $this->get_taxonomies(); $this->html_markup .= $this->get_breadcrumb_leaf_markup('term'); // Date Archives } elseif (is_date()) { global $wp_locale; // Set variables $year = esc_html(get_query_var('year')); if (is_month() || is_day()) { $month = get_query_var('monthnum'); $month_name = $wp_locale->get_month($month); } // Year Archive, only is a leaf if (is_year()) { $this->html_markup .= $this->get_breadcrumb_leaf_markup('year'); // Month Archive, needs year link and month leaf } elseif (is_month()) { $this->html_markup .= $this->get_single_breadcrumb_markup($year, get_year_link($year)); $this->html_markup .= $this->get_breadcrumb_leaf_markup('month'); // Day Archive, needs year and month link and day leaf } elseif (is_day()) { $this->html_markup .= $this->get_single_breadcrumb_markup($year, get_year_link($year)); $this->html_markup .= $this->get_single_breadcrumb_markup($month_name, get_month_link($year, $month)); $this->html_markup .= $this->get_breadcrumb_leaf_markup('day'); } // Author Archives } elseif (is_author()) { $this->html_markup .= $this->get_breadcrumb_leaf_markup('author'); // Search Page } elseif (is_search()) { $this->html_markup .= $this->get_breadcrumb_leaf_markup('search'); // 404 Page } elseif (is_404()) { // Special treatment for Events Calendar to avoid 404 messages on list view if (class_exists('TribeEvents') && tribe_is_event() || is_events_archive()) { $this->html_markup .= $this->get_breadcrumb_leaf_markup('events'); // Default case } else { $this->html_markup .= $this->get_breadcrumb_leaf_markup('404'); } // bbPress } elseif (class_exists('bbPress')) { // Search Page if (bbp_is_search()) { $this->html_markup .= $this->get_breadcrumb_leaf_markup('bbpress_search'); // User page } elseif (bbp_is_single_user()) { $this->html_markup .= $this->get_breadcrumb_leaf_markup('bbpress_user'); } } } }
<?php /** * bbPress "Article" content * * User account * Topic tags edit * * @package WebMan WordPress Theme Framework * @subpackage Post Formats * @copyright 2014 WebMan - Oliver Juhas */ $schema_type = 'article'; if (bbp_is_single_user()) { $schema_type = 'person'; } ?> <article <?php post_class(); echo wm_schema_org($schema_type); ?> > <?php wmhook_entry_top(); the_content(); wmhook_entry_bottom(); ?> </article>
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); }