View backups.sh
#!/bin/bash
#
# Back up my files and databases
#
#
# backup_static_if <fullpath> <shortname>
# use directory fingerprint to avoid unnecessary backups
#
View auto-update.md

Moved

Update core (and db), plugins, and themes, logging status to syslog. Ideal for running on a cronjob

Example of syslog

Apr 26 04:07:56 vvv vagrant: [WPAutoUpdate] Local WordPress Dev | http://local.wordpress.dev
Apr 26 04:08:27 vvv vagrant: [WPAutoUpdate] Core update: WordPress updated successfully to 4.5
Apr 26 04:08:28 vvv vagrant: [WPAutoUpdate] DB update: WordPress database already at latest db version 36686
View wp-excerpt-change.php
<?php
// Plugin Name: Example. Change "Excerpt" meta box heading
namespace KDL\excerpt_change;
function filter_excerpt( $translations, $text, $domain ) {
if ( $text == 'Excerpt' ) {
return "New Excerpt";
}
View tarball-select-uploads.md

create tarball of only end of 2015 and 2016

cd wp-content/uploads/sites/
find 5/ -regextype sed -regex ".*/\(2015/1\|2016\).*" | tar -czvf uploads.tar.gz --files-from -
View meta-to-term-cli.php
<?php
if ( !defined( 'WP_CLI' ) ) return;
/**
* Migrate meta values to terms
*
* @package wp-cli
*/
class Meta_To_Term_Migration extends WP_CLI_Command {
View toggle-debug.php
<?php
/*
Plugin Name: Toggle Debug
Description: Proof-of-concept for an admin-bar debug mode toggle. Needs some UX love.
*/
/*
// In wp-config.php, wrap debug constants in a cookie conditional
if ( isset( $_COOKIE['wp-debug'] ) && $_COOKIE['wp-debug'] == 'on' ) {
define('WP_DEBUG', true);
}
View nginx-proxy
# map block must be outside the server{} block
map $host $productionurl {
default mainsite.com;
## uncomment for multisite
# subsite.dev subsite.com;
# subsite2.dev subsite2.com;
# subsite3.dev subsite3.com;
}
View joomla-k2.php
<?php
/*
// "K2 Tools" Module by JoomlaWorks for Joomla! 1.5.x - Version 2.1
// Copyright (c) 2006 - 2009 JoomlaWorks Ltd. All rights reserved.
// Released under the GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
// More info at http://www.joomlaworks.gr and http://k2.joomlaworks.gr
// Designed and developed by the JoomlaWorks team
// *** Last update: September 9th, 2009 ***
*/
//*****/
View create-encrypted-zip.sh
# goes in my .bash_profile so I can quickly zip files/directories with encryption
# (remove or replace `pbcopy/pbpaste` as needed for your system)
# > pzip [file/directory]
function pzip {
head -n5 /dev/urandom | shasum | awk '{print $1}' | tr -d '\n' | pbcopy
output=${1%/} #trim trailing slash
output=${output%.*} #trim file extension
echo -e "Making \033[32m$output.zip\033[0m from $1"
zip -qrP "$(pbpaste)" $output $1;
View gist:0c4aeaec7d730b248dd6
# generating a list of 50 post permalinks
for pid in $(wp post list --field=ID --posts_per_page=50); do wp eval "echo get_the_permalink( $pid ).\"\n\"; "; done > url.txt
# posts and pages
for pid in $(wp post list --field=ID --posts_per_page=50 --post_type=post,page); do wp eval "echo get_the_permalink( $pid ).\"\n\"; "; done > url.txt
# random sample
for pid in $(wp post list --field=ID --posts_per_page=50 --post_type=post,page --orderby=rand); do wp eval "echo get_the_permalink( $pid ).\"\n\"; "; done > url.txt