Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • The code you have is slightly wrong.

    Here’s what you have:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    The if statement was in the wrong position. I very well might have done that myself. If I did, I apologize. The code should be good to go! PM me if you have any questions. I’d be happy to help you out.

    That definitely be good a start. I would definitely add in the function_exists call, as well, in case some one decides to get crazy and ends up redefining the function. This will protect both aspects.

    And not a problem at all. Gives me a chance to delve into the code more. I know how it can get maintaining code, especially when there’s a lot on your plate.

    Thanks for the plugin, by the way!

    To anyone having an issue, I figured out what the problem is.

    NOTE: I am using WPBook 2.2.3! So any lines I put in here might be incorrect!

    That said…

    In the wpbook.php file, there is a function wpbook_publish_to_facebook() on line 1029. This is the function called through the hook, ‘draft_to_publish.’ This hook was causing the issue we were all seeing. The issue is every time I called wp_publish_post, that hook was running the wpbook_publish_to_facebook() function. Here’s where the problem lies:


    if (!version_compare(PHP_VERSION, '5.0.0', '<')) {
    include(WP_PLUGIN_DIR .'/wpbook/includes/publish_to_facebook.php');
    }

    All that code is doing is making sure we are running PHP5.0.0 or higher. This means, any time this function is called, we are going to reinclude the publish_to_facebook.php file. Ergo, we are going to have redefinition of wpbook_publish_to_facebook(). This will cause that error to get throw.

    Here’s what the code should look like to ensure we don’t have redefinition errors:


    if (!version_compare(PHP_VERSION, '5.0.0', '<')) {
    if(!function_exists('wpbook_publish_to_facebook')) {
    include(WP_PLUGIN_DIR .'/wpbook/includes/publish_to_facebook.php');
    }
    }

    Please make use of this as you see fit! It will clear up any redefinition errors you have with wpbook_publish_to_facebook()!

    Cheers!

    So, I’ve upgraded my version to 2.2.3. This issue still happens: Fatal error: Cannot redeclare wpbook_safe_publish_to_facebook() (previously declared in __FILE__/publish_to_facebook.php:6) in __FILE__/publish_to_facebook.php on line 403.

    I’m writing a simple script to get all of the unpublished posts, and publish them. For some reason, when I run wp_publish_post(), that error gets throw. What’s stranger is that error gets thrown on the third post. What does WPBook have to do with individual posts, especially in reference to publishing a single post? Why does that error get thrown when publishing posts?

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