Search Results for 'code'
-
AuthorSearch Results
-
November 13, 2008 at 2:18 am #66117
In reply to: WordPress + bbPress Integration 101
Gregg
MemberIm integrating my second wp and bb site and this time around it seems there are some easier steps only I cant get this setup to work. I can login to the WP side fine. But when i login from bb side it just redirects to the forum homepage. It will login the person on the wp side but not let them do a thing on the bb side.
I dont have admin access until wipe out the theme and clear the cookies. its very strange.
I followed all steps correctly in the writeup. any help would be much appreciated.
here is what my bb-config file looks like
require_once('/path/to/blog/wp-blog-header.php');
// ** MySQL settings ** //
define(‘BBDB_NAME’, ‘db’); // The name of the database
define(‘BBDB_USER’, ‘user’); // Your MySQL username
define(‘BBDB_PASSWORD’, ‘pswd’); // …and password
define(‘BBDB_HOST’, ‘localhost’); // 99% chance you won’t need to change these last few
define(‘BBDB_CHARSET’, ‘utf8’); // If you are *upgrading*, and your old bb-config.php does
define(‘BBDB_COLLATE’, ”); // not have these two contstants in them, DO NOT define them
// If you are installing for the first time, leave them here
define(‘COOKIEPATH’, ‘/’ );
define(‘SITECOOKIEPATH’, ‘/’);
// Change BB_SECRET_KEY to a unique phrase. You won’t have to remember it later,
// so make it long and complicated. You can visit https://www.grc.com/passwords.htm
// to get a phrase generated for you, or just make something up.
// If you are integrating logins with WordPress, you will need to match the value
// of the “SECRET_KEY” in the WordPress file wp-config.php
define(‘BB_SECRET_KEY’, ‘secretkeydotcom’); // Change this to a unique phrase.
// If you are running multiple bbPress installations in a single database,
// you will probably want to change this.
$bb_table_prefix = ‘bb_’; // Only letters, numbers and underscores please!
// Change this to localize bbPress. A corresponding MO file for the
// chosen language must be installed to bb-includes/languages.
// For example, install de.mo to bb-includes/languages and set BB_LANG to ‘de’
// to enable German language support.
define(‘BB_LANG’, ”);
/* Stop editing */
if ( !defined(‘BB_PATH’) )
define(‘BB_PATH’, dirname(__FILE__) . ‘/’ );
require_once( BB_PATH . ‘bb-settings.php’ );
$bb->wp_siteurl = ‘http://www.site.com/blog/’;
// that’s your WordPress URL, not bbPress
$bb->wp_home = ‘http://www.site.com/blog/’;
// almost always the same as siteurl unless you tinker
$bb->wp_table_prefix = ‘wp_’;
// should almost always be wp_ unless you tinkered
$bb->user_bbdb_name = ‘db’;
// this is the MYSQL database name for *WordPress*
// you can copy it right out of WordPress !
$bb->user_bbdb_user = ‘user’;
// this is the MYSQL user name for *WordPress*
// you can copy it right out of WordPress !
$bb->user_bbdb_password = ‘pswd’;
// this is the MYSQL password for *WordPress*
// you can copy it right out of WordPress !
$bb->user_bbdb_host = ‘localhost’;
// 99.9% of the time it’s going to be localhost, unless you are on DreamHost or some other weird ISP
$bb->custom_user_table = ‘wp_users’;
// 99.9% of the time it’s going to be wp_users
$bb->custom_user_meta_table = ‘wp_usermeta’;
// 99.9% of the time it’s going to be wp_usermeta
$bb->authcookie = ‘wordpress_randomnumbers’;
// in theory you should be able to leave this out
// but this is going to be copied from WordPress cookie
// this *must* match the WordPress setting
// do NOT use the 1234567 part, use your own cookiehash from WordPress – see the note at the very bottom
$bb->cookiedomain = ‘.site.com’;
// note the leading DOT – this is important
// this *must* match the WordPress setting
$bb->cookiepath = ‘/’;
// I *highly* recommend you set the cookie path to /
// this *must* match the WordPress setting
$bb->sitecookiepath = ‘/’;
// I *highly* recommend you set the cookie path to /
// this *must* match the WordPress setting
//tried this – doesnt work with or without…ugh
$bb->usercookie = ‘wordpressuser_randomnumbers’;
$bb->passcookie = ‘wordpresspass_randomnumbers’;
November 12, 2008 at 4:04 pm #68877In reply to: “alphabetical” ordering of hot tags
_ck_
ParticipantAny guide that is for WordPress plugins should work for bbPress, it’s just that bbPress’s “hooks” (do_action, do_filter) will be named differently.
bbPress is unfortunately too young to have decent documentation yet. WordPress itself didn’t really “take off” until 2.0 beta came out.
This is essentially the plugin framework you need:
<?php
/*
Plugin Name: My Tag Sort
*/
remove_filter('sort_tag_heat_map', 'bb_sort_tag_heat_map');
add_filter('sort_tag_heat_map', 'my_sort_tag_heat_map');
function my_sort_tag_heat_map( &$tag_counts ) {
// put your replacement code here
}
?>Save it as
my-tag-sort.php, put it into thebbpress/my-pluginsfolder, activate and you’re in business (well after you figure out the sort method).Typically you’d have to do a
return $tag_counts;at the end of a filter but that&on the&$tag_countsmeans it’s “passed by refererence” which is a fancy way of using the original array directly without making a copy, so the original is changed at the source when you modify it. It’s a much faster way to move large amounts of info around.November 12, 2008 at 3:46 pm #68560In reply to: 1.0a2 + 2.6x cookies: so close!
jonkristian
MemberDeadpan11 , I followed your guide and it worked excellent, however I had to keep the hash on:
$bb->logged_in_cookie = ‘wordpress_logged_in_’;
Setup, http://forums.domain.com & http://domain.com
I can now log in via the forums, and access both admin panels, and via wp, and still access both. If I log out of either, I am logged out of both.
November 12, 2008 at 12:42 pm #68874In reply to: “alphabetical” ordering of hot tags
myu
MemberThanks for reply, ck.
I didn’t know how to make plugins..
So, anywhere that say
apply_filter('___', '___');can be replaced?
Now.. about original question:
$tag_counts is
- key: raw_tag
- value: how many times topics are tagged with this tag
Googling a bit more made me realize, there’re problems associated with ordering Japanese words/strings as there’re 2 types of letters and chinese character used.
strnatcasecmp() seem to put things in order of
- hiragana in ascending
- katakana in ascending
- chinese characters in encoding#
ssetlocale(LC_COLLATE, "jp", "jpn");
ksort($tag_counts, SORT_LOCALE_STRING);shows exactly the same result.
It seems pretty impossible (for me) to order them.
I will flip it to descending, with krsort(); just so the tag “other” won’t come to start.
November 12, 2008 at 7:40 am #68899In reply to: I’m installed now how do I get readers to forums?
_ck_
ParticipantWordPress allows you to make links, go to manage->links under your control panel. Make the link
/forums/if that’s the path to your forums.There are also wordpress plugins to make menu bars, optionally you could use that and put a few primary site links in there, including one to your forums.
Technically if you wanted to place a link more prominently under your pages section, you could actually create a page for the forums and then use the rewriterules in your .htaccess to redirect the user to the actual forums.
November 11, 2008 at 8:14 pm #63069In reply to: Open Links in new window
TrishaM
ParticipantThanks _ck_ – I’ll do as suggested…….
P.S. At cafepress.com you can design your own bumper sticker! I’ve made a few of my own t-shirts that way…..perfect for when you know just what you want but can’t find it anywhere….
November 11, 2008 at 8:01 pm #63068In reply to: Open Links in new window
lstelie
MemberPeople who insist on perfect validation need to find more productive things to do with their time, there’s alot of code out there that needs to be written!

