Skip to content

Instantly share code, notes, and snippets.

View davidwolfpaw's full-sized avatar

david wolfpaw davidwolfpaw

View GitHub Profile
@davidwolfpaw
davidwolfpaw / gist:1af6ba483c66a7f1a2ac7be581f4b6d2
Created March 10, 2025 21:05
Update Image Alt Text in All Blocks (Multisite + Custom Blocks)
<?php
/**
* Plugin Name: Update Image Alt Text in All Blocks (Multisite + Custom Blocks)
* Description: WP-CLI command to update alt text in all images inside blocks for all sites in a multisite network, including custom blocks.
*/
if ( defined( 'WP_CLI' ) && WP_CLI ) {
class Network_Update_All_Image_Alts_Command {
@davidwolfpaw
davidwolfpaw / gist:fbe020cd282c4f6ad7ed805f5ad72a85
Created March 10, 2025 18:11
Sync attachment titles and alt text across WordPress multisite sites
<?php
/**
* Plugin Name: Sync Attachment Meta
* Description: Sync attachment titles and alt text across multisite sites. Choose a source site to pull titles and alt text from, and have matching attachments updated on all other sites.
* Version: 1.0.0
*/
// Confirm that WP-CLI is available.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
@davidwolfpaw
davidwolfpaw / davids-youtube-cleanup.css
Created March 26, 2024 13:30
david's YouTube Cleanup Stylesheet for Stylus
/* ==UserStyle==
@name david's YouTube Cleanup
@namespace github.com/openstyles/stylus
@version 1.0.0
@description Various Options to Cleanup YouTube. You can toggle display of full video titles, blurring out watched videos, hiding a bunch of sidebar buttons, and some body cruft, including YouTube Shorts.
@author david wolfpaw
@preprocessor stylus
@var checkbox show-full-titles "Show Full Titles" 1
@var checkbox hide-watched-videos "Blur Watched Videos" 1
@davidwolfpaw
davidwolfpaw / gravity-forms-confirmation-remain.php
Last active April 1, 2024 06:26
Keep Gravity Forms Displayed After Submission
<?php
// Allow the Gravity form to stay on the page when confirmation displays.
add_filter( 'gform_pre_submission_filter', 'dw_show_confirmation_and_form' );
function dw_show_confirmation_and_form( $form ) {
// Inserts a shortcode for the form without title or description
$shortcode = '[gravityform id="' . $form['id'] . '" title="false" description="false"]';
// Ensures that new lines are not added to HTML Markup
ob_start();
@davidwolfpaw
davidwolfpaw / wp-cli_site-setup.sh
Created November 9, 2018 20:40
A sample WP-CLI script to setup a new site with some defaults of our choosing.
#!/bin/zsh
# delete the default plugins and themes that we don't need
wp plugin delete hello
wp theme delete twentyfifteen
wp theme delete twentysixteen
# install the themes and plugins that we do want
wp plugin install gutenberg --activate
wp plugin activate akismet
@davidwolfpaw
davidwolfpaw / genesis_post_link_shortcode.php
Created September 8, 2018 18:37
This is a custom shortcode to allow the link to a post while using the Genesis Framework for WordPress
<?php
/*
* This is a custom shortcode to allow the link to a post while using the Genesis Framework.
*
* It was created to fill the need of a loop that needed links to posts.
*/
add_shortcode( 'post_link', 'genesis_post_link_shortcode' );
/**
@davidwolfpaw
davidwolfpaw / class-cc-post-republisher-admin.php
Created August 3, 2017 13:20
settings page options for ccpr
/**
* Initializes the general settings by registering the Sections, Fields, and Settings.
*
* This function is registered with the 'admin_init' hook.
*/
public function initialize_general_settings() {
// Control title of republish
// Set Terms text
// Choose CC license to use
@davidwolfpaw
davidwolfpaw / wp_custom_install.sh
Created January 31, 2017 19:01
A starter script for creating a WordPress site on Vagrant using VVV, VV, VASSH, and WP-CLI
#!/bin/bash -e
# Ideas, Drawbacks, and Suggestions: https://davidlaietta.com/bash-scripting-to-automate-site-builds-with-wp-cli/
# Set up some defaults
wpuser='USERNAME'
email='[email protected]'
blueprint='BLUEPRINT-NAME'
clear
@davidwolfpaw
davidwolfpaw / gf_si_int.php
Created September 8, 2016 16:05
Gravity Forms / Sprout Invoices Pro Integration
/**
* Hook into all Gravity Form submissions, check to see if the form id
* matches the one we want to generate an invoice from, and process the
* submission if appropriate.
*
* @param arrat $entry Array of the GF entry
* @return null
*/
function maybe_process_gravity_form_and_create_invoice( $entry = array(), $form = array() ) {
@davidwolfpaw
davidwolfpaw / dynamic_date_dropdown_gravityforms.php
Created August 23, 2016 19:06
Dynamically generate list of dates in Gravity Forms Dropdown and remove past and previously selected dates
<?php
/*
* Dynamically generate list of dates in Gravity Forms Dropdown and remove past and previously selected dates
*/
add_filter( 'gform_pre_render', 'dl_populate_dropdown' );
//Note: when changing drop down values, we also need to use the gform_pre_validation so that the new values are available when validating the field.
add_filter( 'gform_pre_validation', 'dl_populate_dropdown' );