[--file=] */ public static function extract_clean( $args, $assoc_args ) { $type = isset( $args[0] ) ? (string) $args[0] : ''; $id = isset( $args[1] ) ? (string) $args[1] : ''; $idx = isset( $assoc_args['file'] ) ? (int) $assoc_args['file'] : 0; if ( 'quarantine' !== $type && 'snapshot' !== $type ) { \WP_CLI::error( 'First argument must be "quarantine" or "snapshot".' ); return; } if ( '' === $id ) { \WP_CLI::error( 'Usage: wp guardpress extract-clean [--file=]' ); return; } if ( 'quarantine' === $type ) { if ( ! class_exists( 'GuardPress_FreePlus_Quarantine' ) ) { \WP_CLI::error( 'Quarantine module not available.' ); return; } $r = GuardPress_FreePlus_Quarantine::cli_extract_clean( $id ); } else { if ( ! class_exists( 'GuardPress_FreePlus_Snapshot' ) ) { \WP_CLI::error( 'Snapshot module not available.' ); return; } $r = GuardPress_FreePlus_Snapshot::cli_extract_clean( $id, $idx ); } if ( is_array( $r ) && ! empty( $r['ok'] ) ) { $outp = isset( $r['path'] ) ? (string) $r['path'] : ''; \WP_CLI::success( sprintf( 'Wrote %d verified clean bytes (sha256 %s) to: %s', isset( $r['bytes'] ) ? (int) $r['bytes'] : 0, isset( $r['sha256'] ) ? (string) $r['sha256'] : '', $outp ) ); \WP_CLI::log( 'Move it into place yourself, e.g.: mv ' . escapeshellarg( $outp ) . ' /path/to/original' ); \WP_CLI::log( 'Then delete the temporary directory it sat in. The bytes were verified against the recorded checksum.' ); } else { \WP_CLI::error( ( is_array( $r ) && ! empty( $r['error'] ) ) ? (string) $r['error'] : 'Extraction failed.' ); } } } \WP_CLI::add_command( 'guardpress scan', array( 'GuardPress_CLI', 'scan' ) ); \WP_CLI::add_command( 'guardpress extract-clean', array( 'GuardPress_CLI', 'extract_clean' ) ); }