Viewing 6 replies - 1 through 6 (of 6 total)
  • I ham having the same issue. Looking through the code, I found out that the setting only works to stop it from linking the page title to the same page.

    I.E. – if the page title is “Home Remedies” then it will not link the words “Home Remedies” on that page back to itself.

    No solution yet, just wanted to explain what was happening. I’m looking for a way to mod the plugin so it also doesn’t link custom keywords to their respective pages.

    I take that back, I found where it is supposed to not link the text if it would link to itself. But I found the problem, working on fixing it now.

    It has to do with whitespace around the links and keywords. Quick solution is to remove all spaces around custom keywords and their urls.

    I.E.
    change
    Badan si Badun, https://belajar.indonesiamengajar.org/2012/09/badan-si-badun-alat-peraga-anatomi-tubuh-manusia/
    to
    Badan si Badun,https://belajar.indonesiamengajar.org/2012/09/badan-si-badun-alat-peraga-anatomi-tubuh-manusia/

    This also affects using multiple keywords per line, the link will include the space

    E.G.
    if you add Home Remedies as a keyword:
    Badan si Badun, Home Remedies, https://belajar.indonesiamengajar.org/2012/09/badan-si-badun-alat-peraga-anatomi-tubuh-manusia/
    and it is in the text, it would come out as:
    <a href="https://belajar.indonesiamengajar.org/2012/09/badan-si-badun-alat-peraga-anatomi-tubuh-manusia/"> Home Remedies</a>

    Working on adding some trim functions everywhere so we don’t have this problem.

    In seo-links.php, starting at line 145 there is an if-else block inside a foreach loop that builds the array that holds the keywords and their respective urls. Add a couple of trim and str_replace functions to get things working properly, four of them as shown below, marked by the /*MOD*/ comments at the end of the lines:

    if($options['customkey_preventduplicatelink'] == TRUE) {  //Prevent duplicate links for grouped custom keywords
    
    				$line = trim($line);
    				$lastDelimiterPos=strrpos($line, ',');
    				$url = trim(substr($line, $lastDelimiterPos + 1 )); /*MOD*/
    				$keywords = substr($line, 0, $lastDelimiterPos);
    				$keywords = str_replace(', ', ',', $keywords); /*MOD*/
    
    				if(!empty($keywords) && !empty($url)){
    					$kw_array[$keywords] = $url;
    				}
    
    				$keywords='';
    				$url='';
    
    			} else {  //Old custom keywords behaviour
    
    			$chunks = array_map('trim', explode(",", $line));
    			$total_chuncks = count($chunks);
    			if($total_chuncks > 2) {
    				$i = 0;
    				$url = trim($chunks[$total_chuncks-1]); /*MOD*/
    				while($i < $total_chuncks-1) {
    					if (!empty($chunks[$i])) $kw_array[$chunks[$i]] = $url;
    						$i++;
    					}
    				} else {
    					list($keyword, $url) = array_map('trim', explode(",", $line, 2));
    					$keywords = str_replace(', ', ',', $keywords); /*MOD*/
    					if (!empty($keyword)) $kw_array[$keyword] = $url;
    				}
    
    			}

    I’m not positive the last two are needed since it does some trimming already, but my implementation is not using that part of the code (I chose to prevent duplicates), so I have not tested it.

    The code is not very well tabbed to be easy to read, here is a reformatted version, with /*MOD*/ indicators tabbed further out too:

    if($options['customkey_preventduplicatelink'] == TRUE) {  //Prevent duplicate links for grouped custom keywords
    
    	$line = trim($line);
    	$lastDelimiterPos=strrpos($line, ',');
    	$url = trim(substr($line, $lastDelimiterPos + 1 )); 			/*MOD*/
    	$keywords = substr($line, 0, $lastDelimiterPos);
    	$keywords = str_replace(', ', ',', $keywords); 				/*MOD*/
    
    	if(!empty($keywords) && !empty($url)){
    		$kw_array[$keywords] = $url;
    	}
    
    	$keywords='';
    	$url='';
    
    } else {  //Old custom keywords behaviour
    
    	$chunks = array_map('trim', explode(",", $line));
    	$total_chuncks = count($chunks);
    	if($total_chuncks > 2) {
    		$i = 0;
    		$url = trim($chunks[$total_chuncks-1]); 			/*MOD*/
    		while($i < $total_chuncks-1) {
    			if (!empty($chunks[$i])) $kw_array[$chunks[$i]] = $url;
    			$i++;
    		}
    	} else {
    		list($keyword, $url) = array_map('trim', explode(",", $line, 2));
    		$keywords = str_replace(', ', ',', $keywords); 			/*MOD*/
    		if (!empty($keyword)) $kw_array[$keyword] = $url;
    	}
    
    }
    Thread Starter SammyJayJay

    (@sammyjayjay)

    Hi..

    Thanks a lot!

    I just removed the spaces in the keywords set-up as you suggested in your quick fix.. and that has worked.

    But thanks for making the new code, I am sure it will be helpful for everybody having this problem.

    I assume that applying the new code.. will mean that links will not point to themselves no matter if there is a space or not in the link set-up.

    That is correct, spaces or not, it works with the code changes.

    Now if I can get it working in excerpts, I will be happy!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘SEO Smart Links Settings Faulty’ is closed to new replies.