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 / 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-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 / 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 / populate.php
Created September 21, 2016 03:03
populate comments and posts in bp-activity
<?php
$site_id = 7177;
switch_to_blog( $site_id );
$links = get_bookmarks( array(
'category_name' => 'Course Blogs',
) );
$urls = wp_list_pluck( $links, 'link_url' );
<?php
$comment = get_comment( 12345 );
$post_id = $comment->comment_post_ID();
$post = get_post( $post_id ); // Let's say post_title = Foo
do_action( 'comment_goodies', $comment, $post );
var_dump( $post );
@boonebgorges
boonebgorges / LaTeX.js
Created September 9, 2016 04:00
React component for rendering a chunk of LaTeX to be processed by MathJax
import React, { Component } from 'react';
export default class LaTeX extends Component {
componentDidMount() {
this.updateTeX()
}
componentDidUpdate() {
this.updateTeX()
}