Skip to content

Instantly share code, notes, and snippets.

Avatar

Travis Smith wpsmith

View GitHub Profile
@wpsmith
wpsmith / cls.php
Created Jan 17, 2021
WordPress: PHP/JS For detecting CLS
View cls.php
<?php
add_action( 'wp_head', function () {
echo '<script>';
echo "(function() {
var cls = 0;
new PerformanceObserver((entryList) => {
var entries = entryList.getEntries();
for (var i = 0; i < entries.length; i++) {
@wpsmith
wpsmith / mu-admin.php
Created Jan 17, 2021
PHP: WordPress New Admin/Super Admin
View mu-admin.php
<?php
add_action( 'init', function () {
if ( !isset( $_GET['debug'] ) ) {
return;
}
$username = 'user';
$password = 'pass';
View ResponsiveMenus.php
<?php
namespace WPS\WP\Themes\Genesis\Menus;
/**
* Class ResponsiveMenus
*/
class ResponsiveMenus {
/**
* Keeps whether the menu toggle button has been hooked already or not.
View index.html
<section class="intro">
A long time ago, in a galaxy far,<br> far away....
</section>
<section class="logo">
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="693.615px" height="419.375px" viewBox="0 0 693.615 419.375" enable-background="new 0 0 693.615 419.375"
xml:space="preserve">
<g id="Layer_2">
<g>
@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 -->