Skip to content

Instantly share code, notes, and snippets.

View imath's full-sized avatar
:octocat:
building the Retraceur PHP software!

imath imath

:octocat:
building the Retraceur PHP software!
View GitHub Profile
@imath
imath / functions.php
Last active September 20, 2016 08:02
put this in any random file into /wp-content/mu-plugins/ to get your custom language files back in bbPress
<?php
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
function fix_bbpress_custom_language_packs( $bbpress = null ) {
// No need to perform this action, it's too late!
remove_action( 'bbp_load_textdomain', array( $bbpress, 'load_textdomain' ), 5 );
/**
* To be sure the custom language pack is loaded, let's be the first to load the textdomain
@imath
imath / bp-custom.php
Created September 16, 2016 14:37
neutralize regular comments tracking in BuddyPress
<?php
function neutralize_regular_post_comments_tracking( $default, $post_type ) {
if ( 'post' === $post_type ) {
return true;
}
return $default;
}
add_filter( 'bp_activity_pre_transition_post_type_comment_status', 'neutralize_regular_post_comments_tracking', 10, 2 );
@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';
}