Skip to content

Instantly share code, notes, and snippets.

Boone Gorges boonebgorges

Block or report user

Report or block boonebgorges

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@boonebgorges
boonebgorges / bp-date-field-select-today.js
Created Oct 23, 2019
Default to the current date for a BP date profile field
View bp-date-field-select-today.js
$(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 Oct 22, 2019
Run BP 5.0 upgrades if they don't happen automatically
View run-bp-50-upgrades.php
<?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 Dec 5, 2017
Enable BuddyPress Docs search to match based on attachment filenames
View bp-docs-attachment-search.php
<?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 Feb 9, 2017
Networkwide BP notification formatting for bbPress non-network-activated
View bbp-bp-notification-formatter.php
<?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 Sep 21, 2016
populate comments and posts in bp-activity
View populate.php
<?php
$site_id = 7177;
switch_to_blog( $site_id );
$links = get_bookmarks( array(
'category_name' => 'Course Blogs',
) );
$urls = wp_list_pluck( $links, 'link_url' );
View comment.php
<?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 Sep 9, 2016
React component for rendering a chunk of LaTeX to be processed by MathJax
View LaTeX.js
import React, { Component } from 'react';
export default class LaTeX extends Component {
componentDidMount() {
this.updateTeX()
}
componentDidUpdate() {
this.updateTeX()
}
@boonebgorges
boonebgorges / FormattedProblem.js
Created Sep 9, 2016
React component for content that may contain LaTeX chunks
View FormattedProblem.js
import React from 'react';
import LaTeX from './LaTeX'
const FormattedProblem = React.createClass( {
getDefaultProps: function() {
return {
isVisible: true
}
},
@boonebgorges
boonebgorges / parsley-iff.html
Created Sep 8, 2016
Markup for parsley-iff
View parsley-iff.html
<input
name="password"
id="password"
data-parsley-trigger="blur"
data-parsley-iff="#password-confirm"
data-parsley-iff-message=""
/>
<input
name="password-confirm"
@boonebgorges
boonebgorges / parsley-iff.js
Last active Sep 8, 2016
Better "equalto" implementation for Parsley.js
View parsley-iff.js
var iffRecursion = false;
window.Parsley.addValidator( 'iff', {
validateString: function( value, requirement, instance ) {
var $partner = $( requirement );
var isValid = $partner.val() == value;
if ( iffRecursion ) {
iffRecursion = false;
} else {
iffRecursion = true;
You can’t perform that action at this time.