forked from tiborp/rrssb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrrssb.php
346 lines (301 loc) · 10.4 KB
/
rrssb.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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<?php
/*
Plugin Name: Ridiculously Responsive Social Sharing Buttons
Plugin URI: https://github.com/ericakfranz/rrssb/
Description: Ridiculously Responsive Social Sharing Buttons adapted from https://github.com/kni-labs/rrssb.
Version: 2.2.1
Author: Erica Franz
Author URI: https://fatpony.me/
Date: 23 August 2015
License: GNU General Public License (GPL) version 3
License URI: https://www.gnu.org/licenses/gpl.html
*/
include( 'rrssb_admin.php' );
/* Automatic Plugin Update Checker */
require 'plugin-update-checker/plugin-update-checker.php';
$myUpdateChecker = PucFactory::buildUpdateChecker(
'https://github.com/ericakfranz/rrssb/metadata.json',
__FILE__,
'rrssb'
);
/* On Activation & Decativation */
function activate_rrssb() {
add_option('show_twitter' , 1);
add_option('show_facebook' , 1);
add_option('show_google' , 1);
add_option('show_github' , 1);
add_option('show_email' , 1);
add_option('show_linkedin' , 0);
add_option('show_reddit' , 0);
add_option('show_pocket' , 0);
add_option('show_instagram' , 0);
add_option('show_pinterest' , 0);
add_option('show_tumblr' , 0);
add_option('show_youtube' , 0);
add_option('github_link' , "ericakfranz");
add_option('instagram_link' , "");
add_option('pinterest_link' , "");
add_option('tumblr_link' , "");
add_option('youtube_link' , "");
add_option('give_rrssb_credit' , 0);
add_option('show_buttons_below_post', 1);
add_option('show_buttons_above_post', 0);
add_option('use_rrssb_jquery' , 0);
add_option('help_improve_rrssb' , 0);
add_option('rrssb_css' , ".no-margin li {margin: 0!important;}");
add_option('rrssb_css_classes' , "no-margin");
}
function deactive_rrssb() {
delete_option('show_email');
delete_option('show_facebook');
delete_option('show_linkedin');
delete_option('show_twitter');
delete_option('show_reddit');
delete_option('show_google');
delete_option('show_pocket');
delete_option('show_github');
delete_option('show_instagram');
delete_option('show_pinterest');
delete_option('show_tumblr');
delete_option('show_youtube');
delete_option('github_link');
delete_option('instagram_link');
delete_option('pinterest_link');
delete_option('tumblr_link');
delete_option('youtube_link');
delete_option('give_rrssb_credit');
delete_option('show_buttons_below_post');
delete_option('show_buttons_above_post');
delete_option('use_rrssb_jquery');
delete_option('help_improve_rrssb');
delete_option('rrssb_css');
delete_option('rrssb_css_classes');
}
register_activation_hook(__FILE__, 'activate_rrssb');
register_deactivation_hook(__FILE__, 'deactive_rrssb');
/* CSS and JS */
function rrssb_js()
{
// Use rrssb jqeury file.
// wp_register_script('rrssb-jqeury', plugins_url('/js/vendor/jquery.1.10.2.min.js', __FILE__ ) );
// wp_enqueue_script('rrssb-jqeury');
wp_register_script('rrssb-modern-min-script', plugins_url('/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js', __FILE__ ) );
wp_enqueue_script('rrssb-modern-min-script');
wp_register_script('rrssb-min-script', plugins_url('/js/rrssb.min.js', __FILE__ ), array('jquery') );
wp_enqueue_script('rrssb-min-script');
}
add_action('wp_enqueue_scripts', 'rrssb_js' );
function rrssb_css()
{
//wp_register_style('norm_stylesheet', plugins_url('css/normalize.min.css', __FILE__));
//wp_enqueue_style('norm_stylesheet');
wp_register_style('rrssb_stylesheet', plugins_url('css/rrssb.css', __FILE__));
wp_enqueue_style('rrssb_stylesheet');
}
add_action('wp_enqueue_scripts', 'rrssb_css' );
/* Add shortcode */
function rrssb_show_buttons_shortcode()
{
return rrssb_show_buttons("");
}
add_shortcode('rrssb', 'rrssb_show_buttons_shortcode');
/* Add buttons */
function rrssb_show_buttons($rrssb_content)
{
$rrssb_content .= '
<script>window.jQuery || document.write(\'<script src="js/vendor/jquery.1.10.2.min.js"><\/script>\')</script>
<style>
' . get_option('rrssb_css') . '
</style>
<div class="share-container clearfix">
<ul class="rrssb-buttons clearfix ' . get_option('rrssb_css_classes') . '">';
if ( 1 == get_option('show_twitter') )
$rrssb_content .= rrssb_twitter_btn();
if ( 1 == get_option('show_facebook') )
$rrssb_content .= rrssb_facebook_btn();
if ( 1 == get_option('show_google') )
$rrssb_content .= rrssb_google_btn();
if ( 1 == get_option('show_github') )
$rrssb_content .= rrssb_github_btn();
if ( 1 == get_option('show_email') )
$rrssb_content .= rrssb_email_btn();
if ( 1 == get_option('show_linkedin') )
$rrssb_content .= rrssb_linkedin_btn();
if ( 1 == get_option('show_reddit') )
$rrssb_content .= rrssb_reddit_btn();
if ( 1 == get_option('show_pinterest') )
$rrssb_content .= rrssb_pinterest_btn();
if ( 1 == get_option('show_instagram') )
$rrssb_content .= rrssb_instagram_btn();
if ( 1 == get_option('show_youtube') )
$rrssb_content .= rrssb_youtube_btn();
if ( 1 == get_option('show_tumblr') )
$rrssb_content .= rrssb_tumblr_btn();
if ( 1 == get_option('show_pocket') )
$rrssb_content .= rrssb_pocket_btn();
$rrssb_content .= '</ul>';
if ( 1 == get_option('give_rrssb_credit') )
$rrssb_content .= '
<label><small>
<a href="https://github.com/ericakfranz/rrssb/">Get the RRSSB share plugin for your site.</a>
</small></label>';
$rrssb_content .= '
</div>';
return $rrssb_content;
}
/* Show buttons above post */
function rrssb_show_buttons_above_post($content)
{
if ( is_single() && ( 1 == get_option('show_buttons_above_post') ) ) {
$rrssb_content = rrssb_show_buttons("");
$rrssb_content .= $content;
return $rrssb_content;
}
else {
return $content;
}
}
add_filter('the_content', 'rrssb_show_buttons_above_post');
/* Show buttons below post */
function rrssb_show_buttons_below_post($rrssb_content)
{
if ( is_single() && ( 1 == get_option('show_buttons_below_post') ) ) {
$rrssb_content = rrssb_show_buttons($rrssb_content);
}
return $rrssb_content;
}
add_filter('the_content', 'rrssb_show_buttons_below_post');
/* Functions for each button */
function rrssb_twitter_btn()
{
$icon = '<icon class="socicon socicon-twitter"></icon>';
$rrssb_content = '<li class="rrssb-twitter">
<a href="http://twitter.com/home?status=' . urlencode(get_the_title() ) . ' - ' . urlencode(wp_get_shortlink() ). '" class="popup">
<span class="rrssb-icon">
' . $icon . '
</span>
<span class="rrssb-text">twitter</span></a></li>';
return $rrssb_content;
}
function rrssb_facebook_btn()
{
$icon = '<icon class="socicon socicon-facebook"></icon>';
$rrssb_content = '<li class="rrssb-facebook">
<a href="https://www.facebook.com/sharer/sharer.php?u=' .urlencode(get_permalink() ) . ' " class="popup">
<span class="rrssb-icon">
'. $icon . '
</span>
<span class="rrssb-text">facebook</span></a></li>';
return $rrssb_content;
}
function rrssb_google_btn()
{
$icon = '<icon class="socicon socicon-google-plus"></icon>';
$rrssb_content = '<li class="rrssb-googleplus">
<a href="https://plus.google.com/share?url=' . urlencode(get_the_title() ) . ' - ' . urlencode( get_permalink() ) .'" class="popup">
<span class="rrssb-icon">
'. $icon . '
</span>
<span class="rrssb-text">google+</span></a></li>';
return $rrssb_content;
}
function rrssb_github_btn()
{
$icon = '<icon class="socicon socicon-github"></icon>';
$rrssb_content = '<li class="rrssb-github">
<a href="https://github.com/'.get_option('github_link').'" target="_blank">
<span class="rrssb-icon">
'. $icon . '
</span>
<span class="rrssb-text">github</span></a></li>';
return $rrssb_content;
}
function rrssb_email_btn()
{
$icon = '<icon class="dashicons dashicons-email"></icon>';
$rrssb_content = '<li class="rrssb-email">
<a href="mailto:?subject='.urlencode(get_the_title()) .'&body=' .urlencode(get_permalink()). '" class="popup">
<span class="rrssb-icon">
'. $icon . '
</span>
<span class="rrssb-text">email</span></a></li>';
return $rrssb_content;
}
function rrssb_linkedin_btn()
{
$icon = '<icon class="socicon socicon-linkedin"></icon>';
$rrssb_content = '<li class="rrssb-linkedin">
<a href="http://www.linkedin.com/shareArticle?mini=true&url=' . urlencode(get_permalink()) . '&title=' . urlencode(get_the_title() ) . '" class="popup">
<span class="rrssb-icon">
'. $icon . '
</span>
<span class="rrssb-text">linkedin</span></a></li>';
return $rrssb_content;
}
function rrssb_reddit_btn()
{
$icon = '<icon class="socicon socicon-reddit"></icon>';
$rrssb_content = '<li class="rrssb-reddit">
<a href="http://www.reddit.com/submit?url=' . urlencode(get_permalink() ) . '" class="popup">
<span class="rrssb-icon">
'.$icon.'
</span>
<span class="rrssb-text">reddit</span></a></li>';
return $rrssb_content;
}
function rrssb_instagram_btn()
{
$icon = '<icon class="socicon socicon-instagram"></icon>';
$rrssb_content = '<li class="rrssb-instagram">
<a href="https://instagram.com/'.get_option('instagram_link').'" target="_blank">
<span class="rrssb-icon">
'. $icon . '
</span>
<span class="rrssb-text">instagram</span></a></li>';
return $rrssb_content;
}
function rrssb_pinterest_btn()
{
$icon = '<icon class="socicon socicon-pinterest"></icon>';
$rrssb_content = '<li class="rrssb-pinterest">
<a href="https://pinterest.com/'.get_option('pinterest_link').'" target="_blank">
<span class="rrssb-icon">
'. $icon . '
</span>
<span class="rrssb-text">pinterest</span></a></li>';
return $rrssb_content;
}
function rrssb_tumblr_btn()
{
$icon = '<icon class="socicon socicon-tumblr"></icon>';
$rrssb_content = '<li class="rrssb-tumblr">
<a href="https://tumblr.com/'.get_option('tumblr_link').'" target="_blank">
<span class="rrssb-icon">
'. $icon . '
</span>
<span class="rrssb-text">tumblr</span></a></li>';
return $rrssb_content;
}
function rrssb_youtube_btn()
{
$icon = '<icon class="socicon socicon-youtube"></icon>';
$rrssb_content = '<li class="rrssb-youtube">
<a href="https://youtube.com/'.get_option('youtube_link').'" target="_blank">
<span class="rrssb-icon">
'. $icon . '
</span>
<span class="rrssb-text">youtube</span></a></li>';
return $rrssb_content;
}
function rrssb_pocket_btn()
{
$icon = '<icon class="socicon socicon-pocket"></icon>';
$rrssb_content = '<li class="rrssb-pocket">
<a href="https://getpocket.com/save?url=' . urlencode( get_permalink() ) . '" class="popup">
<span class="rrssb-icon">
' . $icon . '
<span class="rrssb-text">pocket</span></a></li>';
return $rrssb_content;
}
/* END FILE */
?>