-
Notifications
You must be signed in to change notification settings - Fork 4
/
readme.txt
121 lines (88 loc) · 4.31 KB
/
readme.txt
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
=== Developer Share Buttons ===
Contributors: terminalpixel
Tags: share buttons, developer, social, share
Requires at least: 3.5
Tested up to: 5.6
Stable tag: 1.3.0
A super lightweight social sharing solution using either the Web Share API or simple sharing links.
== Description ==
A simple, customisable share buttons solution designed specifically for theme developers.
If you would like to help out please contribute to the [GitHub repository](https://github.com/terminalpixel/Developer-Share-Buttons)
== Installation ==
Install the plugin in whatever way you deem fit. Once installed you can set the default settings on the options page.
== Frequently Asked Questions ==
= What functions are available to use? =
There are 4 functions available to use:
1. `get_dev_share_buttons` returns html of share links
2. `the_dev_share_buttons` a wrapper just to echo `get_dev_share_buttons`
3. `get_dev_profile_links` returns an array of the links to social pages that are saved in the admin area
4. `the_dev_profile_links` echos the links as `a` tags in a `div`
`get_dev_share_buttons` and `the_dev_share_buttons` both accept 5 optional parameters:
1. services - An array of service ids eg `array( 'facebook', 'twitter', 'google' )`. Defaults to the options saved on the options page
2. url - The url to share. Defaults to value of `get_the_permalink()`
3. title - The title of the item to share. Defaults to the value of `get_the_title()`
4. text - The text that appears before a service title eg "Share on". Defaults to the value set on the options page.
5. image - The url of an image to go along with the main item, only used by certain services. Defaults to the post thumbnail.
= Are there default styles for this? =
Yes there are! I have added some simple default styles that you can optionally enable:
`add_filter( 'dev_share_buttons_css', '__return_true' );`
= Adding more services =
You can add more services using a filter:
`add_filter( 'dev_share_buttons_services', 'my_new_service' );
function my_new_service( $services ) {
$services['myserviceid'] = array(
'id' => 'myserviceid',
'title' => 'My Service Title',
'url_structure' => 'http://www.shareurl.com/?url=%1$s&title=%2$s&text=%3$s&image=%4$s',
'url_after_title' => false
);
return $services;
}`
= Adding Icons =
Icons can be added via pure css or the filters provided to add content before or after the button text:
`// Add an svg icon to share buttons.
function my_share_social_icons( $html, $service ) {
$icon_url = get_stylesheet_directory_uri() . '/svg-icons.svg#' . $service['id'];
$icon_html = '<svg><use xlink:href="' . $icon_url . '"></use></svg>';
return $html . $icon_html;
}
add_filter( 'dev_share_buttons_after_share_text', 'my_share_social_icons', 10, 2 );
// Add a png icon to profile links.
function my_profile_social_icons( $html, $service ) {
$icon_url = get_stylesheet_directory_uri() . '/social-icons/' . $service['id'] . '.png';
$icon_html = '<img src="' . $icon_url . '" />';
return $html . $icon_html;
}
add_filter( 'dev_share_buttons_after_profile_text', 'my_profile_social_icons', 10, 2 );`
= Disabling the Web Share API =
The Web Share API is disabled by default but I recommend enabling it as it will display a single share button instead of the multiple buttons if the browser supports it. If you wish to enable this feature you can add a filter:
`add_filter( 'dev_share_buttons_share_api', '__return_true' );`
== Changelog ==
= 1.0.1 =
* Prevent `the_` functions from returning values
* Add spaces between profile links
= 1.0.3 =
* Fix profile link widget
= 1.0.4 =
* Improve support for non post object based pages
= 1.0.5 =
* Add `rel="me"` support for profile links
= 1.0.6 =
* Update to all https links
* Use updated twitter and pinterest urls
* Url encode more things for better character support
= 1.0.7 =
* Add extra filters to add content before and after button text (useful for icons)
* Update coding standard
= 1.0.8 =
* Use `rawurlencode` to improve compatibility with some services
= 1.1.0 =
* Add some optional default styles
* Add Medium, Messenger, Skype, Snapchat, WeChat, WhatsApp and YouTube profile links
= 1.2.0 =
* Add support for the Web Share API
= 1.3.0 =
* Add blocks for the new editor
* Add option to enable css from the options screen
* Add mastodon service
* Remove Google plus service