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 / s3Upload.sh
Created Jun 18, 2019
SH: Uploads file to IBM Cloud Object Storage (US Standard)
View s3Upload.sh
#!/usr/bin/env bash
# Set AWS credentials and S3 paramters
S3_KEY="YOUR_KEY_GOES_HERE"
S3_SECRET="YOUR_SECRET_GOES_HERE"
S3_BUCKET="YOUR_BUCKET_NAME_GOES_HERE"
S3_BUCKET_PATH="/"
S3_ACL="x-amz-acl:public-read"
S3_URL="https://s3.us.cloud-object-storage.appdomain.cloud/"
@wpsmith
wpsmith / is_rest.php
Last active Jun 4, 2019
PHP: Determines whether the request is a WordPress API request.
View is_rest.php
<?php
/**
* Determines whether the current request is a RESTful request.
*
* @return bool
*/
function is_rest() {
return (
( defined( 'REST_REQUEST' ) && REST_REQUEST ) ||
@wpsmith
wpsmith / composer.json
Created May 5, 2019
CMB Autoloading with Composer
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 / PHP composer tools.md
Created Feb 27, 2019 — forked from davebarnwell/PHP composer tools.md
Global installation of PHP tools with Composer
View PHP composer tools.md

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 Jan 30, 2019
BowerRC with ignored WP core JS files
View .bowerrc
{
"directory": "assets/",
"ignoredDependencies": [
"babel-polyfill",
"backbone",
"element-closest",
"formdata-polyfill",
"imagesloaded",
"jquery",
"jquery-color",
@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 {
You can’t perform that action at this time.