In http://www.onlineincomestartup.com/drive-traffic-to-your-website/ , In the author bio that shows up inside each posts,
I need to make all the links except Google plus, a no follow for SEO purposes.I am using a plugin called WP about author.I guess I need to make changes to the following code.But I'm not that good in editing codes.someone please help.thanks
// Generate social icons
function wp_about_author_get_social_links($wp_about_author_settings){
$content="";
$socials = wp_about_author_get_socials();
foreach($socials as $social_key=>$social){
if (get_the_author_meta($social_key)){
if(isset($wp_about_author_settings['wp_author_social_images']) && $wp_about_author_settings['wp_author_social_images']){
$content .= "<a class='wpa-social-icons' rel="nofollow" href='".str_replace('%%username%%', get_the_author_meta($social_key), $social['link'])."'><img src='". $social['icon']."' alt='".$social['title']."'/></a>";
} else {
if($content != "")
$content .= apply_filters( 'wp_about_author_separator', " - ");
$content .= "<a href='".str_replace('%%username%%', get_the_author_meta($social_key), $social['link'])."'>".$social['title']."</a>";
}
}
}
return $content;
}
function wp_about_author_get_socials() {
$socials = array();
$socials['twitter'] = array('title'=>'Twitter', 'link'=>'http://www.twitter.com/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/twitter.png');
$socials['facebook'] = array('title'=>'Facebook', 'link'=>'http://www.facebook.com/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/facebook.png');
$socials['linkedin'] = array('title'=>'LinkedIn', 'link'=>'http://www.linkedin.com/in/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/linkedin.png');
$socials['pinterest'] = array('title'=>'Pinterest', 'link'=>'http://www.pinterest.com/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/pinterest.png');
$socials['googleplus'] = array('title'=>'Google Plus', 'link'=>'https://plus.google.com/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/googleplus.png');
$socials['digg'] = array('title'=>'Digg', 'link'=>'http://www.digg.com/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/digg.png');
$socials['flickr'] = array('title'=>'Flickr', 'link'=>'http://www.flickr.com/people/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/flickr.png');
$socials['stumbleupon'] = array('title'=>'StumbleUpon', 'link'=>'http://www.stumbleupon.com/stumbler/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/stumbleupon.png');
$socials['youtube'] = array('title'=>'YouTube', 'link'=>'http://www.youtube.com/user/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/youtube.png');
$socials['yelp'] = array('title'=>'Yelp', 'link'=>'http://www.yelp.com/user_details?userid=%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/yelp.png');
$socials['reddit'] = array('title'=>'Reddit', 'link'=>'http://www.reddit.com/user/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/reddit.png');
$socials['delicious'] = array('title'=>'Delicious', 'link'=>'http://www.delicious.com/%%username%%', 'icon'=> WPAUTHORURL_URL .'/images/delicious.png');
return apply_filters( 'wp_about_author_get_socials', $socials );
}
You can change this line where the username link is generated
$content .= "<a href='".str_replace('%%username%%', get_the_author_meta($social_key), $social['link'])."'>".$social['title']."</a>";
to
$content .= "<a rel='nofollow' href='".str_replace('%%username%%', get_the_author_meta($social_key), $social['link'])."'>".$social['title']."</a>";
and that should add nofollow to your links.
I had the same requirement. I had social links and icons on my site and found that our website was passing off thousands of dofollow links and draining our sites link juice. After some research I came across a nice little feature in Rank Maths SEO plugin that would allow you to actually select certain domains and set them to nofollow site wide. This was really handy. However if you are already using yoast you will need to make sure you turn all of the Rank Math plugins features off and only use the nofollow domains options.
Related
Barcode does not print into next pages on pdf file. Let me explain. If I want to print 60 barcodes and 15 barcodes on each page. It is printing 15 barcodes, rest of barcodes and pages showing blank. Here is my code
public function generatebarcodeAction(){
$this->_helper->layout()->disableLayout();
$pdf = new Zend_Pdf();
$hidden =$_POST['hidden']; // i want to barcode of this field.
// barcode should be print quantity from to quantity to
$quantityfrom =$_POST['quantity_from'];
$quantityto =$_POST['quantity_to'];
$rendererOptions = array(
'topOffset' => 50,
'leftOffset' => 50
);
Zend_Barcode::setBarcodeFont(dirname(ROOT_PATH) . '/inventory/library/Zend/Barcode/Object/fonts/open-sans/OpenSans-Semibold.ttf');
$numberOfPages = $quantityto/15;
$equipmentCount = $quantityto;
for($i = 1; $i <= $numberOfPages; $i++)
{
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 20);
$pdf->pages[] = $page;
}
foreach($pdf->pages as $id => $page)
{
if($equipmentCount > 15)
{
$barcodesOnThisPage = 15;
$equipmentCount = $equipmentCount - 15;
}
else
{
$barcodesOnThisPage = $equipmentCount;
}
for($i=$quantityfrom;$i<=$quantityto;$i++){
$barcodeOptions = array('text' => $hidden.$i);
$rendererOptions = array('topOffset' => 50*$i);
$pdfWithBarcode = Zend_Barcode::factory('code39', 'pdf',
$barcodeOptions, $rendererOptions)->setResource($pdf)->draw();
$pdfWithBarcode->save('testBarcode.pdf');
}
$quantityfrom = $i;
}
}
In this code you are create 4 blank pages and then draw all barcodes in page number 1. you cant see 45 barcodes because their margin is bigger than page height!!
you may want to add barcodes to $pages not to $pdf.
be care you should use for instead of foreach to rewrite $page
I want to get first 140 character from the post content and display it into a homepage. I create plugin for that and it doesn't give me the desire out put. Can you guys tell me where I done mistake and how can I recover it? This is the code that I write in plugin file
$length = 140;
function cp_trim_content($length){
$content = explode(' ', get_the_content(), $length );
if( count($content) >= $length)
{
array_pop($content);
$content = implode (" ", $content).'...';
}
else
{
$content = implode (" ", $content);
}
//$content = preg_replace('/\[.+\]/','', $content);
$content = apply_filters('the_content', $content);
return $content;
}
If you want it for 140 character then the below code will work for you
$length = 140;
function cp_trim_content($length)
{
$content = get_the_content();
if(strlen($content)>$length)
{
$final_content = substr($content,0,140).' ...';
}
else
{
$final_content = $content;
}
return $final_content;
}
I was trying to find the best way to count number of likes for a facebook page url and after googling a lot and playing with the code, i have a code like the one given below. It outputs the likes, name of the page and then the link. I wish to know:
1. How can i use the html tag to convert the link into hyperlink so that I can have something like "Click here to visit"
2. How can monitor performance of 25+ fb_id on an hourly basis with a sorted order (descending) on likes
<?php
$fb_id = '36922302396';
$url = 'https://graph.facebook.com/' . urlencode($fb_id);
$result = json_decode( file_get_contents($url) );
printf("%s %s %s", $result->likes, $result->name, $result->link);
?>
Edited code as per solution provided
<?php
$fb_id = '36922302396';
$pic = 'https://www.facebook.com/' . urlencode($fb_id) . '/picture?type=square';
$url = 'https://graph.facebook.com/' . urlencode($fb_id);
$result = json_decode( file_get_contents($url) );
echo $result->likes , " " , $result->name , " " , "<a target='_blank' href=\"" . $result->link . "\" ><img src = $pic></a>";
?>
Thanks
For 1)
How about
<?php
$fb_id = '36922302396';
$url = 'https://graph.facebook.com/' . urlencode($fb_id);
$result = json_decode( file_get_contents($url) );
//printf("%s %s %s", $result->likes, $result->name, $result->link);
echo "Link";
?>
You can also use
Link
For 2)
If you know the Page's IDs, then you can just concatenate them to the following :
GET /?ids=40796308305,339150749455906&fields=id,name,likes,talking_about_count
The result looks like the following
{
"40796308305": {
"id": "40796308305",
"name": "Coca-Cola",
"likes": 88365218,
"talking_about_count": 635936
},
"339150749455906": {
"id": "339150749455906",
"name": "Pepsi",
"likes": 33321925,
"talking_about_count": 208761
}
}
For hourly stats, you need to setup your script via cron etc. and write the results to a database.
I am using AWD Facebook wordpress plugin to allow my visitors to login with their Facebook account information. When a visitor registers on my site I automatically create a new post that is titled with their username and includes their Facebook profile picture as the content. The code for that is below:
function my_create_page($user_id){
$fbuide = 0;
$the_user = get_userdata($user_id);
$new_user_name = $the_user->user_login;
$new_user_avatar = get_avatar($the_user->user_email);
global $AWD_facebook;
$fbuide = $AWD_facebook->uid;
$headers = get_headers('http://graph.facebook.com/' . $fbuide . '/picture?type=large',1);
if(isset($headers['Location'])) {
$url = $headers['Location']; // string
} else {
$url = false;
}
$my_avatar = "<img src='" . $url . "' class='avatar AWD_fbavatar' alt='" . $alt . "' height='" . $size . "' />";
$my_post = array();
$my_post['post_title'] = $new_user_name;
$my_post['post_type'] = 'post';
$my_post['post_content'] = $my_avatar;
$my_post['post_status'] = 'publish';
wp_insert_post( $my_post );
}
add_action('user_register', 'my_create_page');
What I am looking to accomplish is a bit different though. I also want to include a brief biography about the user (currently the post is simply their picture). So when a visitor logs in with AWD Facebook, their needs to be an additional field that allows the user to type in their bio. Then I would be able to grab that info from their user profile and include it in the post. Any ideas on how I can accomplish this? Is there a different way to do this?
I would recommend storing their Facebook picture as metadata and use the content area as their bio for the automatically generated post. So something like this should get you started:
$my_post = array(
'post_title'=>$new_user_name,
'post_type'=>'post',
'post_content'=>'',
'post_status'=>'publish'
);
if( $id = wp_insert_post( $my_post ) ){
update_post_meta($id, 'avatar', $url);
}
Then you can generate the loop like so:
if ( have_posts() ) : while ( have_posts() ) : the_post();
//... stuff here
$avatar = get_post_meta($post->ID, 'avatar', 'true');
the_content();
echo '<img class="avatar AWD_fbavatar" src="'.$avatar.'" alt="'.$alt.'" height="'.$size.'" />';
endwhile;endif;
I'm trying to create PDF pages with barcodes that have correct margins to be printed on sheets of labels (If you have another idea of how to print barcodes onto labels without PDF generation, I'd love to hear it). Below is what I have currently for code:
$pdf = new Zend_Pdf();
for($i = 1; $i <= $numberOfPages; $i++)
{
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 20);
$pdf->pages[] = $page;
}
foreach($pdf->pages as $id => $page)
{
if($equipmentCount > 10)
{
$barcodesOnThisPage = 10;
$equipmentCount = $equipmentCount - 10;
}
else
{
$barcodesOnThisPage = $equipmentCount;
}
for($i = 1; $i <= $barcodesOnThisPage; $i++)
{
//Zend_Barcode::setBarcodeFont();
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-1');
$rendererOptions = array('topOffset' => 50);
$pdf = Zend_Barcode::factory('code39', 'pdf',
$barcodeOptions, $rendererOptions)->setResource($pdf)->render();
die;
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-2');
$rendererOptions = array('topOffset' => 100);
$pdfBarcode = Zend_Barcode::factory('code39', 'pdf',
$barcodeOptions, $rendererOptions)->setResource($pdf)->draw();
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-3');
$rendererOptions = array('topOffset' => 150);
$pdfBarcode = Zend_Barcode::factory('code39', 'pdf',
$barcodeOptions, $rendererOptions)->setResource($pdf)->draw();
// and the end render your Zend_Pdf
/$pdfBarcode->save('testBarcode.pdf');
}
}
I'm currently getting an error "Invalid file path in: library/Zend/Pdf/FileParserDataSource/File.php on line 79 ()"
Any thoughts on why this is occurring? This happens when I try to render the barcode. Before that the code executes with no errors.
I believe that the complete answer to your question has since been added here:
Zend Framework Render Barcodes Into Multiple PDF Pages with other content
The key seems to be:
Create the Pdf library page content on a page.
Add the Pdf library page to the pdf.
Print the Barcode library barcodes onto that page of the pdf using something like Zend_Barcode::factory('code39', 'pdf', $barcodeOptions, $rendererOptions)->setResource($pdf, $page_index)->draw();
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-1', 'font' => __DIR__ . "/FRE3OF9X.TTF");
TTF file (FRE3OF9X.TTF or what have you) must exist.