" . __("Your theme needs to be fixed. To fix your theme, use the Theme Editor to insert <?php wp_footer(); ?> just before the </body> line of your theme's footer.php file.") . "
";
}
// If header.php exists in the current theme, scan for "wp_head"
$file = $template_directory . '/header.php';
if (is_file($file)) {
$search_string = "wp_head";
$file_lines = @file($file);
foreach ($file_lines as $line) {
$searchCount = substr_count($line, $search_string);
if ($searchCount > 0) {
return true;
}
}
// wp_footer() not found:
echo "
" . __("Your theme needs to be fixed. To fix your theme, use the Theme Editor to insert <?php wp_head(); ?> just before the </head> line of your theme's header.php file.") . "
";
}
}
function A2A_SHARE_SAVE_auto_placement($title) {
global $A2A_SHARE_SAVE_auto_placement_ready;
$A2A_SHARE_SAVE_auto_placement_ready = true;
return $title;
}
/**
* Remove the_content filter and add it for next time
*/
function A2A_SHARE_SAVE_remove_from_content($content) {
remove_filter('the_content', 'A2A_SHARE_SAVE_add_to_content', 98);
add_filter('the_content', 'A2A_SHARE_SAVE_add_to_content_next_time', 98);
return $content;
}
/**
* Apply the_content filter "next time"
*/
function A2A_SHARE_SAVE_add_to_content_next_time($content) {
add_filter('the_content', 'A2A_SHARE_SAVE_add_to_content', 98);
return $content;
}
function A2A_SHARE_SAVE_add_to_content($content) {
global $A2A_SHARE_SAVE_auto_placement_ready;
$is_feed = is_feed();
$options = get_option('addtoany_options');
if( ! $A2A_SHARE_SAVE_auto_placement_ready)
return $content;
if (get_post_status(get_the_ID()) == 'private')
return $content;
if (
(
// Tags
// tag
strpos($content, '')===false ||
// tag
strpos($content, '')!==false
) &&
(
// Posts
// All posts
( ! is_page() && $options['display_in_posts']=='-1' ) ||
// Front page posts
( is_home() && $options['display_in_posts_on_front_page']=='-1' ) ||
// Category posts (same as Front page option)
( is_category() && $options['display_in_posts_on_front_page']=='-1' ) ||
// Tag Cloud posts (same as Front page option) - WP version 2.3+ only
( function_exists('is_tag') && is_tag() && $options['display_in_posts_on_front_page']=='-1' ) ||
// Date-based archives posts (same as Front page option)
( is_date() && $options['display_in_posts_on_front_page']=='-1' ) ||
// Author posts (same as Front page option)
( is_author() && $options['display_in_posts_on_front_page']=='-1' ) ||
// Search results posts (same as Front page option)
( is_search() && $options['display_in_posts_on_front_page']=='-1' ) ||
// Posts in feed
( $is_feed && ($options['display_in_feed']=='-1' ) ||
// Pages
// Individual pages
( is_page() && $options['display_in_pages']=='-1' ) ||
//
( (strpos($content, '')!==false) )
)
)
)
return $content;
$kit_args = array(
"output_later" => true,
"is_kit" => ($is_feed) ? FALSE : TRUE,
);
if ( ! $is_feed ) {
$container_wrap_open = '
';
$container_wrap_close = '
';
} else { // Is feed
$container_wrap_open = '
';
$container_wrap_close = '
';
$kit_args['html_container_open'] = '';
$kit_args['html_container_close'] = '';
$kit_args['html_wrap_open'] = '';
$kit_args['html_wrap_close'] = '';
}
$options['position'] = isset($options['position']) ? $options['position'] : 'bottom';
if ($options['position'] == 'both' || $options['position'] == 'top') {
// Prepend to content
$content = $container_wrap_open.ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close . $content;
}
if ( $options['position'] == 'bottom' || $options['position'] == 'both') {
// Append to content
$content .= $container_wrap_open.ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close;
}
return $content;
}
// Only automatically output button code after the_title has been called - to avoid premature calling from misc. the_content filters (especially meta description)
add_filter('the_title', 'A2A_SHARE_SAVE_auto_placement', 9);
add_filter('the_content', 'A2A_SHARE_SAVE_add_to_content', 98);
// [addtoany url="http://example.com/page.html" title="Some Example Page"]
function A2A_SHARE_SAVE_shortcode( $attributes ) {
extract( shortcode_atts( array(
'url' => 'something',
'title' => 'something else',
), $attributes ) );
$linkname = (isset($attributes['title'])) ? $attributes['title'] : FALSE;
$linkurl = (isset($attributes['url'])) ? $attributes['url'] : FALSE;
$output_later = TRUE;
return ADDTOANY_SHARE_SAVE_KIT( compact('linkname', 'linkurl', 'output_later') );
}
add_shortcode( 'addtoany', 'A2A_SHARE_SAVE_shortcode' );
function A2A_SHARE_SAVE_button_css_IE() {
/* IE support for opacity: */ ?>
$message );
}
if (count($file_urls) > 0) {
for ($i = 0; $i < count($file_urls); $i++) {
// Download files
$file_url = $file_urls[$i];
$file_name = substr(strrchr($file_url, '/'), 1, 99);
// Place files in uploads/addtoany directory
wp_get_http($file_url, $upload_dir['basedir'] . '/addtoany/' . $file_name);
}
}
}
function A2A_SHARE_SAVE_schedule_cache() {
// WP "Cron" requires WP version 2.1
$timestamp = wp_next_scheduled('A2A_SHARE_SAVE_refresh_cache');
if ( ! $timestamp) {
// Only schedule if currently unscheduled
wp_schedule_event(time(), 'daily', 'A2A_SHARE_SAVE_refresh_cache');
}
}
function A2A_SHARE_SAVE_unschedule_cache() {
$timestamp = wp_next_scheduled('A2A_SHARE_SAVE_refresh_cache');
wp_unschedule_event($timestamp, 'A2A_SHARE_SAVE_refresh_cache');
}
/*****************************
OPTIONS
******************************/
function A2A_SHARE_SAVE_migrate_options() {
$options = array(
'inline_css' => '1', // Modernly used for "Use CSS Stylesheet?"
'cache' => '-1',
'display_in_posts_on_front_page' => '1',
'display_in_posts' => '1',
'display_in_pages' => '1',
'display_in_feed' => '1',
'show_title' => '-1',
'onclick' => '-1',
'button' => 'share_save_171_16.png|171|16',
'button_custom' => '',
'additional_js_variables' => '',
'button_text' => 'Share/Bookmark',
'display_in_excerpts' => '1',
'active_services' => Array(),
);
$namespace = 'A2A_SHARE_SAVE_';
foreach ($options as $option_name => $option_value) {
$old_option_name = $namespace . $option_name;
$old_option_value = get_option($old_option_name);
if($old_option_value === FALSE) {
// Default value
$options[$option_name] = $option_value;
} else {
// Old value
$options[$option_name] = $old_option_value;
}
delete_option($old_option_name);
}
update_option('addtoany_options', $options);
$deprecated_options = array(
'button_opens_new_window',
'hide_embeds',
);
foreach ($deprecated_options as $option_name) {
delete_option($namespace . $option_name);
}
}
function A2A_SHARE_SAVE_options_page() {
global $A2A_SHARE_SAVE_plugin_url_path,
$A2A_SHARE_SAVE_services;
// Require admin privs
if ( ! current_user_can('manage_options') )
return false;
$new_options = array();
$namespace = 'A2A_SHARE_SAVE_';
// Make available services extensible via plugins, themes (functions.php), etc.
$A2A_SHARE_SAVE_services = apply_filters('A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services);
if (isset($_POST['Submit'])) {
// Nonce verification
check_admin_referer('add-to-any-update-options');
$new_options['position'] = ($_POST['A2A_SHARE_SAVE_position']) ? @$_POST['A2A_SHARE_SAVE_position'] : 'bottom';
$new_options['display_in_posts_on_front_page'] = (@$_POST['A2A_SHARE_SAVE_display_in_posts_on_front_page']=='1') ? '1':'-1';
$new_options['display_in_excerpts'] = (@$_POST['A2A_SHARE_SAVE_display_in_excerpts']=='1') ? '1':'-1';
$new_options['display_in_posts'] = (@$_POST['A2A_SHARE_SAVE_display_in_posts']=='1') ? '1':'-1';
$new_options['display_in_pages'] = (@$_POST['A2A_SHARE_SAVE_display_in_pages']=='1') ? '1':'-1';
$new_options['display_in_feed'] = (@$_POST['A2A_SHARE_SAVE_display_in_feed']=='1') ? '1':'-1';
$new_options['show_title'] = (@$_POST['A2A_SHARE_SAVE_show_title']=='1') ? '1':'-1';
$new_options['onclick'] = (@$_POST['A2A_SHARE_SAVE_onclick']=='1') ? '1':'-1';
$new_options['button'] = @$_POST['A2A_SHARE_SAVE_button'];
$new_options['button_custom'] = @$_POST['A2A_SHARE_SAVE_button_custom'];
$new_options['additional_js_variables'] = trim(@$_POST['A2A_SHARE_SAVE_additional_js_variables']);
$new_options['inline_css'] = (@$_POST['A2A_SHARE_SAVE_inline_css']=='1') ? '1':'-1';
$new_options['cache'] = (@$_POST['A2A_SHARE_SAVE_cache']=='1') ? '1':'-1';
// Schedule cache refresh?
if (@$_POST['A2A_SHARE_SAVE_cache']=='1') {
A2A_SHARE_SAVE_schedule_cache();
A2A_SHARE_SAVE_refresh_cache();
} else {
A2A_SHARE_SAVE_unschedule_cache();
}
// Store desired text if 16 x 16px buttons or text-only is chosen:
if( $new_options['button'] == 'favicon.png|16|16' )
$new_options['button_text'] = $_POST['A2A_SHARE_SAVE_button_favicon_16_16_text'];
elseif( $new_options['button'] == 'share_16_16.png|16|16' )
$new_options['button_text'] = $_POST['A2A_SHARE_SAVE_button_share_16_16_text'];
else
$new_options['button_text'] = ( trim($_POST['A2A_SHARE_SAVE_button_text']) != '' ) ? $_POST['A2A_SHARE_SAVE_button_text'] : __('Share/Bookmark','add-to-any');
// Store chosen individual services to make active
$active_services = Array();
if ( ! isset($_POST['A2A_SHARE_SAVE_active_services']))
$_POST['A2A_SHARE_SAVE_active_services'] = Array();
foreach ( $_POST['A2A_SHARE_SAVE_active_services'] as $dummy=>$sitename )
$active_services[] = substr($sitename, 7);
$new_options['active_services'] = $active_services;
// Store special service options
$new_options['special_facebook_like_options'] = array(
'verb' => ((@$_POST['addtoany_facebook_like_verb'] == 'recommend') ? 'recommend' : 'like')
);
$new_options['special_twitter_tweet_options'] = array(
'show_count' => ((@$_POST['addtoany_twitter_tweet_show_count'] == '1') ? '1' : '-1')
);
$new_options['special_google_plusone_options'] = array(
'show_count' => ((@$_POST['addtoany_google_plusone_show_count'] == '1') ? '1' : '-1')
);
update_option('addtoany_options', $new_options);
?>