Search Results for 'code'
-
AuthorSearch Results
-
March 22, 2009 at 10:41 pm #5049
Topic: get_bb_location overite doesn’t work
in forum TroubleshootingNull
MemberIf you have a complete new php file that acts like a new page, you can add it’s location with the below code, BUT I want to rename a existing php file. The problem is that its a filtered page: view.php?view=port. The problem is that this is still seen as view.php. How do I change this so that view.php?view=port is seen as a total new page so that the code below works and the location is added?
function bbport_location() {
if (bb_find_filename($_SERVER['PHP_SELF']) == "view.php?view=port"):
return "port-page";
endif;
}
add_filter( 'get_bb_location', 'bbport_location' );
function is_bbport() {
if ( 'port-page' == get_bb_location() )
return true;
else
return false;
}March 22, 2009 at 9:49 pm #72312_ck_
ParticipantWe really should backport the fix that is in 1.0 to 0.9 for our international friends.
I can’t remember what the function was that had the problem but I believe it was
function htmlspecialchars_decode
there may be others.
Unfortunately those functions are not pluggable but you could try replacing them from 1.0 into 0.9 and use SVN to handle upgrades which might work around it.
Made a note on TRAC https://trac.bbpress.org/ticket/1059
March 22, 2009 at 9:25 pm #72615_ck_
ParticipantWe really should backport the fix that is in 1.0 to 0.9 for our international friends.
I can’t remember what the function was that had the problem but I believe it was
function htmlspecialchars_decode
there may be others.
Unfortunately those functions are not pluggable but you could try replacing them from 1.0 into 0.9 and use SVN to handle upgrades which might work around it.
Made a note on TRAC https://trac.bbpress.org/ticket/1059
March 22, 2009 at 8:39 pm #72614chrishajer
ParticipantI think this is because the server is using PHP4 and you have an integrated installation.
https://bbpress.org/forums/tags/mbcs
http://www.google.com/search?q=site%3Abbpress.org%2Fforums%2F+MBCS
March 22, 2009 at 5:59 pm #5048erick_king
MemberHi,
I tried to instal it but in the first step appears this
Warning: cannot yet handle MBCS in html_entity_decode()! in /hermes/bosweb/web077/b771/ipw.erickcacao/forum/bb-includes/wp-functions.php on line 113
Sould I configure wp-functions.php?
March 22, 2009 at 7:57 am #72092In reply to: bbPress Integration Plugin Examples
john32
MemberAs it turns out even if the blog URL for WP is the same as the site URL (WP doesn’t even list the blog URL in the database even though it shows up under WP Admin Options) you need to include it in the bbPress Integration settings. Doing set reset my cookie path from /forums/ to:
define(‘COOKIE_DOMAIN’, ”);
define(‘COOKIEPATH’, ‘/’);
As it turns out, coding logic told me, that the plugin didn’t include the cookie domain sicne it was null.
So in fact, they are exactly the same.
That and I fixed it for full integration.
But that’s another thread!
March 22, 2009 at 4:12 am #72534In reply to: Overwriting Template functions
kevinjohngallagher
MemberThanks for the input _ck_, as always
I’m not often trying to replace an entire function from template-functions.php, i just want to overwrite one function once. But i get now that it has to be in pluggable.php, which is cool.
I suppose my issue here is this: why are many functions that output hardcoded HTML hardcoded into templates-functions.php in the core and not in pluggable.php so that theme / plugin developers can’t overwrite them?
In my opinion (and it’s just my opinion) there are far too few hooks in BBpress and some of them are in the ‘wrong’ or difficult place for theme development or front-end plugin development. This may seem daft to alot of people and long time BBpress contributors, but with the likes of _ck_ writing so many great back end plugins, most of mine focus on making BBpress work in a slightly more modern way (ajax, nestings, wysiwyg, etc); and i keep hitting these ‘walls’ of where BBpress has hardcoded something.
Basically I struggle to see why BBpress doesn’t have a functions.php file in the theme directory. As it stands we’ve got to create a theme the way we want it, then integrate it into the WordPress theme, then remove the conflicts for the WP and BBpress theme as the standard BBpress theme came with a different div structure to the standard WP one (madness), then add the hooks for all the stuff thats not got a hook, then move hooks for the one in a ridiculous place, then write a plugin to load up all the functions that your theme will use as standard (cos god forbid we’d have a functions.php like wordpress).
It makes developing a theme that does anything more than background colour of posts and what happens around/outside the forum a real nightmare. And what’s worse, it means that any theme to stray away from the ‘default’ kakumei theme, needs to have a plugin installed as well.
While this may seem like no big deal to people (and it’s not a huge deal), given that we use a different structure for our folders to WP (again – crazily stoopid given the market BBpress’s aimed at even at this stage), we’re reliant on the user to install and activate everything properly.
example:
Instructions with a theme if we had a functions.php and WP structure:
- Copy theme folder to your theme directory.
- Load up admin section, and select the new theme.
Instructions with a theme as is:
- Create a my-themes folder in your BBpress directory
- Copy the theme folder into that directory
- Create a my-plugins folder in the your BBpress directory
- Copy the plugin folder into that directory
- load up admin section, and select new theme
- activate new plugin to make theme reliant functions work
Now, obviously there is nothing too taxing on the second version, but it’s long been my experience that the less steps users have to undertake the less errors are made. Especially, and this is the bit I don’t get, when WordPress does things in a really simple manner (and has done so for ages).
I appreciate that forums of the nature we create are never going to be the most exciting or ground breaking in the world, but for those who think i’m wrong about more modern / different theme’s being available for bbpress let me ask this:
- If you look at the Top 20 forums in _ck_’s list (http://bbshowcase.org/forums/view/top100), can you tell it’s a BBpress forum before seeing the “powered by BBpress” at the bottom? If you’re bored do the same for the rest of the top100 and see how many you need to check are running BBpress.
- By comparison, when you go to a non-BBpress forum on the internet, can you automatically tell what forum software it is every time?
- But i bet you can tell it’s NOT BBpress straight away. Why do you think that is?
(infact the first one i’d to scroll to the bottom to check it was made my bbpress and it was – a number have switched away form bbpress – was http://soccerlens.com/forum/ which is using one of my template hacks from last year. the other worth mentioning is http://www.dragonballalcine.com/foro/ which is lovely and innovative – so that’s 2 out of the top100)
March 22, 2009 at 4:00 am #66149In reply to: WordPress + bbPress Integration 101
Billy S
MemberHey all. After much help from reading these forums and tinkering endlessly, I have gotten cross site logins working between WP2.6 and bbpress 0.9 . I don’t know if you’d call it ‘integration’, but it allows a user to log in once and gain access to all appropriate site resources. Although probably not the best solution, what I did is create my own cookie login, which is caught before wordpress or bbpress load, and creates a new user object which is universal to WP and BBPress (and any other webapps you use). It does take a little…alteration…of core WP and BBPress files. I strongly encourage you to make backups before doing this, and proceed at your own risk. It worked for me, but I cannot guarantee that it will fork for you. Also, it took a bit of hacking before I came up with this solution, so it may contain minor errors or accidental omissions as I am having to backtrack to recall what exactly I did.
okay, here goes…
First, we have to configure bbpress to use the wp_users table. That is done in the admin area of bbpress (settings->wordpress integration). Check ‘Show Advanced Database Settings’ and enter your database information for the wordpress install. Also, enter the wordpress database secret code near the top of the settings page.
Next, I created a file in the document root called ‘cookie_login.php’:
<?php
if($_SERVER['REQUEST_URI'] == '/cookie_login.php'){die('Cannot access directly');}
//Initial Setup of Variables
$SECRET_KEY = 'SECRET_KEY_DEFINED_IN_BBPRESS_AND_WP';//use a real secret key
$site_user = false;
//Do the DB thing
$the_db= mysql_connect('SERVER','USER','PASS');
mysql_select_db('DATABASE',$the_db);
//Start Session!
session_set_cookie_params(1800,'/','.SITE.com'); //30 minute session
session_start();
if (isset($_COOKIE['site_cookie'])){ //cookie has been set, proceed to get user info!
$tmp = explode(':',$_COOKIE['site_cookie']); //this will make sense later
$tmpusr = $tmp[0];
$wpid = $tmp[1];
$tmphash = $tmp[2];
$hashShouldBe = md5($tmpusr . $SECRET_KEY . $wpid); //what the hash should be - prevent tampering!
if ($tmphash == $hashShouldBe){
if (isset($_SESSION['user'])){
$site_user = $_SESSION['user'];
}else{
$qry = "SELECT * from wp_users WHERE ID = ".mysql_real_escape_string($wpid,$the_db) . " LIMIT 1";
$result = mysql_query($qry,$the_db);
$site_user = mysql_fetch_assoc($result);
$qry = "SELECT meta_key, meta_value from wp_usermeta where user_id = ".mysql_real_escape_string($wpid,$the_db);//get additional data, just for fun
$resulta = mysql_query($qry,$the_db);
$temp_arr = array();
while ($row = mysql_fetch_assoc($resulta)){
$tmp_value = unserialize($row['meta_value']) ? unserialize($row['meta_value']) : $row['meta_value'];//if it a serialized array, unserialize it. otherwise, dont.
$temp_arr[$row['meta_key']] = $tmp_value;
}
$site_user = $temp_arr + $site_user;
$_SESSION['user'] = (object)$site_user;//Object just out of preference, but doesn't have to be
}
}else{//tsk tsk, bad hash
$_SESSION['user'] = array();
setcookie('site_cookie',$_COOKIE['site_cookie'],time()-9600,'/','.SITE.com');
setcookie('PHPSESSID',$_COOKIE['PHPSESSID'],time()-9600,'/','.SITE.com');
setcookie(session_name(), session_id(), time()-9600, '/');//may be unnecessary...not sure...but can't hurt! (famous last words)
session_destroy();
}
}
if (!isset($_COOKIE['site_cookie']) && isset($_SESSION['user'])){//attempt to gain access?
$_SESSION['user'] = array();
setcookie('site_cookie',$_COOKIE['site_cookie'],time()-9600,'/','.SITE.com');
setcookie('PHPSESSID',$_COOKIE['PHPSESSID'],time()-9600,'/','.SITE.com');
setcookie(session_name(), session_id(), time()-9600, '/');//may be unnecessary...not sure...but can't hurt! (famous last words)
session_destroy();
}
session_write_close();
unset($SECRET_KEY,$hashShouldBe,$tmp,$wpid,$tmphash,$tmpusr,$result,$_SESSION['user'],$resulta,$temp_arr);//burn the evidence!
include ('site_functions.php'); //optional, can hook another file with functions (universal to all sites) to deal with this new user object
?>After I finished the cookie_login.php, I rolled up my sleeves and dove into the WordPress and BBPress core to allow my login to occur.
in the /wp-config.php file, define the cookie domain:
define('COOKIE_DOMAIN', '.SITE.com');
Also, that secret key you used earlier in cookie_login…define it here as well
define('SECRET_KEY', 'Same Key from Earlier. IMPORTANT to make sure it's identical');
Next, I hooked in my cookie_login file to wordpress and bbpress by adding an include to the top of BOTH bb-config.php AND wp-config.php
include $_SERVER['DOCUMENT_ROOT'] . '/cookie_login.php';
To set up the ‘site_cookie’ properly, open up /wp-includes/user.php and find wp_signon function (was the first one for me). At the bottom of the function, after
if ( is_wp_error($user) )
return $user;Add the following:
$hashValue = $credentials['user_login'] . SECRET_KEY . $user->data->ID;
$crossCookieValue = $credentials['user_login'] . ':' . $user->data->ID . ':' . md5($hashValue);
setcookie('site_cookie',$crossCookieValue,0,'/','.SITE.com');
wp_set_auth_cookie($user->ID, $credentials['remember'], $secure_cookie);
do_action('wp_login', $credentials['user_login']);//this may have already been there, don't rememberRemember how I mentioned the site_functions.php which can be included at the bottom of cookie_login.php? That is a perfect place to put the next function, for bbpress login, but it can just as well go inside cookie_login.php itself. The function overwrites the bbpress native wp_validate_auth_cookie function, found in /bb-includes/pluggable.php, with one of our own, which is as follows:
function wp_validate_auth_cookie($cookie = '') {
global $site_user;
if (!isset($site_user->ID)){
return false;
}else{
return $site_user->ID;
}
}This is used internally by bbpress to allow the login to proceed.
Next, open /wp-login.php and find the case: logout section, and add the following right after it:
setcookie('site_cookie',$_COOKIE['site_cookie'],time()-9600,'/','.SITE.com');
setcookie('PHPSESSID',$_COOKIE['PHPSESSID'],time()-9600,'/','.SITE.com');'
Finally, and this may be only applicable for subdomain usage, open /wp-includes/pluggable.php and find the function wp_safe_redirect. Add subdomains you want redirects to in the $allowed_hosts array, for example:$allowed_hosts[]=”bbpress.SITE.com”;
$allowed_hosts[]=”test_wordpres.SITE.com”;`
etc…
That’s all (I think) that I had to do. This is probably not ideal, as there are now two copies of a user when hey login, one defined in our new system and one in the wordpress/bbpress systems; however I found this necessary to have happen since I didn’t want to go through all the core code and edit out mention of $user.
Let me know if this works for you, I hope it was coherant enough. I may have accidentally omitted sections since, as I said before, this is the result of a few weeks of on-and-off tweaks and changes. I can always dig into code and find things I missed if I know what problems are occurring. Also, if anyone is interested, I altered a private messenging system I found which was a little outdated (http://www.pixel2life.com/publish/tutorials/608/simple_private_messaging_system/) to work with this model as well. Users can PM one another from within the wordpress dashboard, and message indicators are noted in the header throughout their visit (in wordpress, bbpress, and other subsites).
March 22, 2009 at 3:16 am #72547In reply to: Requring Email Address to end in a domain name
jdhartley
MemberOh thats awesome.
Thanks a lot.
March 22, 2009 at 3:01 am #72311kirabug
MemberSo wait, does this mean BBpress is dropping support for PHP-4? Because WordPress is working just fine…. I’m also downgrading. Would have loved to see some kind of warning/note on the download file page that requirements have changed (if they have).
March 22, 2009 at 1:23 am #5038Null
MemberHi,
The front-page has some div styling for the hottags div. This div is only used on the front-page so they set up the template that this styling only is used on the front-page:
#front-page #hottags {
position: absolute;
top: 0;
left: 0;
width: 150px;
overflow: hidden;
}Now I want to use the hottag div on another page, but the styling is messed up then. This can be fixed to adept the stylesheet and add an extra (copied) div style. My question is if it is also possible to not add a new copied div style but use the front-page one. And if this is possible, how to do that?
Thanks
March 22, 2009 at 1:05 am #72570In reply to: How to get the link to the second post?
Null
MemberHi,
Thanks for the reply, I’ll try your suggested “untested theoretical plugin”. But what does the 999 stand for? Just learning
March 22, 2009 at 12:20 am #72310gradek
MemberI was able to fix the Error using the following .htaccess code:
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4
I got the info here, since I am using a godaddy server.
March 22, 2009 at 12:08 am #72309gradek
MemberI am also having the same issue, the .htaccess trick didn’t help either. any other ways of ensure the use of php5?
March 21, 2009 at 10:52 pm #72569In reply to: How to get the link to the second post?
_ck_
Participantuntested theoretical plugin
add_filter('post_text','first_reply',999);
function first_reply($text) {global $bb_post;
if (!is_bb_feed() && (int) $bb_post->post_position==1) {$text.="<a name='first-reply'></a>";}
return $text;
}Then to get the first-reply link for any topic,
<?php echo "<a href='".get_topic_link()."#first-reply'>replies</a>"; ?>
March 21, 2009 at 10:45 pm #72568In reply to: How to get the link to the second post?
_ck_
ParticipantThey are trying to link to the first reply.
It far easier to inject an anchor at the very bottom of the first post and link to that instead.
It could be done via a plugin that appends post_text and checks the $bb_post->post_position to see if it’s equal to 1
If it’s equal to 1 then append
<a name="first-reply"></a>
Then your first reply is always at http
/topic-link-blah-blah#first-reply
Note that my unread-posts plugin already solves the problem of linking to the first unread reply per user.
March 21, 2009 at 7:06 pm #72579In reply to: What’s the state of WordPress theme integration?
bruinfelix
MemberThe creators of bbPress, are putting their head in to the sand, the function most people wants (theme integration) isnt still available in bbPress, and that’s a big shame!
Eleeist
MemberThanks
.
chrishajer
ParticipantIn the directory of your current template, you want to add it to the file called footer.php. Just put it right after this line:
<?php printf(__('%1$s is proudly powered by bbPress.'), bb_option('name'), "http://bbpress.org") ?>
Before the closing </div>.
March 21, 2009 at 2:08 am #72498In reply to: Integration URL Problems
john32
MemberCan anyone who has successfully got both WP and bbPress to use the same cookies please post what code you used in your wpconfig and bbconfig to them to work?
I understand there are countless thread with this information but I’ve tried different various combinations of the code to no avail.
Thanks!!
March 20, 2009 at 11:33 pm #59344In reply to: Adding a new User Type
lelandf
MemberOkay, it took me a couple hours but I finally got this to work (sorta) using a variation of fel64’s code. I was using it to create a special usergroup with the same capabilities as regular members for use with the Hidden Forums plugin.
The original code kinda worked, because it did create a new user group with the name I had chosen. I soon realized, however, the users in the user group I made had no capabilities and therefore couldn’t post, edit their profile at all, etc. I was expecting they would have the same capabilities as members.
So I made a few changes and…here’s the plugin code I used:
<?php
/*
Plugin Name: Add lusers
Description: adds the luser role
Author: fel64
*/
add_filter('get_roles', 'addlusers');
function addlusers( $roles ) {
$roles['luser'] =& $luser; //convenience
$luser['name'] = __('Luser');
$lusercaps = array('participate','edit_favorites','edit_tags','edit_topics','edit_posts','edit_profile','write_topics','write_posts','change_password','read');
foreach( $lusercaps AS $cap ) {
$luser['capabilities'][$cap] = true;
}
return $roles;
}
?>Basically I removed the first line of the function, because for some reason it wasn’t working. I then copied all the capabilities of a regular member in an array format. You can get other capabilities (like for moderators, admins, and key masters) from the capabilities.php file in /bb-includes/.
Just save the code in a .php file and upload it to your plugins folder and activate. You would also probably want to change the “Luser” name to something else.
Now I know this probably isn’t the best way to do it, but it worked for me, so I thought I’d share it here. Hopefully some of you get some use out of it.
March 20, 2009 at 11:16 pm #72532In reply to: Overwriting Template functions
kevinjohngallagher
MemberTHANK YOU detective!
(also thanks to _ck_ and Ipstenu – i’m sure we would not have gotten there without you).
So in idiots terms (so i can understand ;-] )…
All functions hardcoded into BBpress’s template-functions can be overwritten, but only if they are on a hardcoded list within the core?
And if you want to write a plugin to overwrite one of these template functions that’s hard coded into the core, and not on another the hardcoded list in the core, we have to include a file in the theme directory and not the plugin directory?
Am i the only one that thinks that this hampers theme development with all this hardcoded stuff? Anyway, as long as this works it’s cool with me – thank you all for your help!
March 20, 2009 at 10:46 pm #72530In reply to: Overwriting Template functions
kevinjohngallagher
MemberHI _ck_,
Yeah it was a typo.
I know that functions can have things added to them and overwitten as your plugins prove, i’m not doubting that for a second, and i’m sorry if it came across that way. What i’m saying is that while i’m able to either overwrite or add to some functions, some i’m only able to add to, and some i’m not able to either add to nor overwrite.
Now if that’s not a bug, then cool. Really cool! But i can’t see why that would be, and i’m hoping you can point me in the right direction. You’ve said countless times it works in the same way as wordpress plugins, but a google search of how to overwrite wordpress functions leads me to (see pages below). And the code supplied here works on every function i’ve tried (so far – 9 plugins in) except BB_GET_HEADER, BB_GET_FOOTER and POST_FORM. and i’m wondering why that is.
I’m absolutely 100% cool with the fault being at my end, it would be a relief tbh, but with no documentation and no examples or other plugins that overwrite these functions i’m totally lost.
Basically, typos and what pepole think i’m wanting do to aside, what i really want to know is this:
What code do i have to write so that my function is called instead of the one hard coded into template-functions.php?
Thank you so much.
Edit: Websites i use as a plugin resource:
http://www.catswhocode.com/blog/how-to-overwrite-wordpress-core-functions
https://codex.wordpress.org/Plugin_API
http://comox.textdrive.com/pipermail/wp-hackers/2008-February/018013.html
March 20, 2009 at 10:36 pm #72529In reply to: Overwriting Template functions
_ck_
ParticipantI assume this is just a typo in your example and not what you are really using:
add_filter('topic_pages', 'output_what_i_want, 11');
because the quote should close before the 11
add_filter('topic_pages', 'output_what_i_want', 11);
There’s nothing wrong with the action or filter triggers in bbpress (only that there are not enough of them or in the right places). The code for that is taken right out of wordpress and works fine. My dozens of plugins kinda prove they all work.
March 20, 2009 at 10:23 pm #72527In reply to: Overwriting Template functions
kevinjohngallagher
MemberHI _ck_,
thanks for this. I’m not trying to stop something being called with an add_action, but i’m sorry if i didn’t phrase it well enough. What I have found is that i cannot either get an added filter nor an action to add to certain functions in BBpress. Thats the issue i’ve hit.
Nor am i wanting dynamic theme’s, as your wonderful plugin covers that.
My plugin does this:
ON activation checks for wordpress integration.
If wordpress integrated copies the header file form the wordpress template to a directory.
Inserts BBcode Hooks into the new file.
Now that bit works well and dandy; but what i want in this instance is to overwrite the function BB_GET_HEADER as it’s hardcoded in the template_functions.php file.
So here is my question, how can i/we overwrite the BB_GET_HEADER function ?
1) can we overwrite functions in the template-functions.php file?
2) how?
3) is there an example of this anywhere?
I ask not to be pedantic, but because i think you answered my post based on what you think i’m trying to do with my plugin rather than the issue at hand – namely that i can over write some functions and not others.
You are pretty much the authority on this, so i really appreciate any help insight you might have on how to overwrite the BB_GET_HEADER function. thank you!
-
AuthorSearch Results