Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View westonruter's full-sized avatar

Weston Ruter westonruter

View GitHub Profile
<?php
$data = array();
/* ... */
$tpl_vars = array();
foreach ( $data as $key => $value ) {
$tpl_vars[ '{{' . $key . '}}' ] = esc_attr( $value );
}
@westonruter
westonruter / vvv-db-backup.sh
Created August 16, 2014 23:44
Script to help transfer databases from Varying Vagrant Vagrants (VVV) 1.1 to 1.2
#!/bin/bash
cd /srv/www
mkdir vvv-upgrade-backups
find /etc/nginx/custom-sites/ -name '*.conf' | xargs grep -h 'root' | grep '/' | sed 's:\s*root\s\s*::' | sed 's:;$::' > roots.txt
for root in $(cat roots.txt); do
echo $root;
cd $root;
filename=$( echo $root | sed 's:/srv/www/::' | sed 's:/:-:g' ).sql;
@westonruter
westonruter / Customfile
Created August 17, 2014 06:58
Customfile for Varying Vagrant Vagrants
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 1024]
end
( function () {
var els = [].slice.call( document.querySelectorAll( 'title, meta[content][name], meta[content][property]' ) );
var meta = {};
els.forEach( function ( el ) {
if ( el.nodeName.toLowerCase() === 'title' ) {
meta.title = el.textContent;
} else {
meta[ el.getAttribute( 'property' ) || el.getAttribute( 'name' ) ] = el.getAttribute( 'content' );
}
@westonruter
westonruter / wp-mysql-prompt.sh
Created October 31, 2014 06:28
Drop into a MySQL prompt using WP-CLI. Who ever said eval was evil? >:-)
eval $(wp eval "printf( 'mysql -u%s -p%s %s', escapeshellarg( DB_USER ), escapeshellarg( DB_PASSWORD ), escapeshellarg( DB_NAME ) );")
/data
<?php
class WMR_Auto_Upgrade {
public $whitelisted_plugins = array(
'akismet',
'customizer-everywhere',
'dependency-minification',
'jetpack',
'media-placeholders',
$ phpcs --standard=WordPress-Core test.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
5 | WARNING | Array keys should be surrounded by spaces unless they contain a
| | string or an integer.
6 | WARNING | Array keys should NOT be surrounded by spaces if they only
| | contain a string or an integer.
--------------------------------------------------------------------------------
<?php
class Wide_Widget extends WP_Widget {
public function __construct() {
$id_base = 'wide';
$name = __( 'So Wide');
$widget_options = array(
'description' => __( 'Behold my size!' ),
);
$control_options = array(