make_hash_link

The Facebook Feed make hash link function.

Description

make_hash_link( $str, $link_target ); 

Parameters (2)

0. $str
The str.
1. $link_target
The link target.

Usage

  1. if ( !function_exists( 'make_hash_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'facebook-feed/facebook-feed-shortcode.php'; 
  3.  
  4. // The str. 
  5. $str = null; 
  6.  
  7. // The link target. 
  8. $link_target = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = make_hash_link($str, $link_target); 
  12.  

Defined (1)

The function is defined in the following location(s).

/facebook-feed-shortcode.php  
  1. function make_hash_link($str, $link_target)  
  2. $reg_exUrl = "/(#\w+)/"; 
  3. $urls = array(); 
  4. $urlsToReplace = array(); 
  5. if(preg_match_all($reg_exUrl, $str, $urls)) { 
  6. $numOfMatches = count($urls[0]); 
  7. $numOfUrlsToReplace = 0; 
  8. for($i=0; $i<$numOfMatches; $i++) { 
  9. $alreadyAdded = false; 
  10. $numOfUrlsToReplace = count($urlsToReplace); 
  11. for($j=0; $j<$numOfUrlsToReplace; $j++) { 
  12. if($urlsToReplace[$j] == $urls[0][$i]) { 
  13. $alreadyAdded = true; 
  14. if(!$alreadyAdded) { 
  15. array_push($urlsToReplace, $urls[0][$i]); 
  16. $numOfUrlsToReplace = count($urlsToReplace); 
  17. for($i=0; $i<$numOfUrlsToReplace; $i++) { 
  18. $str_without_hastag[$i] = ltrim ($urlsToReplace[$i], '#'); 
  19. if($link_target == 1) { 
  20. $str = str_replace($urlsToReplace[$i], '<a class="wff-link-tab" href="https://www.facebook.com/hashtag/'.$str_without_hastag[$i].'" target = "_blank">'.$urlsToReplace[$i].'</a>', $str); 
  21. } else { 
  22. $str = str_replace($urlsToReplace[$i], '<a class="wff-link-tab" href="https://www.facebook.com/hashtag/'.$str_without_hastag[$i].'" >'.$urlsToReplace[$i].'</a>', $str); 
  23. return $str; 
  24. }  
  25. else{ 
  26. return $str;