Skip to content

Instantly share code, notes, and snippets.

View danielmcclure's full-sized avatar

Daniel McClure danielmcclure

View GitHub Profile
@danielmcclure
danielmcclure / facebook-wca-standard-events.html
Last active October 14, 2024 07:21
Sample Facebook Standard Events for New Facebook WCA (Website Custom Audience) Pixel
<!-- Facebook Custom Audience Pixel Code - Placed on Every Page of Site -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '{{facebook pixel}}');
fbq('track', 'PageView');
</script>
@danielmcclure
danielmcclure / functions.php
Created July 6, 2015 22:25
Add HSTS to WordPress
<?php
/* Add HSTS for Strict SSL */
function hsts_header() {
isset($_SERVER['HTTPS']) && header('Strict-Transport-Security: max-age=15768000; includeSubDomains');
}
add_action( 'send_headers', 'hsts_header' );
@danielmcclure
danielmcclure / functions.php
Created July 6, 2015 22:27
Customise the number of columns in the WordPress Admn Dashboard
<?php
//* Add Dashboard Column Settings
function tme_custom_dashboard_columns() {
add_screen_option(
'layout_columns',
array(
'max' => 2,
'default' => 1
)
@danielmcclure
danielmcclure / functions.php
Last active August 29, 2015 14:24
Add a custom WordPress Login Logo
<?php
/* Customise the WordPress Login Logo */
function tme_login_logo() { ?>
<style type="text/css">
body.login div#login h1 a {
background-image: url(https://example.com/image.png);
width: 300px;
height: 100px;
background-size: 300px;
@danielmcclure
danielmcclure / functions.php
Created July 6, 2015 22:31
Add a custom default Gravatar for WordPress
<?php
/* Customise Default Gravatar*/
add_filter( 'avatar_defaults', 'tme_gravatar' );
function tme_gravatar ($avatar_defaults) {
$myavatar = 'https://example.com/wp-content/uploads/gravatar.png';
$avatar_defaults[$myavatar] = "TME";
return $avatar_defaults;
@danielmcclure
danielmcclure / functions.php
Created July 6, 2015 22:32
Remove Admin Bar for Everyone Except Admin in WordPress
<?php
/* Remove Admin Bar for Everyone Except Admin */
add_action('after_setup_theme', 'tme_remove_admin_bar');
function tme_remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
@danielmcclure
danielmcclure / functions.php
Created July 6, 2015 22:33
Add ActiveCampaign Tag Mapping to Gravity Forms for WordPress
<?php
/* Enable ActiveCampaign Tag Mapping in Gravity Forms*/
add_filter( 'gform_activecampaign_enable_tag_mapping', '__return_true' );
@danielmcclure
danielmcclure / functions.php
Created July 6, 2015 22:34
Remove Billing Fields from WooCommerce checkout flow for WordPress
<?php
/* Remove Billing Fields for WooCommerce */
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
@danielmcclure
danielmcclure / opengraph-attributes.html
Created July 7, 2015 01:04
Add Social Media & OpenGraph Data to Articles
<!-- Update your html tag to include the itemscope and itemtype attributes. -->
<html itemscope itemtype="http://schema.org/Article">
<!-- Place this data between the <head> tags of your website -->
<title>Page Title. Maximum length 60-70 characters</title>
<meta name="description" content="Page description. No longer than 155 characters." />
<!-- Schema.org markup for Google+ -->
<meta itemprop="name" content="The Name or Title Here">
<meta itemprop="description" content="This is the page description">
@danielmcclure
danielmcclure / genesis-functions.php
Last active August 29, 2015 14:25 — forked from woogist/genesis-functions.php
The code in below will integrate Sensei with the Genesis theme framework from Studio Press. Add the code below into your themes functions.php file.
/*********************
* Sensei Integration
*********************/
/**
* Declare that your theme now supports Sensei
*/
add_action( 'after_setup_theme', 'sensei_support' );
function sensei_support() {
add_theme_support( 'sensei' );