Skip to content

Instantly share code, notes, and snippets.

@bavington
bavington / CF7_Event_Handler_GTM.js
Last active November 23, 2017 14:40
Contact Form 7 (CF7) Event Handler GTM Data Layer Event Push
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
dataLayer.push({'event': 'cf7.contact-page.mailsent', 'cf7.formID': event.detail.contactFormId});
}, false );
</script>
@bavington
bavington / CF7_Event_Handler.js
Last active November 23, 2017 12:56
Basic CF7 Event Handler (Test)
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
alert( "DOM Event 'wpcf7mailsent' was heard on CF7 with the Form ID: " + event.detail.contactFormId);
}, false );
</script>
@bavington
bavington / wp_speed_functions.php
Last active October 1, 2020 10:15
WordPress functions to remove (potentially) redundant functionality and page speed improvements.
<?php
// REMOVE EMOJIS
// Emojis are enabled by default, so if you don't want to use these you can remove the script and stylesheet:
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
// REMOVE COMMENT-REPLY.MIN.JS
// This is added by default to the footer, if you're not using post comments or DISQUS you can remove the script:
function remove_comment_reply_script(){
@bavington
bavington / Site-Search-JSON+LD.html
Last active February 24, 2016 09:05
Simple JSON+LD Boilerplate for configuring your Site Name and Google Sitelinks Search Box Schema.
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
// Include your Site name within Google Search Results
"name" : "James' Donuts",
"alternateName" : "James' Donuts Ltd",
"url": "https://www.jamesdonuts.co.uk",
// Enabe the Google Sitelinks Search Box
@bavington
bavington / .gitignore
Last active December 30, 2016 03:44
Standard Boilerplate Git Ignore file for a WordPress site
####################################
## Ignore everything except theme ##
####################################
/*
### But don't ignore wp-content
!wp-content/
### But ignore everything inside it
@bavington
bavington / local-business-JSON-LD.js
Last active August 13, 2021 19:03
A beautified, commented boilerplate for creating JSON-LD Schema mark-up for a local business. Within the example I'm using my friend's real business, a local plumber in Rugby. When using, review and remove the comments.
<script type="application/ld+json">
// A simple, single location local business JSON-LD Schema Boilerplate
// By @bavington, available on GitHub: http://bit.ly/Local_JSON
{
"@context":"http://schema.org",
"@type":"Plumber", // Change to the most specific type (List of choices: https://goo.gl/tvMVHf)
"name":"Custom Heat", // *REQUIRED
"legalName":"Custom Heat Ltd", // The Registered Business Name
"vatID":"776796257",
"description":"Established in Rugby since 1980, Custom Heat are a family run central heating and plumbing business serving Rugby, Royal Leamington Spa and Warwick.",
@bavington
bavington / wp_custom_toolbar_link.php
Last active March 11, 2019 13:31
Adding a custom link to the WordPress Admin/Toolbar complete with icon.
@bavington
bavington / vertical_rhythm.sass
Created August 13, 2015 19:44
Vertical Rhythm
$fz-mobile: percentage(28/1.6/16);
$fz-desktop: percentage(32/1.6/16);
$lh: 1.6rem;
$h1: 2rem;
$h2: 1.5rem;
$h3: 1.25rem;
$h4: 1rem;
$h5: .875rem;
@bavington
bavington / instagram_deep_links.php
Created June 10, 2015 07:36
Conditional buttons for Deep Linking to the Instagram App
@bavington
bavington / woo_disqus.php
Created June 7, 2015 16:11
Function to Add DISQUS to WooCommerce product pages.
function disqus_embed($disqus_shortname) {
global $post;
wp_enqueue_script('disqus_embed','http://'.$disqus_shortname.'.disqus.com/embed.js');
echo '<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = "'.$disqus_shortname.'";
var disqus_title = "'.$post->post_title.'";
var disqus_url = "'.get_permalink($post->ID).'";
var disqus_identifier = "'.$disqus_shortname.'-'.$post->ID.'";
</script>';