Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Zarate

    (@zarate)

    Too fast 😐

    Actually, nowhere near ok. It turns out I broke WP installation and when reverted the changes, I faced the same problem.

    I keep getting tons of errors I think because some objects haven’t been initialized or PHP can’t just find them. For example, in deprecated.php I was getting an error that I solved declaring $wpdb as global at the beginning of the file.

    Now I get a problem in widgets.php saying that $wp_widget_factory is not an object. If I comment the line I get a similar errors in other files, but it won’t be safe just ignoring all of them.

    Just for the record and if anyone wants to give it a go, this is the code I’m using in app/controllers/app_controller.php (before the class definition) to include WP’s files:

    [code]$pathToWP = $_SERVER['DOCUMENT_ROOT']."/tsd/app/webroot/blog/wp-config.php";

    define('WP_USE_THEMES', false);
    require($pathToWP);[/code]

    Thanks a lot,

    Juan

    Thread Starter Zarate

    (@zarate)

    Got it.

    First I had to set DEBUG to true to get a meaningful error, and finally find out the problem.

    CakePHP defines its own __() function in cake/basics.php. The moment you include WP, wp-includes/l10n.php kicks in trying to define a function with the same name, thus the problem.

    I’ve solved the problem surrounding WP’s __ function with this:

    if ( !function_exists(‘__’) ) :
    // the function
    endif;

    And I’m good to go.

    I don’t expect any conflict because what I’m planning to do with WP when inside Cake has nothing to do with text, so I’ll give Cake’s function precedence. Likewise, when on the blog, none of Cake’s code is going to be present, therefore WP won’t notice.

    If anyone sees a problem with this, please let me know.

    Ta!

    Juan

Viewing 2 replies - 1 through 2 (of 2 total)