Skip to content

Instantly share code, notes, and snippets.

View wpsmith's full-sized avatar

Travis Smith wpsmith

View GitHub Profile
@wpsmith
wpsmith / PHP composer tools.md
Created February 27, 2019 23:55 — forked from davebarnwell/PHP composer tools.md
Global installation of PHP tools with Composer

Global installation of PHP tools with Composer

To install a composer package globally, you run the usual require command, but with the addition of the global modifier. So to install PHPUnit, you would run:

$ composer global require phpunit/phpunit
$ composer global require phpunit/dbunit
$ composer global require phing/phing
$ composer global require phpdocumentor/phpdocumentor
$ composer global require sebastian/phpcpd
@wpsmith
wpsmith / .bowerrc
Created January 30, 2019 01:51
BowerRC with ignored WP core JS files
{
"directory": "assets/",
"ignoredDependencies": [
"babel-polyfill",
"backbone",
"element-closest",
"formdata-polyfill",
"imagesloaded",
"jquery",
"jquery-color",
@wpsmith
wpsmith / android-ios-example.html
Created January 28, 2019 22:22
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
<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 October 11, 2022 21:42
PHP: Hide User Mu-Plugin
{
"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 July 13, 2021 15:42
WordPress: Rewrite Tutorial
{
"name": "wpsmith/post-type-taxonomy-rewrite",
"description": "Rewrite for {taxonomy}/{postname} rewrites.",
"type": "project",
"license": "GPLv2+",
"authors": [
{
"name": "Travis Smith",
"email": "t@wpsmith.net"
}
<?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 19:22
GraphQL Caching Problems
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 July 14, 2017 20:56
Getter and Setter
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 April 25, 2017 00:40
Canonical URL: Always add a trailing slash to the canonical URL.
<?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 April 25, 2017 00:39
Makes rewrite rules verbose. Helpful to have all the rewrite rules for some testing, especially with http://htaccess.mwl.be/
<?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;