Skip to:
Content
Pages
Categories
Search
Top
Bottom

Call to undefined function bp_core_add_subnav_item()

  • @egerrits

    Participant

    After upgrading to latest Trunk (1.01 upwards) my plug-in (bp-events) errors with:

    Call to undefined function bp_core_add_subnav_item()

    And all other bp_core functions after that one, indicating something changed in bp_core referencing for bp plug-ins.

    Anyone have an idea?

Viewing 3 replies - 1 through 3 (of 3 total)
  • @burtadsit

    Participant

    Sounds like your plugin is loading before bp is loaded. If the core fns aren’t there then bp is probably loading after yours. When you do the upgrade it now has a different sequence in the list of sitewide plugins.

    I think jeffsayre put some checking code into the bp skel component. I don’t know if it’s been released yet. In case it hasn’t this is what it looks like:

    /**
    * oci_load_buddypress()
    *
    * Checks to see of bp is active. Attempts to load it if it isn't.
    *
    * @return true if bp is installed and activated
    */
    function oci_load_buddypress() {
    if ( function_exists( 'bp_core_setup_globals' ) )
    return true;

    /* Get the list of active sitewide plugins */
    $active_sitewide_plugins = maybe_unserialize( get_site_option( 'active_sitewide_plugins' ) );

    if ( !isset( $active_sidewide_plugins['buddypress/bp-loader.php'] ) )
    return false;

    if ( isset( $active_sidewide_plugins['buddypress/bp-loader.php'] ) &&
    !function_exists( 'bp_core_setup_globals' ) ) {
    require_once( WP_PLUGIN_DIR . '/buddypress/bp-loader.php' );
    return true;
    }

    return false;
    }

    If this fn returns true then either bp is loaded, bp wasn’t loaded and it loaded it or false bp couldn’t be loaded.

    True is your plugin can continue, false is do some kind of graceful exit.

    @egerrits

    Participant

    Thanks Burt,

    That fixed the bp not loading issue, however… now my plugin never runs because bp is never loaded before my plugin. The function somehow never succeeds in loading bp…

    If I simply add:

    require_once( WP_PLUGIN_DIR . ‘/buddypress/bp-loader.php’ );

    to my requires at the top of my plug-in everything works peachy.

    Does this add too much overhead, though?

    @burtadsit

    Participant

    Well the deal with the is_there_a_bp() fn is that if it is in the activated list it just arbitrarily loads bp. That only happens once so it should be ok when bp actually gets to load in it’s natural seqence.

    If than fn finds bp installed it loads it. Don’t know how your plugin isn’t getting loaded.

    There is an issue with just doing require_once() for bp. The user may have bp deactivated. In that case your plugin shouldn’t just decide to run it. It should respect the wishes of the user.

    There is a long discussion about all this base plugin/dependent plugin stuff going on in the wp-hackers mailing list at the moment.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Call to undefined function bp_core_add_subnav_item()’ is closed to new replies.
Skip to toolbar