Skip to content

Instantly share code, notes, and snippets.

View phillip-boombox's full-sized avatar

Phillip Dodson phillip-boombox

View GitHub Profile
$ dig yourdomain.com ANY @8.8.8.8
@phillip-boombox
phillip-boombox / .htaccess
Created February 5, 2020 18:27
Download images from remote WordPress website
# Pull images from remote site instead of local
# only if file requested is from the uploads folder
# and if the file does not exist locally
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ https://SOMESITE.com/$1 [QSA,L]
@phillip-boombox
phillip-boombox / img2datauri.sh
Last active August 5, 2019 17:42
Convert an image to base64 data URI that's then copied to the clipboard.
#!/bin/bash
# Create a base64 data URI from an image and copy it to clipboard.
# Uses OpenSSL to create the base64 representation.
the_mimetype=$(file -bN --mime-type "$1")
the_content=$(openssl base64 < "$1" | tr -d '\n')
# Use printf instead of echo to avoid the ending newline
printf "data:$the_mimetype;base64,$the_content" | pbcopy
@phillip-boombox
phillip-boombox / mp4-to-sprite-sheet
Last active July 25, 2019 00:13
Create a sprite sheet in the terminal using FFmpeg and ImageMagick
ffmpeg -i video.mp4 %04d.png && montage -geometry $(identify -format '%wx%h' $(ls | sort | head -1)) -tile 8x *.png sprite.jpg && echo $(ls *.png | wc -l) "frames" && rm *.png
@phillip-boombox
phillip-boombox / full_backup.sh
Created June 27, 2018 18:04
BASH script to make a backup of website files and the database. Useful as a CRON script.
#!/bin/bash
# This script creates a compressed backup archive of the given directory and the given MySQL table. More details on implementation here: http://theme.fm
# Feel free to use this script wherever you want, however you want. We produce open source, GPLv2 licensed stuff.
# Author: Konstantin Kovshenin exclusively for Theme.fm in June, 2011
# Original link: https://theme.fm/a-shell-script-for-a-complete-wordpress-backup/
# Set the date format, filename and the directories where your backup files will be placed and which directory will be archived.
NOW=$(date +"%Y-%m-%d-%H%M")
@phillip-boombox
phillip-boombox / wp-functions-help-tab.php
Last active December 12, 2017 21:50
WordPress: Add a help tab to an admin screen.
<?php
/**
* Add a help tab to the new/edit post screen.
* Action: admin_head-post.php, admin_head-post-new.php
*/
function cmfy_add_gumbo_help_tab() {
// Get the WP_Screen object
$screen = get_current_screen();
// Adjust / remove this conditional depending on which hook you're firing on
@phillip-boombox
phillip-boombox / wp-functions-featured-image-help.php
Last active April 22, 2023 02:51
WordPress: Add help text to the featured image metabox.
@phillip-boombox
phillip-boombox / wp-functions-excerpt-character-count.php
Last active December 13, 2017 18:52
WordPress: Add a character counter to post excerpts in admin.
<?php
/**
* Add a character counter to post excerpts in WordPress admin.
* Action: admin_head-post.php, admin_head-post-new.php
* Inspired by @link: https://premium.wpmudev.org/blog/character-counter-excerpt-box/
*/
function cmfy_excerpt_character_counter() {
// If post type does not support excerpt, do nothing
if ( ! post_type_supports( get_post_type(), 'excerpt' ) ) {
return;
@phillip-boombox
phillip-boombox / wp-functions-custom-colors.php
Last active September 27, 2021 22:55
WordPress: Customize TinyMCE text color picker.
<?php
// Custom theme colors
$cmfy_custom_colors = array(
'14bed2' => __( 'Primary blue', 'cmfy' ),
'cadd69' => __( 'Primary green', 'cmfy' ),
'70736f' => __( 'Primary gray', 'cmfy' ),
'f26722' => __( 'Secondary orange', 'cmfy' ),
'fdbb4a' => __( 'Secondary yellow', 'cmfy' ),
);
@phillip-boombox
phillip-boombox / functions.php
Last active June 5, 2021 19:36
WordPress: Required plugins from the plugins repository
add_filter( 'install_plugins_tabs', 'cmfy_required_plugins_tab' );
function cmfy_required_plugins_tab( $tabs ) {
$tabs['cmfy'] = _x( 'Required', 'Plugin Installer', 'cmfy' );
return $tabs;
}
add_action( 'install_plugins_cmfy', 'cmfy_required_plugins_page' );
function cmfy_required_plugins_page() {
$required_plugin_slugs = array(
'cmb2',