Skip to content

Instantly share code, notes, and snippets.

James Bavington bavington

Block or report user

Report or block bavington

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bavington
bavington / CF7_Event_Handler_GTM.js
Last active Nov 23, 2017
Contact Form 7 (CF7) Event Handler GTM Data Layer Event Push
View CF7_Event_Handler_GTM.js
<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 Nov 23, 2017
Basic CF7 Event Handler (Test)
View CF7_Event_Handler.js
<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 Apr 17, 2017
WordPress functions to remove (potentially) redundant functionality and page speed improvements.
View wp_speed_functions.php
<?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 Feb 24, 2016
Simple JSON+LD Boilerplate for configuring your Site Name and Google Sitelinks Search Box Schema.
View Site-Search-JSON+LD.html
<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 Dec 30, 2016
Standard Boilerplate Git Ignore file for a WordPress site
View .gitignore
####################################
## 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 Feb 16, 2017
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.
View local-business-JSON-LD.js
<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 Mar 11, 2019
Adding a custom link to the WordPress Admin/Toolbar complete with icon.
View wp_custom_toolbar_link.php
View vertical_rhythm.sass
$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 Jun 10, 2015
Conditional buttons for Deep Linking to the Instagram App
View instagram_deep_links.php
@bavington
bavington / woo_disqus.php
Created Jun 7, 2015
Function to Add DISQUS to WooCommerce product pages.
View woo_disqus.php
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>';
You can’t perform that action at this time.