Version Description
Download this release
Release Info
Developer | _mjk_ |
Plugin | WordPress Share Buttons Plugin – AddThis |
Version | 1.5.0 |
Comparing to | |
See all releases |
Version 1.5.0
- addthis_social_widget.php +264 -0
- php4/addthis_social_widget.php +265 -0
- readme.txt +49 -0
- screenshot-1.gif +0 -0
- screenshot-2.gif +0 -0
- screenshot-3.gif +0 -0
- screenshot-4.gif +0 -0
- screenshot-5.gif +0 -0
addthis_social_widget.php
ADDED
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
3 |
+
/*
|
4 |
+
* +--------------------------------------------------------------------------+
|
5 |
+
* | Copyright (c) 2008 Add This, LLC |
|
6 |
+
* +--------------------------------------------------------------------------+
|
7 |
+
* | This program is free software; you can redistribute it and/or modify |
|
8 |
+
* | it under the terms of the GNU General Public License as published by |
|
9 |
+
* | the Free Software Foundation; either version 2 of the License, or |
|
10 |
+
* | (at your option) any later version. |
|
11 |
+
* | |
|
12 |
+
* | This program is distributed in the hope that it will be useful, |
|
13 |
+
* | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+
* | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
+
* | GNU General Public License for more details. |
|
16 |
+
* | |
|
17 |
+
* | You should have received a copy of the GNU General Public License |
|
18 |
+
* | along with this program; if not, write to the Free Software |
|
19 |
+
* | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
20 |
+
* +--------------------------------------------------------------------------+
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Plugin Name: AddThis Social Bookmarking Widget
|
25 |
+
* Plugin URI: http://www.addthis.com
|
26 |
+
* Description: Help your visitor promote your site! The AddThis Social Bookmarking Widget allows any visitor to bookmark your site easily with many popular services. Sign up for an AddThis.com account to see how your visitors are sharing your content--which services they're using for sharing, which content is shared the most, and more. It's all free--even the pretty charts and graphs.
|
27 |
+
* Version: 1.5.0
|
28 |
+
*
|
29 |
+
* Author: The AddThis Team
|
30 |
+
* Author URI: http://www.addthis.com
|
31 |
+
*/
|
32 |
+
class addthis_social_widget
|
33 |
+
{
|
34 |
+
/// Set false if you'd like the pop-up menu instead
|
35 |
+
private $addthis_isdropdown;
|
36 |
+
|
37 |
+
/// Advanced customization options here (e.g., 'addthis_options = "email";'). See http://www.addthis.com/customization
|
38 |
+
private $customization;
|
39 |
+
private $addthis_language;
|
40 |
+
|
41 |
+
/// AddThis publisher ID
|
42 |
+
private $addthis_username;
|
43 |
+
|
44 |
+
/// Share button style (possible styles: share, bookmark, addthis, share-small, bookmark-small, plus)
|
45 |
+
private $addthis_style;
|
46 |
+
|
47 |
+
public static $languages = array('zh'=>'Chinese', 'da'=>'Danish', 'nl'=>'Dutch', 'en'=>'English', 'fi'=>'Finnish', 'fr'=>'French', 'de'=>'German', 'he'=>'Hebrew', 'it'=>'Italian', 'ja'=>'Japanese', 'ko'=>'Korean', 'no'=>'Norwegian', 'pl'=>'Polish', 'pt'=>'Portugese', 'ru'=>'Russian', 'es'=>'Spanish', 'sv'=>'Swedish');
|
48 |
+
|
49 |
+
public static $btnStyles = array(
|
50 |
+
'share' => array('img'=>'lg-share-%lang%.gif', 'w'=>125, 'h'=>16),
|
51 |
+
'bookmark' => array('img'=>'lg-bookmark-en.gif', 'w'=>125, 'h'=>16),
|
52 |
+
'addthis' => array('img'=>'lg-addthis-en.gif', 'w'=>125, 'h'=>16),
|
53 |
+
'share-small' => array('img'=>'sm-share-%lang%.gif', 'w'=>83, 'h'=>16),
|
54 |
+
'bookmark-small' => array('img'=>'sm-bookmark-en.gif', 'w'=>83, 'h'=>16),
|
55 |
+
'plus' => array('img'=>'sm-plus.gif', 'w'=>16, 'h'=>16)
|
56 |
+
/* Add your own style here, like this:
|
57 |
+
, 'custom' => array('img'=>'http://example.com/button.gif', 'w'=>16, 'h'=>16) */
|
58 |
+
);
|
59 |
+
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Adds WP filter so we can append the AddThis button to post content.
|
63 |
+
*/
|
64 |
+
function addthis_social_widget($username=null, $style=null)
|
65 |
+
{
|
66 |
+
add_filter('the_content', array(&$this, 'social_widget'));
|
67 |
+
add_filter('admin_menu', array(&$this, 'admin_menu'));
|
68 |
+
|
69 |
+
add_option('addthis_username');
|
70 |
+
add_option('addthis_options', 'email, favorites, digg, delicious, myspace, google, facebook, reddit, live, more');
|
71 |
+
add_option('addthis_isdropdown', true);
|
72 |
+
add_option('addthis_style');
|
73 |
+
add_option('addthis_logo');
|
74 |
+
add_option('addthis_logo_background');
|
75 |
+
add_option('addthis_logo_color');
|
76 |
+
add_option('addthis_brand');
|
77 |
+
add_option('addthis_language', 'en');
|
78 |
+
|
79 |
+
$this->addthis_isdropdown = get_option('addthis_isdropdown') === 'true';
|
80 |
+
|
81 |
+
if (!isset($style)) $style = get_option('addthis_style');
|
82 |
+
if (strlen($style) == 0) $style = 'share';
|
83 |
+
$this->addthis_style = $style;
|
84 |
+
|
85 |
+
if (!isset($username)) $username = get_option('addthis_username');
|
86 |
+
$this->addthis_username = $username;
|
87 |
+
|
88 |
+
$language = get_option('addthis_language');
|
89 |
+
$this->addthis_language = $language;
|
90 |
+
|
91 |
+
$advopts = array('logo', 'brand', 'language', 'logo_background', 'logo_colors', 'options');
|
92 |
+
$this->customization = '';
|
93 |
+
for ($i = 0; $i < count($advopts); $i++)
|
94 |
+
{
|
95 |
+
$opt = $advopts[$i];
|
96 |
+
$val = get_option("addthis_$opt");
|
97 |
+
if (isset($val) && strlen($val)) $this->customization .= "var addthis_$opt = '$val';";
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Appends AddThis button to post content.
|
103 |
+
*/
|
104 |
+
public function social_widget($content)
|
105 |
+
{
|
106 |
+
// add nothing to RSS feed
|
107 |
+
if (is_feed()) return $content;
|
108 |
+
|
109 |
+
$pub = $this->addthis_username;
|
110 |
+
$link = urlencode(get_permalink());
|
111 |
+
$title = urlencode(get_the_title($id));
|
112 |
+
|
113 |
+
$content .= "\n<!-- AddThis Button BEGIN -->\n";
|
114 |
+
if ($this->addthis_isdropdown)
|
115 |
+
{
|
116 |
+
if (isset($pub) || strlen($this->customization))
|
117 |
+
{
|
118 |
+
$content .= '<script type="text/javascript">' . (isset($pub) ? "\nvar addthis_pub = '$pub';\n" : "\n") . ($this->customization) . "\n</script>\n";
|
119 |
+
}
|
120 |
+
$content .= <<<EOF
|
121 |
+
<div><a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '$link', '$title')" onmouseout="addthis_close()" onclick="return addthis_sendto()">{$this->get_button_img()}</a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script></div>
|
122 |
+
EOF;
|
123 |
+
}
|
124 |
+
else
|
125 |
+
{
|
126 |
+
$content .= <<<EOF
|
127 |
+
<div><a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?pub=$pub&url=$link&title=$title', 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no'); return false;" title="Bookmark using any bookmark manager!" target="_blank">{$this->get_button_img()}</a></div>
|
128 |
+
EOF;
|
129 |
+
}
|
130 |
+
$content .= "\n<!-- AddThis Button END -->";
|
131 |
+
return $content;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Generates img tag for share/bookmark button.
|
136 |
+
*/
|
137 |
+
private function get_button_img()
|
138 |
+
{
|
139 |
+
$btnStyle = $this->addthis_style;
|
140 |
+
if ($this->addthis_language != 'en')
|
141 |
+
{
|
142 |
+
// We use a translation of the word 'share' for all verbal buttons
|
143 |
+
switch ($btnStyle)
|
144 |
+
{
|
145 |
+
case 'bookmark':
|
146 |
+
case 'addthis':
|
147 |
+
case 'bookmark-sm':
|
148 |
+
$btnStyle = 'share';
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
if (!isset(self::$btnStyles[$btnStyle])) $btnStyle = 'share';
|
153 |
+
$btnRecord = self::$btnStyles[$btnStyle];
|
154 |
+
$btnUrl = (strpos(trim($btnRecord['img']), 'http://') !== 0 ? "http://s7.addthis.com/static/btn/" : "") . $btnRecord['img'];
|
155 |
+
|
156 |
+
if (strpos($btnUrl, '%lang%') !== false)
|
157 |
+
{
|
158 |
+
$btnUrl = str_replace('%lang%',$this->addthis_language, $btnUrl);
|
159 |
+
}
|
160 |
+
$btnWidth = $btnRecord['w'];
|
161 |
+
$btnHeight = $btnRecord['h'];
|
162 |
+
return <<<EOF
|
163 |
+
<img src="{$btnUrl}" width="{$btnWidth}" height="{$btnHeight}" border="0" alt="" />
|
164 |
+
EOF;
|
165 |
+
}
|
166 |
+
|
167 |
+
public function admin_menu()
|
168 |
+
{
|
169 |
+
add_options_page('AddThis Plugin Options', 'AddThis', 8, __FILE__, 'addthis_plugin_options');
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
function addthis_plugin_options() {
|
174 |
+
?>
|
175 |
+
<div class="wrap">
|
176 |
+
<h2>AddThis</h2>
|
177 |
+
|
178 |
+
<form method="post" action="options.php">
|
179 |
+
<?php wp_nonce_field('update-options'); ?>
|
180 |
+
|
181 |
+
<h3>Required</h3>
|
182 |
+
<table class="form-table">
|
183 |
+
<tr valign="top">
|
184 |
+
<th scope="row"><?php _e("AddThis username:", 'addthis_trans_domain' ); ?></th>
|
185 |
+
<td><input type="text" name="addthis_username" value="<?php echo get_option('addthis_username'); ?>" /></td>
|
186 |
+
</tr>
|
187 |
+
<tr valign="top">
|
188 |
+
<th scope="row"><?php _e("Button style:", 'addthis_trans_domain' ); ?></th>
|
189 |
+
<td>
|
190 |
+
<select name="addthis_style">
|
191 |
+
<?php
|
192 |
+
$curstyle = get_option('addthis_style');
|
193 |
+
foreach (addthis_social_widget::$btnStyles as $style => $info)
|
194 |
+
{
|
195 |
+
echo "<option value=\"$style\"". ($style == $curstyle ? " selected":""). ">$style</option>";
|
196 |
+
}
|
197 |
+
?>
|
198 |
+
</select>
|
199 |
+
</td>
|
200 |
+
</tr>
|
201 |
+
<tr valign="top">
|
202 |
+
<th scope="row"><?php _e("Use dropdown menu:", 'addthis_trans_domain' ); ?></th>
|
203 |
+
<td><input type="checkbox" name="addthis_isdropdown" value="true" <?php echo (get_option('addthis_isdropdown') == 'true' ? 'checked' : ''); ?>/></td>
|
204 |
+
</tr>
|
205 |
+
</table>
|
206 |
+
|
207 |
+
<br />
|
208 |
+
<br />
|
209 |
+
<br />
|
210 |
+
|
211 |
+
<h3>Advanced</h3>
|
212 |
+
See <a href="http://addthis.com/customization">our customization docs</a>.
|
213 |
+
<table class="form-table">
|
214 |
+
<tr valign="top">
|
215 |
+
<th scope="row"><?php _e("Brand:", 'addthis_trans_domain' ); ?></th>
|
216 |
+
<td><input type="text" name="addthis_brand" value="<?php echo get_option('addthis_brand'); ?>" /></td>
|
217 |
+
</tr>
|
218 |
+
<tr valign="top">
|
219 |
+
<th scope="row"><?php _e("Drop-down options (comma-separated):", 'addthis_trans_domain' ); ?></th>
|
220 |
+
<td><input type="text" name="addthis_options" value="<?php echo get_option('addthis_options'); ?>" size="100"/></td>
|
221 |
+
</tr>
|
222 |
+
<tr valign="top">
|
223 |
+
<th scope="row"><?php _e("Language:", 'addthis_trans_domain' ); ?></th>
|
224 |
+
<td>
|
225 |
+
<select name="addthis_language">
|
226 |
+
<?php
|
227 |
+
$curlng = get_option('addthis_language');
|
228 |
+
foreach (addthis_social_widget::$languages as $lng=>$name)
|
229 |
+
{
|
230 |
+
echo "<option value=\"$lng\"". ($lng == $curlng ? " selected":""). ">$name</option>";
|
231 |
+
}
|
232 |
+
?>
|
233 |
+
</select>
|
234 |
+
</td>
|
235 |
+
</tr>
|
236 |
+
<tr valign="top">
|
237 |
+
<th scope="row"><?php _e("Logo:", 'addthis_trans_domain' ); ?></th>
|
238 |
+
<td><input type="text" name="addthis_logo" value="<?php echo get_option('addthis_logo'); ?>" /></td>
|
239 |
+
</tr>
|
240 |
+
<tr valign="top">
|
241 |
+
<th scope="row"><?php _e("Logo background:", 'addthis_trans_domain' ); ?></th>
|
242 |
+
<td><input type="text" name="addthis_logo_background" value="<?php echo get_option('addthis_logo_background'); ?>" /></td>
|
243 |
+
</tr>
|
244 |
+
<tr valign="top">
|
245 |
+
<th scope="row"><?php _e("Logo color:", 'addthis_trans_domain' ); ?></th>
|
246 |
+
<td><input type="text" name="addthis_logo_color" value="<?php echo get_option('addthis_logo_color'); ?>" /></td>
|
247 |
+
</tr>
|
248 |
+
</table>
|
249 |
+
|
250 |
+
<input type="hidden" name="action" value="update" />
|
251 |
+
<input type="hidden" name="page_options" value="addthis_username,addthis_style,addthis_isdropdown,addthis_language,addthis_brand,addthis_options,addthis_logo,addthis_logo_background,addthis_logo_color"/>
|
252 |
+
|
253 |
+
<p class="submit">
|
254 |
+
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
|
255 |
+
</p>
|
256 |
+
|
257 |
+
</form>
|
258 |
+
</div>
|
259 |
+
<?php
|
260 |
+
}
|
261 |
+
|
262 |
+
|
263 |
+
$addthis &= new addthis_social_widget();
|
264 |
+
?>
|
php4/addthis_social_widget.php
ADDED
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
3 |
+
/*
|
4 |
+
* +--------------------------------------------------------------------------+
|
5 |
+
* | Copyright (c) 2008 Add This, LLC |
|
6 |
+
* +--------------------------------------------------------------------------+
|
7 |
+
* | This program is free software; you can redistribute it and/or modify |
|
8 |
+
* | it under the terms of the GNU General Public License as published by |
|
9 |
+
* | the Free Software Foundation; either version 2 of the License, or |
|
10 |
+
* | (at your option) any later version. |
|
11 |
+
* | |
|
12 |
+
* | This program is distributed in the hope that it will be useful, |
|
13 |
+
* | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+
* | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
+
* | GNU General Public License for more details. |
|
16 |
+
* | |
|
17 |
+
* | You should have received a copy of the GNU General Public License |
|
18 |
+
* | along with this program; if not, write to the Free Software |
|
19 |
+
* | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
20 |
+
* +--------------------------------------------------------------------------+
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Plugin Name: AddThis Social Bookmarking Widget
|
25 |
+
* Plugin URI: http://www.addthis.com
|
26 |
+
* Description: Help your visitor promote your site! The AddThis Social Bookmarking Widget allows any visitor to bookmark your site easily with many popular services. Sign up for an AddThis.com account to see how your visitors are sharing your content--which services they're using for sharing, which content is shared the most, and more. It's all free--even the pretty charts and graphs.
|
27 |
+
* Version: 1.5.0
|
28 |
+
*
|
29 |
+
* Author: The AddThis Team
|
30 |
+
* Author URI: http://www.addthis.com
|
31 |
+
*/
|
32 |
+
$addthis_settings = array(array('isdropdown', 'false'),
|
33 |
+
array('customization', ''),
|
34 |
+
array('language', 'en'),
|
35 |
+
array('username', ''),
|
36 |
+
array('style', 'share'));
|
37 |
+
|
38 |
+
$addthis_languages = array('zh'=>'Chinese', 'da'=>'Danish', 'nl'=>'Dutch', 'en'=>'English', 'fi'=>'Finnish', 'fr'=>'French', 'de'=>'German', 'he'=>'Hebrew', 'it'=>'Italian', 'ja'=>'Japanese', 'ko'=>'Korean', 'no'=>'Norwegian', 'pl'=>'Polish', 'pt'=>'Portugese', 'ru'=>'Russian', 'es'=>'Spanish', 'sv'=>'Swedish');
|
39 |
+
|
40 |
+
$addthis_styles = array(
|
41 |
+
'share' => array('img'=>'lg-share-%lang%.gif', 'w'=>125, 'h'=>16),
|
42 |
+
'bookmark' => array('img'=>'lg-bookmark-en.gif', 'w'=>125, 'h'=>16),
|
43 |
+
'addthis' => array('img'=>'lg-addthis-en.gif', 'w'=>125, 'h'=>16),
|
44 |
+
'share-small' => array('img'=>'sm-share-%lang%.gif', 'w'=>83, 'h'=>16),
|
45 |
+
'bookmark-small' => array('img'=>'sm-bookmark-en.gif', 'w'=>83, 'h'=>16),
|
46 |
+
'plus' => array('img'=>'sm-plus.gif', 'w'=>16, 'h'=>16)
|
47 |
+
/* Add your own style here, like this:
|
48 |
+
, 'custom' => array('img'=>'http://example.com/button.gif', 'w'=>16, 'h'=>16) */
|
49 |
+
);
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Adds WP filter so we can append the AddThis button to post content.
|
54 |
+
*/
|
55 |
+
function addthis_init($username=null, $style=null)
|
56 |
+
{
|
57 |
+
global $addthis_settings;
|
58 |
+
|
59 |
+
add_filter('the_content', 'addthis_social_widget');
|
60 |
+
add_filter('admin_menu', 'addthis_admin_menu');
|
61 |
+
|
62 |
+
add_option('addthis_username');
|
63 |
+
add_option('addthis_options', 'email, favorites, digg, delicious, myspace, google, facebook, reddit, live, more');
|
64 |
+
add_option('addthis_isdropdown', true);
|
65 |
+
add_option('addthis_style');
|
66 |
+
add_option('addthis_logo');
|
67 |
+
add_option('addthis_logo_background');
|
68 |
+
add_option('addthis_logo_color');
|
69 |
+
add_option('addthis_brand');
|
70 |
+
add_option('addthis_language', 'en');
|
71 |
+
|
72 |
+
$addthis_settings['isdropdown'] = get_option('addthis_isdropdown') === 'true';
|
73 |
+
|
74 |
+
if (!isset($style)) $style = get_option('addthis_style');
|
75 |
+
if (strlen($style) == 0) $style = 'share';
|
76 |
+
$addthis_settings['style'] = $style;
|
77 |
+
|
78 |
+
if (!isset($username)) $username = get_option('addthis_username');
|
79 |
+
$addthis_settings['username'] = $username;
|
80 |
+
|
81 |
+
$language = get_option('addthis_language');
|
82 |
+
$addthis_settings['language'] = $language;
|
83 |
+
|
84 |
+
$advopts = array('logo', 'brand', 'language', 'logo_background', 'logo_colors', 'options');
|
85 |
+
$addthis_settings['customization'] = '';
|
86 |
+
for ($i = 0; $i < count($advopts); $i++)
|
87 |
+
{
|
88 |
+
$opt = $advopts[$i];
|
89 |
+
$val = get_option("addthis_$opt");
|
90 |
+
if (isset($val) && strlen($val)) $addthis_settings['customization'] .= "var addthis_$opt = '$val';";
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Appends AddThis button to post content.
|
96 |
+
*/
|
97 |
+
function addthis_social_widget($content)
|
98 |
+
{
|
99 |
+
global $addthis_settings;
|
100 |
+
|
101 |
+
// add nothing to RSS feed
|
102 |
+
if (is_feed()) return $content;
|
103 |
+
|
104 |
+
$pub = $addthis_settings['username'];
|
105 |
+
$link = urlencode(get_permalink());
|
106 |
+
$title = urlencode(get_the_title($id));
|
107 |
+
|
108 |
+
$content .= "\n<!-- AddThis Button BEGIN -->\n";
|
109 |
+
if ($addthis_settings['isdropdown'])
|
110 |
+
{
|
111 |
+
if (isset($pub) || strlen($addthis_settings['customization']))
|
112 |
+
{
|
113 |
+
$content .= '<script type="text/javascript">' . (isset($pub) ? "\nvar addthis_pub = '$pub';\n" : "\n") . ($addthis_settings['customization']) . "\n</script>\n";
|
114 |
+
}
|
115 |
+
$content .= <<<EOF
|
116 |
+
<div><a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '$link', '$title')" onmouseout="addthis_close()" onclick="return addthis_sendto()">
|
117 |
+
EOF;
|
118 |
+
$content .= addthis_get_button_img() . '</a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script></div>';
|
119 |
+
}
|
120 |
+
else
|
121 |
+
{
|
122 |
+
$content .= <<<EOF
|
123 |
+
<div><a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?pub=$pub&url=$link&title=$title', 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no'); return false;" title="Bookmark using any bookmark manager!" target="_blank">
|
124 |
+
EOF;
|
125 |
+
$content .= addthis_get_button_img() . '</a></div>';
|
126 |
+
}
|
127 |
+
$content .= "\n<!-- AddThis Button END -->";
|
128 |
+
return $content;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Generates img tag for share/bookmark button.
|
133 |
+
*/
|
134 |
+
function addthis_get_button_img()
|
135 |
+
{
|
136 |
+
global $addthis_settings;
|
137 |
+
global $addthis_styles;
|
138 |
+
|
139 |
+
$btnStyle = $addthis_settings['style'];
|
140 |
+
if ($addthis_settings['language'] != 'en')
|
141 |
+
{
|
142 |
+
// We use a translation of the word 'share' for all verbal buttons
|
143 |
+
switch ($btnStyle)
|
144 |
+
{
|
145 |
+
case 'bookmark':
|
146 |
+
case 'addthis':
|
147 |
+
case 'bookmark-sm':
|
148 |
+
$btnStyle = 'share';
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
if (!isset($addthis_styles[$btnStyle])) $btnStyle = 'share';
|
153 |
+
$btnRecord = $addthis_styles[$btnStyle];
|
154 |
+
$btnUrl = (strpos(trim($btnRecord['img']), 'http://') !== 0 ? "http://s7.addthis.com/static/btn/" : "") . $btnRecord['img'];
|
155 |
+
|
156 |
+
if (strpos($btnUrl, '%lang%') !== false)
|
157 |
+
{
|
158 |
+
$btnUrl = str_replace('%lang%',$addthis_settings['language'], $btnUrl);
|
159 |
+
}
|
160 |
+
$btnWidth = $btnRecord['w'];
|
161 |
+
$btnHeight = $btnRecord['h'];
|
162 |
+
return <<<EOF
|
163 |
+
<img src="$btnUrl" width="$btnWidth" height="$btnHeight" border="0" alt="" />
|
164 |
+
EOF;
|
165 |
+
}
|
166 |
+
|
167 |
+
function addthis_admin_menu()
|
168 |
+
{
|
169 |
+
add_options_page('AddThis Plugin Options', 'AddThis', 8, __FILE__, 'addthis_plugin_options');
|
170 |
+
}
|
171 |
+
|
172 |
+
function addthis_plugin_options() {
|
173 |
+
global $addthis_styles;
|
174 |
+
global $addthis_languages;
|
175 |
+
global $addthis_settings;
|
176 |
+
|
177 |
+
?>
|
178 |
+
<div class="wrap">
|
179 |
+
<h2>AddThis</h2>
|
180 |
+
|
181 |
+
<form method="post" action="options.php">
|
182 |
+
<?php wp_nonce_field('update-options'); ?>
|
183 |
+
|
184 |
+
<h3>Required</h3>
|
185 |
+
<table class="form-table">
|
186 |
+
<tr valign="top">
|
187 |
+
<th scope="row"><?php _e("AddThis username:", 'addthis_trans_domain' ); ?></th>
|
188 |
+
<td><input type="text" name="addthis_username" value="<?php echo get_option('addthis_username'); ?>" /></td>
|
189 |
+
</tr>
|
190 |
+
<tr valign="top">
|
191 |
+
<th scope="row"><?php _e("Button style:", 'addthis_trans_domain' ); ?></th>
|
192 |
+
<td>
|
193 |
+
<select name="addthis_style">
|
194 |
+
<?php
|
195 |
+
$curstyle = get_option('addthis_style');
|
196 |
+
foreach ($addthis_styles as $style => $info)
|
197 |
+
{
|
198 |
+
echo "<option value=\"$style\"". ($style == $curstyle ? " selected":""). ">$style</option>";
|
199 |
+
}
|
200 |
+
?>
|
201 |
+
</select>
|
202 |
+
</td>
|
203 |
+
</tr>
|
204 |
+
<tr valign="top">
|
205 |
+
<th scope="row"><?php _e("Use dropdown menu:", 'addthis_trans_domain' ); ?></th>
|
206 |
+
<td><input type="checkbox" name="addthis_isdropdown" value="true" <?php echo (get_option('addthis_isdropdown') !== '' ? 'checked' : ''); ?>/></td>
|
207 |
+
</tr>
|
208 |
+
</table>
|
209 |
+
|
210 |
+
<br />
|
211 |
+
<br />
|
212 |
+
<br />
|
213 |
+
|
214 |
+
<h3>Advanced</h3>
|
215 |
+
See <a href="http://addthis.com/customization">our customization docs</a>.
|
216 |
+
<table class="form-table">
|
217 |
+
<tr valign="top">
|
218 |
+
<th scope="row"><?php _e("Brand:", 'addthis_trans_domain' ); ?></th>
|
219 |
+
<td><input type="text" name="addthis_brand" value="<?php echo get_option('addthis_brand'); ?>" /></td>
|
220 |
+
</tr>
|
221 |
+
<tr valign="top">
|
222 |
+
<th scope="row"><?php _e("Drop-down options (comma-separated):", 'addthis_trans_domain' ); ?></th>
|
223 |
+
<td><input type="text" name="addthis_options" value="<?php echo get_option('addthis_options'); ?>" size="100"/></td>
|
224 |
+
</tr>
|
225 |
+
<tr valign="top">
|
226 |
+
<th scope="row"><?php _e("Language:", 'addthis_trans_domain' ); ?></th>
|
227 |
+
<td>
|
228 |
+
<select name="addthis_language">
|
229 |
+
<?php
|
230 |
+
$curlng = get_option('addthis_language');
|
231 |
+
foreach ($addthis_languages as $lng=>$name)
|
232 |
+
{
|
233 |
+
echo "<option value=\"$lng\"". ($lng == $curlng ? " selected":""). ">$name</option>";
|
234 |
+
}
|
235 |
+
?>
|
236 |
+
</select>
|
237 |
+
</td>
|
238 |
+
</tr>
|
239 |
+
<tr valign="top">
|
240 |
+
<th scope="row"><?php _e("Logo:", 'addthis_trans_domain' ); ?></th>
|
241 |
+
<td><input type="text" name="addthis_logo" value="<?php echo get_option('addthis_logo'); ?>" /></td>
|
242 |
+
</tr>
|
243 |
+
<tr valign="top">
|
244 |
+
<th scope="row"><?php _e("Logo background:", 'addthis_trans_domain' ); ?></th>
|
245 |
+
<td><input type="text" name="addthis_logo_background" value="<?php echo get_option('addthis_logo_background'); ?>" /></td>
|
246 |
+
</tr>
|
247 |
+
<tr valign="top">
|
248 |
+
<th scope="row"><?php _e("Logo color:", 'addthis_trans_domain' ); ?></th>
|
249 |
+
<td><input type="text" name="addthis_logo_color" value="<?php echo get_option('addthis_logo_color'); ?>" /></td>
|
250 |
+
</tr>
|
251 |
+
</table>
|
252 |
+
|
253 |
+
<input type="hidden" name="action" value="update" />
|
254 |
+
<input type="hidden" name="page_options" value="addthis_username,addthis_style,addthis_isdropdown,addthis_language,addthis_brand,addthis_options,addthis_logo,addthis_logo_background,addthis_logo_color"/>
|
255 |
+
|
256 |
+
<p class="submit">
|
257 |
+
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
|
258 |
+
</p>
|
259 |
+
|
260 |
+
</form>
|
261 |
+
</div>
|
262 |
+
<?php
|
263 |
+
}
|
264 |
+
addthis_init();
|
265 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== AddThis ===
|
2 |
+
Contributors: _mjk_
|
3 |
+
Tags: share, addthis, social, bookmark, sharing, bookmarking, widget
|
4 |
+
Requires at least: 2.3
|
5 |
+
Tested up to: 2.7
|
6 |
+
Stable tag: 1.5.0
|
7 |
+
|
8 |
+
The AddThis Social Bookmarking Widget allows any visitor to bookmark and share your site easily with many popular services.
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
Help your visitor promote your site! The AddThis Social Bookmarking Widget allows your users to bookmark your site easily with over 45 popular services, and to share it with friends via email. Our button is small, unobtrusive, quick to load and recognized all over the web.
|
12 |
+
|
13 |
+
Sign up for an AddThis.com account to see how your visitors are sharing your content: which services they're using for sharing, which content is shared the most, and more. It's all free--even the pretty charts and graphs.
|
14 |
+
|
15 |
+
Over 120,000 sites have installed AddThis. Join us!
|
16 |
+
|
17 |
+
== Installation ==
|
18 |
+
|
19 |
+
1. Upload `addthis_social_widget.php` to the `/wp-content/plugins/` directory
|
20 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
21 |
+
1. (Optional) Customize the plugin in the Settings > AddThis menu
|
22 |
+
|
23 |
+
If you're using PHP 4, make sure to grab the plugin from our /php4 directory.
|
24 |
+
|
25 |
+
== Frequently Asked Questions ==
|
26 |
+
|
27 |
+
= Is AddThis free? =
|
28 |
+
|
29 |
+
Yep! The features you see today on AddThis will always be free.
|
30 |
+
|
31 |
+
= Do I need to create an account? =
|
32 |
+
|
33 |
+
No. You only need to create an account if you want to see how your users are sharing your blog; the sharing itself works the same either way.
|
34 |
+
|
35 |
+
= Is JavaScript required? =
|
36 |
+
|
37 |
+
If you've turned on the drop-down menu (which is recommended, as it's been shown to increase sharing/bookmarking rates), JavaScript must be enabled. We load the actual interface via JavaScript at run-time, which allows us to upgrade the core functionality of the menu itself automatically everywhere.
|
38 |
+
|
39 |
+
== Screenshots ==
|
40 |
+
|
41 |
+
1. The button on a sample post.
|
42 |
+
2. The open menu on a sample post.
|
43 |
+
3. The settings interface on WordPress 2.7.
|
44 |
+
4. A sample sharing trend report.
|
45 |
+
5. A sample service usage report.
|
46 |
+
|
47 |
+
== PHP Version ==
|
48 |
+
|
49 |
+
PHP 5+ is preferred; PHP 4 is supported.
|
screenshot-1.gif
ADDED
Binary file
|
screenshot-2.gif
ADDED
Binary file
|
screenshot-3.gif
ADDED
Binary file
|
screenshot-4.gif
ADDED
Binary file
|
screenshot-5.gif
ADDED
Binary file
|