Skip to content

Instantly share code, notes, and snippets.

@ScreamingDev
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save ScreamingDev/11135721 to your computer and use it in GitHub Desktop.

Select an option

Save ScreamingDev/11135721 to your computer and use it in GitHub Desktop.
WordPress Shell Script
<?php
/*
* Like to do a shell import?
*
* Place this in wp-content/plugins/foo-plugin/bin/import.php
*/
function out( $txt ) {
if ( func_num_args() > 1 ) {
$txt = vsprintf( $txt, array_slice( func_get_args(), 1 ) );
}
fputs( STDOUT, $txt . PHP_EOL );
}
$baseDir = posix_getcwd();
while ( ! realpath( $baseDir . '/wp-load.php' ) ) {
$baseDir = dirname( $baseDir );
}
define( 'DOING_AJAX', true );
define( 'WP_ADMIN', true );
require_once $baseDir . '/wp-load.php';
out( 'DONE' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment