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 / wp-idea-stream-custom.php
Created December 2, 2016 14:47
Temporary fix for https://wordpress.org/support/topic/commenting-bug-under-buddypress-groups-multisite/ so that users can wait for WP Idea Stream 2.3.4...
<?php
/**
* Temporary fix for:
* https://wordpress.org/support/topic/commenting-bug-under-buddypress-groups-multisite/
*
* Will be part of WP Idea Stream 2.3.4
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
@imath
imath / functions.php
Created September 20, 2016 08:58
Put this in any random file inside wp-content/mu-plugins to fix all custom language packs for plugins. Make sure the corresponding custom language packs are in WP_LANG_DIR/pluginName/
<?php
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
function fix_all_custom_language_packs_load_textdomain_mofile( $mofile, $domain ) {
if ( WP_LANG_DIR . '/plugins' === dirname( $mofile ) ) {
$mo = basename( $mofile );
$alt = trailingslashit( WP_LANG_DIR ) . $domain . '/';
@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;