Skip to content

Instantly share code, notes, and snippets.

View michaelbragg's full-sized avatar

Michael Bragg michaelbragg

View GitHub Profile
JSON.stringify({
"email": "epitfieldc@example.test",
"password": "",
"first_name": "Emmit",
"last_name": "Pitfield",
"billing": {
"first_name": "Emmit",
"last_name": "Pitfield",
"address_1": "871 Nya Ranch",
"address_2": "",
@michaelbragg
michaelbragg / acf-validation.php
Last active April 30, 2024 08:21
Hotfix: ACF Block Validation not being checked.
<?php
/**
* Hotfix: ACF Block Validation not being checked.
*
* @version 1.0.0
*
* @author Seriphyn <https://support.advancedcustomfields.com/forums/users/seriphyn/>
* @author Michael Bragg <https://michaelbragg.com> <https://vatu.dev>
* @copyright 2022 Curiosity Stream Inc.
*/
@michaelbragg
michaelbragg / example.php
Created March 28, 2022 10:42
Example of returning a Class object over an array in PHP.
<?php
/**
* Appeals: List All Appeals.
*
* <code>
* class(AllAppeals) {
* "data" => class(Appeals) {
* "christmas_appeal_2022" => class(Appeal) {
* "name" => :string "Christmas Appeal 2022",
* "slug" => :string "christmas-appeal-2022",
@michaelbragg
michaelbragg / woocommerce-form-field-value.php
Created January 21, 2022 15:46
Example plugin to test proposed `woocommerce_form_field_value` filter
<?php
/**
* Plugin Name: WooCommerce Form Field Value Example
* Author: Michael Bragg <email@michaelbragg.com>
* Version: 1.0.0
*/
function custom_checkout_field( $checkout ) {
echo '<section id="example-field">';
@michaelbragg
michaelbragg / cleanup.sh
Last active December 8, 2021 19:41
Empty a WooCommerce database of Orders and Customers
# Delete orders.
wp post delete $(wp post list --post_type='shop_order' --post_status=trash --format=ids --force) --force
wp post delete $(wp post list --post_type='shop_order' --post_status=wc-failed --format=ids --force) --force
wp post delete $(wp post list --post_type='shop_order' --post_status=wc-cancelled --format=ids --force) --force
wp post delete $(wp post list --post_type='shop_order' --post_status=wc-refunded --format=ids --force) --force
wp post delete $(wp post list --post_type='shop_order' --post_status=wc-processing --format=ids --force) --force
wp post delete $(wp post list --post_type='shop_order' --post_status=wc-completed --format=ids --force) --force
# Delete users.
wp user delete $(wp user list --role=subscriber --field=ID --format=ids) --reassign=1
@michaelbragg
michaelbragg / setup.sh
Created October 19, 2021 12:54
[WordPress] Create pages and assign special status
#!/bin/bash
# `--portcelain` makes the comand return only the ID
# `$_` is a special bash command that uses the last comands output.
# Run two commands in sequential, as the second command uses the output of the first.
echo $(wp post create --post_type="page" --post_title="Home" --post_status="publish" --porcelain)
wp option update page_on_front $_
# Run two commands in sequential, as the second cpage_for_posts ommand uses the output of the first.
echo $(wp post create --post_type="page" --post_title="Blog" --post_status="publish" --porcelain)
@michaelbragg
michaelbragg / functions.php
Created October 1, 2021 07:14
[WordPress] Themes: Populate the 'Posts Page' with content from the Editor.
<?php
/**
* Pull content from Posts Page into home template.
*
* @param WP_Query $query WP Query.
*
* @return WP_Query
*/
function ti_load_home_content( $query ) {
@michaelbragg
michaelbragg / auth.json
Last active September 16, 2021 07:44
Delicious Brains Plugins via Composer
{
"http-basic": {
"composer.deliciousbrains.com": {
"username": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"password": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
}
}
@michaelbragg
michaelbragg / composer.json
Last active September 16, 2021 07:37
Loading ACF Pro via Composer
{
"repositories": [
{
"type": "package",
"package": {
"name": "advanced-custom-fields/advanced-custom-fields-pro",
"version": "5.10.2",
"type": "wordpress-plugin",
"dist": {
"type": "zip",
@michaelbragg
michaelbragg / ti-maintenance-mode.php
Created January 19, 2021 18:56
Simple Maintenance Mode redirect
<?php
/**
* Plugin Name: [TI] Maintenance Mode
* Plugin URI: https://www.thoughtsandideas.uk
* Description:
* Author: Michael Bragg <michael.bragg@thoughtsandideas.uk>
* Author URI: https://www.thoughtsandideas.uk
* Version: 1.0.0
* License: GPLv2
*/