Skip to content

Commit

Permalink
Pick Sync Taxonomy: Checkbox & Unblock
Browse files Browse the repository at this point in the history
pods-framework#7334

Signed-off-by: Paul Clark <pdclark@pdclark.com>
  • Loading branch information
pdclark authored Aug 15, 2024
1 parent f681e77 commit 5e7b3cb
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions classes/fields/pick.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ public function options() {
'^taxonomy-.*$',
],
],
'type' => 'boolean',
'default' => 0,
]
];

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 5e7b3cb

Please sign in to comment.