WordPress.org

Plugin Directory

Changeset 689459


Ignore:
Timestamp:
03/31/13 13:51:56 (13 months ago)
Author:
Strictly Software
Message:

Updated the bug fix for nested links/bolded words within single quoted attributes and fixed noise word bug.

Location:
strictly-autotags/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • strictly-autotags/trunk/readme.txt

    r674764 r689459  
    66Requires at least: 2.0.2                     
    77Tested up to: 3.4.2 
    8 Stable tag: 2.8.2 
     8Stable tag: 2.8.3 
    99 
    1010Strictly AutoTags is a plugin that automatically adds the most relevant tags to posts. 
     
    184184= 2.8.2 = 
    185185* Fixed bug that sometimes caused nested deeplinking and bolding within HTML attributes by using placeholders to prevent reverse lookups 
     186 
     187= 2.8.3 = 
     188* Rewrote bug fix that was causing nested tags within certain html attributes like alt, title, src and href so that the wording is stored and replaced after bolding or deep linking. 
     189* Removed placeholders for quotes 
     190* Fixed bug that prevented noise words with the digit 0 from being saved. 
     191* Removed some code 
  • strictly-autotags/trunk/strictlyautotagfuncs.php

    r629514 r689459  
    3434         
    3535        // put your IP here 
    36         if($ip == "81.110.25.86"){ 
     36        if($ip == "81.333.22.86"){ 
    3737            return true; 
    3838        }else{ 
  • strictly-autotags/trunk/strictlyautotags.class.php

    r674764 r689459  
    33/** 
    44 * Plugin Name: Strictly Auto Tags 
    5  * Version: 2.8.2 
     5 * Version: 2.8.3 
    66 * Plugin URI: http://www.strictly-software.com/plugins/strictly-auto-tags/ 
    77 * Description: This plugin automatically detects tags to place against posts using existing tags as well as a simple formula that detects common tag formats such as Acronyms, names and countries. Whereas other smart tag plugins only detect a single occurance of a tag within a post this plugin will search for the most used tags within the content so that only the most relevant tags get added. 
     
    238238    protected $skip_tagged_posts; 
    239239     
     240    /** 
     241    * Array of stored titles, src, alt, href that would cause issues with a nested link/bold tag inside it 
     242    * 
     243    * @access protected 
     244    * @var array 
     245    */ 
     246    protected $storage; 
     247 
    240248    public function __construct(){ 
    241249 
     
    275283        // set a function to run whenever posts are saved that will call our AutoTag function 
    276284        add_action('save_post'              , array(&$this, 'SaveAutoTags'),1); 
    277         //add_action('publish_post'         , array(&$this, 'SaveAutoTags'),1); 
    278         //add_action('post_syndicated_item' , array(&$this, 'SaveAutoTags'),1); 
    279  
     285         
    280286 
    281287    } 
     
    372378                if($this->boldtaggedwords || $this->taglinks){ 
    373379 
     380 
     381                    // store href/alt/src/title attributes that would cause issues with nested tags 
     382                    $newcontent = $this->StoreContent($newcontent, "STORE"); 
     383 
    374384                    ShowDebugAutoTag("call bold or deeplink tags"); 
    375385 
    376386                    if($this->boldtaggedwords){ 
    377387                        // help SEO by bolding our tags 
     388 
     389                        ShowDebugAutoTag("lets auto bold tags"); 
     390 
    378391                        $newcontent = $this->AutoBold($newcontent,$posttags); 
    379392                    } 
     
    388401                        // help SEO by deeplinking our tags 
    389402                        $newcontent = $this->AutoLink($newcontent,$posttags); 
     403 
     404                        ShowDebugAutoTag("after auto link content = $newcontent"); 
    390405                    } 
    391406 
     407                    ShowDebugAutoTag("put stored content back in"); 
     408 
     409                    $newcontent = $this->StoreContent($newcontent, "RETURN"); 
    392410 
    393411                    ShowDebugAutoTag("our new content is === " . $newcontent); 
     
    529547            ShowDebugAutoTag("lets loop through our post tags"); 
    530548 
    531             // replace 
    532             $content = str_replace("'","##Q##",$content); 
    533  
     549             
    534550            //loop and bold unless they are already inside a bold tag 
    535551            foreach($tags as $tag){ 
     
    570586 
    571587                 
    572             } 
    573  
    574         } 
    575  
    576         // replace 
    577         $content = str_replace("'","##Q##",$content); 
    578  
    579         ShowDebugAutoTag("look at how it would appear"); 
    580          
    581  
    582         ShowDebugAutoTag("return $content"); 
     588 
     589            } 
     590             
     591        } 
     592 
     593 
     594        ShowDebugAutoTag("BOLDED RETURNS $content"); 
    583595 
    584596        return $content; 
     
    644656            $lasttag = $lastslug = ""; 
    645657 
    646             // replace 
    647             $content = str_replace("'","##Q##",$content); 
    648  
     658             
    649659            //loop and bold unless they are already inside a bold tag 
    650660            foreach($this->deeplinkarray as $tag){ 
     
    674684 
    675685 
    676                     //ShowDebugAutoTag("did we already bold = " . intval($this->boldtaggedwords)); 
     686                    ShowDebugAutoTag("did we already bold = " . intval($this->boldtaggedwords)); 
    677687 
    678688                    // as this runs after auto bold if thats enabled i can just use those markers as replacements 
    679                     if($this->boldtaggedwords){ 
    680  
     689                    if($this->boldtaggedwords){                      
     690 
     691                        $link = '<a class="StrictlyAutoTagAnchor" href="' . $actualurl . ' title="' . $actualtitle . '">' . $tag->name . '</a>'; 
     692 
     693                        $regex = "@<strong class='StrictlyAutoTagBold'>" . preg_quote($tag->name) . "</strong>@i";                       
    681694                         
    682                         $link = "<a class=\"StrictlyAutoTagAnchor\" href=\"" . $actualurl . "\" title=\"" . $actualtitle . "\" >" . $tag->name . "</a>"; 
    683  
    684  
    685                         $regex = "@<strong class='StrictlyAutoTagBold'>" . preg_quote($tag->name) . "<\/strong>@"; 
    686  
    687695                        // wrap tags in anchors and keep the formatting e.g dont upper case if the tag is lowercase as it might be inside 
    688696                        // an href or src which might screw it up 
     
    691699                    }else{ 
    692700 
     701                        ShowDebugAutoTag("no bolding so just link for first time"); 
     702 
    693703                        $origcontent = $content; 
    694704 
    695705                        // instead of doing negative lookaheads and entering a world of doom match and then clean    
    696706                        // easier to do a positive match than a negative especially with nested matches 
    697                         $link = "<a class=\"StrictlyAutoTagAnchor\" href=\"" . $actualurl  . "\" title=\"" . $actualtitle . "\" >$1</a>"; 
     707 
     708                        $link = '<a class="StrictlyAutoTagAnchor" href="' . $actualurl . ' title="' . $actualtitle . '">$1</a>'; 
    698709 
    699710                         
     711                        ShowDebugAutoTag("replace " . preg_quote($tag->name) . " in content"); 
    700712 
    701713                        // wrap tags in anchors and keep the formatting e.g dont upper case if the tag is lowercase as it might be inside 
     
    703715                        $content = preg_replace("@\b(" . preg_quote($tag->name) . ")\b@",$link,$content,$this->maxtagstolink); 
    704716 
     717                        ShowDebugAutoTag("1 len is now " . strlen($content)); 
    705718 
    706719                        // remove anchor tags that have been put inside attributes e.g <a href="http://www.<a href="http://www.mysite.com/tags/MNSBC">MSNBC</a>>MSNBC</a>.com">  
     
    716729                                ,$content); 
    717730                         
    718                          
     731                        ShowDebugAutoTag("2 after nested remove len is now " . strlen($content)); 
    719732 
    720733                        // remove any anchor tags that are now in other anchors 
    721734                        $content = preg_replace("@(<(a)[^>]*>[^<]*?)(<a class=\"StrictlyAutoTagAnchor\"[^>]+?>" .  preg_quote($tag->name) . "<\/a>)(.*?<\/?\\2>)@i","$1{$tag->name}$4",$content); 
    722735 
     736                        ShowDebugAutoTag("3 after nested anchor remove len is now " . strlen($content)); 
     737 
    723738                    }                    
    724739                } 
    725740                 
    726                 // put placeholder back 
    727                 $content = str_replace("##Q##","'",$content); 
    728             } 
     741                 
     742            } 
     743 
     744            ShowDebugAutoTag("after put ##Q## placeholders back len is now " . strlen($content)); 
    729745 
    730746        } 
     
    736752    } 
    737753     
     754    protected function StoreContent($content, $dir) 
     755    { 
     756        ShowDebugAutoTag("IN StoreContent direction = $dir"); 
     757         
     758        if($dir == "STORE") 
     759        { 
     760            preg_match_all('@((?:title|src|href|alt)\s?=\s?[\'"])([\s\S]+?)([\'"])@',$content,$matches,PREG_SET_ORDER); 
     761 
     762            if($matches) 
     763            { 
     764                $x = 0; 
     765                foreach($matches as $match) 
     766                { 
     767                    $word = $match[0]; 
     768 
     769 
     770                    ShowDebugAutoTag("store match $word"); 
     771 
     772                    $this->storage[] = $word; 
     773 
     774                    $content = str_replace($word, "##M".$x."##", $content); 
     775                    $x++; 
     776                } 
     777            } 
     778 
     779            ShowDebugAutoTag($href); 
     780 
     781        }else{ 
     782             
     783            ShowDebugAutoTag("put them back in"); 
     784 
     785            if(count($this->storage) > 0) 
     786            { 
     787                ShowDebugAutoTag("we have " . count($this->storage) . " stored bits to put back"); 
     788 
     789                $x = 0; 
     790                foreach($this->storage as $match) 
     791                { 
     792                    ShowDebugAutoTag("replace match $match[0]"); 
     793 
     794                    $word = $match; 
     795                    $content = str_replace( "##M".$x."##",$word, $content); 
     796                    $x++; 
     797                } 
     798            } 
     799             
     800            ShowDebugAutoTag("after put content back"); 
     801        } 
     802 
     803        ShowDebugAutoTag("RETURN CONTENT == $content"); 
     804 
     805        return $content; 
     806    } 
     807 
    738808                 
    739809    /** 
     
    21532223 
    21542224                // make sure the noise words don't start or end with pipes 
    2155                 if( preg_match("/^([-a-z'1-9]+\|[-a-z'1-9]*)+$/",$noisewords)){  
     2225                if( preg_match("@^([-a-z'0-9 ]+\|[-a-z'0-9 ]*)+$@i",$noisewords)){ 
    21562226                    $options['noisewords']  = $noisewords; 
    21572227 
     
    21822252 
    21832253                // make sure the noise words don't start or end with pipes 
    2184                 if( preg_match("/^([-a-z'1-9 ]+\|[-a-z'1-9 ]*)+$/i",$noisewords_case_sensitive)){    
     2254                if( preg_match("@^([-a-z'0-9 ]+\|[-a-z'0-9 ]*)+$@i",$noisewords_case_sensitive)){ 
    21852255                    $options['noisewords_case_sensitive']   = $noisewords_case_sensitive; 
    21862256 
     
    25992669                    <p>'.__('If you enjoy using this Wordpress plugin you might be interested in some other websites, tools and plugins I have      developed.', 'strictlyautotags').'</p> 
    26002670                    <ul> 
    2601                         <li><a href="http://www.strictly-software.com/plugins/strictly-google-sitemap">'.__('Strictly Google Sitemap','strictlyautotags').'</a> 
    2602                             <p>'.__('Strictly Google Sitemap is a feature rich Wordpress plugin built for sites requiring high performance. Not only does it use a tiny number of database queries compared to other plugins it uses less memory and was designed specifically for under performing or low spec systems. As well as offering all the features of other sitemap plugins it brings all those missing features such as sitemap index files, XML validation, scheduled builds, configuration analysis and SEO reports.','strictlyautotags').'</p> 
     2671                        <li><a href="http://www.strictly-software.com/applications/twitter-hash-tag-hunter">'.__('Strictly Twitter Hash Tag Hunter','strictlyautotags').'</a> 
     2672                            <p>'.__('Strictly Twitter Hash Tag Hunter is a windows application that lets you find out the hash tags and followers you should be tweeting to. Used mostly with my Tweetbot it is great for new site owners to find out what hash tags people use for the search terms and keywords their site ranks for and then easily find the key Tweeters using those hash tags. With proxy and timeout features this multi threaded application is great for SEO and advertising your website.','strictlyautotags').'</p> 
    26032673                        </li> 
    26042674                        <li><a href="http://wordpress.org/extend/plugins/strictly-tweetbot/">'.__('Strictly Tweetbot','strictlyautotags').'</a> 
Note: See TracChangeset for help on using the changeset viewer.