Skip to content

Instantly share code, notes, and snippets.

View Kevinlearynet's full-sized avatar

Kevinleary.net Kevinlearynet

View GitHub Profile
@Kevinlearynet
Kevinlearynet / gutenberg-sample-blocks.html
Created April 10, 2025 13:16
Sample block content for the WordPress Gutenberg editor
<!-- wp:cover {"url":"https://picsum.photos/1024/430","id":2100,"dimRatio":50,"customOverlayColor":"#886049","isUserOverlayColor":false,"style":{"color":{"duotone":"var:preset|duotone|dark-grayscale"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim" style="background-color:#886049"></span><img class="wp-block-cover__image-background wp-image-2100" alt="" src="https://picsum.photos/1024/430" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size">Cover / Hero</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->
<!-- wp:paragraph -->
<p>This is a paragraph block. Frankfurter beef esse do non turducken strip steak sint in pork chop commodo doner sirloin beef ribs. Qui doner boudin, turkey prosciutto beef ribs sed aliqua. Occaecat quis picanha, pork chop fatba
@Kevinlearynet
Kevinlearynet / functions.php
Created November 29, 2024 03:46
Custom rewrite rules for /quote/:ticker/ WordPress route that uses a single custom page template for all tickers
function custom_quote_rewrite_rule() {
add_rewrite_rule(
'^quote/([^/]+)/?$',
'index.php?pagename=quote&quote_ticker=$matches[1]',
'top'
);
}
add_action('init', 'custom_quote_rewrite_rule');
function custom_quote_query_vars($vars) {
@Kevinlearynet
Kevinlearynet / basic-contact-form.php
Last active November 26, 2024 00:55
Simple WordPress contact form that sends an admin email when submissions happen.
<?php
/*
Plugin Name: Basic Contact Form
Plugin URI: https://kevinleary.net
Description: A simple contact form plugin that sends email submissions using wp_mail().
Version: 1.0
Author: kevinlearynet
Author URI: https://kevinleary.net
*/
@Kevinlearynet
Kevinlearynet / fw-config.php
Last active August 17, 2021 18:59
Folderwave server setup related files
<?php
/**
* FW Connector Config
*
* Add this to: /wordpress/wp-content/mu-plugins/fw-config.php
*/
$host = $_SERVER['SERVER_NAME'];
$api_host = ($host === 'student.student-1.com') ? 'https://www17.student-1.com' : 'https://www46.student-1.com';
if (!defined('FW_ENV')) {
@Kevinlearynet
Kevinlearynet / 1-identify
Last active July 19, 2021 17:16
Specification for creating a "Application Updated" event sent in to Segment by TAP/ArrayWorks.
Analytics.Client.Identify("{UserID}", new Traits() {
{ "id", "{UserID}" },
{ "firstName", "Kevin" },
{ "lastName", "Leary" },
{ "email", "[email protected]" },
{ "age", 35 },
{ "birthday", "1986-04-22" },
{ "createdAt", "YYYY-MM-DD" }, // Date of initial "application sent"
{ "gender", "Male" },
{ "phone", "7814896630" },
@Kevinlearynet
Kevinlearynet / media-types-filter.js
Last active June 23, 2021 16:13 — forked from danielbachhuber/collection-filter.js
Add a custom taxonomy dropdown filter to the WordPress Media Library
(function(){
/**
* Create a new MediaLibraryTaxonomyFilter we later will instantiate
*/
var MediaLibraryTaxonomyFilter = wp.media.view.AttachmentFilters.extend({
id: 'media-attachment-taxonomy-filter',
createFilters: function() {
var filters = {};
// Formats the 'terms' we've included via wp_localize_script()
@Kevinlearynet
Kevinlearynet / 502.html
Created November 13, 2019 14:39
Response body of 502 error
<!DOCTYPE html>
<html>
<head>
<title>Error Loading Site | 502 Bad Gateway</title>
</head>
<body>
<style>
@import url(//fonts.googleapis.com/css?family=Open+Sans:300);
body {
color: #343434;
@Kevinlearynet
Kevinlearynet / gist:29b44003ce45821c369a7064ac7b3313
Created April 30, 2019 12:38
Apple News BannerAdvertisement Example
{
"role": "banner_advertisement",
"anchor": "https://www.tripadvisor.com/",
"animation": "fade_in",
"bannerType": "standard",
"identifier": "tripadvisor-cta",
"style": {
"backgroundColor": "#ffffff",
"border": {
"all": {
// Save PDF from HTML Microservice
https://addaptive-microservices.herokuapp.com/api/html-to-pdf
const puppeteer = require('puppeteer');
class Webpage {
static async generatePDF(html) {
const browser = await puppeteer.launch({ headless: true }); // Puppeteer can only generate pdf in headless mode.
const page = await browser.newPage();
@Kevinlearynet
Kevinlearynet / locale-en_uk.json
Last active August 15, 2018 17:03
String translations needed for each locale.
{
"itunes_app": "https://itunes.apple.com/us/app/tripadvisor-hotels-flights/id284876795?mt=8",
"google_play_app": "https://play.google.com/store/apps/details?id=com.tripadvisor.tripadvisor&hl=en_uk",
"twitter_handle": "tripadvisoruk",
"facebook_link": "https://www.facebook.com/TripAdvisor",
"img_tripadvisor_blog": "tripadvisor-blog.svg",
"img_tripadvisor_tagline": "tripadvisor-tagline.svg",
"hotels": "Hotels",
"flights": "Flights",
"rentals": "Rentals",