Good point
November 11, 2008 at 7:33 pm #63067In reply to: Open Links in new window
_ck_
ParticipantTrishaM, if you are using bb-tweaks.php you can just add the above code to the bottom of it and disable the target_blank filter. But it will work either way.
lstelie, there is another problem with using javascript as it increases the amount of time before the page is ready. If you are going to throw in rel=”external” you might as well do target. (In fact, you don’t even need rel=”external” as you can scan the domain for each link with javascript on the fly.) But I assure you that target will be supported in browsers ten years from now, maybe even twenty. People who insist on perfect validation need to find more productive things to do with their time, there’s alot of code out there that needs to be written!
Throw off the shackles of validation!
(I need that as a bumper sticker)
November 11, 2008 at 7:19 pm #63066In reply to: Open Links in new window
lstelie
MemberHello,
I use for a pretty long time rel=”external” more compliant and this works well.
The following bit of code is from
http://www.sitepoint.com/article/standards-compliant-world
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors;
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;If JS is not activated ? well no external link but the site is prefectly working
November 11, 2008 at 4:28 pm #68487In reply to: Customizing gravatars
Ipstenu (Mika Epstein)
ModeratorOkay, having tested it a bunch of different ways, I can’t get it to work.
I want to make my own image the ‘default’ for the non-gravatard people (which works fine on WordPress).
In WordPress it’s this:
<?php echo get_avatar(get_comment_author_email(),50,'http://www.foo.com/gravatar.png');?>For bbpress we have this
post_author_avatar();on post.php. Passing the URL into that, either on it’s own or as $default doesn’t work.Using
echo bb_get_avatar( bb_get_user_email(post_author()), 48, 'http://www.foo.com/gravatar.png' );didn’t work.I’m gonna keep tossing stuff up against the wall for now.
November 11, 2008 at 3:54 pm #68873In reply to: “alphabetical” ordering of hot tags
_ck_
ParticipantIt uses the action
do_action_ref_array( 'sort_tag_heat_map', array(&$counts) );which looks like
function bb_sort_tag_heat_map( &$tag_counts ) {
uksort($tag_counts, 'strnatcasecmp');
}So it was designed to be replaced fortunately.
First to have to unhook the existing action in your plugin:
remove_filter('sort_tag_heat_map', 'bb_sort_tag_heat_map');Then put in your replacement
add_filter('sort_tag_heat_map', 'my_sort_tag_heat_map');
function my_sort_tag_heat_map( &$tag_counts ) {
// put your replacement code here
}According to this, it’s supposed to support your locale, but there is a bug:
November 11, 2008 at 3:27 pm #68559In reply to: 1.0a2 + 2.6x cookies: so close!
WebDev WaxLotus LLC
MemberSo the web-consensus is that
$bb->cookiedomain = '.domain.com';specifically the leading dot before the domain.com, is key to permitting cookies created in one subdomain to be useful in other related domains.
Darn. I thought I found my magic bullet.
November 11, 2008 at 2:28 pm #68883In reply to: Customize Topic Labels
Ipstenu (Mika Epstein)
Moderatorremove_filter('bb_topic_labels', 'bb_sticky_label', 20);worked.Now it has images
November 11, 2008 at 2:01 pm #63064In reply to: Open Links in new window
_ck_
ParticipantOkay this one is testing working.
For anyone else that wants to use this, you have to replace the domain name by hand. It’s hardcoded for speed, sorry.
All other target=”_blank” plugins should be uninstalled. Any existing links with target=”_blank” will be left in place for performance since target is not added by bbPress by default.
<?php
/*
Plugin Name: Target Nofollow External Only
Description: append target="_blank" and rel="nofollow" only on external links
Plugin URI:
Author: _ck_
Version: 0.0.1
*/
add_filter('post_text', 'target_nofollow_external_only',999); // unfortunately we have to do this on every page load and not in pre_post
function target_nofollow_external_only( $text ) {
$domain="travel-writers-exchange.com"; // domain to exclude from target and nofollow
$text = preg_replace('|<a (.*)rel=['"]nofollow['"](.+)?>|iU','<a $1$2>', $text); // strip ALL nofollow
$text = preg_replace('|<a (?
[^>]+http
//))(?!([^>]+'.$domain.'))(.+)>|iU', '<a $3 rel="nofollow" target="_blank">', $text); // add back in when needed
return $text;
}
?>I’m not happy about the performance of this technique because it has to be done in post_text for every time a page is displayed, but there’s no other easy way around bbPress/WordPress’s unfortunate use of make_clickable with hardcoded “nofollow” in post_text.
November 11, 2008 at 12:25 pm #63063In reply to: Open Links in new window
_ck_
ParticipantOkay I’ll play with it some more and see what I can do.
update: the problem lies within make_clickable which has nofollow hard coded and impossible to “unfilter” at that level
I’ll have to come up with a way to do it at display time and cleanup the mess bbpress (actually wordpress functions) create
November 11, 2008 at 8:37 am #68890In reply to: database character collation ?
chrishajer
ParticipantYou don’t normally need to set anything there. The installation will continue fine without it.
Every MySQL database uses character collation, but it’s normally hidden from sight. For my bbPress installation, the collation is
utf8_general_ci. But I didn’t have to set it, it’s already there. In a unique situation you might need to set it, but I’ve never messed with it.November 10, 2008 at 8:26 pm #63061In reply to: Open Links in new window
TrishaM
ParticipantHmmm…..okay well I did add this code to bb_tweaks……I replaced the function bb_target_blank section with what you have here, and I removed the
add_filter('pre-post','bb_rel_nofollow');and added the remove_filter actions above…….but it did not seem to have any effect – bbPress still strips out any “target” reference and still adds the rel=”nofollow” to all links…..I haven’t made any other tweaks to this….
November 10, 2008 at 8:09 pm #68882In reply to: Customize Topic Labels
Ipstenu (Mika Epstein)
ModeratorOkay, now it’s weird. It works perfect for bb_closed_label, but
remove_filter('bb_topic_labels', 'bb_sticky_label');does nothing.What I tried was
remove_filter('bb_topic_labels', 'bb_sticky_label');
function my_sticky_label( $label ) {
global $topic;
if (is_front()) {
if ( '2' === $topic->topic_sticky ) {
return sprintf(__('<img src="/images/sticky.png" /> %s'), $label);
}
} else {
if ( '1' === $topic->topic_sticky || '2' === $topic->topic_sticky ) {
return sprintf(__('<img src="/images/sticky.png" /> %s'), $label);
}
}
return $label;
}
add_filter('bb_topic_labels', 'my_sticky_label');When I do that I get [sticky] and then my image. Which is close…
November 10, 2008 at 5:52 pm #68864In reply to: visit bbpress in root dir; store it elsewhere
Ipstenu (Mika Epstein)
ModeratorMy first thought on just copying index.php over and changing
require('./bb-load.php');torequire('./forums/bb-load.php');didn’t work (which is how it works for wordpress), though it may work if you do that and then changed the location in settings.See https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory for ideas?
November 10, 2008 at 5:42 pm #68880In reply to: Customize Topic Labels
_ck_
ParticipantYou don’t have to hack anything, it’s done via a filter.
ie.
add_filter('bb_topic_labels', 'bb_closed_label', 10);
add_filter('bb_topic_labels', 'bb_sticky_label', 20);simply remove the filter via a plugin and replace it with your own routine.
remove_filter('bb_topic_labels', 'bb_closed_label');
add_filter('bb_topic_labels', 'my_closed_label');
function my_closed_label( $label ) {
global $topic;
if ( '0' === $topic->topic_open )
return sprintf(__('[Read Only] %s'), $label);
return $label;
}November 10, 2008 at 5:34 pm #4249Topic: Customize Topic Labels
in forum PluginsIpstenu (Mika Epstein)
ModeratorIn bb-includes/formatting-functions.php the values of the closed and sticky labels are hard coded:
function bb_closed_label( $label ) {
global $topic;
if ( '0' === $topic->topic_open )
return sprintf(__('[closed] %s'), $label);
return $label;
}I want to change ‘closed’ to ‘Read Only’. I know I can just hack the file, but there should be a way to use theme functions and I’m just not thawed out enough to think of it.
November 10, 2008 at 7:29 am #68871In reply to: Adding Images to a Post Without Tags?
_ck_
Participantbb-attachments lets you upload an image and it inserts a simple bbcode for you automatically
November 10, 2008 at 5:56 am #68870In reply to: Installation procedure, can’t understand clearly…
chrishajer
ParticipantStep 3:
Do you need to install a language other than English? If so, you can find a list of language files here:
http://bbshowcase.org/forums/topic/bbpress-translation-internationalization-into-local-languages
If you need to use a language other than English, you need to navigate to the folder bb-includes and create a folder inside that folder, called
languages, then put the language files in there.Step 4:
If your website is http://www.example.com, and you put your forum in a directory called
forum, you would open a browser and go to http://www.example.com/forum/ and the installer will start for you.November 10, 2008 at 12:29 am #4245Topic: Fixing WordPress-integrated users without membership
in forum TroubleshootingJeff Waugh
MemberHere’s a quick tip for anyone running an integrated WP+BB setup…
Sometimes you’ll find users who haven’t been properly mapped into bbPress roles, so here is a quick MySQL statement to make them all members:
insert into wp_usermeta (user_id, meta_key, meta_value) select user_id, 'bb_capabilities' as meta_key, 'a:1:{s:6:"member";b:1;}' as meta_value from wp_usermeta where user_id not in (select user_id from wp_usermeta where meta_key = 'bb_capabilities') group by user_id;(It adds a bb_capabilities record to the wp_usermeta table for each user who doesn’t have one. Thus, broken accounts become members. Yay!)
Have fun.
November 9, 2008 at 5:59 pm #63060In reply to: Open Links in new window
_ck_
ParticipantWell we could cheat and make the plugin skip links that have your domain name or no
http://in it.function bb_target_blank( $text ) {
$text = preg_replace('|<a (?=http
//)(?!travel-writers-exchange.com)(.+?)>|i', '<a $3 rel="nofollow" target="_blank">', $text);
return $text;
}This is untested.
It’s a fancy regex feature called negative lookahead.
Try it and see what happens.
Doing nofollow for only externals is essentially the same thing, I’ve added it to the replacement above.Make sure you have no additional tweaks for nofollow. I don’t think it’s on by default? If so, try
remove_filter('post_text', 'bb_rel_nofollow');
remove_filter('pre_post', 'bb_rel_nofollow'); -
AuthorSearch Results