Skip to content

Instantly share code, notes, and snippets.

View daltonrooney's full-sized avatar

Dalton Rooney daltonrooney

View GitHub Profile
@daltonrooney
daltonrooney / img-macros.twig
Created January 23, 2020 21:58 — forked from stenvdb/img-macros.twig
Macro collection for Imager in Craft CMS
{#
# USAGE:
# (transform can either be an object, or an array of objects, aka srcset)
#
# {{ macro.regular(entry.image.one(), { width: 50, height: 50 }, 'class="block"') }}
# ➡️ <img src="..." width="50" height="50" alt="..." class="block" />
#
# {{ macro.url(entry.image.one(), { width: 50, height: 50 }) }}
# ➡️ /uploads_c/../{...}.jpg
#
@daltonrooney
daltonrooney / email.js
Created November 4, 2019 23:18
Email mailto link for Redactor
//Based on https://www.jackbarber.co.uk/blog/2019-04-26-email-address-plugin-for-redactor with small improvements
(function ($R) {
$R.add('plugin', 'email', {
modals: {
// this is variable with modal HTML body
'emailmodal': '<form action=""><div class="form-item"><label>Email Address</label><input type="text" name="emailaddress"><label>Text</label><input type="text" name="anchortext"></div></form>'
},
// set translations
translations: {
en: {
@daltonrooney
daltonrooney / timezoneField.json
Created October 28, 2019 22:16
Craft CMS Field Manager Time Zone import
[
{
"name":"Time Zone",
"handle":"timeZone",
"instructions":"",
"required":null,
"translationMethod":"none",
"translationKeyFormat":null,
"type":"craft\\fields\\Dropdown",
"settings":{
@daltonrooney
daltonrooney / form.js
Last active September 24, 2019 19:03
Craft CMS + Mailchimp signup form in Vue.js
import Vue from 'vue'
import axios from 'axios'
const apiClient = axios.create({
baseURL: '',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
})
@daltonrooney
daltonrooney / calendar.js
Created September 6, 2019 05:50
Output calendar links from event in Vue.js
var MS_IN_MINUTES = 60 * 1000;
var formatTime = function (date) {
date = new Date(date * 1000);
return date.toISOString().replace(/-|:|\.\d\d\d/g, "")
};
var calendarGenerators = {
google: function (event) {
var startTime = formatTime(event.start);
@daltonrooney
daltonrooney / change-class-on-scroll.html
Last active May 17, 2020 16:33 — forked from ohiosveryown/change-class-on-scroll.html
Vanilla JS – change/add class based on scroll position.
// https://codepen.io/cmykw/pen/gemxJm
// layout
<nav/>
// style
<style>
body { min-height: 200vh; }
nav {
@daltonrooney
daltonrooney / .htaccess
Created September 6, 2018 18:34 — forked from zulfajuniadi/.htaccess
Enable CORS via htaccess.
Header add Content-Type "application/json"
Header add Access-Control-Allow-Methods "GET,HEAD,POST,PUT,DELETE,OPTIONS"
Header add Access-Control-Allow-Headers "Auth-Token,Content-Type"
Header add Access-Control-Allow-Origin "*"
@daltonrooney
daltonrooney / typekit.editor.php
Created April 17, 2017 22:47 — forked from mikemanger/typekit.editor.php
Add a TypeKit font to the TinyMCE editor in WordPress.
add_filter( 'mce_external_plugins', 'my_theme_mce_external_plugins' );
function my_theme_mce_external_plugins( $plugin_array ) {
$plugin_array['typekit'] = get_template_directory_uri() . '/typekit.tinymce.js';
return $plugin_array;
}
@daltonrooney
daltonrooney / acf-migrate-db-pro.php
Last active October 27, 2020 04:34
Prevent ACF Pro license key from being overwritten during WP Migrate DB Pro migration
<?php
/*
Based on http://github.com/deliciousbrains/wp-migrate-db-pro-tweaks
*/
class ACF_WP_Migrate_DB_Pro_Tweaks {
function __construct() {
add_filter( 'wpmdb_preserved_options', array( $this, 'preserved_options' ) );
}
@daltonrooney
daltonrooney / twig_file_date_extension.php
Created February 8, 2017 19:36 — forked from Stoffo/twig_file_date_extension.php
Twig Function to get the file mtime in template for HTTP Caching
<?php
$function_filedate = new Twig_SimpleFunction(
'fileDate',
/**
* @param $file_path
* This function generates a new file path with the last date of filechange
* to support better better client caching via Expires header:
* i.e: