Skip to content

Instantly share code, notes, and snippets.

Avatar

Nate Finch n8finch

View GitHub Profile
View wp-cli-subcommands-n8f-toptal.php
<?php
/**
* Plugin Name: TOPTAL WP-CLI Commands
* Version: 0.1
* Plugin URI: https://n8finch.com/
* Description: Some rando wp-cli commands to make life easier...
* Author: Nate Finch
* Author URI: https://n8finch.com/
* Text Domain: toptal-wpcli
* Domain Path: /languages/
View capital-p-test.php
function capital_P_dangit( $text ) {
// Simple replacement for titles.
$current_filter = current_filter();
if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) {
return str_replace( 'Wordpress', 'WordPress', $text );
}
// Still here? Use the more judicious replacement.
static $dblq = false;
if ( false === $dblq ) {
$dblq = _x( '&#8220;', 'opening curly double quote' );
View custom-git-commands.sh
#############################
# GIT STUFFS
#############################
alias gits="git status"
alias gita="git add ."
alias gitap="git add -p"
alias gitco="git checkout"
alias gitcop="git checkout @{-1}"
alias gitcob="git checkout -b"
alias gitmprev="git merge @{-1}"
@n8finch
n8finch / wp-strictly-mu-plugins-plugins-themes-gitignore
Last active Jun 26, 2021
This gitignore will ignore anything that isn't in mu-plugins, plugins, and themes directories of your wp-content directory.
View wp-strictly-mu-plugins-plugins-themes-gitignore
# Ignore everything in the root except the "wp-content" directory.
/*
!.gitignore
!wp-content/
# Ignore everything in the "wp-content" directory, except the "mu-plugins", "plugins", and "themes" directories.
wp-content/*
!wp-content/mu-plugins/
!wp-content/plugins/
!wp-content/themes/
@n8finch
n8finch / no-wp-core-gitignore
Created Dec 16, 2020
This is a gist for to ignore WordPress core files, and some other selected files.
View no-wp-core-gitignore
*~
.DS_Store
.svn
.cvs
*.bak
*.swp
Thumbs.db
# wordpress specific
wp-config.php
View my-first-bash-script-wp-cli.sh
#!/bin/bash
#Double-check you're ready to rock and roll with an update
read -r -p "Are you sure you want to update all specified directories? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
#Set the array of folders
DIRECTORIES=( 'wordpress-default' 'wordpress-develop' );
@n8finch
n8finch / vsc-settings.json
Created Jul 24, 2018
Visual Studio Code settings
View vsc-settings.json
{
"workbench.startupEditor": "newUntitledFile",
"editor.fontSize": 15,
"editor.wordWrap": "on",
"editor.minimap.enabled": false,
"workbench.colorTheme": "Atom One Dark",
"workbench.colorCustomizations": {
"editor.background": "#000000",
"sideBar.background": "#000000",
View XHR-for-OLO.js
/**
* Get the Deliver store
* @param {[type]} theLocation [description]
* @return {[type]} Only one store location will be returned.
*/
const getTheDeliveryStore = function( theLocation ) {
var data = null;
var xhr = new XMLHttpRequest();
@n8finch
n8finch / replace_concat.sql
Created May 10, 2017
some incomplete SQL scripts.
View replace_concat.sql
SELECT
wp_redirection_items.*,
wp_redirection_groups.position AS group_pos
FROM wp_redirection_items
INNER JOIN wp_redirection_groups ON
wp_redirection_groups.id=wp_redirection_items.group_id
AND wp_redirection_groups.status='enabled'
AND wp_redirection_groups.module_id RLIKE 'd'
WHERE (wp_redirection_items.regex=1 OR wp_redirection_items.url RLIKE '\/$')
@n8finch
n8finch / insert_join_redirection.sql
Created May 10, 2017
the following SQL would duplicate the redirects that end with '/', making a copy without a slash.
View insert_join_redirection.sql
INSERT INTO wp_redirection_items(
`url`,
`regex`,
`position`,
`last_count`,
`last_access`,
`group_id`,
`status`,
`action_type`,
`action_code`,