Skip to content

Instantly share code, notes, and snippets.

Avatar

Steve Grunwell stevegrunwell

View GitHub Profile
@stevegrunwell
stevegrunwell / README.md
Created May 10, 2021
Getting PHPUnit 8 working with the WordPress core test suite
View README.md

This code comes from the Nexcess Managed Applications (MAPPS) Must-Use plugin and is used to let the test suite run on PHPUnit 8 and above.

We're able to do this because our test suite takes advantage of Symfony's PHPUnit Bridge component, so we're already able to run our suite across multiple versions of PHPUnit, as the library takes care of differences like return typehints and differences in PHPUnit class names.

The (abbreviated) bootstrap.php file in this gist shows how we load the core test suite and, if we're running PHP 8.0 or above, will duplicate the stock includes/bootstrap.php file from the test suite to includes/bootstrap-phpunit8.php.

The duplicated bootstrap file is the same as the version that ships with core, minus the "Looks like you're using PHPUnit $version" error.


@stevegrunwell
stevegrunwell / limit-orders-shortcode.php
Created Mar 26, 2021
Limit Orders for WooCommerce - Custom Shortcodes
View limit-orders-shortcode.php
<?php
/**
* Plugin Name: Limit Orders for WooCommerce - Shortcode
* Description: Custom shortcode for displaying information from the Order Limiter.
* Author: Nexcess
* Author URI: https://nexcess.net
*/
use Nexcess\LimitOrders\OrderLimiter;
@stevegrunwell
stevegrunwell / limit-orders-do-not-empty-cart.php
Created Feb 4, 2021
Prevent WooCommerce from emptying carts after the order limit has been reached — https://wordpress.org/support/topic/cart-empties-when-limit-is-hit/
View limit-orders-do-not-empty-cart.php
<?php
/**
* Plugin Name: Limit Orders for WooCommerce - Prevent Empty Carts
* Description: Prevent WooCommerce from emptying carts after the order limit has been reached.
* Author: Nexcess
* Author URI: https://nexcess.net
*/
/**
* Prevent WooCommerce from removing non-purchasable items from the cart.
@stevegrunwell
stevegrunwell / limit-orders-custom-daily-interval.php
Last active Nov 17, 2022
Set a custom start time for the "daily" interval when using Limit Orders for WooCommerce.
View limit-orders-custom-daily-interval.php
<?php
/**
* Plugin Name: Limit Orders for WooCommerce - Custom Daily Interval
* Description: Restart daily order limiting at a time other than midnight.
* Author: Nexcess
* Author URI: https://nexcess.net
*/
/**
* Get a DateTime object representing the start of the daily interval.
View limit-orders-forever.php
<?php
/**
* Plugin Name: Limit Orders for WooCommerce - Never-ending Interval
* Description: Add a "Forever" option to Limit Orders for WooCommerce.
* Author: Nexcess
* Author URI: https://nexcess.net
*/
/**
* Add "Forever" to the list of intervals.
@stevegrunwell
stevegrunwell / limit-orders-15min.php
Created May 19, 2020
Add an "Every 15 minutes" option to Limit Orders for WooCommerce
View limit-orders-15min.php
<?php
/**
* Plugin Name: Limit Orders for WooCommerce - 15min Intervals
* Description: Add an "Every 15 minutes" option to Limit Orders for WooCommerce.
* Author: Nexcess
* Author URI: https://nexcess.net
*/
/**
* Add "Every 15min" to the list of intervals.
@stevegrunwell
stevegrunwell / airstory-update-published-posts.php
Created Aug 8, 2018
Enable the Airstory WordPress plugin to update published posts as well as drafts. A response to https://wordpress.org/support/topic/upload-to-wp-from-airstory-not-working-for-me/
View airstory-update-published-posts.php
<?php
/**
* Plugin Name: Airstory: Enable Updating of Published Posts
* Plugin URI: https://wordpress.org/support/topic/upload-to-wp-from-airstory-not-working-for-me/
* Description: Enable Airstory to update the contents of posts of any post status, not just drafts.
* Version: 0.1.0
* Author: Steve Grunwell
* Author URI: https://stevegrunwell.com
*
* @link https://wordpress.org/support/topic/upload-to-wp-from-airstory-not-working-for-me/
@stevegrunwell
stevegrunwell / cdils.php
Created Mar 6, 2018
Modify the available block formats within WordPress' TinyMCE editor. A quick solution for https://twitter.com/cdils/status/970854979735977984
View cdils.php
<?php
/**
* Change the block formats available in TinyMCE.
*
* @link http://codex.wordpress.org/TinyMCE_Custom_Styles
*
* @param array $init Default settings to be overridden.
*
* @return array The modified $init array.
View wordpress-host-checker.sh
#!/usr/bin/env bash
#
# Check a WordPress domain against CVE-2017-8295.
# https://exploitbox.io/vuln/WordPress-Exploit-4-7-Unauth-Password-Reset-0day-CVE-2017-8295.html
#
# Usage:
# ./wordpress-host-check <domain> <username>
#
# <domain>
# The WordPress domain you wish to check. For example, http://example.com.
@stevegrunwell
stevegrunwell / one-time-hooks.php
Created Feb 14, 2017
Enables action and filter callbacks to be executed exactly once via the WordPress Plugin API. https://engineering.growella.com/one-time-callbacks-wordpress-plugin-api/
View one-time-hooks.php
<?php
/**
* Registers the "One time hook" functionality.
*
* Note that this file is intentionally in the *global* namespace!
*
* @author Growella
* @license MIT
*/