Skip to content

Instantly share code, notes, and snippets.

@shanebp
shanebp / api.php
Created Nov 10, 2021 — forked from dexit/api.php
Disable WordPress REST API endpoints
View api.php
// Remove init rest routes
remove_action( 'rest_api_init', 'create_initial_rest_routes', 0 );
// Remove oembed rest routes
function remove_json_api () {
// Remove the REST API lines from the HTML Header
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
@shanebp
shanebp / gist:0cea91fd3b8cf36ed0a3629392c2ffad
Created Jun 16, 2021
Send notifications to friends when a new event is created with BP Simple Events free version
View gist:0cea91fd3b8cf36ed0a3629392c2ffad
function pat_filter_notifications_get_registered_components( $component_names = array() ) {
if ( ! is_array( $component_names ) ) {
$component_names = array();
}
array_push( $component_names, 'events' );
return $component_names;
@shanebp
shanebp / custom-notification.php
Created Oct 27, 2020 — forked from modemlooper/custom-notification.php
BuddyPress add custom notification
View custom-notification.php
<?php
// this is to add a fake component to BuddyPress. A registered component is needed to add notifications
function custom_filter_notifications_get_registered_components( $component_names = array() ) {
// Force $component_names to be an array
if ( ! is_array( $component_names ) ) {
$component_names = array();
}
// Add 'custom' component to registered components array
@shanebp
shanebp / BuddyPress > Nouveau > Add Count to Group Tab
Last active May 20, 2021
Try to add a count bubble next to a custom group tab added via BP_Group_Extension
View BuddyPress > Nouveau > Add Count to Group Tab
// Using the Nouveau template pack
// Add a count bubble on a custom tab on a user profile is straightforward
$count = get_the_count_profile( $group_id );
$class = ( 0 === $count ) ? 'no-count' : 'count';
$name = sprintf( __( 'Events <span class="%s">%s</span>', 'bp-simple-events' ), esc_attr( $class ), number_format_i18n( $count ) );
@shanebp
shanebp / docker-compose.yml
Last active Apr 27, 2019
docker compose WordPress linux
View docker-compose.yml
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
@shanebp
shanebp / gist:b73343e9c9a6509d2bbc47de80c881c1
Last active Nov 4, 2021
add last_activity timestamp to all BP members
View gist:b73343e9c9a6509d2bbc47de80c881c1
/*
* Paste in your theme functions.php or in bp-custom.php.
* Load the site in a browser
* Remove from your theme functions.php or bp-custom.php.
*/
function buddypress_add_last_activity() {
$members = get_users( 'fields=ID' );
// $members = get_users( 'fields=ID&role=subscriber' );
@shanebp
shanebp / gist:0e6a1a5ca91ddf256b70fc77799a018b
Created May 20, 2018
BuddyPress - Nouveau template pack - add nav item
View gist:0e6a1a5ca91ddf256b70fc77799a018b
function add_members_directory_tab_nouveau( $nav_items ) {
$nav_items['custom'] = array(
'component' => 'members',
'slug' => 'custom',
'li_class' => array('custom no-ajax'),
'link' => trailingslashit( bp_get_members_directory_permalink() . 'custom' ),
'text' => __( 'Custom', 'buddypress' ),
'count' => false,
'position' => 15.8,
View tidy
be specific re php version: sudo apt-get install php7.0-tidy
vagrant@vvv:~$ sudo apt-get install php-tidy
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libtidy5 php7.1-common php7.1-tidy
The following NEW packages will be installed:
libtidy5 php-tidy php7.1-common php7.1-tidy
@shanebp
shanebp / list_groups_on_members_loop.php
Created Jul 22, 2016
List a member's groups on the Members Directory
View list_groups_on_members_loop.php
function shanebp_user_groups(){
$group_ids = groups_get_user_groups( bp_get_member_user_id() );
foreach( $group_ids["groups"] as $id ) {
$group = groups_get_group( array( 'group_id' => $id ) );
echo '<a href=' . trailingslashit( bp_get_groups_directory_permalink() . $group->slug . '/' ) . '>' . $group->name . '<a/><br>';
@shanebp
shanebp / xprofile-pending-users.php
Last active Mar 15, 2021
BP - show xprofile data on Pending Users screen
View xprofile-pending-users.php
<?php
// add the custom column header
function philopress_modify_user_columns($column_headers) {
$column_headers['extended'] = 'Meta Fields';
return $column_headers;
}
add_action('manage_users_page_bp-signups_columns','philopress_modify_user_columns');