Search Results for '+.+default+.+'
-
AuthorSearch Results
-
September 7, 2009 at 9:43 am #31661
Topic: How to load the header of my theme?
in forum Themespixelgirl
MemberHi all,
I am running wpmu, buddypress along with bbpress. After deep intergration, Everything works well, except that the theme in my forum doesn’t look the way I want. I want it look like my own theme I use for buddypress, with the header, navi and footer. The Rest can still be adjusted with css, that’s not the big deal, I’d use the default bbpress theme as a base to do that.
I have tried ThemePresss, but it would mess up everything, not show the buddybar and the link to the forums. Is there any other way to make my forums look the way I want?
Thnx in advance,
pxlgirl.
September 5, 2009 at 12:53 am #77508In reply to: All RSS Feeds Broken?
Adam Harley (Kawauso)
MemberWith the final patch from track applied against 1.0.2 trunk you get:
bb-templates/kakumei/rss2.php
<?php
header( 'Content-Type: text/xml; charset=UTF-8' );
echo '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "n";
bb_generator( 'comment' );
?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?php echo $title; ?></title>
<link><?php echo $link; ?></link>
<description><?php echo $description; ?></description>
<language><?php esc_html( bb_option('language') ); ?></language>
<pubDate><?php echo gmdate('D, d M Y H:i:s +0000'); ?></pubDate>
<?php bb_generator( 'rss2' ); ?>
<textInput>
<title><![CDATA[<?php _e('Search'); ?>]]></title>
<description><![CDATA[<?php _e('Search all topics from these forums.'); ?>]]></description>
<name>q</name>
<link><?php bb_uri('search.php'); ?></link>
</textInput>
<atom:link href="<?php echo $link_self; ?>" rel="self" type="application/rss+xml" />
<?php foreach ($posts as $bb_post) : ?>
<item>
<title><?php post_author(); ?> <?php _e('on')?> "<?php topic_title( $bb_post->topic_id ); ?>"</title>
<link><?php post_link(); ?></link>
<pubDate><?php bb_post_time('D, d M Y H:i:s +0000', array( 'localize' => false ) ); ?></pubDate>
<dc:creator><?php post_author(); ?></dc:creator>
<guid isPermaLink="false"><?php post_id(); ?>@<?php bb_uri(); ?></guid>
<description><?php post_text(); ?></description>
</item>
<?php endforeach; ?>
</channel>
</rss>bb-includes/defaults.bb-filters.php
<?php
/**
* Sets up the default filters and actions for most
* of the bbPress hooks.
*
* If you need to remove a default hook, this file will
* give you the priority for which to use to remove the
* hook.
*
* Not all of the default hooks are found in this files
*
* @package bbPress
*/
// Strip, trim, kses, special chars for string saves
$filters = array( 'pre_term_name', 'bb_pre_forum_name', 'pre_topic_title' );
foreach ( $filters as $filter ) {
add_filter( $filter, 'strip_tags' );
add_filter( $filter, 'trim' );
add_filter( $filter, 'bb_filter_kses' );
add_filter( $filter, 'esc_html', 30 );
}
// Kses only for textarea saves
$filters = array( 'pre_term_description', 'bb_pre_forum_desc' );
foreach ( $filters as $filter ) {
add_filter( $filter, 'bb_filter_kses' );
}
// Slugs
add_filter( 'pre_term_slug', 'bb_pre_term_slug' );
// DB truncations
add_filter( 'pre_topic_title', 'bb_trim_for_db_150', 9999 );
add_filter( 'bb_pre_forum_name', 'bb_trim_for_db_150', 9999 );
add_filter( 'pre_term_name', 'bb_trim_for_db_55', 9999 );
// Format Strings for Display
$filters = array( 'forum_name', 'topic_title', 'bb_title', 'bb_option_name' );
foreach ( $filters as $filter ) {
add_filter( $filter, 'esc_html' );
}
// Numbers
$filters = array( 'forum_topics', 'forum_posts', 'total_posts', 'total_users', 'total_topics' );
foreach ( $filters as $filter ) {
add_filter( $filter, 'bb_number_format_i18n' );
}
// Offset Times
$filters = array( 'topic_time', 'topic_start_time', 'bb_post_time' );
foreach ( $filters as $filter ) {
add_filter( $filter, 'bb_offset_time', 10, 2 );
}
add_filter('bb_topic_labels', 'bb_closed_label', 10);
add_filter('bb_topic_labels', 'bb_sticky_label', 20);
add_filter('pre_post', 'trim');
add_filter('pre_post', 'bb_encode_bad');
add_filter('pre_post', 'bb_code_trick');
add_filter('pre_post', 'force_balance_tags');
add_filter('pre_post', 'bb_filter_kses', 50);
add_filter('pre_post', 'bb_autop', 60);
add_filter('post_text', 'do_shortcode');
function bb_contextualise_search_post_text()
{
if ( bb_is_search() ) {
add_filter( 'get_post_text', 'bb_post_text_context' );
}
}
add_action( 'bb_init', 'bb_contextualise_search_post_text' );
add_filter('post_text', 'make_clickable');
add_filter('edit_text', 'bb_code_trick_reverse');
add_filter('edit_text', 'wp_specialchars');
add_filter('edit_text', 'trim', 15);
add_filter('pre_sanitize_with_dashes', 'bb_pre_sanitize_with_dashes_utf8', 10, 3 );
add_filter('get_user_link', 'bb_fix_link');
add_filter('sanitize_profile_info', 'esc_html');
add_filter('sanitize_profile_admin', 'esc_html');
add_filter( 'get_recent_user_replies_fields', 'bb_get_recent_user_replies_fields' );
add_filter( 'get_recent_user_replies_group_by', 'bb_get_recent_user_replies_group_by' );
add_filter('sort_tag_heat_map', 'bb_sort_tag_heat_map');
// URLS
if ( !bb_get_option( 'mod_rewrite' ) ) {
add_filter( 'bb_stylesheet_uri', 'esc_attr', 1, 9999 );
add_filter( 'forum_link', 'esc_attr', 1, 9999 );
add_filter( 'bb_forum_posts_rss_link', 'esc_attr', 1, 9999 );
add_filter( 'bb_forum_topics_rss_link', 'esc_attr', 1, 9999 );
add_filter( 'bb_tag_link', 'esc_attr', 1, 9999 );
add_filter( 'tag_rss_link', 'esc_attr', 1, 9999 );
add_filter( 'topic_link', 'esc_attr', 1, 9999 );
add_filter( 'topic_rss_link', 'esc_attr', 1, 9999 );
add_filter( 'post_link', 'esc_attr', 1, 9999 );
add_filter( 'post_anchor_link', 'esc_attr', 1, 9999 );
add_filter( 'user_profile_link', 'esc_attr', 1, 9999 );
add_filter( 'profile_tab_link', 'esc_attr', 1, 9999 );
add_filter( 'favorites_link', 'esc_attr', 1, 9999 );
add_filter( 'view_link', 'esc_attr', 1, 9999 );
}
// Feed Stuff
function bb_filter_feed_content()
{
if ( bb_is_feed() ) {
add_filter( 'bb_title_rss', 'strip_tags');
add_filter( 'bb_title_rss', 'ent2ncr',;
add_filter( 'bb_title_rss', 'esc_html' );
add_filter( 'bb_description_rss', 'strip_tags');
add_filter( 'bb_description_rss', 'ent2ncr', 8 );
add_filter( 'bb_description_rss', 'esc_html' );
add_filter( 'post_author', 'ent2ncr', 8 );
add_filter( 'post_link', 'esc_html' );
add_filter( 'post_text', 'ent2ncr' );
add_filter( 'post_text', 'htmlspecialchars' ); // encode_bad should not be overruled by esc_html
}
}
add_action( 'bb_init', 'bb_filter_feed_content' );
add_filter( 'init_roles', 'bb_init_roles' );
add_filter( 'map_meta_cap', 'bb_map_meta_cap', 1, 4 );
// Actions
add_action( 'bb_head', 'bb_generator' );
add_action('bb_head', 'bb_template_scripts');
add_action('bb_head', 'wp_print_scripts');
add_action('bb_head', 'wp_print_styles');
add_action('bb_head', 'bb_rsd_link');
add_action('bb_head', 'bb_pingback_link');
if ( $bb_log->type === 'console' ) {
add_action('bb_head', array(&$bb_log, 'console_javascript'));
add_action('bb_admin_head', array(&$bb_log, 'console_javascript'));
}
add_action('bb_send_headers', 'bb_pingback_header');
add_action('bb_admin_print_scripts', 'wp_print_scripts');
add_action('bb_user_has_no_caps', 'bb_give_user_default_role');
add_action('do_pingbacks', array('BB_Pingbacks', 'send_all'), 10, 1);
add_action( 'bb_init', 'bb_register_default_views' );
add_action( 'set_current_user', 'bb_apply_wp_role_map_to_user' );
add_filter( 'bb_pre_get_option_gmt_offset', 'wp_timezone_override_offset' );
unset( $filters, $filter );rss.php
<?php
require('./bb-load.php');
// Determine the type of feed and the id of the object
if ( isset($_GET['view']) || bb_get_path() == 'view' ) {
// View
$feed = 'view';
$feed_id = isset($_GET['view']) ? $_GET['view'] : bb_get_path(2);
} elseif ( isset($_GET['topic']) || bb_get_path() == 'topic' ) {
// Topic
$feed = 'topic';
$topic = get_topic(isset($_GET['topic']) ? $_GET['topic'] : bb_get_path(2));
$feed_id = $topic->topic_id;
} elseif ( isset($_GET['profile']) || bb_get_path() == 'profile' ) {
// Profile
$feed = 'profile';
$feed_id = isset($_GET['profile']) ? $_GET['profile'] : bb_get_path(2);
} elseif ( isset($_GET['tag']) || bb_get_path() == 'tags' ) {
if ( isset($_GET['topics']) || bb_get_path(3) == 'topics' ) {
// Tag recent topics
$feed = 'tag-topics';
} else {
// Tag recent posts
$feed = 'tag-posts';
}
$feed_id = isset($_GET['tag']) ? $_GET['tag'] : bb_get_path(2);
} elseif ( isset($_GET['forum']) || bb_get_path() == 'forum' ) {
if ( isset($_GET['topics']) || bb_get_path(3) == 'topics' ) {
// Forum recent topics
$feed = 'forum-topics';
} else {
// Forum recent posts
$feed = 'forum-posts';
}
$forum = bb_get_forum(isset($_GET['forum']) ? $_GET['forum'] : bb_get_path(2));
$feed_id = $forum->forum_id;
} elseif ( isset($_GET['topics']) || bb_get_path() == 'topics' ) {
// Recent topics
$feed = 'all-topics';
} else {
// Recent posts
$feed = 'all-posts';
}
// Initialise the override variable
$bb_db_override = false;
do_action( 'bb_rss.php_pre_db' );
if ( !$bb_db_override ) {
// Get the posts and the title for the given feed
switch ($feed) {
case 'view':
if ( !isset($bb_views[$feed_id]) )
die();
if ( !$bb_views[$feed_id]['feed'] )
die();
if ( !$topics_object = new BB_Query( 'topic', $bb_views[$feed_id]['query'], "bb_view_$feed_id" ) )
die();
$topics = $topics_object->results;
if ( !$topics || !is_array($topics) )
die();
$posts = array();
foreach ($topics as $topic) {
$posts[] = bb_get_first_post($topic->topic_id);
}
$title = sprintf( __( '%1$s » View: %2$s' ), bb_get_option( 'name' ), $bb_views[$feed_id]['title'] );
$link = get_view_link($feed_id);
$link_self = bb_get_view_rss_link($feed_id);
break;
case 'topic':
if ( !$topic = get_topic ( $feed_id ) )
die();
if ( !$posts = get_thread( $feed_id, 0, 1 ) )
die();
$title = sprintf( __( '%1$s » Topic: %2$s' ), bb_get_option( 'name' ), get_topic_title() );
$link = get_topic_link($feed_id);
$link_self = get_topic_rss_link($feed_id);
break;
case 'profile':
if ( bb_get_option( 'mod_rewrite' ) === 'slugs' ) {
$user = bb_get_user_by_nicename( $feed_id );
} else {
$user = bb_get_user( $feed_id );
}
if ( !$user ) {
die();
}
if ( !$posts = get_user_favorites( $user->ID ) ) {
die();
}
$title = sprintf( __( '%1$s » User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_nicename );
$link = bb_get_profile_link($feed_id);
$link_self = get_favorites_rss_link($feed_id);
break;
case 'tag-topics':
if ( !$tag = bb_get_tag( $feed_id ) )
die();
if ( !$topics = get_tagged_topics( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ) )
die();
$posts = array();
foreach ($topics as $topic) {
$posts[] = bb_get_first_post($topic->topic_id);
}
$title = 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 = 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 = 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':
if ( !$posts = bb_get_latest_forum_posts( $feed_id ) )
die();
$title = sprintf( __( '%1$s » Forum: %2$s - Recent Posts' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) );
$link = get_forum_link($feed_id);
$link_self = bb_get_forum_posts_rss_link($feed_id);
break;
// Get just the first post from the latest topics
case 'all-topics':
if ( !$topics = get_latest_topics() )
die();
$posts = array();
foreach ($topics as $topic) {
$posts[] = bb_get_first_post($topic->topic_id);
}
$title = sprintf( __( '%1$s » Recent Topics' ), bb_get_option( 'name' ) );
$link = bb_get_uri();
$link_self = bb_get_topics_rss_link();
break;
// Get latest posts by default
case 'all-posts':
default:
if ( !$posts = bb_get_latest_posts( 35 ) )
die();
$title = sprintf( __( '%1$s » Recent Posts' ), bb_get_option( 'name' ) );
$link = bb_get_uri();
$link_self = bb_get_posts_rss_link();
break;
}
}
bb_send_304( $posts[0]->post_time );
if (!$description = bb_get_option( 'description' ) ) {
$description = $title;
}
$title = apply_filters( 'bb_title_rss', $title, $feed );
$description = apply_filters( 'bb_description_rss', $description, $feed );
$posts = apply_filters( 'bb_posts_rss', $posts, $feed );
$link_self = apply_filters( 'bb_link_self_rss', $link_self, $feed );
bb_load_template( 'rss2.php', array('bb_db_override', 'title', 'description', 'link', 'link_self'), $feed );
?>September 4, 2009 at 5:08 pm #78300In reply to: How to echo "nice_username" from post_author ?
gerikg
MemberI found it, but it interrupts _CK_’s attachment plugin. and I had other problems with it that hasn’t been resolved yet.
“@gerikg
That is a bug, I have fixed it in Social It 1.2, which is yet to be released.
For now, check the Twittley checkbox, add some default tags in the twittley section, save and then untick Twittley and save. “
September 3, 2009 at 3:31 pm #78584In reply to: Need to fix a couple of things in theme
Ashish Kumar (Ashfame)
ParticipantI fixed the second & third issue but I am still stuck at the first one.
Looking at the markup I found
<select name="forum_id" id="forum-id"">
is being generated by bbPress codebut the same works in default theme flawlessly so this isn’t the cause. Can I have the complete lookup order for file required to generate the “Add new” page.September 2, 2009 at 3:25 pm #78564In reply to: RSS feed for user
Ipstenu (Mika Epstein)
ModeratorInteresting. There actually IS an RSS built into your user ID: https://bbpress.org/forums/rss/profile/otto42
But it’s used for your favorites so not so much. You can see all your posts in your profile (recent posts) so in theory this should be ‘exportable’ to RSS.
The rss.php file has this:
// Get latest posts by default
case 'all-posts':
default:
if ( !$posts = bb_get_latest_posts( 35 ) )
die();
$title = esc_html( sprintf( __( '%1$s » Recent Posts' ), bb_get_option( 'name' ) ) );
$link = bb_get_uri();
$link_self = bb_get_posts_rss_link();
break;Which I think you could toss an extra if
if ( $user->ID == bb_get_current_user_info( 'id' ) )
but that would only punt out a list of the current user’s posts, and not be a way to see anyones. The structure is there, though.September 2, 2009 at 5:46 am #65581In reply to: Delete Post by It’s Owner
_ck_
ParticipantIn theory it should be also possible to allow users to move their own topics if placed in the wrong category:
(untested, should allow a user to move only their own topics within the same time period they can typically edit a topic, ie. 1 hour default)
function move_own_topic($retvalue, $capability, $args) {
if ($capability=="move_topic") {return bb_current_user_can( 'edit_topic', $args[1]);}
return $retvalue;
}
add_filter('bb_current_user_can', 'move_own_topic',10,3);August 30, 2009 at 10:55 am #31619extrakun
MemberHi,
I have installed WP 2.8.4 and the most recent version of BBPress. Via the user role mapping, I managed to get a user who is registered through WordPress to have a default role in BBPress. However, I cannot find any plugins that allow anyone who is registered through BBPress to have a default role (it’s currently set to None) in WP. Any idea how may I achieve that?
August 29, 2009 at 7:20 pm #31616Topic: How to integrate BBpress and WordPress
in forum InstallationMohamed
ParticipantHello,
This is my 1st try to have a website and I’ve goggled a lot for the tools I may use and found that wordpress is the most highly recommended one.
Please I do need a forum to be integrated with the website and according to Google it shows that BBPress is the most recommended one to be used with WordPress.
The question now is that I can find the installation instructions for BBPress standalone but I can not find how to integrate WordPress and BBPress together at all.
So please may you help me and give me any links for such a thing as it was three hours searching in different places with no luck so far and I do fel very stupid for not catching any result yet.
I’ve just installed WordPress only without any plugins or any extra just the pure installation and default settings.
I am sorry if this is a very newbie question but I hope that some one can help.
Thanks,
Take care
August 25, 2009 at 3:44 pm #78429In reply to: Filter to Change Login URL
dbone
MemberWhich file did you edit? I was not able to find it in the default theme.
I did find the code that creates the link in /bb-includes/function-bbtemplate.php, post_form(), line 311 for version 1.0.1.
August 25, 2009 at 12:00 am #78410In reply to: Fatal error: Call to undefined function
johnhiler
MemberTry the following:
* Disable your plugins, and see if the forum link works now
* If it still doesn’t work, then activate your Kakumei default theme and see if that helps.
Also – have you tried turning off pretty permalinks?
August 23, 2009 at 1:07 pm #31568Topic: Hide subforums on homepage
in forum Installationphaniraj01
MemberDear All,
I am using default Kakumei Blue 1.0 theme, I need to hide subforums from the home page of the forum.
Is there any plugin available?
Thanks,
phani
August 22, 2009 at 7:34 pm #78332In reply to: inove theme has a bad suspected link
suzkaw
MemberYes that is not something I would include in any themes I release on purpose. So if you do find it in a file of a default download please contact me directly and I will fix it.
August 22, 2009 at 6:52 pm #78266_ck_
ParticipantOlder installs from 0.8 won’t have a default throttle time so the override won’t show up.
Try putting this into bb-config.php
$bb->throttle_time=30;
August 21, 2009 at 11:09 pm #78310In reply to: Invalid email address
tiny-1
MemberI found the offending code that I added in my BBconfig file in order to pull the same header as the rest of the site.
here’s the offending code:
if (file_exists(‘../wp-blog-header.php’))
require_once(‘../wp-blog-header.php’);
else
if (file_exists(‘../../wp-blog-header.php’))
require_once(‘../../wp-blog-header.php’);
which is place at the end like so:
/**
* bbPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$bb_table_prefix = ‘bb_’;
/**
* bbPress Localized Language, defaults to English.
*
* Change this to localize bbPress. A corresponding MO file for the chosen
* language must be installed to a directory called “my-languages” in the root
* directory of bbPress. For example, install de.mo to “my-languages” and set
* BB_LANG to ‘de’ to enable German language support.
*/
define( ‘BB_LANG’, ” );
$bb->WP_BB = true;
if (file_exists(‘../wp-blog-header.php’))
require_once(‘../wp-blog-header.php’);
else
if (file_exists(‘../../wp-blog-header.php’))
require_once(‘../../wp-blog-header.php’);
?>
anything glaringly wrong with this?
August 21, 2009 at 7:13 pm #75776In reply to: Upgrade to 1.0.1 breaks registration
fiat
MemberOK…I figured out that when nothing happens after hitting the ‘Register’ button, it’s because that email was already in the system. I swapped out the new register.php file from Kakumai default theme and when performing the same function, the email turned red and said it was already in the system. My old regiter.php file did not do this.
So, I think it’s fixed now.
August 18, 2009 at 7:18 am #77064In reply to: bbpress and memcache?
Sam Bauers
ParticipantYou can setup a new memcached instance to avoid clashes with wordpress, but if you are sharing user tables then it shouldn’t matter.
If you add another memcached instance on a different port you can point bbPress to it by adding this to bb-config.php (default IP and port shown here)…
$memcached_servers = array( 'default' => array( '127.0.0.1:11211' ) );
August 18, 2009 at 6:22 am #31513Topic: hide subforms with crystal theme
in forum Themespikatore
MemberI have a problem, i don’t know what to do. I am using the crystal theme, which instead of having:
<?php if ( bb_forums() ) : ?>
it has
<?php if ($forums) : ?>
compared to the default theme.
I want subforums to be hidden on the front page. How do i modify code to do this?
August 18, 2009 at 2:59 am #15343Topic: Number shows on the top of header
in forum ThemesVannak Eng
ParticipantHi,
I modified the default theme of bbpress and it worked fine at first but lately it shows the number like “6d53″ on the top of header. when i view the source code i see it is ‘<body id=”front-page”>6d53’. Please help to advise on that.
Regards,
Vannak
August 17, 2009 at 10:15 pm #78171In reply to: Default Installation directory
Tomcraft1980
MemberThx for the immidiate answer!
That saves me a lot of time!
Kind regards
Tom
August 17, 2009 at 10:09 pm #78170In reply to: Default Installation directory
chrishajer
ParticipantYou can call that directory whatever you want. There should be no plugin that has the installation directory hard-coded. (I’ve never seen one in any case.) You can call it ‘discussions’ or ‘abcdefzyx’ or ‘forum’ or ‘forums’ and it should not matter.
August 17, 2009 at 7:55 am #78136In reply to: How to: allow headings in post
Olaf Lederer
ParticipantBy default mage tags are not allowed too.
create you own plugin and use this code
function allow_img_tag($tags) {
$tags['img'] = array('src' => array(), 'title' => array(), 'alt' => array());
return $tags;
}
add_filter('bb_allowed_tags', 'allow_img_tag');You can the same kind of function for your header elements
August 17, 2009 at 3:14 am #77788In reply to: Sometimes Less Is Just Less
chandersbs
MemberI really love bbPress, but still wished some features existed by default. I know it’s doable via plugins, but default features are more cool, you can always turn it off. I really dislike the fact that some of the solutions I have seen on this forum, are related to “integrate your forum with WordPress, and use this plugin and it will work”, no, I don’t like that. bbPress should be able to do stuff on its own, without WordPress.
I don’t want to install WordPress for the sake of making some things work. I have been a WordPress user for so many years already, but still I refuse to do that. I have managed to convert my forum, which was originally SMF into bbPress (SMF > phpBB > bbPress), that was a lot of work, but I’m really happy I did that.
bbPress is by default very EMPTY, very very very empty. I was not used to a forum, with so less features and options. My users didn’t like it. I managed to add a lot of features via plugins. Now my users are a bit happy, I’m also very happy.
The best part I love so far is, that making changes not always is so difficult compared to SMF or phpBB. phpBB is the last forum software on this planet I’d want to use, OMG so difficult to make changes. SMF is one of the best out there, but has some limits due to their copyright system.
Some things I’d really love to see happening anytime very soon:
1. A codex page, with detailed instruction about the codes, just like its big brother WordPress has, at least a start, so we, the webmasters, can do more cool stuff
2. More features by default, such as:
a. Private message
b. Avatar upload
c. Memberlist
d. Quote option in topics
e. Smilies
These are some very basic options.
I’m sure bbPress will be one of the most professional forum software out there one day, it’s not so far yet, but I see it happen.
That’s why I’m a proud user of this software.
August 17, 2009 at 1:57 am #77061In reply to: bbpress and memcache?
Sam Bauers
ParticipantWe don’t use memcache to store user sessions, user sessions are stored in the browser cookie.
There is a memcache capable object cache though which is built in to bbPress via BackPress. To enable it (with default memcache settings) all you need to do is add this to your bb-config.php:
define( 'BB_OBJECT_CACHE_TYPE', 'memcached' );
Note that this will not work if you are using the memcache object cache in WordPress, and you have WordPress deep integrated into bbPress.
August 17, 2009 at 1:22 am #78154In reply to: Posting error
parity
MemberSome more info: I realized the problem wasn’t with functions.bb-pluggable.php but with bb-post.php. I recently had to fix something in bb-post.php to get rid of a different error message about an undefined call.
Here are the contents of both files.
bb-post.php:
<?php
require('./bb-load.php');
bb_auth(‘logged_in’);
if (
$throttle_time = bb_get_option( ‘throttle_time’ ) )
if ( isset
($bb_current_user->data->last_posted) && time() <
$bb_current_user->data->last_posted + $throttle_time && !
bb_current_user_can(‘throttle’) )
bb_die(__(‘Slow
down; you move too fast.’));
if ( !$post_content = trim($_POST
) )
bb_die(__(‘You need to actually submit
some content!’));
if ( isset($_POST) && $forum_id = (int)
$_POST ) {
if ( !bb_current_user_can(‘write_posts’) )
bb_die(__(‘You are not allowed to post. Are you
logged in?’));
if ( !bb_current_user_can( ‘write_topic’,
$forum_id ) )
bb_die(__(‘You are not allowed
to write new topics.’));
bb_check_admin_referer( ‘create-topic’ );
$topic = trim( $_POST );
$tags = trim( $_POST );
if (” == $topic)
bb_die(__(‘Please enter a topic
title’));
$topic_id = bb_new_topic( $topic, $forum_id, $tags );
}
elseif ( isset($_POST ) ) {
$topic_id = (int)
$_POST;
bb_check_admin_referer( ‘create-post_’ .
$topic_id );
}
if ( !bb_current_user_can( ‘write_post’, $topic_id ) )
bb_die(__(‘You are not allowed to post. Are you logged in?’));
if ( !
topic_is_open( $topic_id ) )
bb_die(__(‘This topic has been
closed’));
$post_id = bb_new_post( $topic_id, $_POST
);
$tags = trim( $_POST );
bb_add_topic_tags(
$topic_id, $tags );
$link = get_post_link($post_id);
$topic =
get_topic( $topic_id, false );
if ( $topic->topic_posts )
$link =
add_query_arg( ‘replies’, $topic->topic_posts, $link );
// This
action used to be bb_post.php, changed to avoid conflict in
bb_load_template()
do_action( ‘bb-post.php’, $post_id );
if
($post_id)
wp_redirect( $link );
else
wp_redirect(
bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
exit;
?>
function.bb-pluggable.php
<?php
if ( !function_exists( ‘bb_auth’ ) ) :
function bb_auth( $scheme = ‘auth’ ) { // Checks if a user has a valid cookie, if not redirects them to the main page
if ( !bb_validate_auth_cookie( ”, $scheme ) ) {
nocache_headers();
if ( ‘auth’ === $scheme && !bb_is_user_logged_in() ) {
wp_redirect( bb_get_uri( ‘bb-login.php’, array( ‘re’ => $_SERVER ), BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_USER_FORMS ) );
} else {
wp_redirect( bb_get_uri( null, null, BB_URI_CONTEXT_HEADER ) );
}
exit;
}
}
endif;
// $already_md5 variable is deprecated
if ( !function_exists(‘bb_check_login’) ) :
function bb_check_login($user, $pass, $already_md5 = false) {
global $wp_users_object;
if ( !bb_get_option( ’email_login’ ) || false === strpos( $user, ‘@’ ) ) { // user_login
$user = $wp_users_object->get_user( $user, array( ‘by’ => ‘login’ ) );
} else { // maybe an email
$email_user = $wp_users_object->get_user( $user, array( ‘by’ => ’email’ ) );
$user = $wp_users_object->get_user( $user, array( ‘by’ => ‘login’ ) );
// 9 cases. each can be FALSE, USER, or WP_ERROR
if (
( !$email_user && $user ) // FALSE && USER, FALSE && WP_ERROR
||
( is_wp_error( $email_user ) && $user && !is_wp_error( $user ) ) // WP_ERROR && USER
) {
// nope: it really was a user_login
// [sic]: use $user
} elseif (
( $email_user && !$user ) // USER && FALSE, WP_ERROR && FALSE
||
( $email_user && !is_wp_error( $email_user ) && is_wp_error( $user ) ) // USER && WP_ERROR
) {
// yup: it was an email
$user =& $email_user;
} elseif ( !$email_user && !$user ) { // FALSE && FALSE
// Doesn’t matter what it was: neither worked
return false;
} elseif ( is_wp_error( $email_user ) && is_wp_error( $user ) ) { // WP_ERROR && WP_ERROR
// This can’t happen. If it does, let’s use the email error. It’s probably “multiple matches”, so maybe logging in with a username will work
$user =& $email_user;
} elseif ( $email_user && $user ) { // USER && USER
// both are user objects
if ( $email_user->ID == $user->ID ); // [sic]: they are the same, use $user
elseif ( bb_check_password($pass, $user->user_pass, $user->ID) ); // [sic]: use $user
elseif ( bb_check_password($pass, $email_user->user_pass, $email_user->ID) )
$user =& $email_user;
} else { // This can’t happen, that’s all 9 cases.
// [sic]: use $user
}
}
if ( !$user )
return false;
if ( is_wp_error($user) )
return $user;
if ( !bb_check_password($pass, $user->user_pass, $user->ID) )
return false;
// User is logging in for the first time, update their user_status to normal
if ( 1 == $user->user_status )
bb_update_user_status( $user->ID, 0 );
return $user;
}
endif;
if ( !function_exists(‘bb_get_current_user’) ) :
function bb_get_current_user() {
global $wp_auth_object;
return $wp_auth_object->get_current_user();
}
endif;
if ( !function_exists(‘bb_set_current_user’) ) :
function bb_set_current_user( $id ) {
global $wp_auth_object;
$current_user = $wp_auth_object->set_current_user( $id );
do_action(‘bb_set_current_user’, isset($current_user->ID) ? $current_user->ID : 0 );
return $current_user;
}
endif;
if ( !function_exists(‘bb_current_user’) ) :
//This is only used at initialization. Use bb_get_current_user_info() (or $bb_current_user global if really needed) to grab user info.
function bb_current_user() {
if (BB_INSTALLING)
return false;
return bb_get_current_user();
}
endif;
if ( !function_exists(‘bb_is_user_authorized’) ) :
function bb_is_user_authorized() {
return bb_is_user_logged_in();
}
endif;
if ( !function_exists(‘bb_is_user_logged_in’) ) :
function bb_is_user_logged_in() {
$current_user = bb_get_current_user();
if ( empty($current_user) )
return false;
return true;
}
endif;
if ( !function_exists(‘bb_login’) ) :
function bb_login( $login, $password, $remember = false ) {
$user = bb_check_login( $login, $password );
if ( $user && !is_wp_error( $user ) ) {
bb_set_auth_cookie( $user->ID, $remember );
do_action(‘bb_user_login’, (int) $user->ID );
}
return $user;
}
endif;
if ( !function_exists(‘bb_logout’) ) :
function bb_logout() {
bb_clear_auth_cookie();
do_action(‘bb_user_logout’);
}
endif;
if ( !function_exists( ‘bb_validate_auth_cookie’ ) ) :
function bb_validate_auth_cookie( $cookie = ”, $scheme = ‘auth’ ) {
global $wp_auth_object;
if ( empty($cookie) && $scheme == ‘auth’ ) {
if ( is_ssl() ) {
$scheme = ‘secure_auth’;
} else {
$scheme = ‘auth’;
}
}
return $wp_auth_object->validate_auth_cookie( $cookie, $scheme );
}
endif;
if ( !function_exists( ‘bb_set_auth_cookie’ ) ) :
function bb_set_auth_cookie( $user_id, $remember = false, $schemes = false ) {
global $wp_auth_object;
if ( $remember ) {
$expiration = $expire = time() + 1209600;
} else {
$expiration = time() + 172800;
$expire = 0;
}
if ( true === $schemes ) {
$schemes = array( ‘secure_auth’, ‘logged_in’ );
} elseif ( !is_array( $schemes ) ) {
$schemes = array();
if ( force_ssl_login() || force_ssl_admin() ) {
$schemes[] = ‘secure_auth’;
}
if ( !( force_ssl_login() && force_ssl_admin() ) ) {
$schemes[] = ‘auth’;
}
$schemes[] = ‘logged_in’;
}
$schemes = array_unique( $schemes );
foreach ( $schemes as $scheme ) {
$wp_auth_object->set_auth_cookie( $user_id, $expiration, $expire, $scheme );
}
}
endif;
if ( !function_exists(‘bb_clear_auth_cookie’) ) :
function bb_clear_auth_cookie() {
global $bb, $wp_auth_object;
$wp_auth_object->clear_auth_cookie();
// Old cookies
setcookie($bb->authcookie, ‘ ‘, time() – 31536000, $bb->cookiepath, $bb->cookiedomain);
setcookie($bb->authcookie, ‘ ‘, time() – 31536000, $bb->sitecookiepath, $bb->cookiedomain);
// Even older cookies
setcookie($bb->usercookie, ‘ ‘, time() – 31536000, $bb->cookiepath, $bb->cookiedomain);
setcookie($bb->usercookie, ‘ ‘, time() – 31536000, $bb->sitecookiepath, $bb->cookiedomain);
setcookie($bb->passcookie, ‘ ‘, time() – 31536000, $bb->cookiepath, $bb->cookiedomain);
setcookie($bb->passcookie, ‘ ‘, time() – 31536000, $bb->sitecookiepath, $bb->cookiedomain);
}
endif;
if ( !function_exists(‘wp_redirect’) ) : // [WP11537]
/**
* Redirects to another page, with a workaround for the IIS Set-Cookie bug.
*
* @link http://support.microsoft.com/kb/q176113/
* @since 1.5.1
* @uses apply_filters() Calls ‘wp_redirect’ hook on $location and $status.
*
* @param string $location The path to redirect to
* @param int $status Status code to use
* @return bool False if $location is not set
*/
function wp_redirect($location, $status = 302) {
global $is_IIS;
$location = apply_filters(‘wp_redirect’, $location, $status);
$status = apply_filters(‘wp_redirect_status’, $status, $location);
if ( !$location ) // allows the wp_redirect filter to cancel a redirect
return false;
$location = wp_sanitize_redirect($location);
if ( $is_IIS ) {
header(“Refresh: 0;url=$location”);
} else {
if ( php_sapi_name() != ‘cgi-fcgi’ )
status_header($status); // This causes problems on IIS and some FastCGI setups
header(“Location: $location”);
}
}
endif;
if ( !function_exists(‘wp_sanitize_redirect’) ) : // [WP11537]
/**
* Sanitizes a URL for use in a redirect.
*
* @since 2.3
*
* @return string redirect-sanitized URL
**/
function wp_sanitize_redirect($location) {
$location = preg_replace(‘|[^a-z0-9-~+_.?#=&;,/:%!]|i’, ”, $location);
$location = wp_kses_no_null($location);
// remove %0d and %0a from location
$strip = array(‘%0d’, ‘%0a’);
$found = true;
while($found) {
$found = false;
foreach( (array) $strip as $val ) {
while(strpos($location, $val) !== false) {
$found = true;
$location = str_replace($val, ”, $location);
}
}
}
return $location;
}
endif;
if ( !function_exists(‘bb_safe_redirect’) ) : // based on [WP6145] (home is different)
/**
* Performs a safe (local) redirect, using wp_redirect().
*
* Checks whether the $location is using an allowed host, if it has an absolute
* path. A plugin can therefore set or remove allowed host(s) to or from the
* list.
*
* If the host is not allowed, then the redirect is to the site url
* instead. This prevents malicious redirects which redirect to another host,
* but only used in a few places.
*
* @uses apply_filters() Calls ‘allowed_redirect_hosts’ on an array containing
* bbPress host string and $location host string.
*
* @return void Does not return anything
**/
function bb_safe_redirect( $location, $status = 302 ) {
// Need to look at the URL the way it will end up in wp_redirect()
$location = wp_sanitize_redirect($location);
// browsers will assume ‘http’ is your protocol, and will obey a redirect to a URL starting with ‘//’
if ( substr($location, 0, 2) == ‘//’ )
$location = ‘http:’ . $location;
// In php 5 parse_url may fail if the URL query part contains http://, bug #38143
$test = ( $cut = strpos($location, ‘?’) ) ? substr( $location, 0, $cut ) : $location;
$lp = parse_url($test);
$bp = parse_url(bb_get_uri());
$allowed_hosts = (array) apply_filters(‘allowed_redirect_hosts’, array($bp), isset($lp) ? $lp : ”);
if ( isset($lp) && ( !in_array($lp, $allowed_hosts) && $lp != strtolower($bp)) )
$location = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
return wp_redirect($location, $status);
}
endif;
if ( !function_exists(‘bb_nonce_tick’) ) :
/**
* Get the time-dependent variable for nonce creation.
*
* A nonce has a lifespan of two ticks. Nonces in their second tick may be
* updated, e.g. by autosave.
*
* @since 1.0
*
* @return int
*/
function bb_nonce_tick() {
$nonce_life = apply_filters(‘bb_nonce_life’, 86400);
return ceil(time() / ( $nonce_life / 2 ));
}
endif;
if ( !function_exists(‘bb_verify_nonce’) ) :
/**
* Verify that correct nonce was used with time limit.
*
* The user is given an amount of time to use the token, so therefore, since the
* UID and $action remain the same, the independent variable is the time.
*
* @param string $nonce Nonce that was used in the form to verify
* @param string|int $action Should give context to what is taking place and be the same when nonce was created.
* @return bool Whether the nonce check passed or failed.
*/
function bb_verify_nonce($nonce, $action = -1) {
$user = bb_get_current_user();
$uid = (int) $user->ID;
$i = bb_nonce_tick();
// Nonce generated 0-12 hours ago
if ( substr(bb_hash($i . $action . $uid, ‘nonce’), -12, 10) == $nonce )
return 1;
// Nonce generated 12-24 hours ago
if ( substr(bb_hash(($i – 1) . $action . $uid, ‘nonce’), -12, 10) == $nonce )
return 2;
// Invalid nonce
return false;
}
endif;
if ( !function_exists(‘bb_create_nonce’) ) :
/**
* Creates a random, one time use token.
*
* @since 2.0.4
*
* @param string|int $action Scalar value to add context to the nonce.
* @return string The one use form token
*/
function bb_create_nonce($action = -1) {
$user = bb_get_current_user();
$uid = (int) $user->ID;
$i = bb_nonce_tick();
return substr(bb_hash($i . $action . $uid, ‘nonce’), -12, 10);
}
endif;
function _bb_get_key( $key, $default_key = false ) {
if ( !$default_key ) {
global $bb_default_secret_key;
$default_key = $bb_default_secret_key;
}
if ( defined( $key ) && ” != constant( $key ) && $default_key != constant( $key ) ) {
return constant( $key );
}
return $default_key;
}
function _bb_get_salt( $constants, $option = false ) {
if ( !is_array( $constants ) ) {
$constants = array( $constants );
}
foreach ($constants as $constant ) {
if ( defined( $constant ) ) {
return constant( $constant );
}
}
if ( !defined( ‘BB_INSTALLING’ ) || !BB_INSTALLING ) {
if ( !$option ) {
$option = strtolower( $constants[0] );
}
$salt = bb_get_option( $option );
if ( empty( $salt ) ) {
$salt = bb_generate_password();
bb_update_option( $option, $salt );
}
return $salt;
}
return ”;
}
// Not verbatim WP, constants have different names, uses helper functions.
if ( !function_exists( ‘bb_salt’ ) ) :
/**
* Get salt to add to hashes to help prevent attacks.
*
* @since 0.9
* @link https://api.wordpress.org/secret-key/1.1/bbpress/ Create a set of keys for bb-config.php
* @uses _bb_get_key()
* @uses _bb_get_salt()
*
* @return string Salt value for the given scheme
*/
function bb_salt($scheme = ‘auth’) {
$secret_key = _bb_get_key( ‘BB_SECRET_KEY’ );
switch ($scheme) {
case ‘auth’:
$secret_key = _bb_get_key( ‘BB_AUTH_KEY’, $secret_key );
$salt = _bb_get_salt( array( ‘BB_AUTH_SALT’, ‘BB_SECRET_SALT’ ) );
break;
case ‘secure_auth’:
$secret_key = _bb_get_key( ‘BB_SECURE_AUTH_KEY’, $secret_key );
$salt = _bb_get_salt( ‘BB_SECURE_AUTH_SALT’ );
break;
case ‘logged_in’:
$secret_key = _bb_get_key( ‘BB_LOGGED_IN_KEY’, $secret_key );
$salt = _bb_get_salt( ‘BB_LOGGED_IN_SALT’ );
break;
case ‘nonce’:
$secret_key = _bb_get_key( ‘BB_NONCE_KEY’, $secret_key );
$salt = _bb_get_salt( ‘BB_NONCE_SALT’ );
break;
default:
// ensure each auth scheme has its own unique salt
$salt = hash_hmac( ‘md5’, $scheme, $secret_key );
break;
}
return apply_filters( ‘salt’, $secret_key . $salt, $scheme );
}
endif;
if ( !function_exists( ‘bb_hash’ ) ) :
function bb_hash( $data, $scheme = ‘auth’ ) {
$salt = bb_salt( $scheme );
return hash_hmac( ‘md5’, $data, $salt );
}
endif;
if ( !function_exists( ‘bb_hash_password’ ) ) :
function bb_hash_password( $password ) {
return WP_Pass::hash_password( $password );
}
endif;
if ( !function_exists( ‘bb_check_password’) ) :
function bb_check_password( $password, $hash, $user_id = ” ) {
return WP_Pass::check_password( $password, $hash, $user_id );
}
endif;
if ( !function_exists( ‘bb_generate_password’ ) ) :
/**
* Generates a random password drawn from the defined set of characters
* @return string the password
*/
function bb_generate_password( $length = 12, $special_chars = true ) {
return WP_Pass::generate_password( $length, $special_chars );
}
endif;
if ( !function_exists(‘bb_check_admin_referer’) ) :
function bb_check_admin_referer( $action = -1, $query_arg = ‘_wpnonce’ ) {
$nonce = ”;
if ( isset( $_POST[$query_arg] ) && $_POST[$query_arg] ) {
$nonce = $_POST[$query_arg];
} elseif ( isset( $_GET[$query_arg] ) && $_GET[$query_arg] ) {
$nonce = $_GET[$query_arg];
}
if ( !bb_verify_nonce($nonce, $action) ) {
bb_nonce_ays($action);
die();
}
do_action(‘bb_check_admin_referer’, $action);
}
endif;
if ( !function_exists(‘bb_check_ajax_referer’) ) :
function bb_check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
$requests = array();
if ( $query_arg ) {
$requests[] = $query_arg;
}
$requests[] = ‘_ajax_nonce’;
$requests[] = ‘_wpnonce’;
$nonce = ”;
foreach ( $requests as $request ) {
if ( isset( $_POST[$request] ) && $_POST[$request] ) {
$nonce = $_POST[$request];
break;
} elseif ( isset( $_GET[$request] ) && $_GET[$request] ) {
$nonce = $_GET[$request];
break;
}
}
$result = bb_verify_nonce( $nonce, $action );
if ( $die && false == $result )
die(‘-1’);
do_action(‘bb_check_ajax_referer’, $action, $result);
return $result;
}
endif;
if ( !function_exists(‘bb_break_password’) ) :
function bb_break_password( $user_id ) {
global $bbdb;
$user_id = (int) $user_id;
if ( !$user = bb_get_user( $user_id ) )
return false;
$secret = substr(bb_hash( ‘bb_break_password’ ), 0, 13);
if ( false === strpos( $user->user_pass, ‘—‘ ) )
return $bbdb->query( $bbdb->prepare(
“UPDATE $bbdb->users SET user_pass = CONCAT(user_pass, ‘—‘, %s) WHERE ID = %d”,
$secret, $user_id
) );
else
return true;
}
endif;
if ( !function_exists(‘bb_fix_password’) ) :
function bb_fix_password( $user_id ) {
global $bbdb;
$user_id = (int) $user_id;
if ( !$user = bb_get_user( $user_id ) )
return false;
if ( false === strpos( $user->user_pass, ‘—‘ ) )
return true;
else
return $bbdb->query( $bbdb->prepare(
“UPDATE $bbdb->users SET user_pass = SUBSTRING_INDEX(user_pass, ‘—‘, 1) WHERE ID = %d”,
$user_id
) );
}
endif;
if ( !function_exists(‘bb_has_broken_pass’) ) :
function bb_has_broken_pass( $user_id = 0 ) {
global $bb_current_user;
if ( !$user_id )
$user =& $bb_current_user->data;
else
$user = bb_get_user( $user_id );
return ( false !== strpos($user->user_pass, ‘—‘ ) );
}
endif;
if ( !function_exists(‘bb_new_user’) ) :
function bb_new_user( $user_login, $user_email, $user_url, $user_status = 1 ) {
global $wp_users_object, $bbdb;
// is_email check + dns
if ( !$user_email = is_email( $user_email ) )
return new WP_Error( ‘user_email’, __( ‘Invalid email address’ ), $user_email );
if ( !$user_login = sanitize_user( $user_login, true ) )
return new WP_Error( ‘user_login’, __( ‘Invalid username’ ), $user_login );
// user_status = 1 means the user has not yet been verified
$user_status = is_numeric($user_status) ? (int) $user_status : 1;
if ( defined( ‘BB_INSTALLING’ ) )
$user_status = 0;
$user_nicename = $_user_nicename = bb_user_nicename_sanitize( $user_login );
if ( strlen( $_user_nicename ) < 1 )
return new WP_Error( ‘user_login’, __( ‘Invalid username’ ), $user_login );
while ( is_numeric($user_nicename) || $existing_user = bb_get_user_by_nicename( $user_nicename ) )
$user_nicename = bb_slug_increment($_user_nicename, $existing_user->user_nicename, 50);
$user_url = $user_url ? bb_fix_link( $user_url ) : ”;
$user_pass = bb_generate_password();
$user = $wp_users_object->new_user( compact( ‘user_login’, ‘user_email’, ‘user_url’, ‘user_nicename’, ‘user_status’, ‘user_pass’ ) );
if ( is_wp_error($user) ) {
if ( ‘user_nicename’ == $user->get_error_code() )
return new WP_Error( ‘user_login’, $user->get_error_message() );
return $user;
}
if (BB_INSTALLING) {
bb_update_usermeta( $user, $bbdb->prefix . ‘capabilities’, array(‘keymaster’ => true) );
} else {
bb_update_usermeta( $user, $bbdb->prefix . ‘capabilities’, array(‘member’ => true) );
bb_send_pass( $user, $user );
}
do_action(‘bb_new_user’, $user, $user);
return $user;
}
endif;
if ( !function_exists( ‘bb_mail’ ) ) :
/**
* Send mail, similar to PHP’s mail
*
* A true return value does not automatically mean that the user received the
* email successfully. It just only means that the method used was able to
* process the request without any errors.
*
* Using the two ‘bb_mail_from’ and ‘bb_mail_from_name’ hooks allow from
* creating a from address like ‘Name <email@address.com>’ when both are set. If
* just ‘bb_mail_from’ is set, then just the email address will be used with no
* name.
*
* The default content type is ‘text/plain’ which does not allow using HTML.
* However, you can set the content type of the email by using the
* ‘bb_mail_content_type’ filter.
*
* The default charset is based on the charset used on the blog. The charset can
* be set using the ‘bb_mail_charset’ filter.
*
* @uses apply_filters() Calls ‘bb_mail’ hook on an array of all of the parameters.
* @uses apply_filters() Calls ‘bb_mail_from’ hook to get the from email address.
* @uses apply_filters() Calls ‘bb_mail_from_name’ hook to get the from address name.
* @uses apply_filters() Calls ‘bb_mail_content_type’ hook to get the email content type.
* @uses apply_filters() Calls ‘bb_mail_charset’ hook to get the email charset
* @uses do_action_ref_array() Calls ‘bb_phpmailer_init’ hook on the reference to
* phpmailer object.
* @uses PHPMailer
*
* @param string $to Email address to send message
* @param string $subject Email subject
* @param string $message Message contents
* @param string|array $headers Optional. Additional headers.
* @param string|array $attachments Optional. Files to attach.
* @return bool Whether the email contents were sent successfully.
*/
function bb_mail( $to, $subject, $message, $headers = ”, $attachments = array() ) {
// Compact the input, apply the filters, and extract them back out
extract( apply_filters( ‘bb_mail’, compact( ‘to’, ‘subject’, ‘message’, ‘headers’, ‘attachments’ ) ) );
if ( !is_array($attachments) )
$attachments = explode( “n”, $attachments );
global $bb_phpmailer;
// (Re)create it, if it’s gone missing
if ( !is_object( $bb_phpmailer ) || !is_a( $bb_phpmailer, ‘PHPMailer’ ) ) {
require_once BACKPRESS_PATH . ‘class.mailer.php’;
require_once BACKPRESS_PATH . ‘class.mailer-smtp.php’;
$bb_phpmailer = new PHPMailer();
}
// Headers
if ( empty( $headers ) ) {
$headers = array();
} else {
if ( !is_array( $headers ) ) {
// Explode the headers out, so this function can take both
// string headers and an array of headers.
$tempheaders = (array) explode( “n”, $headers );
} else {
$tempheaders = $headers;
}
$headers = array();
// If it’s actually got contents
if ( !empty( $tempheaders ) ) {
// Iterate through the raw headers
foreach ( (array) $tempheaders as $header ) {
if ( strpos($header, ‘:’) === false ) {
if ( false !== stripos( $header, ‘boundary=’ ) ) {
$parts = preg_split(‘/boundary=/i’, trim( $header ) );
$boundary = trim( str_replace( array( “‘”, ‘”‘ ), ”, $parts[1] ) );
}
continue;
}
// Explode them out
list( $name, $content ) = explode( ‘:’, trim( $header ), 2 );
// Cleanup crew
$name = trim( $name );
$content = trim( $content );
// Mainly for legacy — process a From: header if it’s there
if ( ‘from’ == strtolower($name) ) {
if ( strpos($content, ‘<‘ ) !== false ) {
// So… making my life hard again?
$from_name = substr( $content, 0, strpos( $content, ‘<‘ ) – 1 );
$from_name = str_replace( ‘”‘, ”, $from_name );
$from_name = trim( $from_name );
$from_email = substr( $content, strpos( $content, ‘<‘ ) + 1 );
$from_email = str_replace( ‘>’, ”, $from_email );
$from_email = trim( $from_email );
} else {
$from_email = trim( $content );
}
} elseif ( ‘content-type’ == strtolower($name) ) {
if ( strpos( $content,’;’ ) !== false ) {
list( $type, $charset ) = explode( ‘;’, $content );
$content_type = trim( $type );
if ( false !== stripos( $charset, ‘charset=’ ) ) {
$charset = trim( str_replace( array( ‘charset=’, ‘”‘ ), ”, $charset ) );
} elseif ( false !== stripos( $charset, ‘boundary=’ ) ) {
$boundary = trim( str_replace( array( ‘BOUNDARY=’, ‘boundary=’, ‘”‘ ), ”, $charset ) );
$charset = ”;
}
} else {
$content_type = trim( $content );
}
} elseif ( ‘cc’ == strtolower($name) ) {
$cc = explode(“,”, $content);
} elseif ( ‘bcc’ == strtolower($name) ) {
$bcc = explode(“,”, $content);
} else {
// Add it to our grand headers array
$headers[trim( $name )] = trim( $content );
}
}
}
}
// Empty out the values that may be set
$bb_phpmailer->ClearAddresses();
$bb_phpmailer->ClearAllRecipients();
$bb_phpmailer->ClearAttachments();
$bb_phpmailer->ClearBCCs();
$bb_phpmailer->ClearCCs();
$bb_phpmailer->ClearCustomHeaders();
$bb_phpmailer->ClearReplyTos();
// From email and name
// If we don’t have a name from the input headers
if ( !isset( $from_name ) ) {
$from_name = bb_get_option(‘name’);
}
// If we don’t have an email from the input headers
if ( !isset( $from_email ) ) {
$from_email = bb_get_option(‘from_email’);
}
// If there is still no email address
if ( !$from_email ) {
// Get the site domain and get rid of www.
$sitename = strtolower( $_SERVER );
if ( substr( $sitename, 0, 4 ) == ‘www.’ ) {
$sitename = substr( $sitename, 4 );
}
$from_email = ‘bbpress@’ . $sitename;
}
// Plugin authors can override the potentially troublesome default
$bb_phpmailer->From = apply_filters( ‘bb_mail_from’, $from_email );
$bb_phpmailer->FromName = apply_filters( ‘bb_mail_from_name’, $from_name );
// Set destination address
$bb_phpmailer->AddAddress( $to );
// Set mail’s subject and body
$bb_phpmailer->Subject = $subject;
$bb_phpmailer->Body = $message;
// Add any CC and BCC recipients
if ( !empty($cc) ) {
foreach ( (array) $cc as $recipient ) {
$bb_phpmailer->AddCc( trim($recipient) );
}
}
if ( !empty($bcc) ) {
foreach ( (array) $bcc as $recipient) {
$bb_phpmailer->AddBcc( trim($recipient) );
}
}
// Set to use PHP’s mail()
$bb_phpmailer->IsMail();
// Set Content-Type and charset
// If we don’t have a content-type from the input headers
if ( !isset( $content_type ) ) {
$content_type = ‘text/plain’;
}
$content_type = apply_filters( ‘bb_mail_content_type’, $content_type );
$bb_phpmailer->ContentType = $content_type;
// Set whether it’s plaintext or not, depending on $content_type
if ( $content_type == ‘text/html’ ) {
$bb_phpmailer->IsHTML( true );
}
// If we don’t have a charset from the input headers
if ( !isset( $charset ) ) {
$charset = bb_get_option( ‘charset’ );
}
// Set the content-type and charset
$bb_phpmailer->CharSet = apply_filters( ‘bb_mail_charset’, $charset );
// Set custom headers
if ( !empty( $headers ) ) {
foreach( (array) $headers as $name => $content ) {
$bb_phpmailer->AddCustomHeader( sprintf( ‘%1$s: %2$s’, $name, $content ) );
}
if ( false !== stripos( $content_type, ‘multipart’ ) && ! empty($boundary) ) {
$bb_phpmailer->AddCustomHeader( sprintf( “Content-Type: %s;nt boundary=”%s””, $content_type, $boundary ) );
}
}
if ( !empty( $attachments ) ) {
foreach ( $attachments as $attachment ) {
$bb_phpmailer->AddAttachment($attachment);
}
}
do_action_ref_array( ‘bb_phpmailer_init’, array( &$bb_phpmailer ) );
// Send!
$result = @$bb_phpmailer->Send();
return $result;
}
endif;
if ( !function_exists( ‘bb_get_avatar’ ) ) :
/**
* Retrieve the avatar for a user provided a user ID or email address
*
* @since 0.9
* @param int|string $id_or_email A user ID or email address
* @param int $size Size of the avatar image
* @param string $default URL to a default image to use if no avatar is available
* @param string $alt Alternate text to use in image tag. Defaults to blank
* @return string <img> tag for the user’s avatar
*/
function bb_get_avatar( $id_or_email, $size = 80, $default = ”, $alt = false ) {
if ( !bb_get_option(‘avatars_show’) )
return false;
if ( false === $alt)
$safe_alt = ”;
else
$safe_alt = esc_attr( $alt );
if ( !is_numeric($size) )
$size = 80;
if ( $email = bb_get_user_email($id_or_email) ) {
$class = ‘photo ‘;
} else {
$class = ”;
$email = $id_or_email;
}
if ( !$email )
$email = ”;
if ( empty($default) )
$default = bb_get_option(‘avatars_default’);
if ( is_ssl() )
$host = ‘https://secure.gravatar.com’;
else
$host = ‘http://www.gravatar.com’;
switch ($default) {
case ‘logo’:
$default = ”;
break;
case ‘blank’:
$default = bb_get_uri( ‘bb-admin/images/blank.gif’, null, BB_URI_CONTEXT_IMG_SRC );
break;
case ‘monsterid’:
case ‘wavatar’:
case ‘identicon’:
break;
case ‘default’:
default:
$default = $host . ‘/avatar/ad516503a11cd5ca435acc9bb6523536?s=’ . $size;
// ad516503a11cd5ca435acc9bb6523536 == md5(‘unknown@gravatar.com’)
break;
}
$src = $host . ‘/avatar/’;
$class .= ‘avatar avatar-‘ . $size;
if ( !empty($email) ) {
$src .= md5( strtolower( $email ) );
} else {
$src .= ‘d41d8cd98f00b204e9800998ecf8427e’;
// d41d8cd98f00b204e9800998ecf8427e == md5(”)
$class .= ‘ avatar-noemail’;
}
$src .= ‘?s=’ . $size;
$src .= ‘&d=’ . urlencode( $default );
$rating = bb_get_option(‘avatars_rating’);
if ( !empty( $rating ) )
$src .= ‘&r=’ . $rating;
$avatar = ‘<img alt=”‘ . $safe_alt . ‘” src=”‘ . $src . ‘” class=”‘ . $class . ‘” style=”height:’ . $size . ‘px; width:’ . $size . ‘px;” />’;
return apply_filters(‘bb_get_avatar’, $avatar, $id_or_email, $size, $default, $alt);
}
endif;
?>
What am I not seeing here?
August 17, 2009 at 1:02 am #77298In reply to: Sneak peek at bbPress.org 2.0
chandersbs
MemberI like the layout, but only wished, that bbpress would have some options by default.
-
AuthorSearch Results