Skip to content

Instantly share code, notes, and snippets.

@holisticnetworking
Last active January 24, 2017 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holisticnetworking/22cb9e3d1c0cc3b05751071039ff92cc to your computer and use it in GitHub Desktop.
Save holisticnetworking/22cb9e3d1c0cc3b05751071039ff92cc to your computer and use it in GitHub Desktop.
/**
* Converts single-key metadata into multiple keys.
*
* @when before_wp_load
*/
$datagram_convert = function() {
$datagrams = WP_CLI::runcommand(
'post list --post_type=datagram --format=json',
[
'return' => true, // Return 'STDOUT'; use 'all' for full object.
'parse' => 'json', // Parse captured STDOUT to JSON array.
'launch' => false, // Reuse the current process.
'exit_error' => true, // Halt script execution on error.
]
);
WP_CLI::success( $datagrams );
};
WP_CLI::add_command( 'datagram-convert', $datagram_convert );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment