Skip to content

Commit

Permalink
Widgets: added Google+ to social widget icons.
Browse files Browse the repository at this point in the history
Props to @brendancarr for proposing the original PR.
  • Loading branch information
zinigor committed Oct 21, 2015
1 parent 02d1791 commit 03be982
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions modules/widgets/social-media-icons.php
Expand Up @@ -31,6 +31,7 @@ public function __construct() {
'github_username' => '',
'youtube_username' => '',
'vimeo_username' => '',
'googleplus_username' => '',
);

$this->services = array(
Expand All @@ -42,6 +43,7 @@ public function __construct() {
'github' => array( 'GitHub', 'https://github.com/%s/' ),
'youtube' => array( 'YouTube', 'https://www.youtube.com/%s/' ),
'vimeo' => array( 'Vimeo', 'https://vimeo.com/%s/' ),
'googleplus' => array( 'Google+', 'https://plus.google.com/u/0/%s/' ),
);

if ( is_active_widget( false, false, $this->id_base ) ) {
Expand Down Expand Up @@ -88,7 +90,15 @@ public function widget( $args, $instance ) {
continue;
}
$index += 10;
$username = $instance[ $service . '_username' ];
$username = $link_username = $instance[ $service . '_username' ];

if (
$service === 'googleplus'
&& ! is_numeric( $username )
&& substr( $username, 0, 1 ) !== "+"
) {
$link_username = "+" . $username;
}

/**
* Fires for each profile link in the social icons widget. Can be used
Expand All @@ -101,7 +111,7 @@ public function widget( $args, $instance ) {
* @param string $url the currently processed URL
* @param string $service the lowercase service slug, e.g. 'facebook', 'youtube', etc.
*/
$link = apply_filters( 'jetpack_social_media_icons_widget_profile_link', esc_url( sprintf( $url, $username ) ), $service );
$link = apply_filters( 'jetpack_social_media_icons_widget_profile_link', esc_url( sprintf( $url, $link_username ) ), $service );

$html[ $index ] =
'<a title="' . sprintf( $alt_text, esc_attr( $username ), $service_name )
Expand Down

0 comments on commit 03be982

Please sign in to comment.