Skip to content

Instantly share code, notes, and snippets.

View stevegrunwell's full-sized avatar

Steve Grunwell stevegrunwell

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

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 March 26, 2021 15:55
Limit Orders for WooCommerce - Custom Shortcodes
<?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 February 4, 2021 19:34
Prevent WooCommerce from emptying carts after the order limit has been reached — https://wordpress.org/support/topic/cart-empties-when-limit-is-hit/
<?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 November 17, 2022 21:57
Set a custom start time for the "daily" interval when using Limit Orders for WooCommerce.
<?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.
@stevegrunwell
stevegrunwell / limit-orders-forever.php
Created June 19, 2020 14:48
Add a "Forever" option to Limit Orders for WooCommerce - https://wordpress.org/support/topic/all-time-interval/
<?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 04:50
Add an "Every 15 minutes" option to Limit Orders for WooCommerce
<?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 August 8, 2018 14:05
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/
<?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 March 6, 2018 14:48
Modify the available block formats within WordPress' TinyMCE editor. A quick solution for https://twitter.com/cdils/status/970854979735977984
<?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.
#!/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 February 14, 2017 20:06
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/
<?php
/**
* Registers the "One time hook" functionality.
*
* Note that this file is intentionally in the *global* namespace!
*
* @author Growella
* @license MIT
*/