Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: custom plugin : hook bp_setup_globals is not fired


grosbouff
Participant

@grosbouff

Ok. Here my code now :

loader.php
function yclads_bp_init() {
require_once( YCLADS_BP_PLUGIN_PATH . 'includes/yclads-bp-core.php' );
}
add_action( 'bp_init', 'yclads_bp_init');

yclads-bp-core.php

function bp_yclads_setup_globals() {
global $bp;

// For internal identification
$bp->yclads->id = 'yclads';

$bp->yclads->format_notification_function = 'bp_yclads_format_notifications';
$bp->yclads->slug = YCLADS_SLUG;

// Register this in the active components array
$bp->active_components[$bp->yclads->slug] = $bp->yclads->id;

do_action( 'bp_yclads_setup_globals' );

}
//TO FIX
//add_action( 'bp_setup_globals', 'bp_yclads_setup_globals' );
add_action( 'wp', 'bp_yclads_setup_globals');
add_action( 'admin_menu', 'bp_yclads_setup_globals');

function bp_yclads_setup_root_component() {
/* Register 'yclads' as a root component */
bp_core_add_root_component( YCLADS_SLUG );

}
//TO FIX
//add_action( 'bp_setup_root_components', 'bp_yclads_setup_root_component' );
add_action( 'wp', 'bp_yclads_setup_root_component');
add_action( 'admin_menu', 'bp_yclads_setup_root_component');

function bp_yclads_setup_nav() {
global $bp;
global $post;

if ((is_single()) && ($post->post_type=='yclad')) {

// This is a single ad.
$bp->is_single_item = true;
$bp->yclads->current_ad = $post;

[...]

}

[...]

print_r($bp->current_component);
exit;

do_action( 'yclads_setup_nav', $bp->yclads->current_ads->user_has_access );

}
//TO FIX
//add_action( 'bp_setup_nav', 'bp_yclads_setup_nav' );
add_action( 'wp', 'bp_yclads_setup_nav' );
add_action( 'admin_menu', 'bp_yclads_setup_nav' );

If I access /wordpress/classified-ads/i-give-kitties/ (single-ad)


print_r($bp->current_component);
exit;

outputs “i-give-kitties” while it should output “classified-ads”. So something is wrong with all this.
Any idea ?

Skip to toolbar