Skip to content

Instantly share code, notes, and snippets.

Nate Finch n8finch

Block or report user

Report or block n8finch

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
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 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`,
@n8finch
n8finch / sql_query_examples.sql
Last active Apr 20, 2017
SQL query samples.
View sql_query_examples.sql
SELECT meta_key, meta_value
FROM wp_postmeta
WHERE meta_key = "issue_id"
But I need to only do posts with a category of
UPDATE wp_postmeta SET meta_value = '0' WHERE meta_value = '1';
View update_in_sql.sql
UPDATE wp_postmeta AS a
JOIN wp_term_relationships AS b
ON a.post_id=b.object_id
SET meta_value=0
WHERE term_taxonomy_id = 9 AND meta_key = 'issue_id' AND meta_value != 0;
View select_in_sql.sql
SELECT wp_term_relationships.term_taxonomy_id, wp_term_relationships.object_id, wp_postmeta.post_id, wp_postmeta.meta_key, wp_postmeta.meta_value
FROM wp_term_relationships
JOIN wp_postmeta
ON wp_postmeta.post_id=wp_term_relationships.object_id
WHERE term_taxonomy_id = 9 AND meta_key = 'issue_id' AND meta_value != 0;
View simple_sql_select.sql
SELECT object_id, term_taxonomy_id
FROM wp_term_relationships
WHERE term_taxonomy_id = 9;
You can’t perform that action at this time.