Skip to content

Instantly share code, notes, and snippets.

@ryanshoover
ryanshoover / functions.php
Created February 2, 2018 16:32
WP Engine GeoIP - Remove slashed apostrophes
<?php
/**
* Filters the WP Engine GeoIP location names.
* Removes any slashes in the names.
*
* @param array $geos GeoIP-identified location names.
* @return array GeoIP-identified location names without slashes.
*/
function myprefix_remove_geoip_slashes( $geos ) {
return wp_unslash( $geos );
@ryanshoover
ryanshoover / calc-revenue-diff.php
Created April 9, 2018 18:59
Calculate revenue difference for a faster site
<?php
/**
* Calculate the difference in revenue I should experience
* if my load time changes.
*
* Based on the assumption that every second of page load
* causes a 7% drop in conversions.
*
* Formula in LaTex: [ R = \frac{ R_p }{ {e}^{\ln(0.93) T_p} }\ e^{\ln(0.93) T_c} - R_p ]
*

Keybase proof

I hereby claim:

  • I am ryanshoover on github.
  • I am ryanshoover (https://keybase.io/ryanshoover) on keybase.
  • I have a public key ASAk-byUVD79TFYZjWC5VHJYjQK3xCAXqTHToUeWXW_SCgo

To claim this, I am signing this object:

@ryanshoover
ryanshoover / show-templates.php
Created August 16, 2018 21:18
Plugin to add the page template to the Pages admin
<?php
/**
* Show Page Templates
*
* @package show-page-templates
* @author ryanshoover
* @license Proprietary
*
* @wordpress-plugin
* Plugin Name: Show Page Templates
@ryanshoover
ryanshoover / bill-wizard-trailing-slash.php
Created August 28, 2018 18:13
WP Plugin - stop removing trailing slash
<?php
/**
* The Bill Wizard Trailing Slash Fix
*
* @package bill-wizard-trailing-slash
* @author wpengine
* @license Proprietary
*
* @wordpress-plugin
* Plugin Name: The Bill Wizard Trailing Slash Fix
diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php
index 9460c80ca6..dd7306e1c2 100644
--- a/wp-admin/custom-header.php
+++ b/wp-admin/custom-header.php
@@ -1461,12 +1461,10 @@ endif;
public function get_uploaded_header_images() {
$header_images = get_uploaded_header_images();
$timestamp_key = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
- $alt_text_key = '_wp_attachment_image_alt';
@ryanshoover
ryanshoover / wpengine-stop-htaccess-rewrites.php
Created February 4, 2019 20:02
WP Plugin Stop htaccess rewrites
<?php
/**
* Stop htaccess rewrites
*
* @package wpengine-stop-htaccess-rewrites
* @author wpengine
* @license Proprietary
*
* @wordpress-muplugin
* Plugin Name: Stop htaccess rewrites
@ryanshoover
ryanshoover / tiles.html
Created June 21, 2019 02:32
Tile testing html
<div class="tiles tiles--two-per-row">
<div class="tile">
<div class="tile__photo">
<img src="https://picsum.photos/id/344/1440/900" class="tile__photo__image">
</div>
<h3 class="tile__title tile_title--small">Beef enim hamburger, doner</h3>
<p class="tile__description">
salami cupidatat ipsum deserunt. Corned beef prosciutto esse eiusmod short loin sausage ut jowl ipsum
cupidatat. Flank meatball pariatur fugiat meatloaf beef. Pork chop turkey jerky, in nostrud in non
consectetur turducken shoulder pig esse cow eu.
@ryanshoover
ryanshoover / Before In Location
Created August 5, 2019 19:53
Server-side A/B testing with NGINX & Varnish (WP Engine)
add_header Set-Cookie "my_test_group=$test_group;Domain=.mydomain.com;Path=/;Max-Age=604800";
@ryanshoover
ryanshoover / demandbase.js
Created June 16, 2020 01:49
Unminified Demandbase
"use strict";
"undefined" == typeof window.console && (window.console = { log: function () {}, debug: function () {} });
"undefined" == typeof JSON && (JSON = { stringify: function () {}, parse: function () {} });
Array.prototype.indexOf ||
(Array.prototype.indexOf = function (e) {
var t = this.length >>> 0,
n = Number(arguments[1]) || 0;
n = 0 > n ? Math.ceil(n) : Math.floor(n);
0 > n && (n += t);
for (; t > n; n++) if (n in this && this[n] === e) return n;