Last active
January 24, 2017 15:13
-
-
Save holisticnetworking/22cb9e3d1c0cc3b05751071039ff92cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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