From 5e7b3cb29215573e5a757b4a6c48f73c7673df07 Mon Sep 17 00:00:00 2001 From: Paul Clark Date: Thu, 15 Aug 2024 17:29:12 -0400 Subject: [PATCH] Pick Sync Taxonomy: Checkbox & Unblock #7334 Signed-off-by: Paul Clark --- classes/fields/pick.php | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/classes/fields/pick.php b/classes/fields/pick.php index df980c2845..baebdd8202 100644 --- a/classes/fields/pick.php +++ b/classes/fields/pick.php @@ -449,6 +449,8 @@ public function options() { '^taxonomy-.*$', ], ], + 'type' => 'boolean', + 'default' => 0, ] ]; @@ -1924,25 +1926,26 @@ public function save( $value, $id = null, $name = null, $options = null, $fields } } elseif ( $options instanceof Field || $options instanceof Value_Field ) { $related_field = $options->get_bidirectional_field(); - - if ( ! $related_field ) { - return; - } - - $related_pod = $related_field->get_parent_object(); - $related_pick_limit = $related_field->get_limit(); - - if ( null === $current_ids ) { - $current_ids = self::$api->lookup_related_items( $options['id'], $pod['id'], $id, $options, $pod ); - } - - // Get ids to remove. - if ( null === $remove_ids ) { - $remove_ids = array_diff( $current_ids, $value_ids ); + + if ( $related_field ) { + $related_pod = $related_field->get_parent_object(); + $related_pick_limit = $related_field->get_limit(); + + if ( null === $current_ids ) { + $current_ids = self::$api->lookup_related_items( $options['id'], $pod['id'], $id, $options, $pod ); + } + + // Get ids to remove. + if ( null === $remove_ids ) { + $remove_ids = array_diff( $current_ids, $value_ids ); + } } } - if ( empty( $related_field ) || empty( $related_pod ) ) { + if ( + ( empty( $related_field ) || empty( $related_pod ) ) + && empty( $options[ static::$type . '_sync_taxonomy' ] ) + ) { return; }