-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-social-icons-add-icons.php
75 lines (71 loc) · 3 KB
/
simple-social-icons-add-icons.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
70
71
72
73
74
75
<?php
/*
Plugin Name: Simple Social Icons - Extra Icons
Plugin URI: https://github.com/damiencarbery/ssi-extra-icons
GitHub Plugin URI: https://github.com/damiencarbery/ssi-extra-icons
Description: Add extra icons to Simple Social Icons list.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.3
*/
add_filter( 'simple_social_default_profiles', 'dcwd_add_social_profiles' );
function dcwd_add_social_profiles( $profiles ) {
// Add icons. Icon path can be within a svg file or a standalone svg file.
// Based on config.php in https://github.com/nickcernis/ssi-custom-icons
$new_icons = array(
[
'label' => 'AppStore',
'widget_label' => 'App Store URI',
'short_name' => 'appstore',
'path' => esc_url( plugin_dir_url( __FILE__ ) . 'ssi-extra-icons.svg#social-app-store' ),
'default' => '',
],
[
'label' => 'PlayStore',
'widget_label' => 'Play Store URI',
'short_name' => 'playstore',
'path' => esc_url( plugin_dir_url( __FILE__ ) . 'ssi-extra-icons.svg#social-play-store' ),
'default' => '',
],
[
'label' => 'TripAdvisor',
'widget_label' => 'TripAdvisor URI',
'short_name' => 'tripadvisor',
'path' => esc_url( plugin_dir_url( __FILE__ ) . 'ssi-extra-icons.svg#social-tripadvisor' ),
'default' => '',
],
[
'label' => 'WhatsApp',
'widget_label' => 'WhatsApp URI',
'short_name' => 'whatsapp',
'path' => esc_url( plugin_dir_url( __FILE__ ) . 'ssi-extra-icons.svg#social-whatsapp' ),
'default' => '',
],
[
'label' => 'Google My Business',
'widget_label' => 'Google My Business URI',
'short_name' => 'googlemybusiness',
'path' => esc_url( plugin_dir_url( __FILE__ ) . 'ssi-extra-icons.svg#social-google-my-business' ),
'default' => '',
],
// Example that uses a standalone SVG file.
/*[
'label' => 'User friendly name',
'widget_label' => 'Widget label in Dashboard',
'short_name' => 'shortname',
'path' => esc_url( plugin_dir_url( __FILE__ ) . 'filename.svg' ),
'default' => '',
],*/
);
foreach ( $new_icons as $icon ) {
$profiles[ $icon['short_name'] ] = [
'label' => $icon['widget_label'],
'pattern' => '<li class="social-' . $icon['short_name'] . '"><a href="%s" %s><svg role="img" class="social-' . $icon['short_name'] . '-svg" aria-labelledby="social-' . $icon['short_name'] . '"><title id="social-' . $icon['short_name'] . '-{WIDGET_INSTANCE_ID}">' . $icon['label'] . '</title><use xlink:href="' . $icon['path'] . '"></use></svg></a></li>',
];
// If the path is a file rather than an index within a file (file.svg#index) then the svg markup is quite different.
if ( false == strpos( $icon['path'], '.svg#' ) ) {
$profiles[ $icon['short_name'] ]['pattern'] = '<li class="social-' . $icon['short_name'] . '"><a href="%s" %s><img title="'. $icon['label'] .'" class="social-' . $icon['short_name'] . '-svg" src="' . $icon['path'] . '" /></a></li>';
}
}
return $profiles;
}