Skip to content

Instantly share code, notes, and snippets.

Avatar

Travis Smith wpsmith

View GitHub Profile
@wpsmith
wpsmith / mac.sh
Last active Sep 18, 2020
Chrome: Disable Guest and Incognito
View mac.sh
#!/bin/sh
defaults write com.google.Chrome BrowserGuestModeEnabled -bool false
defaults write com.google.chrome IncognitoModeAvailability -integer 1
@wpsmith
wpsmith / allow-uptime-robot.js
Created Aug 30, 2020
Allow Uptime Robot in Cloudflare
View allow-uptime-robot.js
(ip.src eq 216.144.250.150) or (ip.src eq 69.162.124.226) or (ip.src eq 69.162.124.227) or (ip.src eq 69.162.124.228) or (ip.src eq 69.162.124.229) or (ip.src eq 69.162.124.230) or (ip.src eq 69.162.124.231) or (ip.src eq 69.162.124.232) or (ip.src eq 69.162.124.233) or (ip.src eq 69.162.124.234) or (ip.src eq 69.162.124.235) or (ip.src eq 69.162.124.236) or (ip.src eq 69.162.124.237) or (ip.src eq 69.162.124.238) or (ip.src eq 63.143.42.242) or (ip.src eq 63.143.42.243) or (ip.src eq 63.143.42.244) or (ip.src eq 63.143.42.245) or (ip.src eq 63.143.42.246) or (ip.src eq 63.143.42.247) or (ip.src eq 63.143.42.248) or (ip.src eq 63.143.42.249) or (ip.src eq 63.143.42.250) or (ip.src eq 63.143.42.251) or (ip.src eq 63.143.42.252) or (ip.src eq 63.143.42.253) or (ip.src eq 216.245.221.82) or (ip.src eq 216.245.221.83) or (ip.src eq 216.245.221.84) or (ip.src eq 216.245.221.85) or (ip.src eq 216.245.221.86) or (ip.src eq 216.245.221.87) or (ip.src eq 216.245.221.88) or (ip.src eq 216.245.221.89) or (ip.src eq 216.
@wpsmith
wpsmith / add_keys.sh
Created Aug 24, 2020
Shell: Adds ssh keys to ssh agent.
View add_keys.sh
#!/usr/bin/env bash
function ssh-keys () {
if ssh-add -l | grep -q "$1"; then
echo "$1 key is ready"
else
/usr/bin/expect -c "
spawn /usr/bin/ssh-add $1;
expect 'Enter passphrase';
send $2\r;
@wpsmith
wpsmith / ssh_read_pass.sh
Created Aug 24, 2020
Shell: Reads a passcode.
View ssh_read_pass.sh
#!/bin/bash
if [ $# -ne 2 ] ; then
echo "Usage: ssh-add-pass keyfile passfile"
exit 1
fi
eval $(ssh-agent)
pass=$(cat $2)
@wpsmith
wpsmith / .phpcs.theme.xml.dist
Created Aug 24, 2020
PHP: PHPCS for a WordPress theme.
View .phpcs.theme.xml.dist
<?xml version="1.0"?>
<ruleset name="WPS">
<description>Generally-applicable sniffs for WordPress plugins.</description>
<!-- What to scan -->
<file>.</file>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/node_modules/</exclude-pattern>
<!-- How to scan -->
@wpsmith
wpsmith / .phpcs.plugin.xml.dist
Created Aug 24, 2020
PHP: PHPCS for a WordPress plugin.
View .phpcs.plugin.xml.dist
<?xml version="1.0"?>
<ruleset name="WPS">
<description>Generally-applicable sniffs for WordPress plugins.</description>
<!-- What to scan -->
<file>.</file>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/node_modules/</exclude-pattern>
<!-- How to scan -->
@wpsmith
wpsmith / auto-update-plugins.php
Created Aug 21, 2020
WP: Auto-update whitelisted set of plugins.
View auto-update-plugins.php
<?php
add_filter( 'auto_update_plugin', 'wps_auto_update_specific_plugins', 10, 2 );
function wps_auto_update_specific_plugins ( $update, $item ) {
// Array of plugin slugs to always auto-update
$plugins = array (
'akismet',
'enhanced-media-library',
'duplicate-page',
);
View functions-disable-cart-fragments-except-shop.php
<?php
add_action( 'wp_enqueue_scripts', 'prefix_dequeue_all_woocommerce_styles_scripts_non_shop_pages', PHP_INT_MAX );
/**
* Disable all WooCommerce styles and scripts everywhere except WooCommerce pages.
*/
function prefix_dequeue_all_woocommerce_styles_scripts_non_shop_pages() {
if ( function_exists( 'is_woocommerce' ) ) {
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
// Styles
View get-refreshed-fragments-example-1.html
<div class="widget_shopping_cart_content">
<ul class="woocommerce-mini-cart cart_list product_list_widget">
<li class="woocommerce-mini-cart-item mini_cart_item">
<a aria-label="Remove this item" class="remove remove_from_cart_button" data-cart_item_key="abcdef12345some00hash67890uvwxyz" data-product_id="9999" data-product_sku="GRA000010" href="https://example.com?remove_item=abcdef12345some00hash67890uvwxyz&#038;_wpnonce=f5e62f5167">&times;</a> <a href="https://example.com/product/some-product"><img alt="" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail" height="300" sizes="(max-width: 300px) 100vw, 300px" src="https://assets.example.com/shop/YYYY/MM/####/some-image-300x300.jpg" srcset="https://assets.example.com/shop/YYYY/MM/####/some-image-300x300.jpg 300w, https://assets.example.com/shop/YYYY/MM/####/some-image-150x150.jpg 150w, https://assets.example.com/shop/YYYY/MM/####/some-image-180x180.jpg 180w, https://assets.example.com/shop/YYYY/MM/####/some-image-600x600.jpg 600w,
View wp-doctor-plugin-status.log
Running checks 100% [===================================================================================] 0:00 / 0:00
+----------------------------------------------------+---------+-----------------------------------------------------+
| name | status | message |
+----------------------------------------------------+---------+-----------------------------------------------------+
| adminer-uninstalled | success | Plugin 'adminer' is 'uninstalled' as expected. |
| async-google-analytics-uninstalled | success | Plugin 'async-google-analytics' is 'uninstalled' as |
| | | expected. |
| backup-uninstalled | success | Plugin 'backup' is 'uninstalled' as expected. |
| backup-scheduler-uninstalled | success | Plugin
You can’t perform that action at this time.