Skip to content

Instantly share code, notes, and snippets.

View rtpHarry's full-sized avatar
🎯
Focusing on learning something every day

Matthew Harris rtpHarry

🎯
Focusing on learning something every day
View GitHub Profile
@rtpHarry
rtpHarry / gist:6e1d73d026fca369569f11798736dc7a
Last active October 14, 2022 22:41 — forked from felixzapata/gist:9144986
How to create a clone role in WordPress
<?php
/**
* Clone the subscriber role to create a tenant role
* Note: this only needs to be run once, so it can be removed after the role is created
*/
function clone_subscriber_to_tenant() {
$new_role = 'tenant';
$new_role_name = 'Tenant';
$source_role = 'subscriber';
@rtpHarry
rtpHarry / rtp-post-grid-parent-title-with-linkphp
Created September 13, 2022 14:20
WordPress Post Grid Layout - Parent Title With Link
<?php
/*
Plugin Name: Post Grid Layout - Parent Title With Link
Plugin URI: https://runthings.dev/
Description: Display the parent page title in the layout editor, with optional link.
Version: 1.0.0
Author: runthings.dev
Author URI: https://runthings.dev/
*/
@rtpHarry
rtpHarry / rtp-post-grid-yoast-primary-category.php
Created September 13, 2022 09:19
WordPress Post Grid - Yoast Primary Category Support
<?php
/*
Plugin Name: Post Grid Yoast Primary Category
Plugin URI: https://runthings.dev/
Description: Bring the primary category to the start of the list
Version: 1.0.0
Author: runthings.dev
Author URI: https://runthings.dev/
*/
@rtpHarry
rtpHarry / soka-elementor-image-carousel-galleryid.php
Last active June 14, 2021 21:40
Inject a randomised prefix into Elementor Image Carousels so that it separates out the lightboxes contained in JetEngine listings
@rtpHarry
rtpHarry / functions.php
Created May 21, 2021 23:56
Convert a start and end timestamp into a nicely formatted and joined up date range
<?php
/**
* Filter for Unlimited Elements to format a date range, from two timestamps
*/
function filter_format_date_range($startTimeStamp, $endTimeStamp){
$displayDate = "";
if($startTimeStamp == $endTimeStamp) {
// same date
$displayDate = date('j M Y', $endTimeStamp);
@rtpHarry
rtpHarry / WordPress Google Analytics
Last active March 16, 2019 21:31 — forked from kenhowardpdx/WordPress Google Analytics
Add Google Analytics to WordPress Theme functions.php
// originally based on https://gist.github.com/kenhowardpdx/8484076
// updated to current gtag.js snippet and moved to head
function rtp_init_analytics() {
$analytics_id = 'YOUR UA CODE HERE';
$analytics = '<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id='. $analytics_id .'"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
@rtpHarry
rtpHarry / animation.js
Last active October 4, 2023 06:20
Three.js - play an AnimationAction in reverse. There are a bunch of threads saying this isn't possible but I found a way so I wanted to post it online in a place that people will hopefully stumble upon it.
// The class itself is based on the animation helper class in
// https://github.com/paulmg/ThreeJS-Webpack-ES6-Boilerplate
// but I have changed almost everything except for the class name and the update function.
import * as THREE from 'three';
export default class Animation {
constructor(scene, animations) {
this.scene = scene;
this.animations = animations;
@rtpHarry
rtpHarry / animation.js
Created October 6, 2018 15:39
Three.js play an AnimationAction in reverse
import * as THREE from 'three';
export default class Animation {
constructor(scene, animations) {
this.scene = scene;
this.animations = animations;
this.mixer = new THREE.AnimationMixer(this.scene);
}
@rtpHarry
rtpHarry / Orchard-Documentation-Notes.md
Created April 16, 2016 12:08
Some notes that I've made so far for contributing to the orchard docs project

Documentation Glossary

  • Admin Dashboard Anything within the admin panel is referred to as the admin dashboard

  • Orchard Just refer to it as Orchard not Orchard CMS or Orchard Project.

  • Guide A page of docs. Not a topic, tutorial, lesson, etc.

@rtpHarry
rtpHarry / GetAlphaRouletteLinksHtmlMarkup.cs
Last active December 21, 2015 05:08
Code sample written for a StackOverflow question to show how to build alpha link roulette html by extracting and grouping the first letters of a list of jobs.
public class GetAlphaRouletteLinks
{
// Outputs markup like this:
// <a href="#rouletteA">A</a> | <a href="#rouletteB">B</a> | <a href="#rouletteC">C</a> | <a href="#rouletteD">D</a> | <a href="#rouletteE">E</a> | <a href="#rouletteF">F</a> | G | <a href="#rouletteH">H</a> | <a href="#rouletteI">I</a> | <a href="#rouletteJ">J</a> | K | <a href="#rouletteL">L</a> | <a href="#rouletteM">M</a> | <a href="#rouletteN">N</a> | <a href="#rouletteO">O</a> | <a href="#rouletteP">P</a> | <a href="#rouletteQ">Q</a> | <a href="#rouletteR">R</a> | <a href="#rouletteS">S</a> | <a href="#rouletteT">T</a> | <a href="#rouletteU">U</a> | V | <a href="#rouletteW">W</a> | X | Y | Z
// Notice how it skips the link for any letters that don't have jobs starting with that letter eg:
// <a href="#rouletteW">W</a> | X | Y | Z
public string GetAlphaRouletteLinksHtmlMarkup()
{
var JobList = new List<String>() {