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 / 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' );
<?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 ) {