Skip to content

Commit 632f0bf

Browse files
refactored the menus
1 parent 4a82519 commit 632f0bf

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

ACF5_Command.php

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,7 @@ protected function select_blog() {
405405
$choices[$i] = get_blog_details( $i )->blogname . ' - ' .get_template() ;
406406
}
407407

408-
while ( true ) {
409-
$choice = \cli\menu( $choices, null, 'Pick a blog' );
410-
\cli\line();
411-
412-
return $choice;
413-
break;
414-
}
408+
return $this->choice( $choices, 'Choose a blog' );
415409
}
416410

417411
protected function select_acf_field() {
@@ -422,36 +416,34 @@ protected function select_acf_field() {
422416
'order' => 'ASC',
423417
) );
424418

425-
$choices = array();
426-
$choices[''] = 'all';
419+
$choices = array( '' => 'all' );
420+
427421
foreach ( $field_groups as $group ) {
428422
$choices[$group->ID] = $group->post_title;
429423
}
430424

431-
while ( true ) {
432-
$choice = \cli\menu( $choices, null, 'Pick a fieldgroup to export' );
433-
\cli\line();
434-
435-
return $choice;
436-
break;
437-
}
425+
return $this->choice( $choices, 'Choose a fieldgroup to export' );
438426
}
439427

440428
protected function select_export_path() {
441-
$patterns = array();
442429
$choices = array();
443430

444431
foreach ( $this->paths as $key => $value ) {
445432
$choices[ $value ] = $key . ': ' . $value;
446433
}
447434

435+
return $this->choice( $choices, 'Choose a path to export the fieldgroup to' );
436+
}
437+
438+
private function choice( $choices, $question = 'Choose something' ) {
448439
while ( true ) {
449440
$choice = \cli\menu( $choices, null, 'Pick a path to export the fieldgroup to' );
450441
\cli\line();
451442

452-
return $choice;
453443
break;
454444
}
445+
446+
return $choice;
455447
}
456448

457449
}

0 commit comments

Comments
 (0)