Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Created January 10, 2018 13:44
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 danielbachhuber/4114d7784ab200d0f2f0f022a7ccadcb to your computer and use it in GitHub Desktop.
Save danielbachhuber/4114d7784ab200d0f2f0f022a7ccadcb to your computer and use it in GitHub Desktop.
<?php
list( $log_file ) = $args;
if ( ! is_file( $log_file ) ) {
WP_CLI::error( 'Invalid log file.' );
}
$contents = file_get_contents( $log_file );
$bits = explode( 'Running: plugin install', $contents );
array_shift( $bits );
WP_CLI::log( 'plugin,classic_percent_diff,gutenberg_percent_diff,gallery_link' );
$total_no_change = 0;
foreach( $bits as $bit ) {
preg_match( '#^(.+)#', $bit, $matches );
$plugin = trim( $matches[0] );
preg_match_all( "#Calculating (classic|gutenberg) difference...\n -> Percent difference: (.+)#", $bit, $matches );
if ( empty( $matches[2][0] ) ) {
continue;
}
WP_CLI::log( "{$plugin},{$matches[2][0]},{$matches[2][1]},http://gutensnaps.handbuilt.co/index.php?plugin_name={$plugin}" );
if ( '0%' === $matches[2][0] && '0%' === $matches[2][1] ) {
$total_no_change++;
}
}
WP_CLI::log( '' );
WP_CLI::log( 'Total no change: ' . $total_no_change );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment