Skip to content

Instantly share code, notes, and snippets.

View martinbkaiser's full-sized avatar

Martin Kaiser martinbkaiser

View GitHub Profile
@martinbkaiser
martinbkaiser / add-gtm-wp.php
Last active May 5, 2020 22:24 — forked from jsn789/add-gtm-wp.php
Add Google Tag Manager through functions.php in WordPress
/* Add Google Tag Manager javascript code as close to
the opening <head> tag as possible
=====================================================*/
function add_gtm_head(){ ?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXX');</script>
@martinbkaiser
martinbkaiser / epanel-integration-body.html
Last active April 22, 2020 17:46 — forked from lots0logs/epanel-integration-body.html
WordPress :: HTML5 Videos :: Pause on last frame
<script>
(function($) {
$(document).ready(function() {
var $videos = $('.play_once video');
$videos.each(function() {
var $video = $(this)[0];
$video.removeAttr('loop');
@martinbkaiser
martinbkaiser / my_pmpro_getfile.php
Last active April 2, 2019 22:39 — forked from ideadude/my_pmpro_getfile.php
How to protect non-WordPress files in a subdirectory of your site using Paid Memberships Pro.
<?php
/*
This code handles loading a file from the /protected-directory/ directory.
(!) Be sure to change line 44 below to point to your protected directory if something other than /protected/
(!) Be sure to change line 64 below to check the levels you need.
(!) Add this code to your active theme's functions.php or a custom plugin.
(!) You should have a corresponding bit of code in your Apache .htaccess file to redirect files to this script. e.g.
###