Skip to content

Instantly share code, notes, and snippets.

View rosswintle's full-sized avatar

Ross Wintle rosswintle

View GitHub Profile
@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 / 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 / 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 / build.php
Last active June 2, 2024 17:14
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 / get_post_meta_filter.php
Last active August 7, 2021 15:56
Generic meta data filter for WordPress posts
<?php
/*
* Add a generic post meta filter that allows you to create filters like
* get_post_metadata_{$key}
*/
add_filter('get_post_metadata', 'generic _meta_filter', 100, 5);
function generic_meta_filter($value, $object_id, $meta_key, $single, $meta_type) {
remove_filter('get_post_metadata' 'generic_meta_filter', 100, 5);
@rosswintle
rosswintle / fathom-scriptable-widget.js
Last active November 7, 2021 20:46
Code to show daily pageviews from the Fathom API in an iOS widget using the Scriptable app
/**
* @returns {string}
*/
function getApiKey() {
return '<YOUR_API_KEY>';
}
/**
* @returns {Promise}
*/
@rosswintle
rosswintle / feedbin-center.js
Created February 7, 2022 22:56
Feedbin: Keep selected centered
// ==UserScript==
// @name Feedbin: Keep selected centered
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Keeps the selected item vertically centered in Feedbin
// @author Ross Wintle
// @match https://feedbin.com/
// @icon https://www.google.com/s2/favicons?domain=feedbin.com
// @grant none
// ==/UserScript==
@rosswintle
rosswintle / wp-full-screen-editor-killer.user.js
Last active February 10, 2022 17:11
WordPress full-screen editor killer
// ==UserScript==
// @name WordPress Full Screen Editor killer
// @namespace http://rosswintle.uk/
// @version 0.1
// @description Auto-removes the full screen editor on WordPress sites
// @author Ross Wintle
// @match https://*/*
// @match http://*/*
// @grant none
// ==/UserScript==
@rosswintle
rosswintle / composer.json
Last active July 7, 2022 15:16
WordPress using Composer: composer.json template
{
"name": "your_organisation_or_name/your_project_name",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org",
"only": [
"wpackagist-plugin/*",
"wpackagist-theme/*"
]
@rosswintle
rosswintle / watch.sh
Last active March 2, 2024 14:56
File watcher shell script - for use with front-end polling script
#!/bin/bash
##
## This script watches for changes in the specified directories and runs the build
## script when changes are detected.
##
## It writes a .modified_time file to the root of the project. This contains the
## timestamp of the last modification time.
##
## This is intended to be used with a front-end script that polls for changes