Skip to content

Instantly share code, notes, and snippets.

View phillip-boombox's full-sized avatar

Phillip Dodson phillip-boombox

View GitHub Profile
@phillip-boombox
phillip-boombox / gist:6f23fc6b491de7a4cc02826a50ef4ed7
Last active September 18, 2017 22:56
PHP DOMDocument manipulation sample
// Create new DOMDocument
$cmb2_mb = new DOMDocument();
// Load cmb2 metabox html string into document
$cmb2_mb->loadHTML( $form, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD );
// Add bootstrap classes to all labels
foreach ( $cmb2_mb->getElementsByTagName( 'label' ) as $node_label ) {
$node_label->setAttribute( 'class', 'control-label' );
}
@phillip-boombox
phillip-boombox / .htaccess
Created January 23, 2017 23:28
Force SSL in .htaccess for WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Force SSL
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
@phillip-boombox
phillip-boombox / gist:48ce1cef05ca1414b20adb90b8f85c3a
Created January 19, 2017 20:46
Terminal command to download and unpack WordPress
wget http://wordpress.org/latest.tar.gz && tar xfz latest.tar.gz && mv wordpress/* ./ && rmdir ./wordpress/ && rm -f latest.tar.gz
@phillip-boombox
phillip-boombox / export-mysql.sh
Last active January 19, 2017 20:39
A BASH script to export all MySQL databases to individual files and another to import the files back to MySQL. Adapted from http://stackoverflow.com/a/26096339/3299349 and https://gist.github.com/tenold/aa5e107d93c0f54436cb
#!/bin/bash
USER="root"
ExcludeDatabases="Database|information_schema|performance_schema|mysql"
databases=`mysql -u $USER -e "SHOW DATABASES;" | tr -d "| " | egrep -v $ExcludeDatabases`
for db in $databases; do
echo "Dumping database: $db"
mysqldump -u $USER --databases $db > `date +%Y%m%d`.$db.sql