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
@modemlooper
modemlooper / paged.php
Created November 2, 2015 22:14
fix page id on bp sub page
function get_post_id() {
global $post, $buddypress_post_id;
$buddypress_post_id = $post->ID;
}
add_action( 'wp', 'get_post_id', 1 );
function my_custom_stuff( $content ) {
if ( function_exists( 'is_buddypress' ) && is_buddypress() ) {
global $buddypress_post_id, $post;
$post->ID = $buddypress_post_id;
function custom_activity_action($action) {
$user_id = bp_get_activity_user_id();
$user_link = bp_core_get_userlink( $user_id );
$activity_timestamp = bp_insert_activity_meta();
if ($activity_type=='YOUR ACTIVITY TYPE HERE i.e activity_update'){
$action = sprintf( __( '%s posted a snippet %2$s', 'buddypress' ), $user_link, $activity_timestamp );
<?php
global $activities_template;
$atname = isset( $activities_template->activity->user_login ) ? '@' . $activities_template->activity->user_login : '';
$time = isset( $activities_template->activity->date_recorded ) ? strtotime( $activities_template->activity->date_recorded ) : '';
$human_time = $time ? sprintf( __( '%1$s Ago', 'clp' ), ucwords( human_time_diff( $time ) ) ) : '';
?>
<span class="username"><?php echo esc_html( $atname ); ?></span>
<span class="arrow-separator"></span>
<span class="time"><?php echo esc_html( $human_time ); ?></span>
@modemlooper
modemlooper / search
Last active November 13, 2015 21:14
@modemlooper
modemlooper / php
Created January 29, 2016 21:40
Example on adding a page to user profile
<?php
/**
* Plugin Name: BP Add Page
* Plugin URI: https://webdevstudios.com
* Description: Example on adding a page to BuddyPress profiles
* Author: WebDevStudios
* Author URI: https://webdevstudios.com
* Version: 1.0.0
* License: GPLv2
*/
@modemlooper
modemlooper / gist:8aeb3b03e2a58f1a129e
Created February 15, 2016 18:22
email bp comment
function bp_custom_email_message() {
// Create post object
$my_post = array(
'post_title' => __( '[{{{site.name}}}] New post comment.', 'buddypress' ),
'post_content' => __( '{{commenter.name}} commented on your blog post.', 'buddypress' ),
'post_status' => 'publish',
'post_type' => bp_get_email_post_type() // this is the post type for emails
);
@modemlooper
modemlooper / update-forum-groupmeta.php
Created April 19, 2016 19:20 — forked from jazzsequence/update-forum-groupmeta.php
Updates the group meta for forum id based on updated forum ids.
<?php
/*
Plugin Name: WDS CLP Update Forum Group Meta Script
Description: Updates the group meta for forum id based on updated forum ids.
Author: WebDevStudios
Author URI: http://webdevstudios.com
Version: 1.0
License: GPL2
*/
@modemlooper
modemlooper / gist:dfd8c7aeaf945f1adb3ac7b8e127823d
Last active August 14, 2016 19:31
Easy Digital Downloads has purchased variation
function edd_has_purchased_variation( $download_slug = '', $price_id = '' ) {
$current_user_info = wp_get_current_user();
$has_puchased = false;
$download = edd_get_download( $download_slug );
$purchases = edd_get_users_purchases( $current_user_info->user_email, 100, false, 'any' );
if ( $purchases ) {
foreach ( $purchases as $purchase ) {
home_url() //> http://example.com
get_stylesheet_directory_uri() //> http://example.com/wp-content/themes/THEME_NAME [same: get_bloginfo('template_url') ]
get_stylesheet_directory() //> /home/www/wp-content/themes/THEME_NAME
plugin_dir_url(__FILE__) //> http://example.com/wp-content/plugins/MY-PLUGIN/ [while used inside plugin.. same as: plugins_url('',__FILE__) ]
plugin_dir_path(__FILE__) //> /home/www/wp-content/plugins/MY-PLUGIN/ [while used inside plugin]
@modemlooper
modemlooper / gist:f5ee4bd0f62a2943815ba557ea3cfdf0
Last active September 5, 2016 20:01
Add custom class to CMB2 box form
function filter_class( $classes, $box ) {
foreach ( $box as $key => $value ) {
if ( isset( $box->meta_box['attributes'] ) && isset( $box->meta_box['attributes']['classes'] ) ) {
if ( ! empty( $box->meta_box['attributes']['classes'] ) ) {
$classes[] = $box->meta_box['attributes']['classes'];
}
}
}