Skip to content

Instantly share code, notes, and snippets.

View rosswintle's full-sized avatar

Ross Wintle rosswintle

View GitHub Profile
@rosswintle
rosswintle / build.php
Last active January 10, 2025 07:28
A VERY simple PHP static HTML generator that does a single-level extend, and includes with variable passing and that's about it.
<?php
/*
* Input: files matching src/pages/*.html
* Output: public/*.html
*
* Pages can extend a template by calling:
*
* extend(string $relativeTemplatePath, array $variables)
*
* at the start and:
@rosswintle
rosswintle / spam-pixel.php
Created March 26, 2021 10:23
WordPress Spam Pixel code for WP Forms
<?php
/**
* Plugin Name: Spam Pixel
* Description: This simple plugin integrates Ross's spam pixel idea with WP Forms
* Author: Ross Wintle
* Author URI: https://rosswintle.uk
* Text Domain: spam-pixel
* Domain Path: /languages
* Version: 0.1.0
*
@rosswintle
rosswintle / AppNavigationMenu.php
Last active September 13, 2023 21:45
Laravel Jetstream Livewire Navigation Menu
<?php
/**
* This class extends the base NavigationClass provided by Jetstream.
* Note that the base class includes the navigation-menu.blade.php
*/
namespace App\Http\Livewire;
class AppNavigationMenu extends \Laravel\Jetstream\Http\Livewire\NavigationMenu
{
@rosswintle
rosswintle / functions.php
Created November 20, 2020 17:54
Filter to make WordPress YouTube oembeds use the nocookie version
<?php
add_filter('oembed_result', 'youtubeEmbedNocookieFilter', 10, 3);
function youtubeEmbedNocookieFilter(string $data, string $url, array $args)
{
return str_replace('src="https://www.youtube.com/embed', 'src="https://www.youtube-nocookie.com/embed', $data);
}
@rosswintle
rosswintle / .bashrc-searches
Last active October 16, 2020 14:13
Command-line (bash) code-searching functions.
# Add these to your .bashrc file for some quick and clever recursive web-dev code searching
# from the command line/terminal.
#
# Should be easy enough to add your own too.
#
# Usage is just:
#
# phprgrep <regular expression>
#
# Regular expresssions need to be escaped/quoted if you're being clever.
@rosswintle
rosswintle / weird-wide-webring.php
Created May 19, 2020 09:32
Simple WordPress Widget for Jack McDade's Weird Wide Webring
<?php
/**
* Plugin Name: Weird Wide Webring
* Plugin URI: https://weirdwidewebring.net
* Description: A widget for displaying the Weird Wide Webring links
* Author: Ross Wintle
* Author URI: https://rosswintle.uk/
* Text Domain: weird-wide-webring
* Domain Path: /languages
* Version: 1.0.0
@rosswintle
rosswintle / AssetCache.php
Last active February 22, 2020 21:16
Statamic tag for my LaravelAssetCache package
<?php
/*
* Tag for my LaravelAssetCache package: https://github.com/rosswintle/laravel-asset-cache/
*
* This grabs the asset file from the specified npm package from jsdelivr.net, and caches and serves it locally
*
* Before use you'll need to:
* composer require rosswintle/laravel-asset-cache
* php artisan storage:link (in all environments)
*
@rosswintle
rosswintle / wordpress-cleanup.php
Created February 1, 2019 17:04
WordPress Cleanup hooks
<?php
/**
* Plugin Name: Wordpress Cleanup
*/
namespace WordPress_Cleanup;
/**
* Change filters here to control what this does
*/
@rosswintle
rosswintle / pair.php
Created January 10, 2019 22:55
Secret Santa Recursive Pairings
function make_valid_pairing( $people_to_pair, $people_yet_to_have_gifts ) {
// We made it! No more people left to pair! Return an empty array of pairings.
if (empty($people_to_pair)) {
return [];
}
// Get the first person
$person_to_pair = $people_to_pair[0];
// Get all the other people
@rosswintle
rosswintle / functions.php
Created July 2, 2018 17:16
WordPress filters to make HTML password reset emails work
<?php
// adding support for html emails
// this converts ALL wp_mail emails to HTML, which messes up the password reset email
add_filter( 'wp_mail_content_type','prefix_set_content_type' );
function prefix_set_content_type() {
return "text/html";
}
// add this filter too
// this will make the password reset email compatible with the HTML format