Skip to content

Instantly share code, notes, and snippets.

View imath's full-sized avatar
:octocat:
Moving to something new!

imath imath

:octocat:
Moving to something new!
View GitHub Profile
@imath
imath / functions.php
Created September 2, 2016 14:18
put this in any random file into /wp-content/mu-plugins/ to get your custom language files back in BuddyPress
<?php
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
remove_action( 'bp_core_loaded', 'bp_core_load_buddypress_textdomain' );
add_action( 'bp_loaded', 'bp_core_load_buddypress_textdomain', 0 );
@imath
imath / bp-custom.php
Last active February 3, 2020 17:05
Edit BuddyPress primary nav so that profile primary item is before the activity primary item
<?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() {
@imath
imath / bp-custom.php
Created June 28, 2016 19:03
How to remove admin tabs for Groups single items.
<?php
function turker_remove_group_admin_tab() {
if ( ! bp_is_group() || ! ( bp_is_current_action( 'admin' ) && bp_action_variable( 0 ) ) || is_super_admin() ) {
return;
}
// Add the admin subnav slug you want to hide in the
// following array
$hide_tabs = array(
@imath
imath / bp-custom.php
Created June 12, 2016 11:10
Snippet to disable the main purpose of BP Reactions to only keep the emoji autocomplete
<?php
/**
* If you don't know how to create/use the bp-custom.php file, please read:
* https://codex.buddypress.org/themes/bp-custom-php/
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* This is just crazy imho!
@imath
imath / bp-custom.php
Last active November 22, 2016 15:01
Snippet to use with the BP Reactions plugin i've created. You can add as many reactions as you wish
<?php
/**
* BuddyPress customs
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
* Watch this video https://vimeo.com/166707145
@imath
imath / wp-idea-stream-custom.php
Created April 11, 2016 20:10
Use the featured image instead of the user's avatar when listing ideas
<?php
/**
* Read about how to use the wp-idea-stream-custom.php file here:
* https://github.com/imath/wp-idea-stream/wiki/wp-idea-stream-custom.php
*/
function pc1271_replace_avatar_with_featured_image( $output, $author, $avatar, $idea ) {
if ( ! wp_idea_stream_featured_images_allowed() || ! current_theme_supports( 'post-thumbnails' ) ) {
return $output;
@imath
imath / bp-custom.php
Created March 5, 2016 11:53
Restrict BuddyDrive to a specific capability. More info about bp-custom.php > https://codex.buddypress.org/themes/bp-custom-php/
<?php
/**
* Get the required cap.
*
* For info about Capabilities
* @see https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table
*/
function wpsouf_get_required_capability() {
return 'manage_options';
}
@imath
imath / wp-idea-stream-custom.php
Created January 12, 2016 12:10
Adds the title of the idea to the BuddyPress activity action string
<?php
/**
* See https://wordpress.org/support/topic/adding-idea-title-to-buddypress-activity-stream
*/
function jasonverdelli_set_wp_idea_stream_activity_actions( $wp_idea_stream_activity_actions = array() ) {
if ( ! empty( $wp_idea_stream_activity_actions['new_' . wp_idea_stream_get_post_type() ] ) ) {
$wp_idea_stream_activity_actions['new_' . wp_idea_stream_get_post_type() ]->action_callback = 'jasonverdelli_format_idea_activity_action';
}
@imath
imath / wp-idea-stream-custom.php
Created December 17, 2015 21:10
More link for WP Idea Stream < 2.3.0
<?php
/**
* Build a custom more link for Ideas
*
* This is to be used with WP Idea Stream < 2.3.0
*
* @param string $more
* @return string the more link
*/
function to_use_till_you_upgraded_to_WP_4_4_and_WP_Idea_Stream_2_3( $more = '' ) {
@imath
imath / bp-custom.php
Created September 3, 2015 06:26
Add BuddyDrive editor to the BuddyPress compose private message screen, the button will appear over the submit one
<?php
function test_bp_message_compose() {
// Always check the editor is available to prevent fatals!
if ( bp_is_my_profile() && function_exists( 'buddydrive_editor' ) ) {
// 'message_content' is the id attribute of the textarea to send private messages
buddydrive_editor( 'message_content' );
}
}
add_action( 'bp_after_messages_compose_content', 'test_bp_message_compose' );