Skip to content

Instantly share code, notes, and snippets.

View crstauf's full-sized avatar
🤔
const THINKING = true;

Caleb Stauffer crstauf

🤔
const THINKING = true;
View GitHub Profile
@crstauf
crstauf / init-github-action-on-update.php
Last active July 20, 2023 17:30
Trigger a GitHub Action on plugin update. #github #plugin #update #trigger
<?php
/**
* Plugin URI: https://gist.github.com/crstauf/0180b506e43f9e3d8730b995afb11849
* Author: Caleb Stauffer
* Author URI: https://develop.calebstauffer.com
*/
defined( 'WPINC' ) || die();
if ( ! defined( 'INIT_GITHUB_ACTION_TOKEN' ) || ! constant( 'INIT_GITHUB_ACTION_TOKEN' ) ) {
@crstauf
crstauf / cssllc-gforms-js-prepopulation.php
Last active June 21, 2022 18:17
Populate Gravity Forms with dynamic population via JavaScript.
<?php declare( strict_types=1 );
/**
* Plugin name: CSSLLC Gravity Forms JavaScript Prepopulation
* Plugin URI: https://gist.github.com/crstauf/5b6da3b818221ec0b408ae70a1cca232
* Description: Populate Gravity Forms with dynamic population via JavaScript.
* Author URI: https://develop.calebstauffer.com
* Author: Caleb Stauffer
* Version: 1.0
*/
@crstauf
crstauf / icon-youtube-play.css
Last active May 6, 2021 04:19
Data encoded SVGs of YouTube play icon
.icon--play {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%231F1F1F' d='M255.7 446.3c-53.3.3-106.6-.4-159.8-3.3-17.4-1-34.7-2.5-50.4-11C35 426.3 27 418.4 22 407.2 13.2 388.6 10.5 369 9 349c-3.4-41.3-3.6-82.6-1.8-123.8 1-22 1.6-44 6.8-65.5 2-8.4 5-16.6 8.8-24.4C32 117 48 108 67.3 104c16.2-3 32.8-3 49.3-3.7 56-2.3 112-3.5 168-3 43 .6 86.2 1.7 129.3 4 13.2.6 26.6.8 39.3 5.5 17.2 6.4 30 17.2 37 34.7 6.6 16.8 9.2 34.2 10.6 52 3.8 48.7 4 97.3.7 146-1 16.3-2.2 32.7-6.5 48.8-9.7 37-32.8 51.5-66.7 53.8-36.2 2.5-72.5 3.8-108.8 4.3-21.3.2-42.7 0-64 0zM203.2 344L348 264.7l-144.8-79.3V344z'/%3E%3Cpath fill='%23FEFDFD' d='M203.2 344V185.5L348 264.8 203.2 344z'/%3E%3C/svg%3E");
}
.icon--play:hover {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23DD2C28' d='M255.7 446.3c-53.3.3-106.6-.4-159.8-3.3-17.4-1-34.7-2.5-50.4-11C35 426.3 27 418.4 22 407.2 13.2 388.6 10.5 369
@crstauf
crstauf / wpcli-flush-cloudflare-cache.php
Created April 14, 2021 14:14
WordPress mu-plugin that adds a WP CLI command to flush Cloudflare cache.
<?php
/**
* Plugin Name: WP CLI Flush Cloudflare Cache
* Description: Register a WP CLI command to flush Cloudflare cache.
* Author: Caleb Stauffer
* Author URI: https://develop.calebstauffer.com
* Plugin URI: https://gist.github.com/crstauf/07725140a81b88f331dc8c3c76d8bf1d
*/
if ( !defined( 'WP_CLI' ) || !WP_CLI )
@crstauf
crstauf / wpcli-flush-cloudflare-cache.php
Created March 31, 2021 16:23
WordPress CLI command to flush Cloudflare cache
<?php
if ( !defined( 'WP_CLI' ) || !WP_CLI )
return;
if ( !function_exists( 'wpcli_flush_cloudflare_cache' ) ) {
function wpcli_flush_cloudflare_cache( array $args, array $assoc_args ) : void {
$zone_id = WP_CLI\Utils\get_flag_value( $assoc_args, 'zone_id', constant( 'CLOUDFLARE_ZONE_ID' ) );
$email_address = WP_CLI\Utils\get_flag_value( $assoc_args, 'email', constant( 'CLOUDFLARE_EMAIL_ADDRESS' ) );
@crstauf
crstauf / release-wpengine.yml
Created November 6, 2020 17:33
GitHub Action to deploy production branch to WP Engine via git
name: Deploy to WP Engine
on:
push:
branches: [ production ]
jobs:
deploy:
runs-on: ubuntu-latest
@crstauf
crstauf / github-gist-create.sh
Created October 29, 2020 21:08
Raycast Script Commands
#!/bin/bash
##################################################################
## Set GitHub username and personal access token and uncomment. ##
##################################################################
# GitHub username
# user=
# GitHub personal access token
@crstauf
crstauf / patch.diff
Created April 1, 2020 21:20
Patch to implement "Past-due" view on Action Scheduler list table
diff --git a/classes/ActionScheduler_ListTable.php b/classes/ActionScheduler_ListTable.php
index b680054..d12667e 100644
--- a/classes/ActionScheduler_ListTable.php
+++ b/classes/ActionScheduler_ListTable.php
@@ -559,6 +559,11 @@ class ActionScheduler_ListTable extends ActionScheduler_Abstract_ListTable {
'search' => $this->get_request_search_query(),
);
+ if ( 'past-due' === $this->get_request_status() ) {
+ $query['status'] = ActionScheduler_Store::STATUS_PENDING;
@crstauf
crstauf / cssllc-enhancements.php
Last active March 28, 2020 05:21
WordPress enhancements
<?php
/**
* Description: WordPress enhancements from CSSLLC.
* Author URI: https://develop.calebstauffer.com
* Author: Caleb Stauffer
* Plugin URI: https://gist.github.com/crstauf/68b4d37ebdc0423d2275bce49527a2f4
*/
/**
* Action: wp_enqueue_scripts
@crstauf
crstauf / cssllc-helpers.php
Last active May 3, 2020 16:13
WordPress helpers
<?php
/**
* Description: WordPress helpers from CSSLLC.
* Author URI: https://develop.calebstauffer.com
* Author: Caleb Stauffer
* Plugin URI: https://gist.github.com/crstauf/46a29f046cfffcaf2829401ae0773c90
*/
if ( !function_exists( 'create_post_type_labels' ) ) {