Разместване на бутони, писане на текст до тях

kmh

Registered
Здравейте,
одавна следя форума, защото чат пат намирам интересни работи, които ми помагат. С HTML се оправям (що-годе, с малко четене), но PHP ми е нещо като ядрената физика за Бойко Борисов.

Сайтът ми изпозлва WordPress, и съм добавил приложения. Най-отгоре в поста ми излизат бутони за споделяне - първо фейсбук, след това GooglePlus.
След фейсбука съм оставил брояч, тъй като често има материали, които се споделят по 10-15 пъти. Когато обаче няма брояч, или някой без фейсбук посети сайта, между Бутона за Фейсбук и Гуугъл остава разстояние (плюс това, ако е фесйбук му е на английски остава още по-голямо разстояние, защото пише само "Like"). Бих искал да елиминарам пространството, като първо сложа бутона за Гуугъл, а след това този за Фейсбу. Така проблемите ще изчезнат. Пробвах и сам да го направя, но целият сайт буквално се срути, и започна да показва само снимките - сигурен фатк, че не съм се справил успешно.

Освен това, ми е интересно, как бих могъл да сложа текст със линк в избран от мен цвят до бутоните?

Прилагам файла tf_display.php, в който според мен стоят настройките за показване на страниците. Има и други три файла, които мога да дам - twitter-facebook-share.php, tfg_style.css и tf_admin_page.php

PHP:
<?php 
/*
Core logic to display social share icons at the required positions. 
*/
require_once('tf_admin_page.php');

function twitter_facebook_share_init() {
	// DISABLED IN THE ADMIN PAGES
	if (is_admin()) {
		return;
	}

	//GET ARRAY OF STORED VALUES
	$option = twitter_facebook_share_get_options_stored();

	if ($option['active_buttons']['twitter']==true) {
		wp_enqueue_script('twitter_facebook_share_twitter', 'http://platform.twitter.com/widgets.js','','',$option['jsload']);
	}
	
	if ($option['active_buttons']['Google_plusone']==true) {
		wp_enqueue_script('twitter_facebook_share_google', 'http://apis.google.com/js/plusone.js','','',$option['jsload']);
	}
	if ($option['active_buttons']['linkedin']==true) {
		wp_enqueue_script('twitter_facebook_share_linkedin', 'http://platform.linkedin.com/in.js','','',$option['jsload']);
	}

	wp_enqueue_style('tfg_style', '/wp-content/plugins/twitter-facebook-google-plusone-share/tfg_style.css');
	
}    

function kc_twitter_facebook_contents($content)
{
	return kc_twitter_facebook($content,'content');
}

function kc_twitter_facebook_excerpt($content)
{
	return kc_twitter_facebook($content,'excerpt');
}

