From f3ac5f3e15916e1fd6199a7f8dba30a73a16b72b Mon Sep 17 00:00:00 2001 From: "Peter J. Herrel" Date: Wed, 9 Aug 2017 11:33:01 +0200 Subject: [PATCH] fix wp pll option sync/unsync --- src/Commands/Option.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Commands/Option.php b/src/Commands/Option.php index 56431df..24e63a4 100644 --- a/src/Commands/Option.php +++ b/src/Commands/Option.php @@ -255,7 +255,7 @@ public function sync( $args, $assoc_args ) { if ( $args[0] === 'all' ) { - $this->pll->model->options['sync'] = array_fill_keys( array_keys( $this->options_sync ), 1 ); + $this->pll->model->options['sync'] = array_keys( $this->options_sync ); # update options, default category and nav menu locations $this->pll->model->update_default_lang( $this->api->default_language() ); @@ -277,7 +277,7 @@ public function sync( $args, $assoc_args ) { $settings = (array) $this->pll->model->options['sync']; # update current settings - $settings = array_merge( $settings, array_fill_keys( $args, 1 ) ); + $settings = array_merge( $settings, $args ); $this->pll->model->options['sync'] = $settings; @@ -332,9 +332,10 @@ public function unsync( $args, $assoc_args ) { $args = explode( ',', $args[0] ); # validate args - foreach ( $args as $key ) { + foreach ( $args as $i => $key ) { if ( ! in_array( $key, array_keys( $this->options_sync ) ) ) { - return $this->cli->error( sprintf( 'Invalid key: %s', $key ) ); + unset( $args[$i] ); + $this->cli->warning( sprintf( 'Invalid key: %s', $key ) ); } } @@ -342,9 +343,9 @@ public function unsync( $args, $assoc_args ) { $settings = (array) $this->pll->model->options['sync']; # update current settings - $settings = array_diff_key( $settings, array_fill_keys( $args, 1 ) ); + $settings = array_diff( $settings, $args ); - $this->pll->model->options['sync'] = $settings; + $this->pll->model->options['sync'] = array_values( $settings ); # update options, default category and nav menu locations $this->pll->model->update_default_lang( $this->api->default_language() );