Skip to content

Commit

Permalink
use json objects when saving metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
tharsheblows committed Aug 8, 2024
1 parent e3d529a commit fa57fae
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions connectors/class-connector-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,11 @@ public function callback_set_object_terms( $object_id, $terms, $tt_ids, $tax_slu
$taxonomy = get_taxonomy( $tax_slug );
$tax_name = is_a( $taxonomy, 'WP_Taxonomy' ) ? $taxonomy->labels->singular_name : $tax_slug;

$removed = array_diff( $old_tt_ids, $tt_ids );
$added = array_diff( $tt_ids, $old_tt_ids );
$old_tt_int_ids = array_map( 'intval', $old_tt_ids );
$tt_int_ids = array_map( 'intval', $tt_ids );

$removed = array_diff( $old_tt_int_ids, $tt_int_ids );
$added = array_diff( $tt_int_ids, $old_tt_int_ids );

if ( empty( $removed ) && empty( $added ) ) {
return;
Expand Down Expand Up @@ -229,9 +232,11 @@ public function callback_set_object_terms( $object_id, $terms, $tt_ids, $tax_slu
'singular_name' => $this->get_post_type_name( $object->post_type ),
'taxonomy_name' => $tax_name,
'taxonomy' => $tax_slug,
'terms_updated' => array(
'added' => $added,
'removed' => $removed,
'terms_updated' => wp_json_encode(
array(
'added' => $added,
'removed' => $removed,
)
),
'post_date' => $object->post_date,
'post_date_gmt' => $object->post_date_gmt,
Expand Down Expand Up @@ -278,8 +283,8 @@ function ( $acc, $id ) use ( $taxonomy ) {
*
* @action transition_post_status
*
* @param mixed $new_status New status.
* @param mixed $old_status Old status.
* @param mixed $new_status New status.
* @param mixed $old_status Old status.
* @param WP_Post $post Post object.
*/
public function log_transition_post_status( $new_status, $old_status, $post ) {
Expand Down Expand Up @@ -412,8 +417,8 @@ public function log_transition_post_status( $new_status, $old_status, $post ) {
* This currently only looks at the posts table.
*
* @param int|string $post_id The post id.
* @param WP_Post $post_after The post object of the final post.
* @param WP_Post $post_before The post object before it was updated.
* @param WP_Post $post_after The post object of the final post.
* @param WP_Post $post_before The post object before it was updated.
* @return void
*/
public function callback_post_updated( $post_id, $post_after, $post_before ) {
Expand Down Expand Up @@ -508,7 +513,7 @@ function ( $acc, $key ) use ( $fields_updated ) {
array(
'post_title' => $post_after->post_title,
'singular_name' => $post_type_name,
'fields_updated' => $fields_updated,
'fields_updated' => wp_json_encode( $fields_updated ),
'post_date' => $post_after->post_date,
'post_date_gmt' => $post_after->post_date_gmt,
'revision_id' => $this->get_revision_id( $post_after ),
Expand Down

0 comments on commit fa57fae

Please sign in to comment.