Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync empty taxonomies to distributed posts. #951

Merged
merged 9 commits into from
Oct 20, 2022
Prev Previous commit
Next Next commit
Only permit taxonomy updates for those that are shown in the REST API.
peterwilsoncc committed Sep 30, 2022
commit 3b9316dd8add31c5da3b232063abfeddf9dc1fe6
5 changes: 5 additions & 0 deletions includes/classes/API/SubscriptionsController.php
Original file line number Diff line number Diff line change
@@ -248,6 +248,11 @@ public function receive_item( $request ) {
'media' => ( isset( $request['post_data']['distributor_media'] ) ) ? $request['post_data']['distributor_media'] : [],
];

// Limit taxonomy updates to those shown in the REST API.
$rest_taxonomies = get_taxonomies( [ 'show_in_rest' => true ] );
$rest_taxonomies = array_fill_keys( $rest_taxonomies, true );
$update['terms'] = array_intersect_key( $update['terms'], $rest_taxonomies );

update_post_meta( (int) $request['post_id'], 'dt_subscription_update', $update );

$unlinked = (bool) get_post_meta( $request['post_id'], 'dt_unlinked', true );