This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: BP Example Block | |
* Plugin URI: https://buddypress.org/ | |
* Description: Example of BuddyPress block. | |
* Author: The BuddyPress Community | |
* Author URI: https://buddypress.org/ | |
* Version: 1.0.0 | |
* Text Domain: buddypress | |
* Domain Path: /languages/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Registers a REST field for the Activity Endpoints. | |
function example_register_activity_rest_field() { | |
bp_rest_register_field( | |
'activity', // Id of the BuddyPress component the REST field is about | |
'example_field', // Used into the REST response/request | |
array( | |
'get_callback' => 'example_get_rest_field_callback', // The function to use to get the value of the REST Field | |
'update_callback' => 'example_update_rest_field_callback', // The function to use to update the value of the REST Field |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf | |
// Remove any duplicates from an array of primitives. | |
const unique = [...new Set(arr)] | |
// Sleep in async functions. Use: await sleep(2000). | |
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms))); | |
// or | |
const sleep = util.promisify(setTimeout); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filters wp_remote_get() to: | |
* 1. Return a value from the cache when it's available. | |
* 2. Write a value to the cache when it's been fetched. | |
* | |
* Requires the WP_IMPORT_CACHE constant to be set to a writable directory. | |
*/ | |
if ( defined( 'WP_CLI' ) && WP_CLI ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName | |
/* | |
* Plugin Name: Non-Handling Shutdown Handler | |
* Description: Disable WSOD protection so that plugins will not auto-suspend during development while errors often occur. | |
* Plugin URI: https://gist.github.com/westonruter/583a42392a0b8684dc268b40d44eb7f1 | |
* Plugin Author: Weston Ruter | |
*/ | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (context, trackingId, options) { | |
const history = context.history; | |
const doc = document; | |
const nav = navigator || {}; | |
const storage = localStorage; | |
const encode = encodeURIComponent; | |
const pushState = history.pushState; | |
const typeException = 'exception'; | |
const generateId = () => Math.random().toString(36); | |
const getId = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* BuddyPress - Members Single Messages Compose | |
* | |
* @package BuddyPress | |
* @subpackage bp-legacy | |
*/ | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Authentication customizations. | |
* | |
* @package BJ\Auth | |
*/ | |
/** | |
* Filters the duration of the authentication cookie expiration period. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'bp_get_member_avatar', 'my_add_user_level_to_avatars', 10, 2 ); | |
/** | |
* @param string $value Formatted HTML <img> element, or raw avatar URL based on $html arg. | |
* @param array $r Array of parsed arguments. See {@link bp_get_member_avatar()}. | |
*/ | |
function my_add_user_level_to_avatars( $value, $r ) { | |
global $members_template; | |
// The args have already been parsed in bp_get_member_avatar. We'll use them except for the css class. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin name: WP Trac #42573: Fix for theme template file caching. | |
* Description: Flush the theme file cache each time the admin screens are loaded which uses the file list. | |
* Plugin URI: https://core.trac.wordpress.org/ticket/42573 | |
* Author: Weston Ruter, XWP. | |
* Author URI: https://weston.ruter.net | |
*/ | |
function wp_42573_fix_template_caching( WP_Screen $current_screen ) { |
NewerOlder