Created
January 10, 2018 13:44
-
-
Save danielbachhuber/4114d7784ab200d0f2f0f022a7ccadcb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?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