Skip to content

Commit

Permalink
Publicize: Simplify meta lookup logic
Browse files Browse the repository at this point in the history
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()`).
  • Loading branch information
mdawaffe committed Oct 24, 2018
1 parent 7af6bf7 commit ea6e6b6
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions modules/publicize/ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ] )
)
);

Expand Down

0 comments on commit ea6e6b6

Please sign in to comment.