136
|
1 |
<?php |
|
2 |
/* |
|
3 |
Plugin Name: Add to Any: Share/Bookmark/Email Button |
|
4 |
Plugin URI: http://www.addtoany.com/ |
|
5 |
Description: Help readers share, bookmark, and email your posts and pages using any service. [<a href="options-general.php?page=add-to-any.php">Settings</a>] |
|
6 |
Version: .9.9.4.3 |
|
7 |
Author: Add to Any |
|
8 |
Author URI: http://www.addtoany.com/contact/ |
|
9 |
*/ |
|
10 |
|
|
11 |
if( !isset($A2A_javascript) ) |
|
12 |
$A2A_javascript = ''; |
|
13 |
if( !isset($A2A_locale) ) |
|
14 |
$A2A_locale = ''; |
|
15 |
|
|
16 |
// Pre-2.6 compatibility |
|
17 |
if ( !defined('WP_CONTENT_URL') ) |
|
18 |
define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); |
|
19 |
if ( ! defined( 'WP_PLUGIN_URL' ) ) |
|
20 |
define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' ); |
|
21 |
|
|
22 |
$A2A_SHARE_SAVE_plugin_basename = plugin_basename(dirname(__FILE__)); |
|
23 |
$A2A_SHARE_SAVE_plugin_url_path = WP_PLUGIN_URL.'/'.$A2A_SHARE_SAVE_plugin_basename; // /wp-content/plugins/add-to-any |
|
24 |
|
|
25 |
function A2A_SHARE_SAVE_textdomain() { |
|
26 |
global $A2A_SHARE_SAVE_plugin_url_path, $A2A_SHARE_SAVE_plugin_basename; |
|
27 |
|
|
28 |
load_plugin_textdomain('add-to-any', |
|
29 |
$A2A_SHARE_SAVE_plugin_url_path.'/languages', |
|
30 |
$A2A_SHARE_SAVE_plugin_basename.'/languages'); |
|
31 |
} |
|
32 |
add_action('init', 'A2A_SHARE_SAVE_textdomain'); |
|
33 |
|
|
34 |
function A2A_SHARE_SAVE_link_vars() { |
|
35 |
global $post; |
|
36 |
|
|
37 |
$linkname = get_the_title($post->ID); |
|
38 |
$linkname_enc = rawurlencode( $linkname ); |
|
39 |
$linkurl = get_permalink($post->ID); |
|
40 |
$linkurl_enc = rawurlencode( $linkurl ); |
|
41 |
|
|
42 |
return compact( 'linkname', 'linkname_enc', 'linkurl', 'linkurl_enc' ); |
|
43 |
} |
|
44 |
|
|
45 |
include_once('services.php'); |
|
46 |
|
|
47 |
function ADDTOANY_SHARE_SAVE_ICONS( $args = false ) { |
|
48 |
if( $args ) |
|
49 |
extract( $args ); // output_later, html_wrap_open, html_wrap_close |
|
50 |
extract(A2A_SHARE_SAVE_link_vars()); // linkname_enc, etc. |
|
51 |
|
|
52 |
global $A2A_SHARE_SAVE_plugin_url_path, $A2A_SHARE_SAVE_services; |
|
53 |
|
|
54 |
// Make available services extensible via plugins, themes (functions.php), etc. |
|
55 |
$A2A_SHARE_SAVE_services = apply_filters('A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services); |
|
56 |
|
|
57 |
$active_services = get_option('A2A_SHARE_SAVE_active_services'); |
|
58 |
|
|
59 |
$ind_html = ""; |
|
60 |
|
|
61 |
if( !$active_services ) |
|
62 |
$active_services = Array(); |
|
63 |
|
|
64 |
foreach($active_services as $active_service) { |
|
65 |
|
|
66 |
// Skip unknown |
|
67 |
if( !in_array($active_service, array_keys($A2A_SHARE_SAVE_services)) ) |
|
68 |
continue; |
|
69 |
|
|
70 |
$service = $A2A_SHARE_SAVE_services[$active_service]; |
|
71 |
$safe_name = $active_service; |
|
72 |
$name = $service['name']; |
|
73 |
|
|
74 |
if (isset($service['href'])) { |
|
75 |
$custom_service = TRUE; |
|
76 |
$href = $service['href']; |
|
77 |
$href = str_replace('A2A_LINKURL', $linkurl_enc, $href); |
|
78 |
$href = str_replace('A2A_LINKNAME', $linkname_enc, $href); |
|
79 |
} else { |
|
80 |
$custom_service = FALSE; |
|
81 |
} |
|
82 |
|
|
83 |
if ( $custom_service && isset($service['icon_url']) ) |
|
84 |
$icon = $service['icon_url']; |
|
85 |
elseif ( ! isset($service['icon'])) |
|
86 |
$icon = 'default'; |
|
87 |
else |
|
88 |
$icon = $service['icon']; |
|
89 |
$width = (isset($service['icon_width'])) ? $service['icon_width'] : '16'; |
|
90 |
$height = (isset($service['icon_height'])) ? $service['icon_height'] : '16'; |
|
91 |
|
|
92 |
$url = ($custom_service) ? $href : "http://www.addtoany.com/add_to/" . $safe_name . "?linkurl=" . $linkurl_enc . "&linkname=" . $linkname_enc; |
|
93 |
$src = ($custom_service) ? $icon : $A2A_SHARE_SAVE_plugin_url_path."/icons/".$icon.".png"; |
|
94 |
|
|
95 |
$link = $html_wrap_open."<a href=\"$url\" title=\"$name\" rel=\"nofollow\" target=\"_blank\">"; |
|
96 |
$link .= "<img src=\"$src\" width=\"$width\" height=\"$height\" alt=\"$name\"/>"; |
|
97 |
$link .= "</a>".$html_wrap_close; |
|
98 |
|
|
99 |
$ind_html .= apply_filters('addtoany_link', $link); |
|
100 |
} |
|
101 |
|
|
102 |
if($output_later) |
|
103 |
return $ind_html; |
|
104 |
else |
|
105 |
echo $ind_html; |
|
106 |
} |
|
107 |
|
|
108 |
function ADDTOANY_SHARE_SAVE_BUTTON( $args = false ) { |
|
109 |
|
|
110 |
global $A2A_SHARE_SAVE_plugin_url_path, $A2A_SHARE_SAVE_services; |
|
111 |
|
|
112 |
// Make available services extensible via plugins, themes (functions.php), etc. |
|
113 |
$A2A_SHARE_SAVE_services = apply_filters('A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services); |
|
114 |
|
|
115 |
if( $args ) |
|
116 |
extract( $args ); // output_later, html_wrap_open, html_wrap_close |
|
117 |
|
|
118 |
extract(A2A_SHARE_SAVE_link_vars()); // linkname_enc, etc. |
|
119 |
|
|
120 |
/* Add to Any button */ |
|
121 |
|
|
122 |
$button_target = (get_option('A2A_SHARE_SAVE_button_opens_new_window')=='1' && (get_option('A2A_SHARE_SAVE_onclick')!='1')) ? ' target="_blank"' : ''; |
|
123 |
|
|
124 |
if( !get_option('A2A_SHARE_SAVE_button') ) { |
|
125 |
$button_fname = 'share_save_171_16.png'; |
|
126 |
$button_width = ' width="171"'; |
|
127 |
$button_height = ' height="16"'; |
|
128 |
$button_src = $A2A_SHARE_SAVE_plugin_url_path.'/'.$button_fname; |
|
129 |
} else if( get_option('A2A_SHARE_SAVE_button') == 'CUSTOM' ) { |
|
130 |
$button_src = get_option('A2A_SHARE_SAVE_button_custom'); |
|
131 |
$button_width = ''; |
|
132 |
$button_height = ''; |
|
133 |
} else if( get_option('A2A_SHARE_SAVE_button') == 'TEXT' ) { |
|
134 |
$button_text = stripslashes(get_option('A2A_SHARE_SAVE_button_text')); |
|
135 |
} else { |
|
136 |
$button_attrs = explode( '|', get_option('A2A_SHARE_SAVE_button') ); |
|
137 |
$button_fname = $button_attrs[0]; |
|
138 |
$button_width = ' width="'.$button_attrs[1].'"'; |
|
139 |
$button_height = ' height="'.$button_attrs[2].'"'; |
|
140 |
$button_src = $A2A_SHARE_SAVE_plugin_url_path.'/'.$button_fname; |
|
141 |
$button_text = stripslashes(get_option('A2A_SHARE_SAVE_button_text')); |
|
142 |
} |
|
143 |
|
|
144 |
if( $button_fname == 'favicon.png' || $button_fname == 'share_16_16.png' ) { |
|
145 |
if( !is_feed() ) { |
|
146 |
$style_bg = 'background:url('.$A2A_SHARE_SAVE_plugin_url_path.'/'.$button_fname.') no-repeat scroll 9px 0px'; // padding-left:9 (9=other icons padding) |
|
147 |
$style_bg = ';' . $style_bg . ' !important;'; |
|
148 |
$style = ' style="'.$style_bg.'padding:0 0 0 30px;display:inline-block;height:16px;line-height:16px;vertical-align:middle;"'; // padding-left:30+9 (9=other icons padding) |
|
149 |
} |
|
150 |
} |
|
151 |
|
|
152 |
if( $button_text && (!$button_fname || $button_fname == 'favicon.png' || $button_fname == 'share_16_16.png') ) { |
|
153 |
$button = $button_text; |
|
154 |
} else { |
|
155 |
$style = ''; |
|
156 |
$button = '<img src="'.$button_src.'"'.$button_width.$button_height.' alt="Share/Bookmark"/>'; |
|
157 |
} |
|
158 |
|
|
159 |
$button_html = $html_wrap_open.'<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?' |
|
160 |
.'linkurl='.$linkurl_enc |
|
161 |
.'&linkname='.$linkname_enc |
|
162 |
.'"' . $style . $button_target |
|
163 |
.'>'.$button.'</a>'.$html_wrap_close; |
|
164 |
|
|
165 |
// If not a feed |
|
166 |
if( !is_feed() ) { |
|
167 |
|
|
168 |
global $A2A_javascript, $A2A_SHARE_SAVE_external_script_called; |
|
169 |
if( $A2A_javascript == '' || !$A2A_SHARE_SAVE_external_script_called ) { |
|
170 |
$external_script_call = '</script><script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>'; |
|
171 |
$A2A_SHARE_SAVE_external_script_called = true; |
|
172 |
} |
|
173 |
else |
|
174 |
$external_script_call = 'a2a_init("page");</script>'; |
|
175 |
$A2A_javascript .= '<script type="text/javascript">' . "\n" |
|
176 |
. A2A_menu_locale() |
|
177 |
. 'a2a_linkname="' . js_escape($linkname) . '";' . "\n" |
|
178 |
. 'a2a_linkurl="' . $linkurl . '";' . "\n" |
|
179 |
. ((get_option('A2A_SHARE_SAVE_onclick')=='1') ? 'a2a_onclick=1;' . "\n" : '') |
|
180 |
. ((get_option('A2A_SHARE_SAVE_hide_embeds')=='-1') ? 'a2a_hide_embeds=0;' . "\n" : '') |
|
181 |
. ((get_option('A2A_SHARE_SAVE_show_title')=='1') ? 'a2a_show_title=1;' . "\n" : '') |
|
182 |
. (($A2A_javascript == '' || !$A2A_SHARE_SAVE_external_script_called) ? stripslashes(get_option('A2A_SHARE_SAVE_additional_js_variables')) . "\n" : '') |
|
183 |
. $external_script_call . "\n\n"; |
|
184 |
|
|
185 |
remove_action('wp_footer', 'A2A_menu_javascript'); |
|
186 |
add_action('wp_footer', 'A2A_menu_javascript'); |
|
187 |
|
|
188 |
} |
|
189 |
|
|
190 |
if($output_later) |
|
191 |
return $button_html; |
|
192 |
else |
|
193 |
echo $button_html; |
|
194 |
} |
|
195 |
|
|
196 |
if (!function_exists('A2A_menu_javascript')) { |
|
197 |
function A2A_menu_javascript() { |
|
198 |
global $A2A_javascript; |
|
199 |
echo $A2A_javascript; |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
if (!function_exists('A2A_menu_locale')) { |
|
204 |
function A2A_menu_locale() {return false; |
|
205 |
global $A2A_locale; |
|
206 |
echo get_locale(); |
|
207 |
if( get_locale() == 'en_US' || $A2A_locale != '' ) |
|
208 |
return false; |
|
209 |
|
|
210 |
$A2A_locale = 'a2a_localize = { |
|
211 |
Share: "' . __("Share", "add-to-any") . '", |
|
212 |
Save: "' . __("Save", "add-to-any") . '", |
|
213 |
Subscribe: "' . __("Subscribe", "add-to-any") . '", |
|
214 |
Email: "' . __("E-mail", "add-to-any") . '", |
|
215 |
Bookmark: "' . __("Bookmark", "add-to-any") . '", |
|
216 |
ShowAll: "' . __("Show all", "add-to-any") . '", |
|
217 |
ShowLess: "' . __("Show less", "add-to-any") . '", |
|
218 |
FindServices: "' . __("Find service(s)", "add-to-any") . '", |
|
219 |
FindAnyServiceToAddTo: "' . __("Instantly find any service to add to", "add-to-any") . '", |
|
220 |
PoweredBy: "' . __("Powered by", "add-to-any") . '", |
|
221 |
ShareViaEmail: "' . __("Share via e-mail", "add-to-any") . '", |
|
222 |
SubscribeViaEmail: "' . __("Subscribe via e-mail", "add-to-any") . '", |
|
223 |
BookmarkInYourBrowser: "' . __("Bookmark in your browser", "add-to-any") . '", |
|
224 |
BookmarkInstructions: "' . __("Press Ctrl+D or ⌘+D to bookmark this page", "add-to-any") . '", |
|
225 |
AddToYourFavorites: "' . __("Add to your favorites", "add-to-any") . '", |
|
226 |
SendFromWebOrProgram: "' . __("Send from any e-mail address or e-mail program", "add-to-any") . '", |
|
227 |
EmailProgram: "' . __("E-mail program", "add-to-any") . '" |
|
228 |
}; |
|
229 |
'; |
|
230 |
return $A2A_locale; |
|
231 |
} |
|
232 |
} |
|
233 |
|
|
234 |
if (!function_exists('A2A_wp_footer_check')) { |
|
235 |
function A2A_wp_footer_check() |
|
236 |
{ |
|
237 |
// If footer.php exists in the current theme, scan for "wp_footer" |
|
238 |
$file = get_template_directory() . '/footer.php'; |
|
239 |
if( is_file($file) ) { |
|
240 |
$search_string = "wp_footer"; |
|
241 |
$file_lines = @file($file); |
|
242 |
|
|
243 |
foreach($file_lines as $line) { |
|
244 |
$searchCount = substr_count($line, $search_string); |
|
245 |
if($searchCount > 0) { |
|
246 |
return true; |
|
247 |
break; |
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
// wp_footer() not found: |
|
252 |
echo "<div class=\"plugin-update\">" . __("Your theme needs to be fixed. To fix your theme, use the <a href=\"theme-editor.php\">Theme Editor</a> to insert <code><?php wp_footer(); ?></code> just before the <code></body></code> line of your theme's <code>footer.php</code> file.") . "</div>"; |
|
253 |
} |
|
254 |
} |
|
255 |
} |
|
256 |
|
|
257 |
|
|
258 |
function A2A_SHARE_SAVE_to_bottom_of_content($content) { |
|
259 |
$is_feed = is_feed(); |
|
260 |
|
|
261 |
if ( |
|
262 |
( |
|
263 |
// Tags |
|
264 |
strpos($content, '<!--sharesave-->')===false || // <!--sharesave--> tag |
|
265 |
strpos($content, '<!--nosharesave-->')!==false // <!--nosharesave--> tag |
|
266 |
) && |
|
267 |
( |
|
268 |
// Posts |
|
269 |
( ! is_page() && get_option('A2A_SHARE_SAVE_display_in_posts')=='-1' ) || // All posts |
|
270 |
( is_home() && get_option('A2A_SHARE_SAVE_display_in_posts_on_front_page')=='-1' ) || // Front page posts |
|
271 |
( is_category() && get_option('A2A_SHARE_SAVE_display_in_posts_on_front_page')=='-1' ) || // Category posts (same as Front page option) |
|
272 |
( is_tag() && get_option('A2A_SHARE_SAVE_display_in_posts_on_front_page')=='-1' ) || // Tag Cloud posts (same as Front page option) |
|
273 |
( is_date() && get_option('A2A_SHARE_SAVE_display_in_posts_on_front_page')=='-1' ) || // Date-based archives posts (same as Front page option) |
|
274 |
( is_author() && get_option('A2A_SHARE_SAVE_display_in_posts_on_front_page')=='-1' ) || // Author posts (same as Front page option) |
|
275 |
( is_search() && get_option('A2A_SHARE_SAVE_display_in_posts_on_front_page')=='-1' ) || // Search results posts (same as Front page option) |
|
276 |
( $is_feed && (get_option('A2A_SHARE_SAVE_display_in_feed')=='-1' ) || // Posts in feed |
|
277 |
|
|
278 |
// Pages |
|
279 |
( is_page() && get_option('A2A_SHARE_SAVE_display_in_pages')=='-1' ) || // Individual pages |
|
280 |
( (strpos($content, '<!--nosharesave-->')!==false) ) // <!--nosharesave--> |
|
281 |
) |
|
282 |
) |
|
283 |
) |
|
284 |
return $content; |
|
285 |
|
|
286 |
$icons_args = array( |
|
287 |
"output_later" => true, |
|
288 |
"html_wrap_open" => ($is_feed) ? "" : "<li>", |
|
289 |
"html_wrap_close" => ($is_feed) ? " " : "</li>", |
|
290 |
); |
|
291 |
|
|
292 |
$A2A_SHARE_SAVE_options = array( |
|
293 |
"output_later" => true, |
|
294 |
"html_wrap_open" => ($is_feed) ? "" : "<li>", |
|
295 |
"html_wrap_close" => ($is_feed) ? "" : "</li>", |
|
296 |
); |
|
297 |
|
|
298 |
if ( ! $is_feed ) { |
|
299 |
$container_wrap_open = '<div class="addtoany_share_save_container"><ul class="addtoany_list">'; |
|
300 |
$container_wrap_close = '</ul></div>'; |
|
301 |
} |
|
302 |
|
|
303 |
$content .= $container_wrap_open.ADDTOANY_SHARE_SAVE_ICONS( $icons_args ).ADDTOANY_SHARE_SAVE_BUTTON( $A2A_SHARE_SAVE_options ).$container_wrap_close; |
|
304 |
return $content; |
|
305 |
} |
|
306 |
|
|
307 |
add_action('the_content', 'A2A_SHARE_SAVE_to_bottom_of_content', 98); |
|
308 |
|
|
309 |
|
|
310 |
function A2A_SHARE_SAVE_button_css() { |
|
311 |
?><style type="text/css"> |
|
312 |
.addtoany_share_save_container{margin:16px 0;} |
|
313 |
ul.addtoany_list{ |
|
314 |
display:inline; |
|
315 |
list-style-type:none; |
|
316 |
margin:0 !important; |
|
317 |
padding:0 !important; |
|
318 |
text-indent:0 !important; |
|
319 |
} |
|
320 |
ul.addtoany_list li{ |
|
321 |
background:none !important; |
|
322 |
border:0; |
|
323 |
display:inline !important; |
|
324 |
line-height:32px;<?php /* For vertical space in the event of wrapping*/ ?> |
|
325 |
list-style-type:none; |
|
326 |
margin:0 !important; |
|
327 |
padding:0 !important; |
|
328 |
} |
|
329 |
ul.addtoany_list li:before{content:"";} |
|
330 |
ul.addtoany_list li a{padding:0 9px;} |
|
331 |
ul.addtoany_list img{ |
|
332 |
float:none; |
|
333 |
border:0; |
|
334 |
margin:0; |
|
335 |
padding:0; |
|
336 |
vertical-align:middle; |
|
337 |
} |
|
338 |
ul.addtoany_list a img{ |
|
339 |
opacity:.6; |
|
340 |
-moz-opacity:.6; |
|
341 |
filter:alpha(opacity=60); |
|
342 |
} |
|
343 |
ul.addtoany_list a:hover img, ul.addtoany_list a.addtoany_share_save img{ |
|
344 |
opacity:1; |
|
345 |
-moz-opacity:1; |
|
346 |
filter:alpha(opacity=100); |
|
347 |
} |
|
348 |
a.addtoany_share_save img{border:0;width:auto;height:auto;}<?php /* Must declare after "ul.addtoany_list img" */ ?> |
|
349 |
</style> |
|
350 |
<?php |
|
351 |
} |
|
352 |
|
|
353 |
add_action('wp_head', 'A2A_SHARE_SAVE_button_css'); |
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
|
|
358 |
/***************************** |
|
359 |
OPTIONS |
|
360 |
******************************/ |
|
361 |
|
|
362 |
|
|
363 |
function A2A_SHARE_SAVE_options_page() { |
|
364 |
|
|
365 |
global $A2A_SHARE_SAVE_plugin_url_path, $A2A_SHARE_SAVE_services; |
|
366 |
|
|
367 |
// Make available services extensible via plugins, themes (functions.php), etc. |
|
368 |
$A2A_SHARE_SAVE_services = apply_filters('A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services); |
|
369 |
|
|
370 |
if( $_POST[ 'A2A_SHARE_SAVE_submit_hidden' ] == 'Y' ) { |
|
371 |
|
|
372 |
update_option( 'A2A_SHARE_SAVE_display_in_posts_on_front_page', ($_POST['A2A_SHARE_SAVE_display_in_posts_on_front_page']=='1') ? '1':'-1' ); |
|
373 |
update_option( 'A2A_SHARE_SAVE_display_in_posts', ($_POST['A2A_SHARE_SAVE_display_in_posts']=='1') ? '1':'-1' ); |
|
374 |
update_option( 'A2A_SHARE_SAVE_display_in_pages', ($_POST['A2A_SHARE_SAVE_display_in_pages']=='1') ? '1':'-1' ); |
|
375 |
update_option( 'A2A_SHARE_SAVE_display_in_feed', ($_POST['A2A_SHARE_SAVE_display_in_feed']=='1') ? '1':'-1' ); |
|
376 |
update_option( 'A2A_SHARE_SAVE_hide_embeds', ($_POST['A2A_SHARE_SAVE_hide_embeds']=='1') ? '1':'-1' ); |
|
377 |
update_option( 'A2A_SHARE_SAVE_show_title', ($_POST['A2A_SHARE_SAVE_show_title']=='1') ? '1':'-1' ); |
|
378 |
update_option( 'A2A_SHARE_SAVE_onclick', ($_POST['A2A_SHARE_SAVE_onclick']=='1') ? '1':'-1' ); |
|
379 |
update_option( 'A2A_SHARE_SAVE_button_opens_new_window', ($_POST['A2A_SHARE_SAVE_button_opens_new_window']=='1') ? '1':'-1' ); |
|
380 |
update_option( 'A2A_SHARE_SAVE_button', $_POST['A2A_SHARE_SAVE_button'] ); |
|
381 |
update_option( 'A2A_SHARE_SAVE_button_custom', $_POST['A2A_SHARE_SAVE_button_custom'] ); |
|
382 |
update_option( 'A2A_SHARE_SAVE_additional_js_variables', trim($_POST['A2A_SHARE_SAVE_additional_js_variables']) ); |
|
383 |
|
|
384 |
// Store desired text if 16 x 16px buttons or text-only is chosen: |
|
385 |
if( get_option('A2A_SHARE_SAVE_button') == 'favicon.png|16|16' ) |
|
386 |
update_option( 'A2A_SHARE_SAVE_button_text', $_POST['A2A_SHARE_SAVE_button_favicon_16_16_text'] ); |
|
387 |
elseif( get_option('A2A_SHARE_SAVE_button') == 'share_16_16.png|16|16' ) |
|
388 |
update_option( 'A2A_SHARE_SAVE_button_text', $_POST['A2A_SHARE_SAVE_button_share_16_16_text'] ); |
|
389 |
else |
|
390 |
update_option( 'A2A_SHARE_SAVE_button_text', ( trim($_POST['A2A_SHARE_SAVE_button_text']) != '' ) ? $_POST['A2A_SHARE_SAVE_button_text'] : __('Share/Bookmark','add-to-any') ); |
|
391 |
|
|
392 |
// Store chosen individual services to make active |
|
393 |
$active_services = Array(); |
|
394 |
if( !$_POST['A2A_SHARE_SAVE_active_services'] ) |
|
395 |
$_POST['A2A_SHARE_SAVE_active_services'] = Array(); |
|
396 |
foreach( $_POST['A2A_SHARE_SAVE_active_services'] as $dummy=>$sitename ) |
|
397 |
$active_services[] = substr($sitename, 7); |
|
398 |
update_option('A2A_SHARE_SAVE_active_services', $active_services); |
|
399 |
// Delete then re-add to ensure sorting works (re-sorting doesn't effect associated array equality in PHP so update doesn't hit the dB for identical arrays |
|
400 |
delete_option('A2A_SHARE_SAVE_active_services', $active_services); |
|
401 |
add_option('A2A_SHARE_SAVE_active_services', $active_services); |
|
402 |
|
|
403 |
?> |
|
404 |
<div class="updated fade"><p><strong><?php _e('Settings saved.'); ?></strong></p></div> |
|
405 |
<?php |
|
406 |
|
|
407 |
} |
|
408 |
|
|
409 |
?> |
|
410 |
|
|
411 |
<?php A2A_wp_footer_check(); ?> |
|
412 |
|
|
413 |
<div class="wrap"> |
|
414 |
|
|
415 |
<h2><?php _e( 'Add to Any: Share/Save ', 'add-to-any' ) . _e( 'Settings' ); ?></h2> |
|
416 |
|
|
417 |
<form method="post" action=""> |
|
418 |
|
|
419 |
<?php wp_nonce_field('update-options'); ?> |
|
420 |
|
|
421 |
<input type="hidden" name="A2A_SHARE_SAVE_submit_hidden" value="Y"> |
|
422 |
|
|
423 |
<table class="form-table"> |
|
424 |
<tr valign="top"> |
|
425 |
<th scope="row"><?php _e("Standalone Services", "add-to-any"); ?></th> |
|
426 |
<td><fieldset> |
|
427 |
<ul id="addtoany_services_sortable" class="addtoany_admin_list"> |
|
428 |
<li class="dummy"><img src="<?php echo $A2A_SHARE_SAVE_plugin_url_path; ?>/icons/transparent.gif" width="16" height="16" alt="" /></li> |
|
429 |
</ul> |
|
430 |
<p id="addtoany_services_info"><?php _e("Choose the services you want below. Click a chosen service again to remove. Reorder services by dragging and dropping as they appear above.", "add-to-any"); ?></p> |
|
431 |
<ul id="addtoany_services_selectable" class="addtoany_admin_list"> |
|
432 |
<?php |
|
433 |
// Show all services |
|
434 |
$active_services = get_option('A2A_SHARE_SAVE_active_services'); |
|
435 |
if( !$active_services ) |
|
436 |
$active_services = Array(); |
|
437 |
|
|
438 |
foreach ($A2A_SHARE_SAVE_services as $service_safe_name=>$site) { |
|
439 |
if (isset($site['href'])) |
|
440 |
$custom_service = TRUE; |
|
441 |
else |
|
442 |
$custom_service = FALSE; |
|
443 |
if ( ! isset($site['icon'])) |
|
444 |
$site['icon'] = 'default'; |
|
445 |
?> |
|
446 |
<li id="a2a_wp_<?php echo $service_safe_name; ?>" |
|
447 |
title="<?php echo $site['name']; ?>"> |
|
448 |
<span><img src="<?php echo ($custom_service) ? $site['icon_url'] : $A2A_SHARE_SAVE_plugin_url_path.'/icons/'.$site['icon'].'.png'; ?>" width="<?php echo (isset($site['icon_width'])) ? $site['icon_width'] : '16'; ?>" height="<?php echo (isset($site['icon_height'])) ? $site['icon_height'] : '16'; ?>" alt="" /><?php echo $site['name']; ?></span> |
|
449 |
</li> |
|
450 |
<?php |
|
451 |
} ?> |
|
452 |
</ul> |
|
453 |
</fieldset></td> |
|
454 |
</tr> |
|
455 |
<tr valign="top"> |
|
456 |
<th scope="row"><?php _e("Button", "add-to-any"); ?></th> |
|
457 |
<td><fieldset> |
|
458 |
<label> |
|
459 |
<input name="A2A_SHARE_SAVE_button" value="favicon.png|16|16" type="radio"<?php if(get_option('A2A_SHARE_SAVE_button')=='favicon.png|16|16') echo ' checked="checked"'; ?> |
|
460 |
style="margin:9px 0;vertical-align:middle"> |
|
461 |
<img src="<?php echo $A2A_SHARE_SAVE_plugin_url_path.'/favicon.png'; ?>" width="16" height="16" border="0" style="padding:9px;vertical-align:middle" alt="+ <?php _e('Share/Bookmark','add-to-any'); ?>" title="+ <?php _e('Share/Bookmark','add-to-any'); ?>" |
|
462 |
onclick="this.parentNode.firstChild.checked=true"/> |
|
463 |
</label> |
|
464 |
<input name="A2A_SHARE_SAVE_button_favicon_16_16_text" type="text" class="code" size="50" onclick="e=document.getElementsByName('A2A_SHARE_SAVE_button');e[e.length-7].checked=true" style="vertical-align:middle;width:150px" |
|
465 |
value="<?php echo (get_option('A2A_SHARE_SAVE_button_text') !== FALSE) ? stripslashes(get_option('A2A_SHARE_SAVE_button_text')) : __('Share/Bookmark','add-to-any'); ?>" /> |
|
466 |
<label style="padding-left:9px"> |
|
467 |
<input name="A2A_SHARE_SAVE_button" value="share_16_16.png|16|16" type="radio"<?php if(get_option('A2A_SHARE_SAVE_button')=='share_16_16.png|16|16') echo ' checked="checked"'; ?> |
|
468 |
style="margin:9px 0;vertical-align:middle"> |
|
469 |
<img src="<?php echo $A2A_SHARE_SAVE_plugin_url_path.'/share_16_16.png'; ?>" width="16" height="16" border="0" style="padding:9px;vertical-align:middle" alt="+ <?php _e('Share/Bookmark','add-to-any'); ?>" title="+ <?php _e('Share/Bookmark','add-to-any'); ?>" |
|
470 |
onclick="this.parentNode.firstChild.checked=true"/> |
|
471 |
</label> |
|
472 |
<input name="A2A_SHARE_SAVE_button_share_16_16_text" type="text" class="code" size="50" onclick="e=document.getElementsByName('A2A_SHARE_SAVE_button');e[e.length-6].checked=true" style="vertical-align:middle;width:150px" |
|
473 |
value="<?php echo (get_option('A2A_SHARE_SAVE_button_text') !== FALSE) ? stripslashes(get_option('A2A_SHARE_SAVE_button_text')) : __('Share/Bookmark','add-to-any'); ?>" /><br> |
|
474 |
<label> |
|
475 |
<input name="A2A_SHARE_SAVE_button" value="share_save_120_16.png|120|16" type="radio"<?php if(get_option('A2A_SHARE_SAVE_button' )=='share_save_120_16.png|120|16') echo ' checked="checked"'; ?> |
|
476 |
style="margin:9px 0;vertical-align:middle"> |
|
477 |
<img src="<?php echo $A2A_SHARE_SAVE_plugin_url_path.'/share_save_120_16.png'; ?>" width="120" height="16" border="0" style="padding:9px;vertical-align:middle" |
|
478 |
onclick="this.parentNode.firstChild.checked=true"/> |
|
479 |
</label><br> |
|
480 |
<label> |
|
481 |
<input name="A2A_SHARE_SAVE_button" value="share_save_171_16.png|171|16" type="radio"<?php if( !get_option('A2A_SHARE_SAVE_button') || get_option('A2A_SHARE_SAVE_button')=='share_save_171_16.png|171|16' ) echo ' checked="checked"'; ?> |
|
482 |
style="margin:9px 0;vertical-align:middle"> |
|
483 |
<img src="<?php echo $A2A_SHARE_SAVE_plugin_url_path.'/share_save_171_16.png'; ?>" width="171" height="16" border="0" style="padding:9px;vertical-align:middle" |
|
484 |
onclick="this.parentNode.firstChild.checked=true"/> |
|
485 |
</label><br> |
|
486 |
<label> |
|
487 |
<input name="A2A_SHARE_SAVE_button" value="share_save_256_24.png|256|24" type="radio"<?php if(get_option('A2A_SHARE_SAVE_button')=='share_save_256_24.png|256|24') echo ' checked="checked"'; ?> |
|
488 |
style="margin:9px 0;vertical-align:middle"> |
|
489 |
<img src="<?php echo $A2A_SHARE_SAVE_plugin_url_path.'/share_save_256_24.png'; ?>" width="256" height="24" border="0" style="padding:9px;vertical-align:middle" |
|
490 |
onclick="this.parentNode.firstChild.checked=true"/> |
|
491 |
</label><br> |
|
492 |
<label> |
|
493 |
<input name="A2A_SHARE_SAVE_button" value="CUSTOM" type="radio"<?php if( get_option('A2A_SHARE_SAVE_button') == 'CUSTOM' ) echo ' checked="checked"'; ?> |
|
494 |
style="margin:9px 0;vertical-align:middle"> |
|
495 |
<span style="margin:0 9px;vertical-align:middle"><?php _e("Image URL"); ?>:</span> |
|
496 |
</label> |
|
497 |
<input name="A2A_SHARE_SAVE_button_custom" type="text" class="code" size="50" onclick="e=document.getElementsByName('A2A_SHARE_SAVE_button');e[e.length-2].checked=true" style="vertical-align:middle" |
|
498 |
value="<?php echo get_option('A2A_SHARE_SAVE_button_custom'); ?>" /><br> |
|
499 |
<label> |
|
500 |
<input name="A2A_SHARE_SAVE_button" value="TEXT" type="radio"<?php if( get_option('A2A_SHARE_SAVE_button') == 'TEXT' ) echo ' checked="checked"'; ?> |
|
501 |
style="margin:9px 0;vertical-align:middle"> |
|
502 |
<span style="margin:0 9px;vertical-align:middle"><?php _e("Text only"); ?>:</span> |
|
503 |
</label> |
|
504 |
<input name="A2A_SHARE_SAVE_button_text" type="text" class="code" size="50" onclick="e=document.getElementsByName('A2A_SHARE_SAVE_button');e[e.length-1].checked=true" style="vertical-align:middle;width:150px" |
|
505 |
value="<?php echo ( trim(get_option('A2A_SHARE_SAVE_button_text')) != '' ) ? stripslashes(get_option('A2A_SHARE_SAVE_button_text')) : __('Share/Bookmark','add-to-any'); ?>" /> |
|
506 |
|
|
507 |
</fieldset></td> |
|
508 |
</tr> |
|
509 |
<tr valign="top"> |
|
510 |
<th scope="row"><?php _e('Placement', 'add-to-any'); ?></th> |
|
511 |
<td><fieldset> |
|
512 |
<label> |
|
513 |
<input name="A2A_SHARE_SAVE_display_in_posts" |
|
514 |
onclick="e=getElementsByName('A2A_SHARE_SAVE_display_in_posts_on_front_page')[0];f=getElementsByName('A2A_SHARE_SAVE_display_in_feed')[0]; |
|
515 |
if(!this.checked){e.checked=false;e.disabled=true; f.checked=false;f.disabled=true}else{e.checked=true;e.disabled=false; f.checked=true;f.disabled=false}" |
|
516 |
onchange="e=getElementsByName('A2A_SHARE_SAVE_display_in_posts_on_front_page')[0];f=getElementsByName('A2A_SHARE_SAVE_display_in_feed')[0]; |
|
517 |
if(!this.checked){e.checked=false;e.disabled=true; f.checked=false;f.disabled=true}else{e.checked=true;e.disabled=false; f.checked=true;f.disabled=false}" |
|
518 |
type="checkbox"<?php if(get_option('A2A_SHARE_SAVE_display_in_posts')!='-1') echo ' checked="checked"'; ?> value="1"/> |
|
519 |
<?php _e('Display Share/Save button at the bottom of posts', 'add-to-any'); ?> <strong>*</strong> |
|
520 |
</label><br/> |
|
521 |
<label> |
|
522 |
<input name="A2A_SHARE_SAVE_display_in_posts_on_front_page" type="checkbox"<?php |
|
523 |
if(get_option('A2A_SHARE_SAVE_display_in_posts_on_front_page')!='-1') echo ' checked="checked"'; |
|
524 |
if(get_option('A2A_SHARE_SAVE_display_in_posts')=='-1') echo ' disabled="disabled"'; |
|
525 |
?> value="1"/> |
|
526 |
<?php _e('Display Share/Save button at the bottom of posts on the front page', 'add-to-any'); ?> |
|
527 |
</label><br/> |
|
528 |
<label> |
|
529 |
<input name="A2A_SHARE_SAVE_display_in_feed" type="checkbox"<?php |
|
530 |
if(get_option('A2A_SHARE_SAVE_display_in_feed')!='-1') echo ' checked="checked"'; |
|
531 |
if(get_option('A2A_SHARE_SAVE_display_in_posts')=='-1') echo ' disabled="disabled"'; |
|
532 |
?> value="1"/> |
|
533 |
<?php _e('Display Share/Save button at the bottom of posts in the feed', 'add-to-any'); ?> |
|
534 |
</label><br/> |
|
535 |
<label> |
|
536 |
<input name="A2A_SHARE_SAVE_display_in_pages" type="checkbox"<?php if(get_option('A2A_SHARE_SAVE_display_in_pages')!='-1') echo ' checked="checked"'; ?> value="1"/> |
|
537 |
<?php _e('Display Share/Save button at the bottom of pages', 'add-to-any'); ?> |
|
538 |
</label> |
|
539 |
<br/><br/> |
|
540 |
<div class="setting-description"> |
|
541 |
<strong>*</strong> <?php _e("If unchecked, be sure to place the following code in <a href=\"theme-editor.php\">your template pages</a> (within <code>index.php</code>, <code>single.php</code>, and/or <code>page.php</code>)", "add-to-any"); ?>: <span id="addtoany_show_template_button_code" class="button-secondary">»</span> |
|
542 |
<div id="addtoany_template_button_code"> |
|
543 |
<code><?php echo '<ul class="addtoany_list">'; if( function_exists('ADDTOANY_SHARE_SAVE_ICONS') ) ADDTOANY_SHARE_SAVE_ICONS( array("html_wrap_open" => "<li>", "html_wrap_close" => "</li>") ); if( function_exists('ADDTOANY_SHARE_SAVE_BUTTON') ) ADDTOANY_SHARE_SAVE_BUTTON( array("html_wrap_open" => "<li>", "html_wrap_close" => "</li>") ); echo '</ul>'; ?></code> |
|
544 |
</div> |
|
545 |
<noscript<code><?php echo '<ul class="addtoany_list">'; if( function_exists('ADDTOANY_SHARE_SAVE_ICONS') ) ADDTOANY_SHARE_SAVE_ICONS( array("html_wrap_open" => "<li>", "html_wrap_close" => "</li>") ); if( function_exists('ADDTOANY_SHARE_SAVE_BUTTON') ) ADDTOANY_SHARE_SAVE_BUTTON( array("html_wrap_open" => "<li>", "html_wrap_close" => "</li>") ); echo '</ul>'; ?></code></noscript> |
|
546 |
</div> |
|
547 |
</fieldset></td> |
|
548 |
</tr> |
|
549 |
<tr valign="top"> |
|
550 |
<th scope="row"><?php _e('Menu Style', 'add-to-any'); ?></th> |
|
551 |
<td><fieldset> |
|
552 |
<p><?php _e("Using Add to Any's Menu Styler, you can customize the colors of your Share/Save menu! When you're done, be sure to paste the generated code in the <a href=\"#\" onclick=\"document.getElementById('A2A_SHARE_SAVE_additional_js_variables').focus();return false\">Additional Options</a> box below.", "add-to-any"); ?></p> |
|
553 |
<p> |
|
554 |
<a href="http://www.addtoany.com/buttons/share_save/menu_style/wordpress" class="button-secondary" title="<?php _e("Open the Add to Any Menu Styler in a new window", "add-to-any"); ?>" target="_blank" |
|
555 |
onclick="document.getElementById('A2A_SHARE_SAVE_additional_js_variables').focus(); |
|
556 |
document.getElementById('A2A_SHARE_SAVE_menu_styler_note').style.display='';"><?php _e("Open Menu Styler", "add-to-any"); ?></a> |
|
557 |
</p> |
|
558 |
</fieldset></td> |
|
559 |
</tr> |
|
560 |
<tr valign="top"> |
|
561 |
<th scope="row"><?php _e('Menu Options', 'add-to-any'); ?></th> |
|
562 |
<td><fieldset> |
|
563 |
<label> |
|
564 |
<input name="A2A_SHARE_SAVE_hide_embeds" |
|
565 |
type="checkbox"<?php if(get_option('A2A_SHARE_SAVE_hide_embeds')!='-1') echo ' checked="checked"'; ?> value="1"/> |
|
566 |
<?php _e('Hide embedded objects (Flash, video, etc.) that intersect with the menu when displayed', 'add-to-any'); ?> |
|
567 |
</label><br /> |
|
568 |
<label> |
|
569 |
<input name="A2A_SHARE_SAVE_show_title" |
|
570 |
type="checkbox"<?php if(get_option('A2A_SHARE_SAVE_show_title')=='1') echo ' checked="checked"'; ?> value="1"/> |
|
571 |
<?php _e('Show the title of the post (or page) within the menu', 'add-to-any'); ?> |
|
572 |
</label><br /> |
|
573 |
<label> |
|
574 |
<input name="A2A_SHARE_SAVE_onclick" |
|
575 |
type="checkbox"<?php if(get_option('A2A_SHARE_SAVE_onclick')=='1') echo ' checked="checked"'; ?> value="1" |
|
576 |
onclick="e=getElementsByName('A2A_SHARE_SAVE_button_opens_new_window')[0];if(this.checked){e.checked=false;e.disabled=true}else{e.disabled=false}" |
|
577 |
onchange="e=getElementsByName('A2A_SHARE_SAVE_button_opens_new_window')[0];if(this.checked){e.checked=false;e.disabled=true}else{e.disabled=false}"/> |
|
578 |
<?php _e('Only show the menu when the user clicks the Share/Save button', 'add-to-any'); ?> |
|
579 |
</label><br /> |
|
580 |
<label> |
|
581 |
<input name="A2A_SHARE_SAVE_button_opens_new_window" |
|
582 |
type="checkbox"<?php if(get_option('A2A_SHARE_SAVE_button_opens_new_window')=='1') echo ' checked="checked"'; ?> value="1" |
|
583 |
<?php if(get_option('A2A_SHARE_SAVE_onclick')=='1') echo ' disabled="disabled"'; ?>/> |
|
584 |
<?php _e('Open the addtoany.com menu page in a new tab or window if the user clicks the Share/Save button', 'add-to-any'); ?> |
|
585 |
</label> |
|
586 |
</fieldset></td> |
|
587 |
</tr> |
|
588 |
<tr valign="top"> |
|
589 |
<th scope="row"><?php _e('Additional Options', 'add-to-any'); ?></th> |
|
590 |
<td><fieldset> |
|
591 |
<p id="A2A_SHARE_SAVE_menu_styler_note" style="display:none"> |
|
592 |
<label for="A2A_SHARE_SAVE_additional_js_variables" class="updated"> |
|
593 |
<strong><?php _e("Paste the code from Add to Any's Menu Styler in the box below!", 'add-to-any'); ?></strong> |
|
594 |
</label> |
|
595 |
</p> |
|
596 |
<label for="A2A_SHARE_SAVE_additional_js_variables"> |
|
597 |
<p><?php _e('Below you can set special JavaScript variables to apply to each Share/Save menu.', 'add-to-any'); ?> |
|
598 |
<?php _e("Advanced users might want to explore Add to Any's <a href=\"http://www.addtoany.com/buttons/api/\" target=\"_blank\">JavaScript API</a>.", "add-to-any"); ?></p> |
|
599 |
</label> |
|
600 |
<p> |
|
601 |
<textarea name="A2A_SHARE_SAVE_additional_js_variables" id="A2A_SHARE_SAVE_additional_js_variables" class="code" style="width: 98%; font-size: 12px;" rows="5" cols="50"><?php echo stripslashes(get_option('A2A_SHARE_SAVE_additional_js_variables')); ?></textarea> |
|
602 |
</p> |
|
603 |
<?php if( get_option('A2A_SHARE_SAVE_additional_js_variables')!='' ) { ?> |
|
604 |
<label for="A2A_SHARE_SAVE_additional_js_variables" class="setting-description"><?php _e("<strong>Note</strong>: If you're adding new code, be careful not to accidentally overwrite any previous code.</label>", 'add-to-any'); ?> |
|
605 |
<?php } ?> |
|
606 |
</fieldset></td> |
|
607 |
</tr> |
|
608 |
</table> |
|
609 |
|
|
610 |
<p class="submit"> |
|
611 |
<input class="button-primary" type="submit" name="Submit" value="<?php _e('Save Changes', 'add-to-any' ) ?>" /> |
|
612 |
</p> |
|
613 |
|
|
614 |
</form> |
|
615 |
|
|
616 |
<h2><?php _e('Like this plugin?','add-to-any'); ?></h2> |
|
617 |
<p><?php _e('<a href="http://wordpress.org/extend/plugins/add-to-any/">Give it a good rating</a> on WordPress.org.','add-to-any'); ?></p> |
|
618 |
<p><?php _e('<a href="http://www.addtoany.com/share_save?linkname=WordPress%20Share%20Plugin%20by%20AddToAny.com&linkurl=http%3A%2F%2Fwordpress.org%2Fextend%2Fplugins%2Fadd-to-any%2F">Share it</a> with your friends.','add-to-any'); ?></p> |
|
619 |
|
|
620 |
<h2><?php _e('Need support?','add-to-any'); ?></h2> |
|
621 |
<p><?php _e('See the <a href="http://wordpress.org/extend/plugins/add-to-any/faq/">FAQs</a>.','add-to-any'); ?></p> |
|
622 |
<p><?php _e('Search the <a href="http://wordpress.org/tags/add-to-any">support forums</a>.','add-to-any'); ?></p> |
|
623 |
</div> |
|
624 |
|
|
625 |
<?php |
|
626 |
|
|
627 |
} |
|
628 |
|
|
629 |
// Admin page header |
|
630 |
function A2A_SHARE_SAVE_admin_head() { |
|
631 |
if (isset($_GET['page']) && $_GET['page'] == 'add-to-any.php') { |
|
632 |
global $wp_version; |
|
633 |
|
|
634 |
// Must be on WP 2.6+ |
|
635 |
if ($wp_version < "2.6") |
|
636 |
return; |
|
637 |
?> |
|
638 |
<script language="JavaScript" type="text/javascript"><!-- |
|
639 |
jQuery(document).ready(function(){ |
|
640 |
|
|
641 |
var to_input = function(this_sortable){ |
|
642 |
// Clear any previous services stored as hidden inputs |
|
643 |
jQuery('input[name="A2A_SHARE_SAVE_active_services[]"]').remove(); |
|
644 |
|
|
645 |
var services_array = jQuery(this_sortable).sortable('toArray'), |
|
646 |
services_size = services_array.length; |
|
647 |
if(services_size<1) return; |
|
648 |
|
|
649 |
for(var i=0;i<services_size;i++){ |
|
650 |
if(services_array[i]!='') // Exclude dummy icon |
|
651 |
jQuery('form:first').append('<input name="A2A_SHARE_SAVE_active_services[]" type="hidden" value="'+services_array[i]+'"/>'); |
|
652 |
} |
|
653 |
}; |
|
654 |
|
|
655 |
jQuery('#addtoany_services_sortable').sortable({ |
|
656 |
items: 'li:not(#addtoany_show_services, .dummy)', |
|
657 |
placeholder: 'ui-sortable-placeholder', |
|
658 |
opacity: .6, |
|
659 |
tolerance: 'pointer', |
|
660 |
update: function(){to_input(this)} |
|
661 |
}); |
|
662 |
|
|
663 |
// Service click = move to sortable list |
|
664 |
var moveToSortableList = function(){ |
|
665 |
if( jQuery('#addtoany_services_sortable li').not('.dummy').length==0 ) |
|
666 |
jQuery('#addtoany_services_sortable').find('.dummy').hide(); |
|
667 |
|
|
668 |
jQuery(this).toggleClass('addtoany_selected') |
|
669 |
.unbind('click', moveToSortableList) |
|
670 |
.bind('click', moveToSelectableList) |
|
671 |
.clone() |
|
672 |
.html( jQuery(this).find('img').clone().attr('alt', jQuery(this).attr('title')) ) |
|
673 |
.hide() |
|
674 |
.insertBefore('#addtoany_services_sortable .dummy') |
|
675 |
.fadeIn('fast'); |
|
676 |
|
|
677 |
jQuery(this).attr( 'id', 'old_'+jQuery(this).attr('id') ); |
|
678 |
|
|
679 |
jQuery('#addtoany_services_sortable li:last').fadeTo('fast', 1); |
|
680 |
}; |
|
681 |
|
|
682 |
// Service click again = move back to selectable list |
|
683 |
var moveToSelectableList = function(){ |
|
684 |
jQuery(this).toggleClass('addtoany_selected') |
|
685 |
.unbind('click', moveToSelectableList) |
|
686 |
.bind('click', moveToSortableList); |
|
687 |
|
|
688 |
jQuery( '#'+jQuery(this).attr('id').substr(4).replace(/\./, '\\.') ) |
|
689 |
.hide('fast', function(){ |
|
690 |
jQuery(this).remove(); |
|
691 |
}); |
|
692 |
|
|
693 |
|
|
694 |
if( jQuery('#addtoany_services_sortable li').not('.dummy').length==1 ) |
|
695 |
jQuery('#addtoany_services_sortable').find('.dummy').show(); |
|
696 |
|
|
697 |
jQuery(this).attr('id', jQuery(this).attr('id').substr(4)); |
|
698 |
}; |
|
699 |
|
|
700 |
// Service click = move to sortable list |
|
701 |
jQuery('#addtoany_services_selectable li').bind('click', moveToSortableList); |
|
702 |
|
|
703 |
// Form submit = get sortable list |
|
704 |
jQuery('form').submit(function(){to_input('#addtoany_services_sortable')}); |
|
705 |
|
|
706 |
// Auto-select active services |
|
707 |
<?php |
|
708 |
$admin_services_saved = is_array($_POST['A2A_SHARE_SAVE_active_services']) || isset($_POST['A2A_SHARE_SAVE_submit_hidden']); |
|
709 |
$active_services = ( $admin_services_saved ) |
|
710 |
? $_POST['A2A_SHARE_SAVE_active_services'] : get_option('A2A_SHARE_SAVE_active_services'); |
|
711 |
if( !$active_services ) |
|
712 |
$active_services = Array(); |
|
713 |
$active_services_last = end($active_services); |
|
714 |
$active_services_quoted = ''; |
|
715 |
foreach ($active_services as $service) { |
|
716 |
if($admin_services_saved) |
|
717 |
$service = substr($service, 7); // Remove a2a_wp_ |
|
718 |
$active_services_quoted .= '"'.$service.'"'; |
|
719 |
if ( $service != $active_services_last ) |
|
720 |
$active_services_quoted .= ','; |
|
721 |
} |
|
722 |
?> |
|
723 |
var services = [<?php echo $active_services_quoted; ?>]; |
|
724 |
jQuery.each(services, function(i, val){ |
|
725 |
jQuery('#a2a_wp_'+val).click(); |
|
726 |
}); |
|
727 |
|
|
728 |
// Add/Remove Services |
|
729 |
jQuery('#addtoany_services_sortable .dummy:first').after('<li id="addtoany_show_services"><?php _e('Add/Remove Services', 'add-to-any'); ?> »</li>'); |
|
730 |
jQuery('#addtoany_show_services').click(function(e){ |
|
731 |
jQuery('#addtoany_services_selectable, #addtoany_services_info').slideDown('fast'); |
|
732 |
jQuery(this).fadeOut('fast'); |
|
733 |
}); |
|
734 |
jQuery('#addtoany_show_template_button_code').click(function(e){ |
|
735 |
jQuery('#addtoany_template_button_code').slideDown('fast'); |
|
736 |
jQuery(this).fadeOut('fast'); |
|
737 |
}); |
|
738 |
}); |
|
739 |
--></script> |
|
740 |
|
|
741 |
<style type="text/css"> |
|
742 |
.ui-sortable-placeholder{border:1px dashed #AAA;} |
|
743 |
.addtoany_admin_list{list-style:none;padding:0;margin:0;} |
|
744 |
.addtoany_admin_list li{-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px;} |
|
745 |
|
|
746 |
#addtoany_services_selectable{clear:left;display:none;} |
|
747 |
#addtoany_services_selectable li{cursor:crosshair;float:left;width:150px;font-size:11px;margin:0;padding:3px;border:1px solid transparent;_border-color:#FAFAFA/*IE6*/;overflow:hidden;} |
|
748 |
<?php // white-space:nowrap could go above, but then webkit does not wrap floats if parent has no width set; wrapping in <span> instead (below) ?> |
|
749 |
#addtoany_services_selectable li span{white-space:nowrap;} |
|
750 |
#addtoany_services_selectable li:hover, #addtoany_services_selectable li.addtoany_selected{border:1px solid #AAA;background-color:#FFF;} |
|
751 |
#addtoany_services_selectable li.addtoany_selected:hover{border-color:#F00;} |
|
752 |
#addtoany_services_selectable li:active{border:1px solid #000;} |
|
753 |
#addtoany_services_selectable li span img{margin:0 4px 0 4px;width:16px;height:16px;border:0;vertical-align:middle;} |
|
754 |
|
|
755 |
#addtoany_services_sortable li, #addtoany_services_sortable li.dummy:hover{cursor:move;float:left;padding:9px;border:1px solid transparent;_border-color:#FAFAFA/*IE6*/;} |
|
756 |
#addtoany_services_sortable li:hover{border:1px solid #AAA;background-color:#FFF;} |
|
757 |
#addtoany_services_sortable li.dummy, #addtoany_services_sortable li.dummy:hover{cursor:auto;background-color:transparent;} |
|
758 |
#addtoany_services_sortable img{width:16px;height:16px;border:0;vertical-align:middle;} |
|
759 |
|
|
760 |
li#addtoany_show_services{border:1px solid #DFDFDF;background-color:#FFF;cursor:pointer;} |
|
761 |
li#addtoany_show_services:hover{border:1px solid #AAA;} |
|
762 |
#addtoany_services_info{clear:left;display:none;} |
|
763 |
|
|
764 |
#addtoany_template_button_code{display:none;} |
|
765 |
</style> |
|
766 |
<?php |
|
767 |
} |
|
768 |
} |
|
769 |
|
|
770 |
add_action('admin_head', 'A2A_SHARE_SAVE_admin_head'); |
|
771 |
|
|
772 |
function A2A_SHARE_SAVE_add_menu_link() { |
|
773 |
if( current_user_can('manage_options') ) { |
|
774 |
add_options_page( |
|
775 |
'Add to Any: '. __("Share/Save", "add-to-any"). " " . __("Settings") |
|
776 |
, __("Share/Save Buttons", "add-to-any") |
|
777 |
, 8 |
|
778 |
, basename(__FILE__) |
|
779 |
, 'A2A_SHARE_SAVE_options_page' |
|
780 |
); |
|
781 |
|
|
782 |
// Load jQuery UI Sortable |
|
783 |
wp_enqueue_script('jquery-ui-sortable'); |
|
784 |
} |
|
785 |
} |
|
786 |
|
|
787 |
add_action('admin_menu', 'A2A_SHARE_SAVE_add_menu_link'); |
|
788 |
|
|
789 |
// Place in Settings Option List |
|
790 |
function A2A_SHARE_SAVE_actlinks( $links, $file ){ |
|
791 |
//Static so we don't call plugin_basename on every plugin row. |
|
792 |
static $this_plugin; |
|
793 |
if ( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__); |
|
794 |
|
|
795 |
if ( $file == $this_plugin ){ |
|
796 |
$settings_link = '<a href="options-general.php?page=add-to-any.php">' . __('Settings') . '</a>'; |
|
797 |
array_unshift( $links, $settings_link ); // before other links |
|
798 |
} |
|
799 |
return $links; |
|
800 |
} |
|
801 |
|
|
802 |
add_filter("plugin_action_links", 'A2A_SHARE_SAVE_actlinks', 10, 2); |
|
803 |
|
|
804 |
|
|
805 |
?> |