Skip to content

Instantly share code, notes, and snippets.

View tammalee's full-sized avatar

Tammy Lee tammalee

  • Edmonton, AB
View GitHub Profile
@tammalee
tammalee / 0_reuse_code.js
Created November 13, 2015 15:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@tammalee
tammalee / wp_remove_p_tags.php
Last active April 2, 2023 18:49
Remove P tags wrapping around images and iframes
<?php
/**
* Removes P tags from around images and iframes
* Original source: https://interconnectit.com/blog/2011/06/16/how-to-remove-p-tags-from-images-in-wordpress/
* @param [type] $pee [description]
* @return [type] [description]
*/
function img_unautop($pee) {
// commented out example shows how you can wrap your IMG tag in a div if you like
/* $pee = preg_replace('/<p>\\s*?(<a .*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s', '<div class="figure">$1</div>', $pee); */
@tammalee
tammalee / wp_enqueue_google_fonts.php
Created April 8, 2017 18:52
[WP] Enqueue Google Fonts
<?
/**
* Enqueues Google Fonts
* Original source: http://webdesignfromscratch.com/wordpress/using-google-web-fonts-with-wordpress-the-right-way/
* @return [type] [description]
*/
function load_fonts() {
wp_register_style('googleFonts', 'https://fonts.googleapis.com/css?family=Montserrat|Open+Sans');
wp_enqueue_style( 'googleFonts');
}
@tammalee
tammalee / wp_gtm_data_layer_gravity_forms.php
Last active May 13, 2024 15:04
[WP] GTM data layer push for Gravity Forms
<?
/**
* GTM data layer push for gravity forms contact form
*/
/**
* Pushes a submission variables to the GTM dataLayer
* Also pushes the event label for use in GTM tracking
* @param Array $entry the data submitted with the form
* @param Array $form Form data
* @return null
@tammalee
tammalee / wp_gtm_data_layer_mailchimp_4_wordpress.js
Last active September 10, 2018 19:26
MailChimp 4 WordPress GTM data layer push after form submission
/**
* Hooking into MailChimp for WordPress
* MC4WP JS Form Events: https://mc4wp.com/kb/javascript-form-events/
* Form success
*/
(function($) {
$(document).ready(function() {
mc4wp.forms.on('748.success', function(form) {
//GTM Data Layer Code Goes Here
window.dataLayer = window.dataLayer || [];
@tammalee
tammalee / wp_enqueue_typekit_fonts.php
Created April 8, 2017 19:10
[WP] Enqueue Typekit Fonts
<?php
/**
* Enqueue Typekit
* Original source: https://wptheming.com/2013/02/typekit-code-snippet/
* @return [type] [description]
*/
function kp_scripts() {
wp_enqueue_script( 'kp-typekit', '//use.typekit.net/<YOUR CODE HERE>.js', array('jquery'), '201610122', false );
}
add_action( 'wp_enqueue_scripts', 'kp_scripts' );
@tammalee
tammalee / cpt-testimonial.php
Created April 16, 2017 03:01
mu-plugin Testimonial Custom Post Type
<?php
/**
* @wordpress-plugin
* Plugin Name: Testimonials custom post type
* Plugin URI: [URL HERE]
* Description: Testimonials custom post type
* Version: 1.0.0
* Author: [AUTHOR HERE]
* Author URI: [AUTHOR URI HERE]
<?php
function acf_json_save_point ($path) {
return __DIR__.'/data/acf';
}
function acf_json_load_point ($path) {
return [__DIR__.'/data/acf'];
}
@tammalee
tammalee / content-page.php
Last active April 16, 2017 04:14
ACF Template Partials in a mu-plugin Class
<?php
/* Wherever you place this code, the ACF partials for the post will output. I tend to put it after the default content. */
$tmpart = new <name of class>();
$tmpart->tmpltPartials();
?>
@tammalee
tammalee / Element Styling Test Template
Created May 16, 2018 15:57
HTML to copy and paste into a WordPress page to test element styling
<h1>Typography</h1>
<h2>Headings</h2>
<h1>This is an H1 heading</h1>
<h2>This is an H2 heading</h2>
<h3>This is an H3 heading</h3>
<h4>This is an H4 heading</h4>
<h5>This is an H5 heading</h5>
<h6>This is an H6 heading</h6>
<h2>Body text</h2>