function kc_twitter_facebook($content, $filter)
{
  global $single;
  
  $option = twitter_facebook_share_get_options_stored();
  $custom_disable = get_post_custom_values('disable_social_share');
  if (is_single() && ($option['show_in']['posts']) && ($custom_disable[0] != 'yes')) {
	    $output = kc_social_share('auto');
  		if ($option['position'] == 'above')
        	return  $output . $content;
		if ($option['position'] == 'below')
			return  $content . $output;
		if ($option['position'] == 'left')
			return  $output . $content;
		if ($option['position'] == 'both')
			return  $output . $content . $output;
    } 
	if (is_home() && ($option['show_in']['home_page'])){
        $output = kc_social_share('auto');
		if ($option['position'] == 'above')
        	return  $output . $content;
		if ($option['position'] == 'below')
			return  $content . $output;
		if ($option['position'] == 'left')
			return  $output . $content;
		if ($option['position'] == 'both')
			return  $output . $content . $output;
	}
	if (is_page() && ($option['show_in']['pages']) && ($custom_disable[0] != 'yes')) {
		  $output = kc_social_share('auto');
  		if ($option['position'] == 'above')
        	return  $output . $content;
		if ($option['position'] == 'below')
			return  $content . $output;
		if ($option['position'] == 'left')
			return  $output . $content;
		if ($option['position'] == 'both')
			return  $output . $content . $output;
    }  
	if (is_category() && ($option['show_in']['categories'])) {
		  $output = kc_social_share('auto');
  		if ($option['position'] == 'above')
        	return  $output . $content;
		if ($option['position'] == 'below')
			return  $content . $output;
		if ($option['position'] == 'left')
			return  $output . $content;
		if ($option['position'] == 'both')
			return  $output . $content . $output;
    } 
	if (is_tag() && ($option['show_in']['tags'])) {
		  $output = kc_social_share('auto');
  		if ($option['position'] == 'above')
        	return  $output . $content;
		if ($option['position'] == 'below')
			return  $content . $output;
		if ($option['position'] == 'left')
			return  $output . $content;
		if ($option['position'] == 'both')
			return  $output . $content . $output;
    } 
	if (is_author() && ($option['show_in']['authors'])) {
		  $output = kc_social_share('auto');
  		if ($option['position'] == 'above')
        	return  $output . $content;
		if ($option['position'] == 'below')
			return  $content . $output;
		if ($option['position'] == 'left')
			return  $output . $content;
		if ($option['position'] == 'both')
			return  $output . $content . $output;
    } 
	if (is_search() && ($option['show_in']['search'])) {
		  $output = kc_social_share('auto');
  		if ($option['position'] == 'above')
        	return  $output . $content;
		if ($option['position'] == 'below')
			return  $content . $output;
		if ($option['position'] == 'left')
			return  $output . $content;
		if ($option['position'] == 'both')
			return  $output . $content . $output;
    } 
	if (is_date() && ($option['show_in']['date_arch'])) {
		  $output = kc_social_share('auto');
  		if ($option['position'] == 'above')
        	return  $output . $content;
		if ($option['position'] == 'below')
			return  $content . $output;
		if ($option['position'] == 'left')
			return  $output . $content;
		if ($option['position'] == 'both')
			return  $output . $content . $output;
    } 
	return $content;
}

// Function to manually display related posts.
function kc_add_social_share()
{
 $output = kc_social_share('manual');
 echo $output;
}



