From ea6e6b639d6eeacaf16b3bcb10bff3c4b203b173 Mon Sep 17 00:00:00 2001 From: Michael D Adams Date: Wed, 24 Oct 2018 10:01:19 -0700 Subject: [PATCH] Publicize: Simplify meta lookup logic Connections are arrays in Jetpack and objects in WordPress.com. * When looking for their corresponding services' names, just look at the service itself instead of the connection's copy. * Ensure we're accessing their data via helper methods (like `->get_connection_meta()`). --- modules/publicize/ui.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/publicize/ui.php b/modules/publicize/ui.php index f09e5efd955c8..d9b3f97e658fc 100644 --- a/modules/publicize/ui.php +++ b/modules/publicize/ui.php @@ -730,21 +730,18 @@ private function get_metabox_form_connected( $services ) { in_array( $post->post_status, array( 'publish', 'draft', 'future' ) ) && ( + // New flags get_post_meta( $post->ID, $this->publicize->POST_SKIP . $unique_id, true ) || - get_post_meta( $post->ID, $this->publicize->POST_SKIP . $connection->name ) + // Old flags + get_post_meta( $post->ID, $this->publicize->POST_SKIP . $service_name ) ) ) || ( is_array( $connection ) && - ( - ( isset( $connection['meta']['external_id'] ) && ! empty( $service_id_done[ $service_name ][ $connection['meta']['external_id'] ] ) ) - || - // Jetpack's connection data looks a little different. - ( isset( $connection['external_id'] ) && ! empty( $service_id_done[ $service_name ][ $connection['external_id'] ] ) ) - ) + isset( $connection_meta['external_id'] ) && ! empty( $service_id_done[ $service_name ][ $connection_meta['external_id'] ] ) ) );