Skip to content

Instantly share code, notes, and snippets.

View rosswintle's full-sized avatar

Ross Wintle rosswintle

View GitHub Profile
@rosswintle
rosswintle / composer.json
Last active July 7, 2022 15:16
WordPress using Composer: composer.json template
View composer.json
{
"name": "your_organisation_or_name/your_project_name",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org",
"only": [
"wpackagist-plugin/*",
"wpackagist-theme/*"
]
@rosswintle
rosswintle / wp-full-screen-editor-killer.user.js
Last active February 10, 2022 17:11
WordPress full-screen editor killer
View wp-full-screen-editor-killer.user.js
// ==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 / feedbin-center.js
Created February 7, 2022 22:56
Feedbin: Keep selected centered
View feedbin-center.js
// ==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 / 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
View fathom-scriptable-widget.js
/**
* @returns {string}
*/
function getApiKey() {
return '<YOUR_API_KEY>';
}
/**
* @returns {Promise}
*/
@rosswintle
rosswintle / get_post_meta_filter.php
Last active August 7, 2021 15:56
Generic meta data filter for WordPress posts
View get_post_meta_filter.php
<?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 / build.php
Last active August 6, 2023 19:05
A VERY simple PHP static HTML generator that does a single-level extend, and includes with variable passing and that's about it.
View build.php
<?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
View spam-pixel.php
<?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
View AppNavigationMenu.php
<?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
View functions.php
<?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.
View .bashrc-searches
# 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.