Title: dasfisch's Replies | WordPress.org

---

# dasfisch

  [  ](https://wordpress.org/support/users/dasfisch/)

 *   [Profile](https://wordpress.org/support/users/dasfisch/)
 *   [Topics Started](https://wordpress.org/support/users/dasfisch/topics/)
 *   [Replies Created](https://wordpress.org/support/users/dasfisch/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/dasfisch/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/dasfisch/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/dasfisch/engagements/)
 *   [Favorites](https://wordpress.org/support/users/dasfisch/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WPBook] [Plugin: WPBook] Fatal Error when publishing post](https://wordpress.org/support/topic/plugin-wpbook-fatal-error-when-publishing-post/)
 *  [dasfisch](https://wordpress.org/support/users/dasfisch/)
 * (@dasfisch)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-wpbook-fatal-error-when-publishing-post/page/2/#post-1796360)
 * The code you have is slightly wrong.
 * Here’s what you have:
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * 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.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WPBook] [Plugin: WPBook] Fatal Error when publishing post](https://wordpress.org/support/topic/plugin-wpbook-fatal-error-when-publishing-post/)
 *  [dasfisch](https://wordpress.org/support/users/dasfisch/)
 * (@dasfisch)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/plugin-wpbook-fatal-error-when-publishing-post/#post-1796343)
 * 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!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WPBook] [Plugin: WPBook] Fatal Error when publishing post](https://wordpress.org/support/topic/plugin-wpbook-fatal-error-when-publishing-post/)
 *  [dasfisch](https://wordpress.org/support/users/dasfisch/)
 * (@dasfisch)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/plugin-wpbook-fatal-error-when-publishing-post/#post-1796341)
 * 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!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WPBook] [Plugin: WPBook] Fatal Error when publishing post](https://wordpress.org/support/topic/plugin-wpbook-fatal-error-when-publishing-post/)
 *  [dasfisch](https://wordpress.org/support/users/dasfisch/)
 * (@dasfisch)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/plugin-wpbook-fatal-error-when-publishing-post/#post-1796340)
 * 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)