@@ -255,7 +255,7 @@ public function sync( $args, $assoc_args ) {
255255
256256 if ( $ args [0 ] === 'all ' ) {
257257
258- $ this ->pll ->model ->options ['sync ' ] = array_fill_keys ( array_keys ( $ this ->options_sync ), 1 );
258+ $ this ->pll ->model ->options ['sync ' ] = array_keys ( $ this ->options_sync );
259259
260260 # update options, default category and nav menu locations
261261 $ this ->pll ->model ->update_default_lang ( $ this ->api ->default_language () );
@@ -277,7 +277,7 @@ public function sync( $args, $assoc_args ) {
277277 $ settings = (array ) $ this ->pll ->model ->options ['sync ' ];
278278
279279 # update current settings
280- $ settings = array_merge ( $ settings , array_fill_keys ( $ args, 1 ) );
280+ $ settings = array_merge ( $ settings , $ args );
281281
282282 $ this ->pll ->model ->options ['sync ' ] = $ settings ;
283283
@@ -332,19 +332,20 @@ public function unsync( $args, $assoc_args ) {
332332 $ args = explode ( ', ' , $ args [0 ] );
333333
334334 # validate args
335- foreach ( $ args as $ key ) {
335+ foreach ( $ args as $ i => $ key ) {
336336 if ( ! in_array ( $ key , array_keys ( $ this ->options_sync ) ) ) {
337- return $ this ->cli ->error ( sprintf ( 'Invalid key: %s ' , $ key ) );
337+ unset( $ args [$ i ] );
338+ $ this ->cli ->warning ( sprintf ( 'Invalid key: %s ' , $ key ) );
338339 }
339340 }
340341
341342 # get current settings
342343 $ settings = (array ) $ this ->pll ->model ->options ['sync ' ];
343344
344345 # update current settings
345- $ settings = array_diff_key ( $ settings , array_fill_keys ( $ args, 1 ) );
346+ $ settings = array_diff ( $ settings , $ args );
346347
347- $ this ->pll ->model ->options ['sync ' ] = $ settings ;
348+ $ this ->pll ->model ->options ['sync ' ] = array_values ( $ settings ) ;
348349
349350 # update options, default category and nav menu locations
350351 $ this ->pll ->model ->update_default_lang ( $ this ->api ->default_language () );
0 commit comments