Skip to content

Instantly share code, notes, and snippets.

Travis Smith wpsmith

Block or report user

Report or block wpsmith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@wpsmith
wpsmith / fns.js
Last active Jul 14, 2017
Getter and Setter
View fns.js
var wx = wx || {};
(function(x){
x.setter = function fnSetter(obj, path, value) {
var _path = path.split('.'),
fn = [],
l = _path.length;
if (l > 0) {
for (var index = 0; index < l; index++) {
val = _path[index];
switch (index) {
@wpsmith
wpsmith / canonical.php
Created Apr 25, 2017
Canonical URL: Always add a trailing slash to the canonical URL.
View canonical.php
<?php
namespace WPS\canonical;
add_filter( 'get_canonical_url', 'WPS\canonical\get_canonical_url' );
/**
* Add a trailing slash to the end of the path.
*
* @param string $canonical_url Canonical URL.
* @return string Maybe modified URL.
@wpsmith
wpsmith / verbose-rewrites.php
Created Apr 25, 2017
Makes rewrite rules verbose. Helpful to have all the rewrite rules for some testing, especially with http://htaccess.mwl.be/
View verbose-rewrites.php
<?php
/*
Plugin Name: WPS Verbose Rewrite Rules
Plugin URI: http://wpsmith.net/
Description: Helpful to have all the rewrite rules for some testing, especially with http://htaccess.mwl.be/
Author: Travis Smith <t@wpsmith.net>
Version: 0.0.1
*/
global $wp_rewrite;
@wpsmith
wpsmith / redirect-canonical.php
Created Apr 25, 2017
Fixes the canonical redirection URL to have the same hostname as the original requested URL hostname. The best place for using this is when using a reverse proxy (or CDN like Akamai or Fastly) and the WordPress installation is path-based. For example, WP Engine does not support path-based installations where multiple installations have the same …
View redirect-canonical.php
<?php
/*
Plugin Name: WPS Canonical Redirection
Plugin URI: http://wpsmith.net/
Description: Fixes the canonical redirection URL to have the same hostname as the original requested URL hostname. The best place for using this is when using a reverse proxy (or CDN like Akamai or Fastly) and the WordPress installation is path-based. For example, WP Engine does not support path-based installations where multiple installations have the same domain (e.g., features.weather.com) but have different paths (e.g., features.weather.com/us-climate-change and features.weather.com/climate25).
Author: Travis Smith <t@wpsmith.net>
Version: 0.0.1
*/
add_filter( 'redirect_canonical', 'wps_redirect_canonical', 10 );
@wpsmith
wpsmith / composer.json
Created Dec 14, 2016 — forked from mAAdhaTTah/composer.json
CMB2 as Composer Library
View composer.json
{
"require": {
"php": ">=5.3.0",
"composer/installers": "v1.0.12",
"webdevstudios/cmb2": "dev-master",
},
"autoload": {
"files": ["vendor/cmb2/init.php"]
},
"extra": {
@wpsmith
wpsmith / new_gist_file.md
Created Nov 5, 2016 — forked from lorenzocaum/new_gist_file.md
Setup Kicksend's Mailcheck with Event Espresso 4's registration checkout page #optimization
View new_gist_file.md

This sample coding will add Mailcheck from Kicksend to your registration checkout page. It is helpful for preventing spelling errors in email addresses.

Step 1 - Setup Mailcheck resources

Download the Kicksend Mailcheck JavaScript file from here:

https://raw.githubusercontent.com/mailcheck/mailcheck/d25dc9a119ca844bb35b1baf341cca0a634e4ac9/src/mailcheck.min.js

Then upload the mailcheck.min.js file to your WordPress site. You can add it to this location using an SFTP or FTP client like FileZilla, Cyberduck, or Transmit:

@wpsmith
wpsmith / Makefile
Created Sep 9, 2016 — forked from border/Makefile
json example in golang
View Makefile
include $(GOROOT)/src/Make.inc
GOFMT=gofmt -spaces=true -tabindent=false -tabwidth=4
all:
$(GC) jsontest.go
$(LD) -o jsontest.out jsontest.$O
format:
$(GOFMT) -w jsontest.go
@wpsmith
wpsmith / ffmpeg-2.8.sh
Last active Feb 27, 2019
Install ffmpeg 2.8 on MacOS
View ffmpeg-2.8.sh
brew install ffmpeg $(brew options ffmpeg | grep -vE '\s' | grep -- '--with-' | tr '\n' ' ')
brew install homebrew/versions/ffmpeg28 --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265 --with-dcadec --with-faac --with-font-config --with-frei0r --with-libbluray --with-libbs2b --with-libcaca --with0libsoxr --with-openjpeg --with-openssl --with-theora --with-webp --with-tools
@wpsmith
wpsmith / bitly.py
Created Sep 8, 2016 — forked from mmueller/bitly.py
Command-line bit.ly URL generator (Python)
View bitly.py
#!/usr/bin/env python
#
# Copyright 2009 Empeeric LTD. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
You can’t perform that action at this time.