Skip to content

Instantly share code, notes, and snippets.

@ChrisLTD
ChrisLTD / related_posts.php
Created April 9, 2018 18:38
WordPress Related Posts by Category
// Creates iframe to submit lead data to pardot
// @paramList should be in the format param1=something&param2=somethingelse
function submitPardotLead(formHandlerUrl = '//localhost/no-valid-form-handler-url',
paramList = 'noparams=provided',
callbackFn = function() {}) {
// build URL
var srcUrl = formHandlerUrl + '?' + paramList;
// create iframe el
@ChrisLTD
ChrisLTD / docker-compose.yml
Last active November 14, 2020 00:37
Docker Compose for WordPress with Data Persistence
# Docker Compose for WordPress with Data Persistence
#
# Resources
# https://medium.com/@tatemz/local-wordpress-development-with-docker-3-easy-steps-a7c375366b9
# https://hub.docker.com/_/wordpress/
# https://hub.docker.com/r/_/mariadb/
# https://stackoverflow.com/a/39208187/648844
# https://github.com/nezhar/wordpress-docker-compose
#
version: "2"
@ChrisLTD
ChrisLTD / pardot-form-handler-iframe.html
Created October 19, 2017 20:51 — forked from afischoff/pardot-form-handler-iframe.html
Example of using a hidden iframe to pass data to a Pardot form handler before continuing with normal form submission.
<html>
<head>
<title>Pardot Example Form Handler Submit</title>
<!-- Include jQuery -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Post to Pardot function -->
<script type="text/javascript">
// set the pardot form handler url and form element id
<?php
$redirects = array(
"/aboutus.php" => "/about-us/",
"/blog/2010/02" => "/blog/",
"/blog/2010/04" => "/blog/",
"/blog/2010/07" => "/blog/",
"/blog/2010/12" => "/blog/",
"/blog/2011/01" => "/blog/",
);
@ChrisLTD
ChrisLTD / functions.php
Last active May 23, 2017 15:16
Add ACF Fields to WP API responses
<?php
/*
* Add ACF Fields to REST responses
* Modified from: https://support.advancedcustomfields.com/forums/topic/rest-api/#post-32890
*/
add_action( 'rest_api_init', 'slug_register_acf' );
function slug_register_acf() {
$post_types = get_post_types(['public'=>true], 'names');
foreach ($post_types as $type) {
register_rest_field( $type,
@ChrisLTD
ChrisLTD / webpack.config.js
Created May 21, 2017 23:31
ChrisLTD Craft CMS Webpack Build
const webpack = require('webpack');
// Let's us put the CSS in a separate file
const ExtractTextPlugin = require("extract-text-webpack-plugin");
// Minifies the JavaScript
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
// Cleans the build directory before each build
const CleanWebpackPlugin = require('clean-webpack-plugin');
@ChrisLTD
ChrisLTD / range.scss
Last active March 20, 2017 17:32
Cross Browser input[type="range"] styling
// Styling Cross-Browser Compatible Range Inputs with Sass
// Modified from Github: https://github.com/darlanrod/input-range-sass
$track-color: #9896AB !default;
$thumb-color: $color-purple-6 !default;
$thumb-radius: 50% !default;
$thumb-height: 24px !default;
$thumb-width: 24px !default;
$thumb-shadow-size: 4px !default;
@ChrisLTD
ChrisLTD / geolocation-test.js
Last active November 21, 2016 14:55
Pull latitude and longitude from the HTML5 geolocation API with a fallback to Freegeoip. ES6.
'use strict';
const GEOLOCATION_TYPE = {
GEOPOSITION: 'GEOPOSITION',
FREEGEOIP: 'FREEGEOIP'
};
class Localizer {
constructor() {
@ChrisLTD
ChrisLTD / add-warning-to-acf.php
Created August 17, 2016 19:36
Put message in ACF interface to warn people to edit custom fields in the PHP
<?php
// put message in ACF interface to warn people to edit custom fields here
function acf_warning( $hook ) {
if ('edit.php' != $hook) {
return;
}
$javascript = "
var acfFieldGroupEl = document.getElementById('acf-field-group-wrap');