Skip to content

Instantly share code, notes, and snippets.

View modemlooper's full-sized avatar
🏠
Working from home

modemlooper modemlooper

🏠
Working from home
View GitHub Profile
// blocks changing group type on edit screen
function bp_block_private_groups_edit( $status ) {
//no restriction to site admin
if ( !is_super_admin() ) {
$status = array( 'public' );
}
return $status;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Oauth</title>
</head>
<body>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="response"></div>
@modemlooper
modemlooper / gist:e0a5a6f52eae757d425e
Created June 6, 2014 04:19
remove group activity from main and profile activity stream
function bp_filter_groups_from_activity( $a, $activities ) {
if ( bp_is_current_component( 'activity' ) ) {
foreach ( $activities->activities as $key => $activity ) {
if ( $activity->component =='groups') {
unset( $activities->activities[$key] );
$activities->activity_count = $activities->activity_count-1;
$activities->total_activity_count = $activities->total_activity_count-1;
$activities->pag_num = $activities->pag_num -1;
@modemlooper
modemlooper / gist:339460ce07933269536d
Created June 17, 2014 02:45
Limit AppPresser to iPhone and Android browser only
function apppresser_limit_access_app() {
$agents = $_SERVER['HTTP_USER_AGENT'] ;
$app = false;
$useragents = array (
"iPhone",
"iPod",
"iPad",
if( $spoonful_of_sugar >= 1 )
return $medicine;
function wds_google_url( $url ){
$parsed_url = parse_url( $url );
$url = explode( '/', $parsed_url );
return $parsed_url['scheme'] . '://' . $parsed_url['host'] . '.../' . end( $url );
}
@modemlooper
modemlooper / gist:0dc904a89fefb79bf6bd
Last active August 29, 2015 14:06
Linking to BP profiles in WP templates
When linking to BP content it's best to use BP functions. This method is good because it shows somebody else that it's BP content that the link is going to.
bp_loggedin_user_domain() // url to logged in user profile
bp_loggedin_user_username()
bp_loggedin_user_id()
bp_displayed_user_username() // use displayed for when you are on a profile instead of loggedin
or you can use this to display a complete anchor link to logged in user
bp_core_get_userlink( bp_loggedin_user_id() )
@modemlooper
modemlooper / gist:912325bc95e3ed2ce6b2
Last active August 29, 2015 14:09
add meta to api
function custom_json_api_prepare_post( $post_response, $post, $context ) {
$post_response['do_api_action']['above_title'] = 'this is above the title';
$post_response['do_api_action']['below_title'] = 'this is below the title';
$post_response['do_api_action']['above_content'] = 'this is above the content';
$post_response['do_api_action']['below_content'] = 'this is below the content';
if( 1842 === $post['ID'] ) {
$post_response['do_api_action']['above_title'] = 'this is above the title on post 1842';
function custom_json_api_prepare_post( $post_response, $post, $context ) {
$post_response['do_api_action']['default']['above_title'] = 'this is above the title';
$post_response['do_api_action']['default']['below_title'] = 'this is below the title';
$post_response['do_api_action']['default']['above_content'] = 'this is above the content';
$post_response['do_api_action']['default']['below_content'] = 'this is below the content';
return $post_response;
}
add_filter( 'json_prepare_post', 'custom_json_api_prepare_post', 10, 3 );
@modemlooper
modemlooper / gist:77c602416879da6ea128
Created December 5, 2014 19:09
block post type from WP api
add_action( 'init', function() {
global $wp_post_types;
$wp_post_type['type_name']->show_in_json = false;
}, 99 );