WordPress Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Retrieves an array of all network sites | |
| * | |
| * @since 1.0 | |
| * @return array | |
| */ | |
| function get_network_sites() { | |
| global $wpdb; | |
| $blogs = $wpdb->get_results(" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Sets a user's buddypress member type(s) globally across all sites | |
| * | |
| * @since 1.0 | |
| */ | |
| function bp_set_global_member_type( $user_id = 0, $member_type = '', $append = false ) { | |
| // Append new member type to global member type array | |
| if ( $append == true ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function sync_member_type( $user_id = 0 ) { | |
| if ( empty( $user_id ) ) | |
| $user_id = get_current_user_id(); | |
| $memb_types = bp_get_member_type( $user_id, false ); | |
| switch_to_blog( 3 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'bp_setup_nav', 'jmw_make_edit_default_for_own_bp_profile', 15 ); | |
| /* | |
| * Edit the buddypress menus | |
| */ | |
| function jmw_make_edit_default_for_own_bp_profile() { | |
| global $bp; | |
| if ( ! bp_is_my_profile() ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function conditional_bbpress_styles_scripts() { | |
| // First check that bbpress exists to prevent fatal errors | |
| if ( function_exists( 'is_bbpress' ) ) { | |
| //dequeue scripts and styles | |
| if ( ! is_bbpress() && ! is_buddypress() ) { | |
| wp_dequeue_style('bbp-default'); | |
| wp_dequeue_style( 'bbp_private_replies_style'); | |
| wp_dequeue_script('bbpress-editor'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $new_group = new BP_Groups_Group; | |
| $new_group->creator_id = 1; | |
| $new_group->name = 'test'; | |
| $new_group->slug = 'test'; | |
| $new_group->description = 'nothing'; | |
| $new_group->news = 'whatever'; | |
| $new_group->status = 'public'; | |
| $new_group->is_invitation_only = 1; | |
| $new_group->enable_wire = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * BuddyPress 2.6.0 introduced a new nav API | |
| * with a Backcompat mechanism. But accessing/editing | |
| * deprecated globals can lead to such problems... | |
| * | |
| * It's too bad Theme designers forget to test betas :) | |
| */ | |
| function strothi_profile_primary_nav_first() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Exit if accessed directly | |
| defined( 'ABSPATH' ) || exit; | |
| function georgio_idea_footer_actions( $footer = '' ) { | |
| if ( ! bp_is_group() ) { | |
| return $footer; | |
| } |