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.dev\/"}],"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"}}

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
}

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']} failedn";
  }
  print $log;
  file_put_contents("output.log", $log, FILE_APPEND | LOCK_EX);
  $n++;
}

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;
}

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();
		});
	}
})();

Algo to pick every item from array once

		$num_posts = count( $languages );

		$this->gistpens = $this->factory->post->create_many( $num_posts, array(
			'post_type' => 'gistpens',
		), array(
			'post_title' => new WP_UnitTest_Generator_Sequence( 'Post title %s' ),
			'post_name' => new WP_UnitTest_Generator_Sequence( 'Post title %s' ),
			'post_content' => new WP_UnitTest_Generator_Sequence( 'Post content %s' )
		));

		foreach ( $this->gistpens as $gistpen_id ) {
			// Pick a random language
			$num_posts = $num_posts - 1;
			$lang_num = rand( 0, ( $num_posts ) );

			// Get the language's id
			$lang_id = $languages[$lang_num];

			// Remove the language and reindex the languages array
			unset( $languages[$lang_num] );
			$languages = array_values( $languages );

PHP Version check for WP Boilerplate

public static function activate() {
	if ( ! version_compare( PHP_VERSION, '5.3', '<' ) ) {
		return;
	}

	deactivate_plugins( 'url-embedlifier' );
	wp_die('<p>The <strong>URL Embedlifier</strong> plugin requires PHP version 5.3 or greater.</p>',
		'Plugin Activation Error',  array( 'response' => 200, 'back_link' => true ) );
}