Skip to content

Instantly share code, notes, and snippets.

@BFTrick
BFTrick / heap.php
Last active November 4, 2016 14:59
Load Heap Analytics
<?php
/*
* Plugin Name: Heap Analytics
* Plugin URI: https://gist.github.com/BFTrick/bb3b3b0e0497e8adecfa00e3c8e1b33d
* Description: Send all site data to Heap Analytics
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com
* Version: 1.0
*/
@GaryJones
GaryJones / .htaccess
Last active October 6, 2023 08:35
Security Headers
<IfModule mod_headers.c>
# HSTS - force redirect to HTTPS at the browser level.
# Submit for Chrome preload list at https://hstspreload.appspot.com/
# Header always set Strict-Transport-Security: "max-age=31536000; includeSubDomains; preload" env=HTTPS
# X-Xss-Protection
Header always set X-XSS-Protection "1; mode=block"
# Stop clickjacking by only allowing us to frame our own site
Header always set X-Frame-Options "SAMEORIGIN"
@edwardsfriedman
edwardsfriedman / gist:17a66e22e5f5b81bf4e4470e9ce26f29
Created August 16, 2016 15:33
Heap super property implementation
<%# Enables heap super properties so heap will send properties even when called before it has loaded. %>
window.heap = window.heap || []; for (var n = ["clearEventProperties", "removeEventProperty", "addEventProperties", "setEventProperties", "unsetEventProperty", "addUserProperties", "identify", "track"], o = function(e) { return function() { window.heap.push([e].concat(Array.prototype.slice.call(arguments, 0))) }}, t = 0; t < n.length; t++) { var r = n[t]; window.heap[r] = o(r)};
var locale = "<%= I18n.locale %>"
<%# Set locale as heap super property. %>
window.heap.addUserProperties({ locale: locale });
analytics.load("<%= segment_key %>");
@cartpauj
cartpauj / mepr-autoembed-thankyou-page-messages.php
Created June 7, 2016 16:09
WP Autoembed MemberPress thank you page messages
<?php
/* Enter Your Custom Functions Here */
function mepr_autoembed_thankyou_message($message) {
global $wp_embed;
if(!class_exists('MeprTransaction')) { return $message; }
if(!isset($_REQUEST['trans_num'])) { return $message; }
$txn = new MeprTransaction();
<?php
/*
// recipients array example
$recipients = array(
array('address'=>
array(
'email' => '[email protected]',
'name'=>'Carlos Cabral'
)
<script>
var intercomSettings = {
app_id: "{{Intercom app ID}}"
};
(function() {var w = window;var ic = w.Intercom;if (typeof ic === "function") {ic('reattach_activator');ic('update', intercomSettings);} else {var d = document;var i = function() {i.c(arguments)};i.q = [];i.c = function(args) {i.q.push(args)};w.Intercom = i;var s = d.createElement('script');s.type = 'text/javascript';s.async = true;
s.src = 'https://widget.intercom.io/widget/{{Intercom app ID}}';
var x = d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s, x);}})();
</script>
@beastawakens
beastawakens / gtm-intercom.js
Created January 22, 2016 14:33
Adding Google Tag Manager variables to intercomSettings
<script>
// app ID
var intercomSettings = {
app_id: "{{IC - Dynamic app ID}}"
};
// Verifies and cleans all GTM variables
function pushGTMVariablesToIntercom(gtmKey, gtmValue) {
if("{{User - Account - Type}}" != "Guest"){
if(gtmValue != null && gtmValue != "" && gtmValue != "undefined") {
@polevaultweb
polevaultweb / wpos-copy-hidpi-images.php
Created January 8, 2016 16:03
Restores the functionality of copying of HiDPI (@2x) images during S3 offload of attachments.
<?php
/*
Plugin Name: WP Offload S3 - Copy HiDPI Images
Description: Restores the functionality of copying of HiDPI (@2x) images during S3 offload of attachments.
Author: Delicious Brains
Version: 1.0
Author URI: https://deliciousbrains.com/
*/
add_filter( 'as3cf_attachment_file_paths', 'wpos3_hipdi_add_hidpi_file_paths' );
@renventura
renventura / genesis-post-info-with-est-read-time.php
Created October 30, 2015 19:08
Modified Genesis post info with estimated read time
<?php //* Mind this opening php tag
/**
* Display Last Updated date if a post has been updated (Genesis Framework)
* Includes estimated read time via the Estimated Post Reading Time plugin
*
* @author Ren Ventura <EngageWP.com>
* @link http://www.engagewp.com/display-updated-date-instead-of-published-date-in-genesis/
*/
add_filter( 'genesis_post_info', 'rv_post_info_filter_with_est_read_time' );
@soderlind
soderlind / a_faster_load_textdomain.php
Created October 26, 2015 22:08
A faster load_textdomain for WordPress
<?php
/*
Plugin Name: A faster load_textdomain
Version: 0.0.1
Description: While we're wating for https://core.trac.wordpress.org/ticket/32052.
Author: Per Soderlind
Author URI: https://soderlind.no
Plugin URI: https://gist.github.com/soderlind/610a9b24dbf95a678c3e
License: GPL