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 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' );
<?php
function job_listing_activity_args() {
if ( ! bp_is_active( 'activity' ) ) {
return;
}
add_post_type_support( 'job_listing', 'buddypress-activity' );
bp_activity_set_post_type_tracking_args( 'job_listing', array(
<?php
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
/**
* This will only get the displayed group's menu items
* 1/ if a group is displayed
* 2/ if the theme is containing the template 'buddypress/groups/single/home.php'
* 3/ if the theme's template replaced <ul><?php bp_get_options_nav();?></ul> by <?php bp_nav_menu();?>
*/
@imath
imath / bp-custom.php
Created February 20, 2015 19:47
Filtering bp_ajax_querystring
<?php
/**
* Filter the querystring when on the activity directory
*
* @param string/array $query_string component loop arguments
* @param sting $object component name
* @return string the edited query string
*/
function bphelp_ajax_querystring( $query_string, $object ) {
@imath
imath / wp-idea-stream-custom.php
Created February 8, 2015 18:37
WP Idea Stream Custom : Replace the author avatar by the first image found in the idea content
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Replace the author avatar by the first image found in the idea content
* if no image was found keep the avatar.
*/
function first_idea_image_as_avatar( $avatar_link, $author, $avatar, $idea ) {
if ( empty( $idea->post_content ) ) {
@imath
imath / bp-custom.php
Created February 6, 2015 14:27
BuddyPress member types : display the type near each user in the members loop (requires BuddyPress 2.2)
<?php
/**
* Using BuddyPress Member types API
*
* see codex: https://codex.buddypress.org/developer/member-types/
*
* Required config:
* - WordPress 4.1
* - BuddyPress 2.2
*
@imath
imath / bp-custom.php
Created February 5, 2015 17:36
Temporarly fix to BuddyPress Links when used with BuddyPress 2.2.
<?php
/**
* This is temparary, please advise the plugin author to use the BP_Component Class
* @see https://github.com/boonebgorges/buddypress-skeleton-component/blob/1.7/includes/bp-example-loader.php
*/
function buddypress_links_temporary_fix( $retval, $component = '' ) {
if ( 'links' != $component ) {
@imath
imath / bp-custom.php
Created January 29, 2015 19:06
Code Snippet to put in your bp-custom.php file to be able to filter the BuddyPress members directory by member types (requires BuddyPress version 2.2-beta1)
<?php
/**
* Using BuddyPress Member types API
*
* see codex: https://codex.buddypress.org/developer/member-types/
*
* Required config:
* - WordPress 4.1
* - BuddyPress 2.2
*
@imath
imath / functions.php
Created November 1, 2014 16:12
Add a custom support status to Buddy-bbPress Support topic.
<?php
/**
* Filter the available status to add a custom one
*
* Requires buddy-bbpress-support topic plugin
* bbPress 2.5+
* WordPress 4.0
*
* @param array $allstatus the available status