Plugin wordpress
Hiermee kan een bezoeker mij pagina tweeten of like op facebook.
Het probleem is dat bij het tweeten, er + ipv spaties komen en de cijfercodes voor de symbolen. Ik zoek een manier om dit te voorkomen. Ik was zelf al aan het puzzelen geweest maar het lukt me niet.
Code (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
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
<?php
/*
Plugin Name: Simple Social - Sharing Widgets & Icons
Version: 0.2
Description: Adds a set of social sharing widgets & icons after each post.
*/
function simple_social($content) {
global $post,$simplesocial_icons_pixels;
$simplesocial_permlink = get_permalink($post->ID);
$simplesocial_enclink = urlencode($simplesocial_permlink);
$simplesocial_title = urlencode(get_the_title($post->ID);
$simplesocial_dir = get_settings('home').'/wp-content/plugins/simple-social-sharing-widgets-icons/icons_'.get_option('ss_iconsize',32).'/';
if (!is_feed() && !is_page()){
$simplesocialcontent.='<div>';
// Title
$simplesocialcontent .= '<div style="padding-top:10px;margin-bottom:10px;font-size:10pt;font-family:arial;font-weight:bold;">'.get_option('ss_title','Did you like this? Share it:').'</div>';
// Twitter widget
if(get_option('ss_twitterwidget','1')){
$simplesocialcontent .= '<div class=simplesocial><a href="http://twitter.com/share" data-url="'.$simplesocial_permlink.'" data-text="'.$simplesocial_title.'" class="twitter-share-button" data-count="horizontal">Just tweet it!</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>';
}
// Facebook widget
if(get_option('ss_facebookwidget','1')){
$simplesocialcontent .= '<div class=simplesocial><iframe src="http://www.facebook.com/plugins/like.php?href='.$simplesocial_enclink.'&layout=standard&show_faces=false&width=450&action=like&colorscheme=light&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px;" allowTransparency="true"></iframe></div>';
}
// New Line
$simplesocialcontent .= '<div style="clear:both"></div>';
// Facebook Button
if(get_option('ss_facebook','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,500,400)" title="Share on Facebook" style="background:url('.$simplesocial_dir.'facebook.png)" href="http://www.facebook.com/share.php?u='.$simplesocial_enclink.'&t='.$simplesocial_title.'"></a>';
}
// Twitter Button
if(get_option('ss_twitter','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,420)" title="Share on Twitter" style="background:url('.$simplesocial_dir.'twitter.png)" href="http://twitter.com/home?status='.$simplesocial_enclink.'"></a>';
}
// Email Button
if(get_option('ss_email','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,435,500)" title="Email a Friend" style="background:url('.$simplesocial_dir.'email.png)" href="http://www.freetellafriend.com/tell/?heading=Share+This+Article&bg=1&option=email&url='.$simplesocial_enclink.'"></a>';
}
// Blogger Button
if(get_option('ss_blogger','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,750,500)" title="Share on Blogger" style="background:url('.$simplesocial_dir.'blogger.png)" href="http://www.blogger.com/blog_this.pyra?t&u='.$simplesocial_enclink.'&n='.$simplesocial_title.'&pli=1"></a>';
}
// Delicious Button
if(get_option('ss_delicious','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,890,550)" title="Share on Delicious" style="background:url('.$simplesocial_dir.'delicious.png)" href="http://del.icio.us/post?url='.$simplesocial_enclink.'&title='.$simplesocial_title.'"></a>';
}
// Digg Button
if(get_option('ss_digg','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,420)" title="Share on Digg" style="background:url('.$simplesocial_dir.'digg.png)" href="http://digg.com/submit?url='.$simplesocial_enclink.'&title='.$simplesocial_title.'"></a>';
}
// Google Button
if(get_option('ss_google','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,750,500)" title="Share on Google" style="background:url('.$simplesocial_dir.'google.png)" href="http://www.google.com/bookmarks/mark?op=add&bkmk='.$simplesocial_enclink.'&title='.$simplesocial_title.'"></a>';
}
// Myspace Button
if(get_option('ss_myspace','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,420)" title="Share on Myspace" style="background:url('.$simplesocial_dir.'myspace.png)" href="http://www.myspace.com/Modules/PostTo/Pages/?u='.$simplesocial_enclink.'&t='.$simplesocial_title.'&c='.$simplesocial_enclink.'"></a>';
}
// StumbleUpon Button
if(get_option('ss_stumbleupon','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,750,500)" title="Share on StumbleUpon" style="background:url('.$simplesocial_dir.'stumbleupon.png)" href="http://www.stumbleupon.com/submit?url='.$simplesocial_enclink.'&title='.$simplesocial_title.'"></a>';
}
// Yahoo Button
if(get_option('ss_yahoo','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,900,550)" title="Share on Yahoo" style="background:url('.$simplesocial_dir.'yahoo.png)" href="http://buzz.yahoo.com/buzz?targetUrl='.$simplesocial_enclink.'&headline='.$simplesocial_title.'"></a>';
}
// Reddit Button
if(get_option('ss_reddit','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,700,500)" title="Share on Reddit" style="background:url('.$simplesocial_dir.'reddit.png)" href="http://reddit.com/submit?url='.$simplesocial_enclink.'&title='.$simplesocial_title.'"></a>';
}
// Technorati Button
if(get_option('ss_technorati','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,500)" title="Share on Technorati" style="background:url('.$simplesocial_dir.'technorati.png)" href="http://technorati.com/faves?sub=favthis&add='.$simplesocial_enclink.'"></a>';
}
// RSS Button
if(get_option('ss_rss','1')){
$simplesocialcontent .= '<a class=simplesocial title="RSS Feed" style="background:url('.$simplesocial_dir.'rss.png)" href="'.get_settings('home').'/?feed=rss2"></a>';
}
// End
$simplesocialcontent.='</div><div style="clear:both;margin-bottom:20px"></div>';
}
return $content.$simplesocialcontent;
}
function simple_social_css() {
echo '<style type="text/css">div.simplesocial,a.simplesocial{float:left;display:block}a.simplesocial{margin-right:5px;width:'.get_option('ss_iconsize',32).'px;height:'.get_option('ss_iconsize',32).'px}a.simplesocial:hover{margin-top:-2px}</style>
<script language="javascript">function simplesocial(t,w,h){
window.open(t.href, \'simplesocial\', \'scrollbars=1,menubar=0,width=\'+w+\',height=\'+h+\',resizable=1,toolbar=0,location=0,status=0,left=\'+(screen.width-w)/2+\',top=\'+(screen.height-h)/3);
return false;}</script>' . "\n";
}
function simple_social_options(){
$simple_social_icons=array('twitterwidget','facebookwidget','facebook','twitter','email','blogger','delicious','digg','google','myspace','stumbleupon','yahoo','reddit','technorati','rss');
foreach($simple_social_icons as $item){$simple_social_pageoptions.='ss_'.$item.',';}
echo '<form method="post" action="options.php"><h3>Text shown above icons:</h3><div style="padding:20px;"><input type="text" size=50 name="ss_title" value="'.get_option('ss_title','Did you like this? Share it:').'"></div><h3>Select Icon Size:</h3><div style="padding:20px;">
<input type="radio" value="16" name="ss_iconsize" id=ss_16 '.(get_option('ss_iconsize',32)==16?'checked':'unchecked').'> <label for=ss_16>Small (16x16)</label> <input type="radio" '.(get_option('ss_iconsize',32)==32?'checked':'unchecked').' id=ss_32 value="32" name="ss_iconsize"> <label for=ss_32>Large (32x32)</label></div>
<h3>Select icons/widgets to display:</h3><div style="padding:20px;">';
foreach($simple_social_icons as $item){
if($item=='twitterwidget'){echo '<div style="margin-bottom:10px;font-weight:bold;font-size:9pt"><input style="margin-right:10px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_settings('home').'/wp-content/plugins/simple-social-sharing-widgets-icons/img/twitterwidget.png"></label></div>';}
else if($item=='facebookwidget'){echo '<div style="margin-bottom:10px;font-weight:bold;font-size:9pt"><input style="margin-right:10px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_settings('home').'/wp-content/plugins/simple-social-sharing-widgets-icons/img/facebookwidget.png"></label></div><div style="clear:both"></div>';}
else{echo '<div style="float:left;margin-right:30px;margin-bottom:10px;"><input style="margin-top:-15px;margin-right:5px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_settings('home').'/wp-content/plugins/simple-social-sharing-widgets-icons/icons_32/'.$item.'.png"></label></div>';
}}
echo '</div><div style="clear:both"></div><p class="submit"><input type="submit" class="button-primary" value="Save Changes"/>';
wp_nonce_field('update-options');
echo '<input type="hidden" name="page_options" value="'.$simple_social_pageoptions.'ss_title,ss_iconsize"><input type="hidden" name="action" value="update" /></form>';
}
add_action('wp_head', 'simple_social_css');
add_filter('the_content', 'simple_social');
add_filter('plugin_action_links', 'simple_social_settinglink', 10, 2);
add_action('admin_menu', 'simple_social_addmenu');
function simple_social_addmenu(){
add_options_page("Simple Social", "Simple Social Icons", "administrator", "simple_social", "simple_social_options");
}
function simple_social_settinglink($links,$file){
if ($file=='simple-social-sharing-widgets-icons/simple-social.php'){
array_unshift($links,'<a href="options-general.php?page=simple_social">Settings</a>');
}
return $links;
}
?>
/*
Plugin Name: Simple Social - Sharing Widgets & Icons
Version: 0.2
Description: Adds a set of social sharing widgets & icons after each post.
*/
function simple_social($content) {
global $post,$simplesocial_icons_pixels;
$simplesocial_permlink = get_permalink($post->ID);
$simplesocial_enclink = urlencode($simplesocial_permlink);
$simplesocial_title = urlencode(get_the_title($post->ID);
$simplesocial_dir = get_settings('home').'/wp-content/plugins/simple-social-sharing-widgets-icons/icons_'.get_option('ss_iconsize',32).'/';
if (!is_feed() && !is_page()){
$simplesocialcontent.='<div>';
// Title
$simplesocialcontent .= '<div style="padding-top:10px;margin-bottom:10px;font-size:10pt;font-family:arial;font-weight:bold;">'.get_option('ss_title','Did you like this? Share it:').'</div>';
// Twitter widget
if(get_option('ss_twitterwidget','1')){
$simplesocialcontent .= '<div class=simplesocial><a href="http://twitter.com/share" data-url="'.$simplesocial_permlink.'" data-text="'.$simplesocial_title.'" class="twitter-share-button" data-count="horizontal">Just tweet it!</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>';
}
// Facebook widget
if(get_option('ss_facebookwidget','1')){
$simplesocialcontent .= '<div class=simplesocial><iframe src="http://www.facebook.com/plugins/like.php?href='.$simplesocial_enclink.'&layout=standard&show_faces=false&width=450&action=like&colorscheme=light&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px;" allowTransparency="true"></iframe></div>';
}
// New Line
$simplesocialcontent .= '<div style="clear:both"></div>';
// Facebook Button
if(get_option('ss_facebook','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,500,400)" title="Share on Facebook" style="background:url('.$simplesocial_dir.'facebook.png)" href="http://www.facebook.com/share.php?u='.$simplesocial_enclink.'&t='.$simplesocial_title.'"></a>';
}
// Twitter Button
if(get_option('ss_twitter','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,420)" title="Share on Twitter" style="background:url('.$simplesocial_dir.'twitter.png)" href="http://twitter.com/home?status='.$simplesocial_enclink.'"></a>';
}
// Email Button
if(get_option('ss_email','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,435,500)" title="Email a Friend" style="background:url('.$simplesocial_dir.'email.png)" href="http://www.freetellafriend.com/tell/?heading=Share+This+Article&bg=1&option=email&url='.$simplesocial_enclink.'"></a>';
}
// Blogger Button
if(get_option('ss_blogger','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,750,500)" title="Share on Blogger" style="background:url('.$simplesocial_dir.'blogger.png)" href="http://www.blogger.com/blog_this.pyra?t&u='.$simplesocial_enclink.'&n='.$simplesocial_title.'&pli=1"></a>';
}
// Delicious Button
if(get_option('ss_delicious','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,890,550)" title="Share on Delicious" style="background:url('.$simplesocial_dir.'delicious.png)" href="http://del.icio.us/post?url='.$simplesocial_enclink.'&title='.$simplesocial_title.'"></a>';
}
// Digg Button
if(get_option('ss_digg','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,420)" title="Share on Digg" style="background:url('.$simplesocial_dir.'digg.png)" href="http://digg.com/submit?url='.$simplesocial_enclink.'&title='.$simplesocial_title.'"></a>';
}
// Google Button
if(get_option('ss_google','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,750,500)" title="Share on Google" style="background:url('.$simplesocial_dir.'google.png)" href="http://www.google.com/bookmarks/mark?op=add&bkmk='.$simplesocial_enclink.'&title='.$simplesocial_title.'"></a>';
}
// Myspace Button
if(get_option('ss_myspace','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,420)" title="Share on Myspace" style="background:url('.$simplesocial_dir.'myspace.png)" href="http://www.myspace.com/Modules/PostTo/Pages/?u='.$simplesocial_enclink.'&t='.$simplesocial_title.'&c='.$simplesocial_enclink.'"></a>';
}
// StumbleUpon Button
if(get_option('ss_stumbleupon','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,750,500)" title="Share on StumbleUpon" style="background:url('.$simplesocial_dir.'stumbleupon.png)" href="http://www.stumbleupon.com/submit?url='.$simplesocial_enclink.'&title='.$simplesocial_title.'"></a>';
}
// Yahoo Button
if(get_option('ss_yahoo','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,900,550)" title="Share on Yahoo" style="background:url('.$simplesocial_dir.'yahoo.png)" href="http://buzz.yahoo.com/buzz?targetUrl='.$simplesocial_enclink.'&headline='.$simplesocial_title.'"></a>';
}
// Reddit Button
if(get_option('ss_reddit','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,700,500)" title="Share on Reddit" style="background:url('.$simplesocial_dir.'reddit.png)" href="http://reddit.com/submit?url='.$simplesocial_enclink.'&title='.$simplesocial_title.'"></a>';
}
// Technorati Button
if(get_option('ss_technorati','1')){
$simplesocialcontent .= '<a class=simplesocial onclick="return simplesocial(this,812,500)" title="Share on Technorati" style="background:url('.$simplesocial_dir.'technorati.png)" href="http://technorati.com/faves?sub=favthis&add='.$simplesocial_enclink.'"></a>';
}
// RSS Button
if(get_option('ss_rss','1')){
$simplesocialcontent .= '<a class=simplesocial title="RSS Feed" style="background:url('.$simplesocial_dir.'rss.png)" href="'.get_settings('home').'/?feed=rss2"></a>';
}
// End
$simplesocialcontent.='</div><div style="clear:both;margin-bottom:20px"></div>';
}
return $content.$simplesocialcontent;
}
function simple_social_css() {
echo '<style type="text/css">div.simplesocial,a.simplesocial{float:left;display:block}a.simplesocial{margin-right:5px;width:'.get_option('ss_iconsize',32).'px;height:'.get_option('ss_iconsize',32).'px}a.simplesocial:hover{margin-top:-2px}</style>
<script language="javascript">function simplesocial(t,w,h){
window.open(t.href, \'simplesocial\', \'scrollbars=1,menubar=0,width=\'+w+\',height=\'+h+\',resizable=1,toolbar=0,location=0,status=0,left=\'+(screen.width-w)/2+\',top=\'+(screen.height-h)/3);
return false;}</script>' . "\n";
}
function simple_social_options(){
$simple_social_icons=array('twitterwidget','facebookwidget','facebook','twitter','email','blogger','delicious','digg','google','myspace','stumbleupon','yahoo','reddit','technorati','rss');
foreach($simple_social_icons as $item){$simple_social_pageoptions.='ss_'.$item.',';}
echo '<form method="post" action="options.php"><h3>Text shown above icons:</h3><div style="padding:20px;"><input type="text" size=50 name="ss_title" value="'.get_option('ss_title','Did you like this? Share it:').'"></div><h3>Select Icon Size:</h3><div style="padding:20px;">
<input type="radio" value="16" name="ss_iconsize" id=ss_16 '.(get_option('ss_iconsize',32)==16?'checked':'unchecked').'> <label for=ss_16>Small (16x16)</label> <input type="radio" '.(get_option('ss_iconsize',32)==32?'checked':'unchecked').' id=ss_32 value="32" name="ss_iconsize"> <label for=ss_32>Large (32x32)</label></div>
<h3>Select icons/widgets to display:</h3><div style="padding:20px;">';
foreach($simple_social_icons as $item){
if($item=='twitterwidget'){echo '<div style="margin-bottom:10px;font-weight:bold;font-size:9pt"><input style="margin-right:10px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_settings('home').'/wp-content/plugins/simple-social-sharing-widgets-icons/img/twitterwidget.png"></label></div>';}
else if($item=='facebookwidget'){echo '<div style="margin-bottom:10px;font-weight:bold;font-size:9pt"><input style="margin-right:10px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_settings('home').'/wp-content/plugins/simple-social-sharing-widgets-icons/img/facebookwidget.png"></label></div><div style="clear:both"></div>';}
else{echo '<div style="float:left;margin-right:30px;margin-bottom:10px;"><input style="margin-top:-15px;margin-right:5px" id=cb_'.$item.' type="checkbox" size="20" name="ss_'.$item.'" '.(get_option('ss_'.$item,true)==true?'checked':'unchecked').'><label for="cb_'.$item.'"><img src="'.get_settings('home').'/wp-content/plugins/simple-social-sharing-widgets-icons/icons_32/'.$item.'.png"></label></div>';
}}
echo '</div><div style="clear:both"></div><p class="submit"><input type="submit" class="button-primary" value="Save Changes"/>';
wp_nonce_field('update-options');
echo '<input type="hidden" name="page_options" value="'.$simple_social_pageoptions.'ss_title,ss_iconsize"><input type="hidden" name="action" value="update" /></form>';
}
add_action('wp_head', 'simple_social_css');
add_filter('the_content', 'simple_social');
add_filter('plugin_action_links', 'simple_social_settinglink', 10, 2);
add_action('admin_menu', 'simple_social_addmenu');
function simple_social_addmenu(){
add_options_page("Simple Social", "Simple Social Icons", "administrator", "simple_social", "simple_social_options");
}
function simple_social_settinglink($links,$file){
if ($file=='simple-social-sharing-widgets-icons/simple-social.php'){
array_unshift($links,'<a href="options-general.php?page=simple_social">Settings</a>');
}
return $links;
}
?>
Er zijn nog geen reacties op dit bericht.