Skip to content

Instantly share code, notes, and snippets.

View boonebgorges's full-sized avatar

Boone Gorges boonebgorges

View GitHub Profile
@boonebgorges
boonebgorges / dk-pdf.diff
Created March 15, 2024 17:12
dk-pdf PHP 8+ patch
commit 4587312ae27de3c37ddfbe05bcf2ef448b9f0e7b
Author: Boone B Gorges <boonebgorges@gmail.com>
Date: Wed Jan 4 12:02:21 2023 -0600
PHP compat for dk-pdf.
diff --git a/wp-content/plugins/dk-pdf/vendor/mpdf/mpdf/src/Barcode/Code128.php b/wp-content/plugins/dk-pdf/vendor/mpdf/mpdf/src/Barcode/Code128.php
index 4e1e2122cd..f3fa8e46f3 100644
--- a/wp-content/plugins/dk-pdf/vendor/mpdf/mpdf/src/Barcode/Code128.php
+++ b/wp-content/plugins/dk-pdf/vendor/mpdf/mpdf/src/Barcode/Code128.php
@boonebgorges
boonebgorges / bbg-csv-export.php
Created May 13, 2014 18:13
WordPress script for doing a .csv export of misc data
<?php
function bbg_csv_export() {
if ( ! is_super_admin() ) {
return;
}
if ( ! isset( $_GET['bbg_export'] ) ) {
return;
}
@boonebgorges
boonebgorges / gist:2401529
Created April 16, 2012 21:09
Add an "Other" option at the end of a list of BuddyPress profile checkbox options, where users can enter custom text
<?php
/**
* Add an 'Other' type to xprofile fields
*
* @link https://buddypress.trac.wordpress.org/ticket/3775
* @link http://redmine.gc.cuny.edu/issues/1199
*/
class CAC_Xprofile_Other {
function __construct() {
add_action( 'xprofile_field_additional_options', array( &$this, 'render_admin' ) );
@boonebgorges
boonebgorges / cboxol-fix-open-cloneable.php
Created January 27, 2021 19:36
Modify 'Open' and 'Cloneable' badge markup for Commons In A Box OpenLab
<?php
add_filter(
'openlab_badges_badge_links',
function( $badge_links, $group_id, $context ) {
foreach ( $badge_links as &$link ) {
if ( false !== strpos( $link, '>Open<' ) ) {
$link = str_replace( 'href="somelink"', 'href="#"', $link );
}
@boonebgorges
boonebgorges / prevent-bp-message-reply-notifications.php
Created July 7, 2020 21:08
Prevent BP message replies from triggering notifications
<?php
remove_action( 'messages_message_sent', 'messages_notification_new_message', 10 );
add_action(
'messages_message_sent',
function( $message ) {
$thread_messages = BP_Messages_Thread::get_messages( $message->thread_id );
if ( 1 === count( $thread_messages ) && $message->id === $thread_messages[0]->id ) {
messages_notification_new_message( $message );
}
@boonebgorges
boonebgorges / bp-docs-attachment-search.php
Created December 5, 2017 19:36
Enable BuddyPress Docs search to match based on attachment filenames
<?php
/**
* This is not needed for BP Docs 2.1+. See https://github.com/boonebgorges/buddypress-docs/issues/592
*/
add_filter( 'bp_docs_pre_query_args', function( $args, BP_Docs_Query $query ) {
// For attachments, search separately and then append to WP's default search handling.
if ( bp_docs_enable_attachments() ) {
add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
@boonebgorges
boonebgorges / bbp-bp-notification-formatter.php
Created February 9, 2017 03:34
Networkwide BP notification formatting for bbPress non-network-activated
<?php
/*
Plugin name: bbPress BP Notification Formatter
Description: A REST API endpoint for WP multisite installations that need to format bbPress-related BP notifications on secondary sites.
Version: 1.0
*/
/**
* Load the plugin.
@boonebgorges
boonebgorges / bp-date-field-select-today.js
Created October 23, 2019 19:06
Default to the current date for a BP date profile field
$(document).ready(function(){
var $day_field = $('#field_511_day');
var $month_field = $('#field_511_month');
var $year_field = $('#field_511_year');
if ( ! $day_field.val().length && ! $month_field.val().length && ! $year_field.val().length ) {
var dateObj = new Date();
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var monthNumber = months[ dateObj.getMonth() ];
@boonebgorges
boonebgorges / run-bp-50-upgrades.php
Created October 22, 2019 15:34
Run BP 5.0 upgrades if they don't happen automatically
<?php
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
bp_update_to_5_0();
@boonebgorges
boonebgorges / gist:4754549
Created February 11, 2013 13:57
Dynamically add items to a wp_nav_menu list
<?php
function bbg_activity_subnav( $items, $menu, $args ) {
// Find the Activity item
$bp_pages = bp_core_get_directory_page_ids();
if ( isset( $bp_pages['activity'] ) ) {
$activity_directory_page = $bp_pages['activity'];
} else {
return $items;