/** * Links the users & tags in posts * * @see bp_activity_at_name_filter() BuddyPress Function * * @param $content The content to be parsed */ function em_do_linking($content) { global $em_plugopts; if ($em_plugopts['link-tags'] == 1) { preg_match_all('/[#]+([A-Za-z0-9-_]+)/', $content, $tags); $tags = $tags[1]; foreach ((array) $tags as $tag) { if (!($t = bb_get_tag($tag))) { continue; } if ($link = bb_get_tag_link($t)) { $content = str_replace("#{$tag}", "#<a href='" . $link . "'>{$tag}</a>", $content); } //should we add rel='nofollow'? } } if ($em_plugopts['link-users'] == 1) { preg_match_all('/[@]+([A-Za-z0-9-_]+)/', $content, $usernames); $usernames = $usernames[1]; foreach ((array) $usernames as $username) { if (!($user = bb_get_user($username, array('by' => 'login')))) { //check #1, by username if (!($user = bb_get_user($username, array('by' => 'nicename')))) { //check #2, by nicename continue; } } /* Increase the number of new @ mentions for the user - maybe later */ /*$new_mention_count = (int)bb_get_usermeta( $user_id, 'em_mention_count' ); bb_update_usermeta( $user_id, 'em_mention_count', $new_mention_count + 1 );*/ if ('website' == $em_plugopts['link-user-to']) { if (!($link = $user->user_url)) { $link = get_user_profile_link($user->ID); } } else { $link = get_user_profile_link($user->ID); } if ($link) { $content = str_replace("@{$username}", "@<a href='" . $link . "'>{$username}</a>", $content); } //should we add rel='nofollow'? } } return $content; }
<?php require 'admin.php'; if (!bb_current_user_can('manage_tags')) { bb_die(__('You are not allowed to manage tags.')); } $tag_id = (int) $_POST['id']; $tag = stripslashes($_POST['tag']); bb_check_admin_referer('rename-tag_' . $tag_id); if (!($old_tag = bb_get_tag($tag_id))) { bb_die(__('Tag not found.')); } if ($tag = bb_rename_tag($tag_id, $tag)) { wp_redirect(bb_get_tag_link()); } else { bb_die(printf(__('There already exists a tag by that name or the name is invalid. <a href="%s">Try Again</a>'), wp_get_referer())); } exit;
function bb_repermalink() { global $page; $location = bb_get_location(); $uri = $_SERVER['REQUEST_URI']; if (isset($_GET['id'])) { $id = $_GET['id']; } else { $id = bb_get_path(); } $_original_id = $id; do_action('pre_permalink', $id); $id = apply_filters('bb_repermalink', $id); switch ($location) { case 'front-page': $path = null; $querystring = null; if ($page > 1) { if (bb_get_option('mod_rewrite')) { $path = 'page/' . $page; } else { $querystring = array('page' => $page); } } $permalink = bb_get_uri($path, $querystring, BB_URI_CONTEXT_HEADER); $issue_404 = true; break; case 'forum-page': if (empty($id)) { $permalink = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER); break; } global $forum_id, $forum; $forum = bb_get_forum($id); $forum_id = $forum->forum_id; $permalink = get_forum_link($forum->forum_id, $page); break; case 'topic-edit-page': case 'topic-page': if (empty($id)) { $permalink = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER); break; } global $topic_id, $topic; $topic = get_topic($id); $topic_id = $topic->topic_id; $permalink = get_topic_link($topic->topic_id, $page); break; case 'profile-page': // This handles the admin side of the profile as well. global $user_id, $user, $profile_hooks, $self; if (isset($_GET['id'])) { $id = $_GET['id']; } elseif (isset($_GET['username'])) { $id = $_GET['username']; } else { $id = bb_get_path(); } $_original_id = $id; if (!$id) { $user = bb_get_current_user(); // Attempt to go to the current users profile } else { if (bb_get_option('mod_rewrite') === 'slugs') { if (!($user = bb_get_user_by_nicename($id))) { $user = bb_get_user($id); } } else { if (!($user = bb_get_user($id))) { $user = bb_get_user_by_nicename($id); } } } if (!$user || 1 == $user->user_status && !bb_current_user_can('moderate')) { bb_die(__('User not found.'), '', 404); } $user_id = $user->ID; bb_global_profile_menu_structure(); $valid = false; if ($tab = isset($_GET['tab']) ? $_GET['tab'] : bb_get_path(2)) { foreach ($profile_hooks as $valid_tab => $valid_file) { if ($tab == $valid_tab) { $valid = true; $self = $valid_file; } } } if ($valid) { $permalink = get_profile_tab_link($user->ID, $tab, $page); } else { $permalink = get_user_profile_link($user->ID, $page); unset($self, $tab); } break; case 'favorites-page': $permalink = get_favorites_link(); break; case 'tag-page': // It's not an integer and tags.php pulls double duty. $id = isset($_GET['tag']) ? $_GET['tag'] : false; if (!$id || !bb_get_tag((string) $id)) { $permalink = bb_get_tag_page_link(); } else { global $tag, $tag_name; $tag_name = $id; $tag = bb_get_tag((string) $id); $permalink = bb_get_tag_link(0, $page); // 0 => grabs $tag from global. } break; case 'view-page': // Not an integer if (isset($_GET['view'])) { $id = $_GET['view']; } else { $id = bb_get_path(); } $_original_id = $id; global $view; $view = $id; $permalink = get_view_link($view, $page); break; default: return; break; } nxt_parse_str($_SERVER['QUERY_STRING'], $args); $args = urlencode_deep($args); if ($args) { $permalink = add_query_arg($args, $permalink); if (bb_get_option('mod_rewrite')) { $pretty_args = array('id', 'page', 'tag', 'tab', 'username'); // these are already specified in the path if ($location == 'view-page') { $pretty_args[] = 'view'; } foreach ($pretty_args as $pretty_arg) { $permalink = remove_query_arg($pretty_arg, $permalink); } } } $permalink = apply_filters('bb_repermalink_result', $permalink, $location); $domain = bb_get_option('domain'); $domain = preg_replace('/^https?/', '', $domain); $check = preg_replace('|^.*' . trim($domain, ' /') . '|', '', $permalink, 1); $uri = rtrim($uri, " \t\n\r\v?"); $uri = str_replace('/index.php', '/', $uri); global $bb_log; $bb_log->debug($uri, 'bb_repermalink() ' . __('REQUEST_URI')); $bb_log->debug($check, 'bb_repermalink() ' . __('should be')); $bb_log->debug($permalink, 'bb_repermalink() ' . __('full permalink')); $bb_log->debug(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : null, 'bb_repermalink() ' . __('PATH_INFO')); if ($check != $uri && $check != str_replace(urlencode($_original_id), $_original_id, $uri)) { if ($issue_404 && rtrim($check, " \t\n\r\v/") !== rtrim($uri, " \t\n\r\v/")) { status_header(404); bb_load_template('404.php'); } else { nxt_redirect($permalink); } exit; } do_action('post_permalink', $permalink); }
/** * Prepares topic tag data for return in an XML-RPC object * * @since 1.0 * @return array The prepared topic tag data * @param array|object The unprepared topic tag data **/ function prepare_topic_tag($tag) { // Cast to an array $_tag = (array) $tag; // Set the URI $_tag['topic_tag_uri'] = bb_get_tag_link($tag); // Consistent nomenclature $_tag['topic_tag_name'] = (string) $_tag['name']; $_tag['topic_tag_slug'] = (string) $_tag['slug']; $_tag['topic_tag_count'] = (int) $_tag['count']; // Remove some sensitive data unset($_tag['object_id'], $_tag['name'], $_tag['slug'], $_tag['count'], $_tag['term_id'], $_tag['term_group'], $_tag['term_taxonomy_id'], $_tag['taxonomy'], $_tag['description'], $_tag['parent'], $_tag['count'], $_tag['user_id'], $_tag['tag_id'], $_tag['tag'], $_tag['raw_tag'], $_tag['tag_count']); // Allow plugins to modify the data return apply_filters('bb_xmlrpc_prepare_topic_tag', $_tag, (array) $tag); }
function get_tag_link() { bb_log_deprecated('function', __FUNCTION__, 'bb_get_tag_link'); bb_get_tag_link(); }
function bb_get_tag_heat_map($tags, $args = '') { $defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'limit' => 45, 'format' => 'flat'); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); if (!$tags) { return; } foreach ((array) $tags as $tag) { $counts[$tag->raw_tag] = $tag->tag_count; $taglinks[$tag->raw_tag] = bb_get_tag_link($tag); } $min_count = min($counts); $spread = max($counts) - $min_count; if ($spread <= 0) { $spread = 1; } $fontspread = $largest - $smallest; if ($fontspread <= 0) { $fontspread = 1; } $fontstep = $fontspread / $spread; do_action_ref_array('sort_tag_heat_map', array(&$counts)); $a = array(); foreach ($counts as $tag => $count) { $taglink = esc_attr($taglinks[$tag]); $tag = str_replace(' ', ' ', esc_html($tag)); $fontsize = round($smallest + ($count - $min_count) * $fontstep, 1); $a[] = "<a href='{$taglink}' title='" . esc_attr(sprintf(__('%d topics'), $count)) . "' rel='tag' style='font-size:{$fontsize}{$unit};'>{$tag}</a>"; } switch ($format) { case 'array': $r =& $a; break; case 'list': $r = "<ul class='bb-tag-heat-map'>\n\t<li>"; $r .= join("</li>\n\t<li>", $a); $r .= "</li>\n</ul>\n"; break; default: $r = join("\n", $a); break; } return apply_filters('bb_get_tag_heat_map', $r, $tags, $args); }
foreach ($topics as $topic) { $posts[] = bb_get_first_post($topic->topic_id); } $title = esc_html(sprintf(__('%1$s » Tag: %2$s - Recent Topics'), bb_get_option('name'), bb_get_tag_name())); $link = bb_get_tag_link($feed_id); $link_self = bb_get_tag_topics_rss_link($feed_id); break; case 'tag-posts': if (!($tag = bb_get_tag($feed_id))) { die; } if (!($posts = get_tagged_topic_posts(array('tag_id' => $tag->tag_id, 'page' => 0)))) { die; } $title = esc_html(sprintf(__('%1$s » Tag: %2$s - Recent Posts'), bb_get_option('name'), bb_get_tag_name())); $link = bb_get_tag_link($feed_id); $link_self = bb_get_tag_posts_rss_link($feed_id); break; case 'forum-topics': if (!($topics = get_latest_topics($feed_id))) { die; } $posts = array(); foreach ($topics as $topic) { $posts[] = bb_get_first_post($topic->topic_id); } $title = esc_html(sprintf(__('%1$s » Forum: %2$s - Recent Topics'), bb_get_option('name'), get_forum_name($feed_id))); $link = get_forum_link($feed_id); $link_self = bb_get_forum_topics_rss_link($feed_id); break; case 'forum-posts':
<?php require 'admin.php'; if (!bb_current_user_can('manage_tags')) { bb_die(__('You are not allowed to manage tags.')); } $old_id = (int) $_POST['id']; $tag = $_POST['tag']; bb_check_admin_referer('merge-tag_' . $old_id); if (!($tag = bb_get_tag($tag))) { bb_die(__('The destination tag you specified could not be found.')); } if (!bb_get_tag($old_id)) { bb_die(__('The original tag could not be found.')); } if ($merged = bb_merge_tags($old_id, $tag->tag_id)) { bb_die(sprintf(__("Number of topics from which the old tag was removed: %d <br />\n"), $merged['old_count']) . sprintf(__("Number of topics to which the new tag was added: %d <br />\n"), $merged['diff_count']) . sprintf(__("Number of rows deleted from tags table:%d <br />\n"), $merged['destroyed']['tags']) . sprintf(__('<a href="%s">View Results of Merge</a>'), bb_get_tag_link())); } else { bb_die(printf(__("Something odd happened when attempting to merge those tags.<br />\n<a href=\"%s\">Try Again?</a>"), nxt_get_referer())); }
<?php require 'admin.php'; if (!bb_current_user_can('manage_tags')) { bb_die(__('You are not allowed to manage tags.')); } $old_id = (int) $_POST['id']; $tag = $_POST['tag']; bb_check_admin_referer('merge-tag_' . $old_id); if (!($tag = bb_get_tag($tag))) { bb_die(__('Tag specified not found.')); } if (!bb_get_tag($old_id)) { bb_die(__('Tag to be merged not found.')); } if ($merged = bb_merge_tags($old_id, $tag->tag_id)) { printf(__("Number of topics from which the old tag was removed: %d <br />\n"), $merged['old_count']); printf(__("Number of topics to which the new tag was added: %d <br />\n"), $merged['diff_count']); printf(__("Number of rows deleted from tags table:%d <br />\n"), $merged['destroyed']['tags']); printf(__('<a href="%s">New Tag</a>'), bb_get_tag_link()); } else { die(printf(__("Something odd happened when attempting to merge those tags.<br />\n<a href=\"%s\">Try Again?</a>"), wp_get_referer())); }