forked from studio-goliath/goliath-add-social-media-link
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-social-media-link.php
70 lines (52 loc) · 1.5 KB
/
add-social-media-link.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
*
* Plugin Name: Add Social Media Link
* Description: Add the social media link. Set it in the customizer
* Version: 2.5
* Author: ArnaudBan
* Author URI: https://arnaudban.me
*
* SVG sprite from :
* https://github.com/Automattic/social-logos
*
*
*/
namespace ABSocialMediaLink;
if( ! class_exists( 'SocialMediaMenu' ) && file_exists( __DIR__ . '/vendor/autoload.php' ) ){
require __DIR__ . '/vendor/autoload.php';
}
add_action( 'init', function(){
$asml = new SocialMediaMenu();
$asml->init();
$shareMenu = new SocialMediaShareMenu();
$shareMenu->init();
});
/**
* Display social media menu
*
* @param string $target
*/
function social_media_menu( $target = '' ){
$asml = new SocialMediaMenu();
$all_supported_social_media = $asml->getSupportedSocialMedia();
echo '<div class="social-media-link">';
foreach ( $all_supported_social_media as $social_media ){
$social_media_url = get_theme_mod( $social_media );
if( $social_media_url ){
$target_string = $target ? " target='$target'" : '';
echo "<a href='{$social_media_url}' class='social-link'" . $target_string ."><svg class='icon icon-social'><use xlink:href='#{$social_media}'/></svg></a>";
}
}
echo '</div>';
}
/**
* get social share link
*
* @param string $target
* @return string
*/
function social_media_share_links( $target = '' ){
$shareMenu = new SocialMediaShareMenu();
return $shareMenu->display_share_links( $target );
}