BP_Legacy::setup_actions()
Setup the theme hooks.
Description Description
Source Source
File: bp-templates/bp-legacy/buddypress-functions.php
protected function setup_actions() {
// Template Output.
add_filter( 'bp_get_activity_action_pre_meta', array( $this, 'secondary_avatars' ), 10, 2 );
// Filter BuddyPress template hierarchy and look for page templates.
add_filter( 'bp_get_buddypress_template', array( $this, 'theme_compat_page_templates' ), 10, 1 );
/** Scripts ***********************************************************/
add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS
add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS
add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization
/** Body no-js Class **************************************************/
add_filter( 'body_class', array( $this, 'add_nojs_body_class' ), 20, 1 );
/** Buttons ***********************************************************/
if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
// Register buttons for the relevant component templates
// Friends button.
if ( bp_is_active( 'friends' ) )
add_action( 'bp_member_header_actions', 'bp_add_friend_button', 5 );
// Activity button.
if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() )
add_action( 'bp_member_header_actions', 'bp_send_public_message_button', 20 );
// Messages button.
if ( bp_is_active( 'messages' ) )
add_action( 'bp_member_header_actions', 'bp_send_private_message_button', 20 );
// Group buttons.
if ( bp_is_active( 'groups' ) ) {
add_action( 'bp_group_header_actions', 'bp_group_join_button', 5 );
add_action( 'bp_directory_groups_actions', 'bp_group_join_button' );
add_action( 'bp_groups_directory_group_filter', 'bp_legacy_theme_group_create_nav', 999 );
add_action( 'bp_after_group_admin_content', 'bp_legacy_groups_admin_screen_hidden_input' );
add_action( 'bp_before_group_admin_form', 'bp_legacy_theme_group_manage_members_add_search' );
}
// Blog button.
if ( bp_is_active( 'blogs' ) ) {
add_action( 'bp_directory_blogs_actions', 'bp_blogs_visit_blog_button' );
add_action( 'bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999 );
}
}
/** Notices ***********************************************************/
// Only hook the 'sitewide_notices' overlay if the Sitewide
// Notices widget is not in use (to avoid duplicate content).
if ( bp_is_active( 'messages' ) && ! is_active_widget( false, false, 'bp_messages_sitewide_notices_widget', true ) ) {
add_action( 'wp_footer', array( $this, 'sitewide_notices' ), 9999 );
}
/** Ajax **************************************************************/
$actions = array(
// Directory filters.
'blogs_filter' => 'bp_legacy_theme_object_template_loader',
'forums_filter' => 'bp_legacy_theme_object_template_loader',
'groups_filter' => 'bp_legacy_theme_object_template_loader',
'members_filter' => 'bp_legacy_theme_object_template_loader',
'messages_filter' => 'bp_legacy_theme_messages_template_loader',
'invite_filter' => 'bp_legacy_theme_invite_template_loader',
'requests_filter' => 'bp_legacy_theme_requests_template_loader',
// Friends.
'accept_friendship' => 'bp_legacy_theme_ajax_accept_friendship',
'addremove_friend' => 'bp_legacy_theme_ajax_addremove_friend',
'reject_friendship' => 'bp_legacy_theme_ajax_reject_friendship',
// Activity.
'activity_get_older_updates' => 'bp_legacy_theme_activity_template_loader',
'activity_mark_fav' => 'bp_legacy_theme_mark_activity_favorite',
'activity_mark_unfav' => 'bp_legacy_theme_unmark_activity_favorite',
'activity_widget_filter' => 'bp_legacy_theme_activity_template_loader',
'delete_activity' => 'bp_legacy_theme_delete_activity',
'delete_activity_comment' => 'bp_legacy_theme_delete_activity_comment',
'get_single_activity_content' => 'bp_legacy_theme_get_single_activity_content',
'new_activity_comment' => 'bp_legacy_theme_new_activity_comment',
'post_update' => 'bp_legacy_theme_post_update',
'bp_spam_activity' => 'bp_legacy_theme_spam_activity',
'bp_spam_activity_comment' => 'bp_legacy_theme_spam_activity',
// Groups.
'groups_invite_user' => 'bp_legacy_theme_ajax_invite_user',
'joinleave_group' => 'bp_legacy_theme_ajax_joinleave_group',
// Messages.
'messages_autocomplete_results' => 'bp_legacy_theme_ajax_messages_autocomplete_results',
'messages_close_notice' => 'bp_legacy_theme_ajax_close_notice',
'messages_delete' => 'bp_legacy_theme_ajax_messages_delete',
'messages_markread' => 'bp_legacy_theme_ajax_message_markread',
'messages_markunread' => 'bp_legacy_theme_ajax_message_markunread',
'messages_send_reply' => 'bp_legacy_theme_ajax_messages_send_reply',
);
// Conditional actions.
if ( bp_is_active( 'messages', 'star' ) ) {
$actions['messages_star'] = 'bp_legacy_theme_ajax_messages_star_handler';
}
/**
* Register all of these AJAX handlers.
*
* The "wp_ajax_" action is used for logged in users, and "wp_ajax_nopriv_"
* executes for users that aren't logged in. This is for backpat with BP <1.6.
*/
foreach( $actions as $name => $function ) {
add_action( 'wp_ajax_' . $name, $function );
add_action( 'wp_ajax_nopriv_' . $name, $function );
}
add_filter( 'bp_ajax_querystring', 'bp_legacy_theme_ajax_querystring', 10, 2 );
/** Override **********************************************************/
/**
* Fires after all of the BuddyPress theme compat actions have been added.
*
* @since 1.7.0
*
* @param BP_Legacy $this Current BP_Legacy instance.
*/
do_action_ref_array( 'bp_theme_compat_actions', array( &$this ) );
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.7.0 | Introduced. |