Skip to content

Instantly share code, notes, and snippets.

View martinbkaiser's full-sized avatar

Martin Kaiser martinbkaiser

View GitHub Profile
@martinbkaiser
martinbkaiser / geUserData.php
Last active April 18, 2019 04:26
HTML/CSS/JavaScript Developer Console Animation with Menu Hover Responses
<?php
// Get user name and/or IP
function get_user_data_processing_function(){
$name = [];
// Sanitize $_GET parameters to avoid XSS and other attacks
$urlName = preg_replace('/[^-a-zA-Z0-9_]/', '', $_GET['n']);
if($urlName){
// Get user name from URL variable
$name['name'] = $urlName;
}
@martinbkaiser
martinbkaiser / particle-network-optimized.js
Created March 27, 2019 01:57
Optimized Particle Network
// Martins Super Amazing Optimized Particle Network
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
(function(factory) {
// Establish the root object, `window` in the browser, or `global` on the server.
var root = (typeof self === 'object' && self.self === self && self) || (typeof global === 'object' && global.global === global && global);
@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.
###
@martinbkaiser
martinbkaiser / image_cycler.js
Last active April 6, 2019 23:15
Javascript and jQuery script for creating a animation out of Media Encoder image sequence exports
$(function() {
// Main function for creatng the animation loop
function createImgAnimation(imgInfo){
// Pad zero's for Adobe Media Encoder output filenames
Number.prototype.pad = function(size) {
var s = String(this);
while (s.length < (size || 2)) {s = "0" + s;}
return s;
}
@martinbkaiser
martinbkaiser / gravity-forms-profanity.php
Created November 9, 2019 00:41
Gravity Forms Profanity Filter/Detector
// Put in your themes functions.php file
add_filter( 'gform_pre_send_email', 'before_email', 10, 3);
function before_email( $email, $form, $entry ) {
// Add your own words to the array, or convert a CSV like I did
$swear_array = ['very','bad','language','word','array'];
$swear_alert = "";
$email_message = strval(strip_tags($email['message']));
foreach ($swear_array as $swear) {
if (preg_match("/\b".$swear."\b/i", $email_message)) {
@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 / 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>