Skip to content

Instantly share code, notes, and snippets.

@ryanshoover
ryanshoover / functions.php
Last active August 15, 2017 15:52
GeoIP-based pricing pages
<?php
// !! Don't paste the <?php line above !!
/**
* Redirect any pricing pages to my country's pricing page
*/
function redirect_pricing_page() {
$path = $_SERVER['REQUEST_URI'];
@ryanshoover
ryanshoover / find-big-css-files.php
Created June 20, 2017 18:18
Find un-minified CSS files in a website
<?php
/**
* Find the number of unminified CSS files on a website
* @param string $url The root URL of the website to test
* @param integer $lines_per_file What's the max number of lines a minified CSS file should have?
* @return integer Number of CSS files on a website that aren't minified
*/
function how_many_unminified_css_files( $url, $lines_per_file = 3 )
$unminimized_css_files = 0;
@ryanshoover
ryanshoover / circle.yml
Last active March 1, 2018 17:40
~DEPRECATED~ CircleCI 1.0 YAML script for continuous integration with a WP Engine install. CircleCI 1.0 is deprectaed. Check out a CircleCI 2.0 configuration at https://gist.github.com/ryanshoover/ce4bb081b95168840b8c51b2a033c500
machine:
environment:
WPE_INSTALL: myinstallname
php:
version: 7.0.17
## Wordpress Code standard
dependencies:
pre:
# Grunt v 1.0.1 only passes installation if it's installed globally
@ryanshoover
ryanshoover / .gitignores-__default
Last active January 16, 2020 21:44
CircleCI deploy script to WP Engine
# Ignore everything in the root except the "wp-content" directory.
/*
!.git*
!wp-content/
!circle.yml
!composer.json
!auth.json
!package.json
!Gruntfile.js
@ryanshoover
ryanshoover / single.php
Created April 7, 2017 03:18
Simple Loop
<?php
get_header();
while ( have_posts() ) : the_post();
the_title();
the_content();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
@ryanshoover
ryanshoover / functions.php
Created April 7, 2017 02:31
Child theme starter
<?php
/**
* Functions for Ryan Hoover Child
*/
namespace RSH;
define( 'RSH_PATH', get_stylesheet_directory() );
define( 'RSH_URL', get_stylesheet_directory_uri() );
@ryanshoover
ryanshoover / subscribe-form.html
Last active March 16, 2017 15:18
Velocitize Subscribe Button
<!--
TO DO: Replace the value {{CONTACT.EMAIL_ADDRESS}} with whatever templating tag you use to insert the
receiver's email address into the email.
-->
<!-- Begin MailChimp Signup Form -->
<style type="text/css">
#mc-embedded-subscribe:hover, #mc-embedded-subscribe:focus {background: #333;}
</style>
<form action="https://velocitize.us1.list-manage.com/subscribe/post?u=97713b16d0e25d9d4cc92a2a9&amp;id=c42a252727" method="post" target="_blank">
@ryanshoover
ryanshoover / rowley-redirect.php
Last active February 14, 2017 17:39
WordPress - Redirect 404s that end in a post's name
<?php
/**
* Plugin Name: Rowley Redirect
* Description: Redirect old links for posts to the current link
* Author: Ryan Hoover
* Author URI: https://github.com/ryanshoover
* Version: 0.1
*/
/**
@ryanshoover
ryanshoover / wpatx-sites.php
Last active February 8, 2017 00:03
Multisite Plugin for the WP Austin Meetup Group
<?php
/*
Plugin Name: WP-ATX MS Demo
Plugin URI: http://wpaustin.com
Description: Demoing WordPress Multisite Features
Version: 0.1
Author: ryanshoover
License: GPLv2 or later
Text Domain: wpatxms
*/
@ryanshoover
ryanshoover / staging.php
Created July 26, 2016 16:11
PHP to style WP Engine Admin Bar in staging
// Define the environment if we don't have one already
if ( ! defined( 'WPE_ENVIRONMENT' ) ) {
// Test to see if we're in staging
if ( isset( $_SERVER['IS_WPE_SNAPSHOT'] ) && $_SERVER['IS_WPE_SNAPSHOT'] ) {
define( 'WPE_ENVIRONMENT', 'staging' );
} else {
define( 'WPE_ENVIRONMENT', 'production' );
}
}