115 | | if ( !is_admin() ) { |
116 | | // Register buttons for the relevant component templates |
| 115 | // Register buttons for the relevant component templates |
| 116 | // Friends button |
| 117 | if ( bp_is_active( 'friends' ) ) |
| 118 | add_action( 'bp_member_header_actions', 'bp_add_friend_button', 5 ); |
| 119 | |
| 120 | // Activity button |
| 121 | if ( bp_is_active( 'activity' ) ) |
| 122 | add_action( 'bp_member_header_actions', 'bp_send_public_message_button', 20 ); |
| 123 | |
| 124 | // Messages button |
| 125 | if ( bp_is_active( 'messages' ) ) |
| 126 | add_action( 'bp_member_header_actions', 'bp_send_private_message_button', 20 ); |
| 127 | |
| 128 | // Group buttons |
| 129 | if ( bp_is_active( 'groups' ) ) { |
| 130 | add_action( 'bp_group_header_actions', 'bp_group_join_button', 5 ); |
| 131 | add_action( 'bp_group_header_actions', 'bp_group_new_topic_button', 20 ); |
| 132 | add_action( 'bp_directory_groups_actions', 'bp_group_join_button' ); |
| 133 | } |
| 134 | |
| 135 | // Blog button |
| 136 | if ( bp_is_active( 'blogs' ) ) |
| 137 | add_action( 'bp_directory_blogs_actions', 'bp_blogs_visit_blog_button' ); |
| 138 | } |
| 139 | add_action( 'after_setup_theme', 'bp_dtheme_setup' ); |
| 140 | endif; |
| 141 | |
| 142 | /** |
| 143 | * Backward compatibility for a backpat problem introduced in BP 1.6 when AJAX callbacks were hooked to admin-ajax.php. |
| 144 | * |
| 145 | * While handling AJAX via admin-ajax.php, is_admin() and DOING_AJAX are both true. BP-Default's registered the button |
| 146 | * actions in a block with an !is_admin() check, so the add_actions were ignored when we returned templates with buttons. |
| 147 | * This function is hooked to after_setup_theme with priority 11, so that it happens after bp_dtheme_setup() is run, and |
| 148 | * re-adds the button actions if they are missing. |
| 149 | * |
| 150 | * @see bp_dtheme_setup() |
| 151 | * @since BuddyPress (1.7) |
| 152 | */ |
| 153 | function bp_dtheme_fix_buttons() { |
| 154 | if ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 155 | |
136 | | // Blog button |
137 | | if ( bp_is_active( 'blogs' ) ) |
138 | | add_action( 'bp_directory_blogs_actions', 'bp_blogs_visit_blog_button' ); |
| 171 | if ( ! has_action( 'bp_group_header_actions', 'bp_group_join_button' ) ) |
| 172 | add_action( 'bp_group_header_actions', 'bp_group_join_button', 5 ); |
| 173 | |
| 174 | if ( ! has_action( 'bp_group_header_actions', 'bp_group_new_topic_button' ) ) |
| 175 | add_action( 'bp_group_header_actions', 'bp_group_new_topic_button', 20 ); |
| 176 | |
| 177 | if ( ! has_action( 'bp_directory_groups_actions', 'bp_group_join_button' ) ) |
| 178 | add_action( 'bp_directory_groups_actions', 'bp_group_join_button' ); |
| 179 | } |