WordPress Site Boilerplate

{
"name": "name/site",
"type": "project",
"license": "MIT",
"description": "A modern WordPress stack for Name.com",
"homepage": "http://name.com/",
"authors": [
{
"name": "James DiGioia",
"email": "jamesorodig@gmail.com",
"homepage": "https://jamesdigioia.com/"
}
],
"repositories": [{ "type": "composer", "url": "http://wpackagist.org" }],
"require": {
"php": ">=5.4",
"johnpbloch/wordpress": "4.1.1",
"wpackagist-theme/casper": "1.1.0",
"wpackagist-plugin/akismet": "3.0.3",
"wpackagist-plugin/batcache": "1.2",
"wpackagist-plugin/backwpup": "3.1.2",
"wpackagist-plugin/limit-login-attempts": "1.7.1",
"wpackagist-plugin/media-file-renamer": "1.9.4",
"wpackagist-plugin/post-thumbnail-editor": "2.4.2",
"wpackagist-plugin/wordpress-seo": "1.6.3",
"wpackagist-plugin/wp-smushit": "1.6.5.4",
"composer/installers": "v1.0.12",
"vlucas/phpdotenv": "~1.0.6",
"wp-sync-db/wp-sync-db": "dev-master#c0475de77ca28891a35726eee7d30f9c0d804ba0",
"wp-sync-db/wp-sync-db-media-files": "dev-master#f49c90ff8716b80bfbcc650212fd3f583d06f234",
"wp-sync-db/wp-sync-db-cli": "dev-master#28188ea6c4081e5bd322e9c14bbfc4946d5dcb73"
},
"require-dev": {
"wpackagist-plugin/debug-bar": "0.8.2",
"wpackagist-plugin/debug-bar-console": "0.3",
"wpackagist-plugin/debug-bar-cron": "0.1.2",
"wpackagist-plugin/debug-bar-extender": "0.5",
"wpackagist-plugin/log-deprecated-notices": "0.3",
"wpackagist-plugin/rewrite-rules-inspector": "1.2.1"
},
"extra": {
"installer-paths": {
"web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
"web/app/plugins/{$name}/": ["type:wordpress-plugin"],
"web/app/themes/{$name}/": ["type:wordpress-theme"]
},
"wordpress-install-dir": "web/wp"
}
}
composer.json

Ngrok & Ansible

- name: ngrok
src: mAAdhaTTah.ngrok
requirements.yml
- { role: ngrok, tags: [ngrok] }
dev.yml
ngrok:
subdomain: domain
token: your_token
group_vars/development

userAgent checking

// Source: https://github.com/pixelcog/parallax.js/blob/master/parallax.js#L96
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
// if iOS
}
if (navigator.userAgent.match(/(Android)/)) {
// if Android
}
user-agent.js

ParseCSV Image Downloading

require("ParseCSV.php");
$csv = new ParseCSV("youtube-images.csv");
$n = 1;
foreach($csv->data as $data) {
if(false != file_put_contents("pics/{$data['filename']}.jpg", file_get_contents($data['url']))) {
$log = "File {$n}: Downloaded {$data['filename']} from {$data['url']}\n";
} else {
$log = "File {$n}: Download from {$data['url']} failed\n";
}
print $log;
file_put_contents("output.log", $log, FILE_APPEND | LOCK_EX);
$n++;
}
parsecsv-image-downloading.php

Register TinyMCE Plugin and Button

add_filter( 'mce_external_plugins', 'plugin_slug_add_button' );
function plugin_slug_add_button( $plugins ) {
$plugins['plugin_slug'] = 'path/to/editor/plugin.js';
return $plugins;
}
add_filter( 'mce_buttons', 'plugin_slug_register_button' );
function plugin_slug_register_button( $buttons ) {
array_push( $buttons, 'plugin_slug' );
return $buttons;
}
register-tiny-mce-plugin.php

TinyMCE Button Plugin

( function() {
// Register plugin
tinymce.create( 'tinymce.plugins.plugin_slug', {
init: function( editor, url ) {
// Add the Insert Gistpen button
editor.addButton( 'plugin_slug', {
//text: 'Insert Shortcode',
icon: 'icons dashicons-icon',
tooltip: 'Insert Shortcode',
cmd: 'plugin_command'
});
// Called when we click the Insert Gistpen button
editor.addCommand( 'plugin_command', function() {
// Calls the pop-up modal
editor.windowManager.open({
// Modal settings
title: 'Insert Shortcode',
width: jQuery( window ).width() * 0.7,
// minus head and foot of dialog box
height: (jQuery( window ).height() - 36 - 50) * 0.7,
inline: 1,
id: 'plugin-slug-insert-dialog',
buttons: [{
text: 'Insert',
id: 'plugin-slug-button-insert',
class: 'insert',
onclick: function( e ) {
insertShortcode();
},
},
{
text: 'Cancel',
id: 'plugin-slug-button-cancel',
onclick: 'close'
}],
});
appendInsertDialog();
});
}
});
tinymce.PluginManager.add( 'plugin_slug', tinymce.plugins.plugin_slug );
function appendInsertDialog () {
var dialogBody = jQuery( '#plugin-slug-insert-dialog-body' ).append( '[Loading element like span.spinner]' );
// Get the form template from WordPress
jQuery.post( ajaxurl, {
action: 'plugin_slug_insert_dialog'
}, function( response ) {
template = response;
dialogBody.children( '.loading' ).remove();
dialogBody.append( template );
jQuery( '.spinner' ).hide();
});
}
})();
tinyce-plugin.php

Register Ajax Form Return

add_action( 'wp_ajax_plugin_slug_insert_dialog', 'plugin_slug_insert_gistpen_dialog' );
function plugin_slug_insert_gistpen_dialog() {
die(include 'path/to/dialog/form.php');
}
register-ajax.php

Vagrant WordPress Post-up for WP-Gistpen

sudo apt-get -y install subversion phpunit
cd /srv/www/jamesdigioia.com/current
cd $(wp plugin path --dir wp-gistpen)
bash test/install-wp-tests.sh wordpress_test root devpw localhost latest
vg-wp-post-up.sh