File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -722,15 +722,13 @@ public function recount( $args ) {
722722 * Success: Pruned 1 of 5 terms.
723723 */
724724 public function prune ( $ args , $ assoc_args ) {
725+ $ dry_run = (bool ) Utils \get_flag_value ( $ assoc_args , 'dry-run ' , false );
726+
725727 foreach ( $ args as $ taxonomy ) {
726728 if ( ! taxonomy_exists ( $ taxonomy ) ) {
727729 WP_CLI ::error ( "Taxonomy {$ taxonomy } doesn't exist. " );
728730 }
729- }
730731
731- $ dry_run = (bool ) Utils \get_flag_value ( $ assoc_args , 'dry-run ' , false );
732-
733- foreach ( $ args as $ taxonomy ) {
734732 $ terms = get_terms (
735733 [
736734 'taxonomy ' => $ taxonomy ,
@@ -748,18 +746,15 @@ public function prune( $args, $assoc_args ) {
748746 * @var \WP_Term[] $terms
749747 */
750748
751- $ total = count ( $ terms );
752- $ prunable = 0 ;
753- $ successes = 0 ;
754- $ errors = 0 ;
749+ $ total = count ( $ terms );
750+ $ successes = 0 ;
751+ $ errors = 0 ;
755752
756753 foreach ( $ terms as $ term ) {
757754 if ( $ term ->count > 1 ) {
758755 continue ;
759756 }
760757
761- ++$ prunable ;
762-
763758 if ( $ dry_run ) {
764759 WP_CLI ::log ( "Would delete {$ taxonomy } {$ term ->term_id }. " );
765760 ++$ successes ;
You can’t perform that action at this time.
0 commit comments