src/web/app/themes/atahualpa/functions/bfa_sociable2.php
changeset 0 505fe5249d9c
equal deleted inserted replaced
-1:000000000000 0:505fe5249d9c
       
     1 <?php
       
     2 function sociable_html2($display=Array()) {
       
     3 	global $sociable_known_sites, $sociablepluginpath, $wp_query; 
       
     4 
       
     5 	$active_sites = get_option('sociable_active_sites');
       
     6 	$html = "";
       
     7 	$imagepath = $sociablepluginpath.'images/';
       
     8 
       
     9 	// if no sites are specified, display all active
       
    10 	// have to check $active_sites has content because WP
       
    11 	// won't save an empty array as an option
       
    12 	if (empty($display) and $active_sites)
       
    13 		$display = $active_sites;
       
    14 	// if no sites are active, display nothing
       
    15 	if (empty($display))
       
    16 		return "";
       
    17 
       
    18 	// Load the post's data
       
    19 	$blogname 	= urlencode(get_bloginfo('name')." ".get_bloginfo('description'));
       
    20 	$post 		= $wp_query->post;
       
    21 	
       
    22 	$excerpt	= $post->post_excerpt;
       
    23 	if ($excerpt == "") {
       
    24 		$excerpt = urlencode(substr(strip_tags($post->post_content),0,250));
       
    25 	}
       
    26 	$excerpt	= str_replace('+','%20',$excerpt);
       
    27 	
       
    28 	$permalink 	= urlencode(get_permalink($post->ID));
       
    29 	
       
    30 	$title 		= urlencode($post->post_title);
       
    31 	$title 		= str_replace('+','%20',$title);
       
    32 	
       
    33 	$rss 		= urlencode(get_bloginfo('ref_url'));
       
    34 
       
    35 	$html .= "\n<span class=\"sociable\">\n";
       
    36 	$html .= "<ul>\n";
       
    37 
       
    38 	foreach($display as $sitename) {
       
    39 		// if they specify an unknown or inactive site, ignore it
       
    40 		if (!in_array($sitename, $active_sites))
       
    41 			continue;
       
    42 
       
    43 		$site = $sociable_known_sites[$sitename];
       
    44 
       
    45 		$url = $site['url'];
       
    46 		$url = str_replace('PERMALINK', $permalink, $url);
       
    47 		$url = str_replace('TITLE', $title, $url);
       
    48 		$url = str_replace('RSS', $rss, $url);
       
    49 		$url = str_replace('BLOGNAME', $blogname, $url);
       
    50 		$url = str_replace('EXCERPT', $excerpt, $url);
       
    51 
       
    52 		if (isset($site['description']) && $site['description'] != "") {
       
    53 			$description = $site['description'];
       
    54 		} else {
       
    55 			$description = $sitename;
       
    56 		}
       
    57 		$link = "<li>";		
       
    58 		$link .= "<a rel=\"nofollow\"";
       
    59 		if (get_option('sociable_usetargetblank')) {
       
    60 			$link .= " target=\"_blank\"";
       
    61 		}
       
    62 		$link .= " href=\"$url\" title=\"$description\">";
       
    63 		$link .= "<img src=\"$imagepath{$site['favicon']}\" title=\"$description\" alt=\"$description\" class=\"sociable-hovers";
       
    64 		if ($site['class'])
       
    65 			$link .= " sociable_{$site['class']}";
       
    66 		$link .= "\" />";
       
    67 		$link .= "</a></li>";
       
    68 		
       
    69 		$html .= "\t".apply_filters('sociable_link',$link)."\n";
       
    70 	}
       
    71 
       
    72 	$html .= "</ul>\n</span>\n";
       
    73 
       
    74 	return $html;
       
    75 }
       
    76 ?>