function kc_social_share($source)
{
	//GET ARRAY OF STORED VALUES
	$option = twitter_facebook_share_get_options_stored();
	if (empty($option['bkcolor_value']))
		$option['bkcolor_value'] = '#F0F4F9';
	$border ='';
 	if ($option['border'] == 'flat') 
		$border = 'border:1px solid #808080;';
	else if ($option['border'] == 'round')
	    $border = 'border:1px solid #808080; border-radius:5px 5px 5px 5px; box-shadow:2px 2px 5px rgba(0,0,0,0.3);';
		
	if ($option['bkcolor'] == true)
		$bkcolor = 'background-color:' . $option['bkcolor_value']. ';'; 
	else
		$bkcolor = '';

 	$post_link = get_permalink();
	$post_title = get_the_title();
	if ($option['position'] == 'left' && ( !is_single() && !is_page()))
		if (($source != 'manual') || ($source != 'shortcode')) 
			$option['position'] = 'above';

	if ($option['position'] == 'left'){
		$output = '<div id="leftcontainerBox" style="' .$border. $bkcolor. 'position:' .$option['float_position']. '; top:' .$option['bottom_space']. '; left:' .$option['left_space']. ';">';
		if ($option['active_buttons']['facebook_like']==true) {
		$output .= '
			<div class="buttons">
			<iframe src="http://www.facebook.com/plugins/like.php?href=' . urlencode($post_link) . '&layout=box_count&show_faces=false&action=like&font=verdana&colorscheme=light" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:60px;" allowTransparency="true"></iframe>
			</div>';
		}
		
		if ($option['active_buttons']['twitter']==true) {
		if ($option['twitter_id'] != ''){
		$output .= '
			<div class="buttons">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="'. $post_link .'"  data-text="'. $post_title . '" data-count="vertical" data-via="'. $option['twitter_id'] . '">Tweet</a>
			</div>';
		} else {
		$output .= '
			<div class="buttons">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="'. $post_link .'"  data-text="'. $post_title . '" data-count="vertical">Tweet</a>
			</div>';
		}
		}
		
		if ($option['active_buttons']['Google_plusone']==true) {
		$output .= '
			<div class="buttons">
			<g:plusone size="tall" href="'. $post_link .'"></g:plusone>
			</div>';
		}
		
		if ($option['active_buttons']['stumbleupon']==true) {
		$output .= '
			<div class="buttons"><script src="http://www.stumbleupon.com/hostedbadge.php?s=5&r='.$post_link.'"></script></div>';
		}
		if ($option['active_buttons']['linkedin']==true) {
		$output .= '<div class="buttons" style="padding-left:0px;"><script type="in/share" data-url="' . $post_link . '" data-counter="top"></script></div>';
		}
		$output .= '</div><div style="clear:both"></div>';
		return $output;
	}

		
	if (($option['position'] == 'below') || ($option['position'] == 'above') || ($option['position'] == 'both'))
	{
		$output = '<div class="bottomcontainerBox" style="' .$border. $bkcolor. '">';
		if ($option['active_buttons']['facebook_like']==true) {
		$output .= '
			<div style="float:left; width:' .$option['facebook_like_width']. 'px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=' . urlencode($post_link) . '&layout=button_count&show_faces=false&width='.$option['facebook_like_width'].'&action=like&font=verdana&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width='.$option['facebook_like_width'].'px; height:21px;" allowTransparency="true"></iframe></div>';
		}

		if ($option['active_buttons']['Google_plusone']==true) {
		$data_count = ($option['google_count']) ? '' : 'count="false"';
		$output .= '
			<div style="float:left; width:' .$option['google_width']. 'px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="' . $post_link . '"'.$data_count.'></g:plusone>
			</div>';
		}
		
		if ($option['active_buttons']['twitter']==true) {
		$data_count = ($option['twitter_count']) ? 'horizontal' : 'none';
		if ($option['twitter_id'] != ''){
		$output .= '
			<div style="float:left; width:' .$option['twitter_width']. 'px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="'. $post_link .'"  data-text="'. $post_title . '" data-count="'.$data_count.'" data-via="'. $option['twitter_id'] . '">Tweet</a>
			</div>';
		} else {
		$output .= '
			<div style="float:left; width:' .$option['twitter_width']. 'px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="'. $post_link .'"  data-text="'. $post_title . '" data-count="'.$data_count.'">Tweet</a>
			</div>';
		}
		}
		if ($option['active_buttons']['linkedin']==true) {
		$counter = ($option['linkedin_count']) ? 'right' : '';
		$output .= '<div style="float:left; width:' .$option['linkedin_width']. 'px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="' . $post_link . '" data-counter="' .$counter. '"></script></div>';
		}
		if ($option['active_buttons']['stumbleupon']==true) {
		$output .= '			
			<div style="float:left; width:' .$option['stumbleupon_width']. 'px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&r='.$post_link.'"></script></div>';
		}
		
		$output .= '			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>';
			
		return $output;
	}
}

function tfg_social_share_shortcode () {
	$output = kc_social_share('shortcode');
	echo $output;
}

function fb_like_thumbnails()
{
global $posts;
$default = '';
$content = $posts[0]->post_content; // $posts is an array, fetch the first element
$output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
if ( $output > 0 ) {
$thumb = $matches[1][0];
echo "\n\n\n<link rel=\"image_src\" href=\"$thumb\" />\n\n";
}
else
$thumb = $default;
}
?>


Ще се радвам, ако ми помогнете.

Поздрави
 
:oops: Ще се радвам ако някой се включи. И също така, как се слага текст с php на определено място. Смятам, че може да се добави в този плъгийн, тъй като той се показва на всеки пост, и така линка ще излиза на всяка новина.

Благодаря
 

Back
Горе