Skip to content

Commit

Permalink
Social | Fix profile links for LinkedIn connections (#40873)
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk authored Jan 23, 2025
1 parent 4ff6a22 commit 706ba07
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Social: Fix profile links for LinkedIn connections
35 changes: 13 additions & 22 deletions projects/packages/publicize/src/class-publicize-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,19 @@ public function get_profile_link( $service_name, $connection ) {
return 'https://instagram.com/' . $cmeta['connection_data']['meta']['username'];
}

if ( 'linkedin' === $service_name ) {

$entity_type = $cmeta['connection_data']['meta']['entity_type'] ?? 'person';

if ( 'organization' === $entity_type && ! empty( $cmeta['connection_data']['meta']['external_name'] ) ) {
return 'https://www.linkedin.com/company/' . $cmeta['connection_data']['meta']['external_name'];
}

if ( 'person' === $entity_type && ! empty( $cmeta['external_name'] ) ) {
return 'https://www.linkedin.com/in/' . $cmeta['external_name'];
}
}

if ( 'threads' === $service_name && isset( $cmeta['external_name'] ) ) {
return 'https://www.threads.net/@' . $cmeta['external_name'];
}
Expand All @@ -521,28 +534,6 @@ public function get_profile_link( $service_name, $connection ) {
return 'https://bsky.app/profile/' . $cmeta['external_id'];
}

if ( 'linkedin' === $service_name ) {
if ( ! isset( $cmeta['connection_data']['meta']['profile_url'] ) ) {
return false;
}

$profile_url_query = wp_parse_url( $cmeta['connection_data']['meta']['profile_url'], PHP_URL_QUERY );
$profile_url_query_args = array();
wp_parse_str( $profile_url_query, $profile_url_query_args );

$id = null;

if ( isset( $profile_url_query_args['key'] ) ) {
$id = $profile_url_query_args['key'];
} elseif ( isset( $profile_url_query_args['id'] ) ) {
$id = $profile_url_query_args['id'];
} else {
return false;
}

return esc_url_raw( add_query_arg( 'id', rawurlencode( $id ), 'https://www.linkedin.com/profile/view' ) );
}

return false; // no fallback. we just won't link it.
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Social: Fix profile links for LinkedIn connections
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fixed profile links for LinkedIn connections

0 comments on commit 706ba07

Please sign in to comment.