Skip to:
Content
Pages
Categories
Search
Top
Bottom

Having trouble integrating WP functions

  • Hi,

    I have bbPress running along with WordPress. It’s working fine so far, but now I’m trying to use WP functions in my bbPress theme.

    I followed the directions and added “require_once(‘/var/www/web7/web/wp-blog-header.php’);” to the top of my bbPress config.php file.

    But all I get is “Connection Reset by Server” when I open bbPress. As soon as I remove that line, it’ll work again, but without the WP functions, of course.

    What am I doing wrong here?

Viewing 25 replies - 1 through 25 (of 33 total)
  • Could you paste the web server’s error log?

    Well, actually it’s a Safari error message and it’s in German, but I’ll post it anyway:

    “Safari kann die Seite „..“ nicht öffnen, da der Server die Verbindung unerwartet beendet hat. Dies tritt manchmal auf, wenn ein Server überlastet ist. Möglicherweise können Sie die Seite später öffnen.”

    Rough translation: “Safari can’t open the page .., because the connection was unexpectedly reset by the server. This may occur if the server is busy. You might try again later.”

    In Firefox, I just get a white page, no error message.

    When I add the “”require_once(‘/var/www/web7/web/wp-blog-header.php’);” line to the bottom of config.php, I get this error message:

    “Fatal error: Cannot redeclare _http_build_query() in /var/www/web7/web/wp-includes/compat.php on line 108”

    Again, both WordPress and bbPress are running fine on its own, but it seems as soon as I try to load them together, something goes wrong.

    Well, I didn’t mean that kind of error message. If your hosting provider gives you cpanel, there should be a “Error Logs”

    And put that line top of original config.php is correct, but to bottom isn’t.

    Maybe you can try to use relative path? (I don’t think this will help…)

    What are the versions of WordPress and bbPress which you are using?

    Still need the error log.

    I’m running WP 2.3.1 and bbPres 0.8.3.

    The server’s error log looks like this:

    [Sun Dec 16 21:52:52 2007] [error] [client 217.255.224.134] PHP Fatal error: Cannot redeclare _http_build_query() in /var/www/web7/web/wp-includes/compat.php on line 108

    But I suspect those are the errors from when I put the integration line to the end of the config.php file. There do not seem to be any errors in the log file from when put at the top.

    Btw, I just deactivated all bbPress plugins and switched to the standard theme, but still no luck.

    I don’t have any clues to solve you problem.

    If I were you, I will

    1. put error_log('WordPress loaded'); after that request_once to make sure wp has been loaded.

    2. check error log for WordPress loaded, if I get that, that means the problem should be on bbPress, or on WordPress.

    3. keep using error_log, find out where causes a program end.

    This is my no-debugger-debugging method.

    thanks, livibetter.

    well, i tried your method, and “WordPress loaded” does show up in the error log..

    Then, you should trace in bbPress’ code to find out where causes an exit.

    BTW, you can also test error_log(get_option('blogname')); to make sure WordPress loaded database correctly.

    PS. debugging with no debugger is a crazy thing. You have to guess by experiences for best shot.

    hey, using your method i found what’s causing the problem.

    i’s the following lines from bb-settings.php:

    if ( defined(‘BBLANG’) && ” != constant(‘BBLANG’) ) {

    include_once(BBPATH . BBINC . ‘streams.php’);

    include_once(BBPATH . BBINC . ‘gettext.php’);

    }

    When I remove them, it works. However, then it doesn’t load my language file (which is perfectly working without integration, btw). Any ideas?

    Reproduced.

    I didn’t use any language files. But after I put a language code in bb-config.php (for r988) and wp-config.php, I got a blank page.

    Don’t know if I can fix this.

    Thanks for your support on this, wouldn’t have come this far whithout you.

    I guess I could manually change everything to German, but that’s obviously just the second best solution.

    I think this needs to change bbPress core and even WordPress’.

    What’s the WordPress function that you are planning to use?

    Well, basically all of them, including plugins. I want to use my WP header, sidebar etc. and I am planning to build some custom functions that make use both of WP and bbPress functions. So I really do need integration.

    Did you find out anything on what exactly is causing the hick-up?

    This is a quick workaround:

    if ( defined('BBLANG') && '' != constant('BBLANG') ) {
    if ( function_exists('load_default_textdomain') ) :
    global $l10n;

    $locale = BBLANG;
    $mofile = BBLANGDIR . "$locale.mo";

    load_textdomain('default', $mofile);
    else:
    include_once(BBPATH . BBINC . 'streams.php');
    include_once(BBPATH . BBINC . 'gettext.php');
    endif;
    }
    if ( !( defined('DB_NAME') || defined('WP_BB') && WP_BB ) ) { // Don't include these when WP is running.
    require( BBPATH . BBINC . 'kses.php');
    if ( !function_exists('load_default_textdomain') )
    require( BBPATH . BBINC . 'l10n.php');
    }

    It should drops WordPress’ language file, and replaces with bbPress’. That means translations need to be done in WordPress won’t be translated since this code drops language file. This wont happen when you read your blog. However, I don’t have any language files, so this is coded by guessing.

    This is not a solution, just a temporary fix. I will file a ticket.

    Seems you will use a lot of stuff from WordPress. If your WordPress template is already written in German, then you should have no problems. If not or some functions use gettext functions, then you will see many text in original language.

    tried out your workaround, does not seem to work (doesn’t load language file).

    also, shouldn’t it be $mofile = BBLANGDIR . $locale . ".mo";?

    but even with that fixed, it doesn’t work.

    but still, thanks a lot!!


    Sam Bauers
    Participant

    @sambauers

    streams.php and gettext.php are just libraries, so if they are loaded by WordPress, then they don’t need to be loaded again. Although “include_once” should take care of that.

    The problem with the language file not loading is because of the next couple of lines. They say that if WordPress is loaded not to load the kses.php and l10n.php files. This means it is looking for yor language file for bbPress in the same place as the WordPress language file.

    It’s possible (but I don’t know enough about how gettext works) that just dropping the bbPress mo file into the same place as the WordPress mo file will work… just call the bbPress mo file bbpress-de.mo or something like that.

    I think someone solved this before… search a little harder through the forums I think.

    echoed $mofile, and it does reference the right language file.. just doesn’t load it.

    guys, thanks for your help. it’s time to go to bed on this side of the pond now, but I’ll investigate further tomorrow!

    Sorry, didn’t read bbPress source carefully. Replace first if clause with

    if ( defined('BBLANG') && '' != constant('BBLANG') ) {
    if ( function_exists('load_default_textdomain') ) {
    global $l10n;

    $locale = BBLANG;
    $mofile = BBPATH . BBINC . 'languages/' . "$locale.mo";
    if ( is_readable($mofile) ) {
    $input = new CachedFileReader($mofile);
    $l10n['default'] = new gettext_reader($input);
    }
    }
    else {
    include_once(BBPATH . BBINC . 'streams.php');
    include_once(BBPATH . BBINC . 'gettext.php');
    }
    }

    PS. That “..” is how you put variable to be parsed in string in PHP ( Variable parsing )

    @livibetter: Awesome, now it works. You made my day!!!

    And regarding variable parsing: Nice to know, wasn’t aware of that.

    The workaround won’t work for plugins.

    @sambauers: I think there is no complete working solution if you don’t touch the core files.

    First, load_default_textdomain and load_plugin_textdomain are WordPress version, they only look language files in WordPress directories. So, in bbPress, all text won’t be translated since language file are not loaded because WordPress load_*_textdomain won’t find language files in bbPress’ directories.

    Second, WordPress and bbPress both use default as textdomain when calling __() or _e() without assigning textdomain, that means we can only use either WordPress’ or bbPress’ language files at the same time, not both.

    (edit: plugin’s problem can be solved by add a bb_load_plugin_textdomain, but bbPress’s part. If we don’t want to use something like bb__(), bb_e(), maybe we can try to merge bbPress translations into WordPress’ in runtime? or search bbPress’ first, then WordPress’ if can’t find)

    Okay, here is another problem:

    Ever since I’ve integrated WordPress as detailed above, I can’t access the bb-admin .. it’s just a blank page.. as soon as I remove WordPress integration, it’ll work again.

    Here is a quick workaround I just figured out, but I’m not sure this is state of the art:

    Instead of

    require_once(dirname(__FILE__) . '/../wp-blog-header.php');

    in config.php, I put

    `if ( !defined(‘DB_NAME’) && !strstr($_SERVER[“PHP_SELF”],’bb-admin’) )

    require_once(dirname(__FILE__) . ‘/../wp-blog-header.php’); `

    !defined('DB_NAME') is redundant, since you should be only one can code on your files.

    I will use

    if ( !strpos($_SERVER["PHP_SELF"], 'bb-admin') )
    require_once('../wp-blog-header.php');

    Anyway, you did a great job!

    PS. could you show us your forums?

Viewing 25 replies - 1 through 25 (of 33 total)
  • You must be logged in to reply to this topic.
Skip to toolbar