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 / android-ios-example.html
Created Jan 28, 2019
AppPresser 3 Custom Page Example: How to target a specific platform(Android/iOS) example linking to either Google Maps on Android or Apple Maps on iOS
View android-ios-example.html
<div style="padding: 20px; font-size: 2rem;">
<strong>My Company Name</strong><br>
123 Main St<br>
City, ST 12345<br>
<br>
<div *ngIf=" this.platform.is('ios') "><a class="button" onclick="window.open('https://maps.apple.com/?daddr=123+Main+St,+City,+ST+12345', '_system'); return false;">Get Directions</a></div>
<div *ngIf=" !this.platform.is('ios') "><a class="button" onclick="window.open('https://maps.google.com/?daddr=123+Main+St,+City,+ST+12345', '_system'); return false;">Get Directions</a></div>
<br>
<br>
Phone: <a href="tel:+1-123-456-7890">(123) 456-7890</a><br>
@wpsmith
wpsmith / composer.json
Last active Jan 11, 2019
PHP: Hide User Mu-Plugin
View composer.json
{
"name": "wpsmith/hide-user",
"description": "Hides user in WordPress Admin.",
"type": "project",
"license": "GPLv2+",
"authors": [
{
"name": "Travis Smith",
"email": "t@wpsmith.net"
}
@wpsmith
wpsmith / composer-landing-pages.json
Last active Jan 5, 2019
WordPress: Rewrite Tutorial
View composer-landing-pages.json
{
"name": "wpsmith/post-type-taxonomy-rewrite",
"description": "Rewrite for {taxonomy}/{postname} rewrites.",
"type": "project",
"license": "GPLv2+",
"authors": [
{
"name": "Travis Smith",
"email": "t@wpsmith.net"
}
View wordpress-javascript-functions.php
<?php
/*
Using the native WordPress functions and Script Manager (`WP_Scripts`).
Functions include:
wp_register_script
wp_deregister_script
wp_enqueue_script
wp_dequeue_script
wp_add_inline_script
@wpsmith
wpsmith / base-post.graphql
Last active May 16, 2018
GraphQL Caching Problems
View base-post.graphql
query{
observations(geocode: "38.00,-97.00", unit: METRIC, locale: "en-US") {
temperature,
feelsLike,
snowDepth
},
astro(locId:"38.00,-97.00", language:"en-US", min:0, max:3) {
dateLocal,
sun {
riseSet {
@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": {
You can’t perform that action at this time.