Skip to content

Instantly share code, notes, and snippets.

@pbiron
pbiron / db-sub-command-test.php
Created January 31, 2022 17:41
This simple plugin demonstrates a problem I'm having creating a sub-command * of `wp db`.
<?php
/**
* Plugin Name: DB Sub-Comannd Test
* Description: Demonstrate problem creating a sub-command of `wp db`.
* Version: 0.1.0
* Author: Paul V. Biron/Sparrow Hawk Computing
* Author URI: http://sparrowhawkcomputing.com/
*
* This simple plugin demonstrates a problem I'm having creating a sub-command
@pbiron
pbiron / gf-2.5.10-datepicker-bug-in-repeater.diff
Created September 12, 2021 21:59
Patch for Gravity Forms 2.5.10 bug where date fields with datepickers within a repeater don't initialize the datepicker when the field on when a new repeat is added by the user
From 0f3fe93e4c7b82cf625e30b49db7b43ea1b46704 Mon Sep 17 00:00:00 2001
From: Paul Biron <paul@sparrowhawkcomputing.com>
Date: Sun, 12 Sep 2021 15:53:13 -0600
Subject: [PATCH] Fix bug that causes subsequent repeats of date fields that
use a datepicker from showing the jQuery datepicker.
---
js/gravityforms.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@pbiron
pbiron / disable-plugin-theme-auto-update-email-notifications.php
Last active August 13, 2020 18:07
Disable WordPress plugin/theme auto-update email notifications
<?php
/**
* Plugin Name: Disable plugin/theme auto-update email notficiations
* Description: Disable plugin/theme auto-update email notficiations
* Author: Paul V. Biron/Sparrow Hawk Computing
* Author URI: https://sparrowhawkcomputing.com/
* Plugin URI: https://gist.github.com/pbiron/ec0d7d0bf84308c905acaf8900764aec
* Version: 0.1.0
* License: GPLv2 or later
<?php
/*
Plugin Name: Enable/Disable plugins when doing local dev
Plugin URL: https://gist.github.com/pbiron/52bb63042cf220256ece89bc07fb57b0
Description: If the WP_LOCAL_DEV constant is true, enables/disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Paul V. Biron/Sparrow Hawk Computing
Author URI: https://sparrowhawkcomputing.com
*/
@pbiron
pbiron / MediaEditBackupSizes.php
Last active June 7, 2018 19:47
proposed WP unit tests for testing `_wp_attachment_backup_sizes` meta for ajax media editing
<?php
/**
* Admin ajax functions to be tested
*/
require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' );
/**
* Testing `_wp_attachment_backup_sizes` meta for ajax media editing
*
* Does NOT test that the edits made are correct
@pbiron
pbiron / shc_responsive_images.php
Created May 19, 2018 14:10
partial solution to WP responsive images
<?php
/*
* full version of code I added in a comment on wpscholar.com about how
* make it easier for WP to produce responsive images
* @link https://wpscholar.com/blog/remove-wp-image-size-attributes/#comment-23731
*
* Note: I make no claims that this handles all cases, just those problems
* identified by others commenting on the OP's code
*/
@pbiron
pbiron / shc_attachment_url_to_postid_filter.php
Last active August 16, 2018 14:30
func to hook into WP's attachment_url_to_postid filter to try to resolve attachment URLs for intermediate/backup sizes
<?php
if ( version_compare( get_bloginfo( 'version' ), '4.2', '>=') ) :
/*
* WP 4.0 introduced attachment_url_to_postid(). However, it fails when the
* URL is for an intermediate sized image (e.g., `.../filename-150x150.jpg`).
*
* WP 4.2.0 introduced the attachment_url_to_postid filter. The filter func
* defined below hooks into that filter and attempts remedy that limitation.
*/
add_filter( 'attachment_url_to_postid' , 'shc_attachment_url_to_postid_filter', 10, 2 );
@pbiron
pbiron / test-well-formed.php
Last active July 12, 2017 15:41
WP unit test for export redux plugin
<?php
require_once dirname( __FILE__ ) . '/base.php';
// the path on this to the main export code in the export redux plugin
// if/when testing the export in core, modify this path
require_once __DIR__ . '/../includes/export.php';
/**
* @group export
*/
@pbiron
pbiron / base.php
Last active July 12, 2017 15:41
base class for WP export unit tests
<?php
abstract class WXR_Export_UnitTestCase extends WP_UnitTestCase {
protected function _export_wp( $args ) {
ob_start();
export_wp( $args );
$wxr = ob_get_contents();
ob_end_clean();