/** * 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 bbpress_hl_add_buttons() { global $wp_sh_allowed_str, $wp_sh_setting_opt; if (bbp_is_single_forum() || bbp_is_single_topic() || bbp_is_topic_edit() || bbp_is_reply_edit()) { if (bbp_is_single_forum()) { $textarea_id = "bbp_topic_content"; } elseif (bbp_is_topic_edit()) { $textarea_id = "bbp_topic_content"; } elseif (bbp_is_reply_edit()) { $textarea_id = "bbp_reply_content"; } elseif (bbp_is_single_topic()) { $textarea_id = "bbp_reply_content"; } echo "<div class=\"bbpress_highlight\">"; if ($wp_sh_setting_opt['bbpress_hl_description_before_enable'] == 1) { $wp_sh_bbpress_hl_description_before = wp_sh_valid_text(get_option('wp_sh_bbpress_hl_description_before'), $wp_sh_allowed_str); if ($wp_sh_bbpress_hl_description_before == "invalid") { $wp_sh_bbpress_hl_description_before = wp_sh_default_setting_value('bbp_desc'); } echo "<p>" . str_replace("<pre>", "<pre>", $wp_sh_bbpress_hl_description_before) . "</p>"; } if ($wp_sh_setting_opt['bbpress_hl_bt_tag'] == "shortcode") { $tag = "shorcode"; } else { $tag = "pre"; } echo "<div class=\"bbpress_highlight_button\">"; if ($wp_sh_setting_opt['lib_version'] == '3.0') { $languages = get_option('wp_sh_language3'); } elseif ($wp_sh_setting_opt['lib_version'] == '2.1') { $languages = get_option('wp_sh_language2'); } $gutter = $wp_sh_setting_opt['gutter']; if (is_array($languages)) { asort($languages); foreach ($languages as $key => $val) { if ($val[1] == 'true' || $val[1] == 'added') { echo "<a href=\"javascript:void(0);\" onclick=\"surroundHTML('" . $key . "','" . $textarea_id . "','" . $gutter . "','" . $wp_sh_setting_opt['first_line'] . "','" . $tag . "','0');\">" . $val[0] . "</a> | "; } } unset($val); } echo "</div>"; echo "</div>"; } }
static function nav_menu_css_class($classes, $item, $args, $depth) { if ($item->object == bbp_get_forum_post_type() && is_bbpress()) { if (bbp_is_topic_edit() || bbp_is_single_topic()) { $forum_id = bbp_get_topic_forum_id(); if ($forum_id == $item->object_id) { $classes[] = 'current-menu-parent'; $classes[] = 'current-' . bbp_get_topic_post_type() . '-parent'; } elseif ($ancestors = self::forum_ancestors($forum_id, array())) { if (in_array($item->object_id, $ancestors)) { $classes[] = 'current-menu-ancestor'; $classes[] = 'current-' . bbp_get_topic_post_type() . '-ancestor'; } } } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) { $forum_id = bbp_get_reply_forum_id(); } } return $classes; }
/** * 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); }
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); }
static function media_view_settings($settings, $post) { $forum_id = 0; if (is_admin()) { } elseif (bbp_is_single_user_edit() || bbp_is_single_user()) { } elseif (bbp_is_forum_archive()) { } elseif (bbp_is_forum_edit()) { $forum_id = bbp_get_forum_id(); } elseif (bbp_is_single_forum()) { $forum_id = bbp_get_forum_id(); } elseif (bbp_is_topic_archive()) { } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) { $forum_id = bbp_get_forum_id(); } elseif (is_post_type_archive(bbp_get_reply_post_type())) { } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) { $forum_id = bbp_get_forum_id(); } elseif (bbp_is_single_view()) { } elseif (bbp_is_search()) { } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) { $forum_id = bbp_get_forum_id(); } if ($forum_id) { // @setcookie('_bbp_forum_id', $forum_id, 0, COOKIEPATH, COOKIE_DOMAIN); if (empty($settings['post'])) { $settings['post'] = array('id' => $forum_id, 'nonce' => wp_create_nonce('update-post_' . $forum_id)); } } else { // @setcookie('_bbp_forum_id', ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN); } return $settings; }
/** * Returns topic status downdown * * This dropdown is only intended to be seen by users with the 'moderate' * capability. Because of this, no additional capablitiy checks are performed * within this function to check available topic statuses. * * @since bbPress (r5059) * * @param $args This function supports these arguments: * - select_id: Select id. Defaults to bbp_open_close_topic * - tab: Tabindex * - topic_id: Topic id * - selected: Override the selected option */ function stachestack_bbp_get_form_topic_status_dropdown($args = '') { // Parse arguments against default values $r = bbp_parse_args($args, array('select_id' => 'bbp_topic_status', 'tab' => bbp_get_tab_index(), 'topic_id' => 0, 'selected' => false), 'topic_open_close_select'); // No specific selected value passed if (empty($r['selected'])) { // Post value is passed if (bbp_is_post_request() && isset($_POST[$r['select_id']])) { $r['selected'] = $_POST[$r['select_id']]; // No Post value was passed } else { // Edit topic if (bbp_is_topic_edit()) { $r['topic_id'] = bbp_get_topic_id($r['topic_id']); $r['selected'] = bbp_get_topic_status($r['topic_id']); // New topic } else { $r['selected'] = bbp_get_public_status_id(); } } } // Used variables $tab = !empty($r['tab']) ? ' tabindex="' . (int) $r['tab'] . '"' : ''; // Start an output buffer, we'll finish it after the select loop ob_start(); ?> <select class="form-control" name="<?php echo esc_attr($r['select_id']); ?> " id="<?php echo esc_attr($r['select_id']); ?> _select"<?php echo $tab; ?> > <?php foreach (bbp_get_topic_statuses($r['topic_id']) as $key => $label) { ?> <option value="<?php echo esc_attr($key); ?> "<?php selected($key, $r['selected']); ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <?php // Return the results return apply_filters('bbp_get_form_topic_status_dropdown', ob_get_clean(), $r); }
<label for="bbp_topic_subscription"><?php _e('Notify me of follow-up replies via email', 'bbpress'); ?> </label> <?php } ?> </p> <?php } ?> <?php if (bbp_is_topic_edit()) { ?> <fieldset class="bbp-form"> <legend><?php _e('Revision', 'bbpress'); ?> </legend> <div> <input name="bbp_log_topic_edit" id="bbp_log_topic_edit" type="checkbox" value="1" <?php bbp_form_topic_log_edit(); ?> tabindex="<?php bbp_tab_index(); ?> " />
/** * Return a breadcrumb ( forum -> topic -> reply ) * * @since bbPress (r2589) * * @param string $sep Separator. Defaults to '←' * @param bool $current_page Include the current item * @param bool $root Include the root page if one exists * * @uses get_post() To get the post * @uses bbp_get_forum_permalink() To get the forum link * @uses bbp_get_topic_permalink() To get the topic link * @uses bbp_get_reply_permalink() To get the reply link * @uses get_permalink() To get the permalink * @uses bbp_get_forum_post_type() To get the forum post type * @uses bbp_get_topic_post_type() To get the topic post type * @uses bbp_get_reply_post_type() To get the reply post type * @uses bbp_get_forum_title() To get the forum title * @uses bbp_get_topic_title() To get the topic title * @uses bbp_get_reply_title() To get the reply title * @uses get_the_title() To get the title * @uses apply_filters() Calls 'bbp_get_breadcrumb' with the crumbs * @return string Breadcrumbs */ function bbp_get_breadcrumb($args = array()) { // Turn off breadcrumbs if (apply_filters('bbp_no_breadcrumb', is_front_page())) { return; } // Define variables $front_id = $root_id = 0; $ancestors = $crumbs = $tag_data = array(); $pre_root_text = $pre_front_text = $pre_current_text = ''; $pre_include_root = $pre_include_home = $pre_include_current = true; /** Home Text *********************************************************/ // No custom home text if (empty($args['home_text'])) { // Set home text to page title $front_id = get_option('page_on_front'); if (!empty($front_id)) { $pre_front_text = get_the_title($front_id); // Default to 'Home' } else { $pre_front_text = __('Home', 'bbpress'); } } /** Root Text *********************************************************/ // No custom root text if (empty($args['root_text'])) { $page = bbp_get_page_by_path(bbp_get_root_slug()); if (!empty($page)) { $root_id = $page->ID; } $pre_root_text = bbp_get_forum_archive_title(); } /** Includes **********************************************************/ // Root slug is also the front page if (!empty($front_id) && $front_id == $root_id) { $pre_include_root = false; } // Don't show root if viewing forum archive if (bbp_is_forum_archive()) { $pre_include_root = false; } // Don't show root if viewing page in place of forum archive if (!empty($root_id) && ((is_single() || is_page()) && $root_id == get_the_ID())) { $pre_include_root = false; } /** Current Text ******************************************************/ // Forum archive if (bbp_is_forum_archive()) { $pre_current_text = bbp_get_forum_archive_title(); // Topic archive } elseif (bbp_is_topic_archive()) { $pre_current_text = bbp_get_topic_archive_title(); // View } elseif (bbp_is_single_view()) { $pre_current_text = bbp_get_view_title(); // Single Forum } elseif (bbp_is_single_forum()) { $pre_current_text = bbp_get_forum_title(); // Single Topic } elseif (bbp_is_single_topic()) { $pre_current_text = bbp_get_topic_title(); // Single Topic } elseif (bbp_is_single_reply()) { $pre_current_text = bbp_get_reply_title(); // Topic Tag (or theme compat topic tag) } elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag') && !bbp_is_topic_tag_edit()) { // Always include the tag name $tag_data[] = bbp_get_topic_tag_name(); // If capable, include a link to edit the tag if (current_user_can('manage_topic_tags')) { $tag_data[] = '<a href="' . bbp_get_topic_tag_edit_link() . '" class="bbp-edit-topic-tag-link">' . __('(Edit)', 'bbpress') . '</a>'; } // Implode the results of the tag data $pre_current_text = sprintf(__('Topic Tag: %s', 'bbpress'), implode(' ', $tag_data)); // Edit Topic Tag } elseif (bbp_is_topic_tag_edit()) { $pre_current_text = __('Edit', 'bbpress'); // Single } else { $pre_current_text = get_the_title(); } /** Parse Args ********************************************************/ // Parse args $defaults = array('before' => '<div class="bbp-breadcrumb"><p>', 'after' => '</p></div>', 'sep' => __('›', 'bbpress'), 'pad_sep' => 1, 'include_home' => $pre_include_home, 'home_text' => $pre_front_text, 'include_root' => $pre_include_root, 'root_text' => $pre_root_text, 'include_current' => $pre_include_current, 'current_text' => $pre_current_text); $r = bbp_parse_args($args, $defaults, 'get_breadcrumb'); extract($r); /** Ancestors *********************************************************/ // Get post ancestors if (is_page() || is_single() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit()) { $ancestors = array_reverse(get_post_ancestors(get_the_ID())); } // Do we want to include a link to home? if (!empty($include_home) || empty($home_text)) { $crumbs[] = '<a href="' . trailingslashit(home_url()) . '" class="bbp-breadcrumb-home">' . $home_text . '</a>'; } // Do we want to include a link to the forum root? if (!empty($include_root) || empty($root_text)) { // Page exists at root slug path, so use its permalink $page = bbp_get_page_by_path(bbp_get_root_slug()); if (!empty($page)) { $root_url = get_permalink($page->ID); // Use the root slug } else { $root_url = get_post_type_archive_link(bbp_get_forum_post_type()); } // Add the breadcrumb $crumbs[] = '<a href="' . $root_url . '" class="bbp-breadcrumb-root">' . $root_text . '</a>'; } // Ancestors exist if (!empty($ancestors)) { // Loop through parents foreach ((array) $ancestors as $parent_id) { // Parents $parent = get_post($parent_id); // Switch through post_type to ensure correct filters are applied switch ($parent->post_type) { // Forum case bbp_get_forum_post_type(): $crumbs[] = '<a href="' . bbp_get_forum_permalink($parent->ID) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title($parent->ID) . '</a>'; break; // Topic // Topic case bbp_get_topic_post_type(): $crumbs[] = '<a href="' . bbp_get_topic_permalink($parent->ID) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title($parent->ID) . '</a>'; break; // Reply (Note: not in most themes) // Reply (Note: not in most themes) case bbp_get_reply_post_type(): $crumbs[] = '<a href="' . bbp_get_reply_permalink($parent->ID) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title($parent->ID) . '</a>'; break; // WordPress Post/Page/Other // WordPress Post/Page/Other default: $crumbs[] = '<a href="' . get_permalink($parent->ID) . '" class="bbp-breadcrumb-item">' . get_the_title($parent->ID) . '</a>'; break; } } // Edit topic tag } elseif (bbp_is_topic_tag_edit()) { $crumbs[] = '<a href="' . get_term_link(bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id()) . '" class="bbp-breadcrumb-topic-tag">' . sprintf(__('Topic Tag: %s', 'bbpress'), bbp_get_topic_tag_name()) . '</a>'; } /** Current ***********************************************************/ // Add current page to breadcrumb if (!empty($include_current) || empty($pre_current_text)) { $crumbs[] = '<span class="bbp-breadcrumb-current">' . $current_text . '</span>'; } /** Separator *********************************************************/ // Wrap the separator in a span before padding and filter if (!empty($sep)) { $sep = '<span class="bbp-breadcrumb-separator">' . $sep . '</span>'; } // Pad the separator if (!empty($pad_sep)) { $sep = str_pad($sep, strlen($sep) + (int) $pad_sep * 2, ' ', STR_PAD_BOTH); } /** Finish Up *********************************************************/ // Filter the separator and breadcrumb $sep = apply_filters('bbp_breadcrumb_separator', $sep); $crumbs = apply_filters('bbp_breadcrumbs', $crumbs); // Build the trail $trail = !empty($crumbs) ? $before . implode($sep, $crumbs) . $after : ''; return apply_filters('bbp_get_breadcrumb', $trail, $crumbs, $r); }
/** * Remove the canonical redirect to allow pretty pagination * * @since bbPress (r2628) * @param string $redirect_url Redirect url * @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks * @uses bbp_get_paged() To get the current page number * @uses bbp_is_single_topic() To check if it's a topic page * @uses bbp_is_single_forum() To check if it's a forum page * @return bool|string False if it's a topic/forum and their first page, * otherwise the redirect url */ function bbp_redirect_canonical($redirect_url) { global $wp_rewrite; // Canonical is for the beautiful if ($wp_rewrite->using_permalinks()) { // If viewing beyond page 1 of several if (1 < bbp_get_paged()) { // Only on single topics... if (bbp_is_single_topic()) { $redirect_url = false; // ...and single forums... } elseif (bbp_is_single_forum()) { $redirect_url = false; // ...and single replies... } elseif (bbp_is_single_reply()) { $redirect_url = false; // ...and any single anything else... // // @todo - Find a more accurate way to disable paged canonicals for // paged shortcode usage within other posts. } elseif (is_page() || is_singular()) { $redirect_url = false; } // If editing a topic } elseif (bbp_is_topic_edit()) { $redirect_url = false; // If editing a reply } elseif (bbp_is_reply_edit()) { $redirect_url = false; } } return $redirect_url; }
/** * Get the Post ID * Added support for sale of bbPress items. * @since 1.3.3.2 * @version 1.0 */ public function get_post_ID() { $post_id = $bbp_topic_id = $bbp_reply_id = 0; if (function_exists('bbpress')) { global $wp_query; $bbp = bbpress(); // Currently inside a topic loop if (!empty($bbp->topic_query->in_the_loop) && isset($bbp->topic_query->post->ID)) { $bbp_topic_id = $bbp->topic_query->post->ID; } elseif (!empty($bbp->search_query->in_the_loop) && isset($bbp->search_query->post->ID) && bbp_is_topic($bbp->search_query->post->ID)) { $bbp_topic_id = $bbp->search_query->post->ID; } elseif ((bbp_is_single_topic() || bbp_is_topic_edit()) && !empty($bbp->current_topic_id)) { $bbp_topic_id = $bbp->current_topic_id; } elseif ((bbp_is_single_topic() || bbp_is_topic_edit()) && isset($wp_query->post->ID)) { $bbp_topic_id = $wp_query->post->ID; } // So far, no topic found, check if we are in a reply if ($bbp_topic_id == 0) { // Currently inside a replies loop if (!empty($bbp->reply_query->in_the_loop) && isset($bbp->reply_query->post->ID)) { $bbp_reply_id = $bbp->reply_query->post->ID; } elseif (!empty($bbp->search_query->in_the_loop) && isset($bbp->search_query->post->ID) && bbp_is_reply($bbp->search_query->post->ID)) { $bbp_reply_id = $bbp->search_query->post->ID; } elseif ((bbp_is_single_reply() || bbp_is_reply_edit()) && !empty($bbp->current_reply_id)) { $bbp_reply_id = $bbp->current_reply_id; } elseif ((bbp_is_single_reply() || bbp_is_reply_edit()) && isset($wp_query->post->ID)) { $bbp_reply_id = $wp_query->post->ID; } if ($bbp_reply_id != 0) { $post_id = $bbp_reply_id; } } else { $post_id = $bbp_topic_id; } } if ($post_id == 0 && isset($GLOBALS['post'])) { $post_id = $GLOBALS['post']->ID; } return apply_filters('mycred_sell_this_get_post_ID', $post_id, $this); }
/** * 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); }
?> <?php do_action('bbp_theme_before_reply_form_content'); ?> <?php bbp_the_content(array('context' => 'reply', 'tinymce' => true)); ?> <?php do_action('bbp_theme_after_reply_form_content'); ?> <?php if (bbp_is_anonymous() || bbp_is_topic_edit() && bbp_is_topic_anonymous() || bbp_is_reply_edit() && bbp_is_reply_anonymous()) { ?> </div><!-- col-xs-12 col-sm-8 col-md-8 --> </div><!-- row --> <?php } ?> <?php /*if ( !current_user_can( 'unfiltered_html' ) ) : ?> <p class="form-allowed-tags"> <label><?php _e( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes:', 'firmasite' ); ?></label><br /> <pre><?php bbp_allowed_tags(); ?></pre> </p>
function get_forum_id($forum_id) { if (!$forum_id) { if (bbp_is_topic_edit()) { $forum_id = bbp_get_topic_forum_id(); } elseif (bbp_is_single_reply() || bbp_is_reply_edit()) { $forum_id = bbp_get_reply_forum_id(); } } return $forum_id; }
/** * Performs a series of checks to ensure the current user can create topics. * * @since bbPress (r3127) * * @uses bbp_is_topic_edit() * @uses current_user_can() * @uses bbp_get_topic_id() * @uses bbp_allow_anonymous() * @uses is_user_logged_in() * * @return bool */ function bbp_current_user_can_access_create_topic_form() { // Users need to earn access $retval = false; // Always allow super admins if (is_super_admin()) { $retval = true; } elseif ((bbp_is_single_forum() || is_page() || is_single()) && bbp_is_forum_open()) { $retval = bbp_current_user_can_publish_topics(); } elseif (bbp_is_topic_edit()) { $retval = current_user_can('edit_topic', bbp_get_topic_id()); } // Allow access to be filtered return (bool) apply_filters('bbp_current_user_can_access_create_topic_form', (bool) $retval); }
* @package bbPress * @subpackage Theme */ ?> <?php if (bbp_current_user_can_access_anonymous_user_form()) { ?> <?php do_action('bbp_theme_before_anonymous_form'); ?> <fieldset class="bbp-form"> <legend><?php bbp_is_topic_edit() || bbp_is_reply_edit() ? _e('Author Information', 'omega-td') : _e('Your information:', 'omega-td'); ?> </legend> <?php do_action('bbp_theme_anonymous_form_extras_top'); ?> <p> <label for="bbp_anonymous_author"><?php _e('Name (required):', 'omega-td'); ?> </label><br /> <input type="text" id="bbp_anonymous_author" value="<?php bbp_author_display_name(); ?>
/** * Return checked value of topic subscription * * @since bbPress (r2976) * * @uses bbp_is_topic_edit() To check if it's the topic edit page * @uses bbp_is_user_subscribed() To check if the user is subscribed to * the topic * @uses apply_filters() Calls 'bbp_get_form_topic_subscribed' with the * option * @return string Checked value of topic subscription */ function bbp_get_form_topic_subscribed() { // Get _POST data if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && isset($_POST['bbp_topic_subscription'])) { $topic_subscribed = $_POST['bbp_topic_subscription']; // Get edit data } elseif (bbp_is_topic_edit() || bbp_is_reply_edit()) { // Get current posts author $post_author = bbp_get_global_post_field('post_author', 'raw'); // Post author is not the current user if (bbp_get_current_user_id() != $post_author) { $topic_subscribed = bbp_is_user_subscribed($post_author); // Post author is the current user } else { $topic_subscribed = bbp_is_user_subscribed(bbp_get_current_user_id()); } // Get current status } elseif (bbp_is_single_topic()) { $topic_subscribed = bbp_is_user_subscribed(bbp_get_current_user_id()); // No data } else { $topic_subscribed = 0; } // Get checked output $checked = checked($topic_subscribed, true, false); return apply_filters('bbp_get_form_topic_subscribed', $checked, $topic_subscribed); }
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; }
/** * Redirect if unathorized user is attempting to edit a topic * * @since bbPress (r3605) * * @uses bbp_is_topic_edit() * @uses current_user_can() * @uses bbp_get_topic_id() * @uses wp_safe_redirect() * @uses bbp_get_topic_permalink() */ function bbp_check_topic_edit() { // Bail if not editing a topic if (!bbp_is_topic_edit()) { return; } // User cannot edit topic, so redirect back to topic if (!current_user_can('edit_topic', bbp_get_topic_id())) { wp_safe_redirect(bbp_get_topic_permalink()); exit; } }
type="checkbox" value="bbp_subscribe" <?php bbp_form_topic_subscribed(); ?> <?php if (!bbp_is_topic_edit()) { echo 'checked="checked"'; } ?> tabindex="<?php bbp_tab_index(); ?> " /> <?php if (bbp_is_topic_edit() && bbp_get_topic_author_id() !== bbp_get_current_user_id()) { ?> <?php _e('Notify the author of follow-up replies via email', 'bbpress'); ?> <?php } else { ?> <?php _e('Notify me of follow-up replies via email', 'bbpress'); ?> <?php } ?> </label> </p>
* @package bbPress * @subpackage Theme */ ?> <?php if (bbp_current_user_can_access_anonymous_user_form()) { ?> <?php do_action('bbp_theme_before_anonymous_form'); ?> <fieldset class="bbp-form"> <legend><?php bbp_is_topic_edit() || bbp_is_reply_edit() ? _e('Author Information', 'bbpress') : _e('Your information:', 'bbpress'); ?> </legend> <?php do_action('bbp_theme_anonymous_form_extras_top'); ?> <p> <label for="bbp_anonymous_author"><?php _e('Name (required):', 'bbpress'); ?> </label><br /> <input type="text" id="bbp_anonymous_author" value="<?php bbp_author_display_name(); ?>
<input type="text" id="bbp_anonymous_email" value="<?php bbp_is_topic_edit() ? bbp_topic_author_email() : bbp_is_reply_edit() ? bbp_reply_author_email() : bbp_current_anonymous_user_data('email'); ?> " tabindex="<?php bbp_tab_index(); ?> " size="40" name="bbp_anonymous_email" /> </p> <p> <label for="bbp_anonymous_website"><?php _e('Website:', 'bbpress'); ?> </label><br /> <input type="text" id="bbp_anonymous_website" value="<?php bbp_is_topic_edit() ? bbp_topic_author_url() : bbp_is_reply_edit() ? bbp_reply_author_url() : bbp_current_anonymous_user_data('website'); ?> " tabindex="<?php bbp_tab_index(); ?> " size="40" name="bbp_anonymous_website" /> </p> <?php do_action('bbp_theme_anonymous_form_extras_bottom'); ?> </fieldset> <?php do_action('bbp_theme_after_anonymous_form');
*/ ?> <?php if (bbp_current_user_can_access_anonymous_user_form()) { ?> <div class="row"> <div class="col-xs-12 col-sm-5 col-md-5"> <?php do_action('bbp_theme_before_anonymous_form'); ?> <fieldset class="bbp-form"> <legend><?php bbp_is_topic_edit() || bbp_is_reply_edit() ? _e('Author Information', 'firmasite') : _e('Your information:', 'firmasite'); ?> </legend> <?php do_action('bbp_theme_anonymous_form_extras_top'); ?> <div class="form-group"> <div class="input-group"> <span class="input-group-addon"><i class="icon-user"></i></span> <input type="text" id="bbp_anonymous_author" class="form-control" placeholder="<?php _e('Name (required):', 'firmasite'); ?> " value="<?php bbp_author_display_name();
/** * Return checked value of topic subscription * * @since 2.0.0 bbPress (r2976) * * @uses bbp_is_topic_edit() To check if it's the topic edit page * @uses bbp_is_user_subscribed_to_topic() To check if the user is * subscribed to the topic * @uses apply_filters() Calls 'bbp_get_form_topic_subscribed' with the * option * @return string Checked value of topic subscription */ function bbp_get_form_topic_subscribed() { // Get _POST data if (bbp_is_topic_form_post_request() && isset($_POST['bbp_topic_subscription'])) { $topic_subscribed = (bool) $_POST['bbp_topic_subscription']; // Get edit data } elseif (bbp_is_topic_edit() || bbp_is_reply_edit()) { // Get current posts author $post_author = bbp_get_global_post_field('post_author', 'raw'); // Post author is not the current user if (bbp_get_current_user_id() !== $post_author) { $topic_subscribed = bbp_is_user_subscribed_to_topic($post_author); // Post author is the current user } else { $topic_subscribed = bbp_is_user_subscribed_to_topic(bbp_get_current_user_id()); } // Get current status } elseif (bbp_is_single_topic()) { $topic_subscribed = bbp_is_user_subscribed_to_topic(bbp_get_current_user_id()); // No data } else { $topic_subscribed = false; } // Get checked output $checked = checked($topic_subscribed, true, false); return apply_filters('bbp_get_form_topic_subscribed', $checked, $topic_subscribed); }
/** * Performs a series of checks to ensure the current user should see the * anonymous user form fields. * * @since 2.5.0 bbPress (r5119) * * @uses bbp_is_anonymous() * @uses bbp_is_topic_edit() * @uses bbp_is_topic_anonymous() * @uses bbp_is_reply_edit() * @uses bbp_is_reply_anonymous() * * @return bool */ function bbp_current_user_can_access_anonymous_user_form() { // Users need to earn access $retval = false; // User is not logged in, and anonymous posting is allowed if (bbp_is_anonymous()) { $retval = true; // User is editing a topic, and topic is authored by anonymous user } elseif (bbp_is_topic_edit() && bbp_is_topic_anonymous()) { $retval = true; // User is editing a reply, and reply is authored by anonymous user } elseif (bbp_is_reply_edit() && bbp_is_reply_anonymous()) { $retval = true; } // Allow access to be filtered return (bool) apply_filters('bbp_current_user_can_access_anonymous_user_form', (bool) $retval); }
/** * 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); }
/** * 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 } ?> </p> <?php do_action('bbp_theme_after_topic_form_subscriptions'); ?> <?php } ?> <?php if (bbp_allow_revisions() && bbp_is_topic_edit()) { ?> <?php do_action('bbp_theme_before_topic_form_revisions'); ?> <fieldset class="bbp-form"> <legend> <input name="bbp_log_topic_edit" id="bbp_log_topic_edit" type="checkbox" value="1" <?php bbp_form_topic_log_edit(); ?> tabindex="<?php bbp_tab_index(); ?> " />
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>"; }