Changeset 557158
- Timestamp:
- 06/13/2012 08:57:20 AM (14 years ago)
- Location:
- outbound-link-manager/trunk
- Files:
-
- 1 added
- 4 edited
-
links-manager-actions.php (modified) (5 diffs)
-
links-manager-manage.php (modified) (13 diffs)
-
links-manager-options.php (added)
-
links-manager.php (modified) (5 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
outbound-link-manager/trunk/links-manager-actions.php
r303980 r557158 39 39 40 40 $post = get_post($post_id); 41 preg_match_all("/(<a. *>)(.*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER);41 preg_match_all("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 42 42 43 43 $new_post = array(); … … 51 51 52 52 $post = get_post($post_id); 53 preg_match_all("/((<a)(. *>))(.*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER);53 preg_match_all("/((<a)(.[^>]*>))(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 54 54 55 55 $new_post = array(); 56 56 $new_post['ID'] = $post_id; 57 $new_post['post_content'] = str_replace($matches[$link_number][0],$matches[$link_number][2].' rel="nofollow" '.$matches[$link_number][3].$matches[$link_number][4].$matches[$link_number][5],$post->post_content); 57 $new_post['post_content'] = str_replace($matches[$link_number][0],$matches[$link_number][2].' rel="nofollow"'.$matches[$link_number][3].$matches[$link_number][4].$matches[$link_number][5],$post->post_content); 58 59 if(preg_match("/<img\s*.[^>]*src\s*=\s*[\"|\']([a-z0-9\.\-;:\/\?&=_|\r|\n]{1,})[\"|\']/isxmU",$matches[$link_number][0],$imgs)){ 60 echo($matches[$link_number][2].' rel="nofollow"'.$matches[$link_number][3].substr($imgs[1],strrpos($imgs[1],"/")+1).$matches[$link_number][5]."[links-manager-separator]".$matches[$link_number][2].' rel="nofollow"'.$matches[$link_number][3].$matches[$link_number][4].$matches[$link_number][5]); 61 }else{ 62 echo($matches[$link_number][2].' rel="nofollow"'.$matches[$link_number][3].$matches[$link_number][4].$matches[$link_number][5]."[links-manager-separator]".$matches[$link_number][2].' rel="nofollow"'.$matches[$link_number][3].$matches[$link_number][4].$matches[$link_number][5]); 63 } 64 65 $outbound_link_manager_options = get_option("outbound_link_manager_options"); 66 67 if(isset($_POST["add_to_the_list"])){ 68 $add_to_the_list = trim($_POST["add_to_the_list"]); 69 70 if(!empty($add_to_the_list)){ 71 if(is_array($outbound_link_manager_options["blacklist"])){ 72 $outbound_link_manager_options["blacklist"] = array_unique(array_merge($outbound_link_manager_options["blacklist"],array($add_to_the_list))); 73 }else{ 74 $outbound_link_manager_options["blacklist"] = array($add_to_the_list); 75 } 76 77 update_option("outbound_link_manager_options",$outbound_link_manager_options); 78 79 links_manager_check_posts_white_black_lists(); 80 } 81 }else{ 82 if(preg_match("/href\s*=\s*[\'|\"]\s*(.[^\'|\"]*)\s*[\'|\"]/i",$matches[$link_number][1],$href)){ 83 $domain = preg_replace("/^http:\/\/|https:\/\//i","",$href[1]); 84 85 $outbound_link_manager_options["ignored_list"][$post->post_name][] = $domain; 86 $outbound_link_manager_options["ignored_list"][$post->post_name] = array_unique($outbound_link_manager_options["ignored_list"][$post->post_name]); 87 88 update_option("outbound_link_manager_options",$outbound_link_manager_options); 89 } 90 } 58 91 59 92 wp_update_post($new_post); 60 61 if(preg_match("/<img\s*.*src\s*=\s*[\"|\']([a-zA-Z0-9\.\-;:\/\?&=_|\r|\n]{1,})[\"|\']/isxmU",$matches[$link_number][0],$imgs)){62 echo($matches[$link_number][2].' rel="nofollow" '.$matches[$link_number][3].substr($imgs[1],strrpos($imgs[1],"/")+1).$matches[$link_number][5]."[links-manager-separator]".$matches[$link_number][2].' rel="nofollow" '.$matches[$link_number][3].$matches[$link_number][4].$matches[$link_number][5]);63 }else{64 echo($matches[$link_number][2].' rel="nofollow" '.$matches[$link_number][3].$matches[$link_number][4].$matches[$link_number][5]."[links-manager-separator]".$matches[$link_number][2].' rel="nofollow" '.$matches[$link_number][3].$matches[$link_number][4].$matches[$link_number][5]);65 }66 93 67 94 break; … … 69 96 70 97 $post = get_post($post_id); 71 preg_match_all("/(<a. *>)(.*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER);98 preg_match_all("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 72 99 73 100 $new_post = array(); 74 101 $new_post['ID'] = $post_id; 75 $new_post['post_content'] = str_replace($matches[$link_number][0],preg_replace("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$link_number][0]),$post->post_content); 102 $new_post['post_content'] = str_replace($matches[$link_number][0],preg_replace("/\s+rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$link_number][0]),$post->post_content); 103 104 if(preg_match("/<img\s*.[^>]*src\s*=\s*[\"|\']([a-z0-9\.\-;:\/\?&=_|\r|\n]{1,})[\"|\']/isxmU",$matches[$link_number][0],$imgs)){ 105 echo(preg_replace("/\s+rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$link_number][1].substr($imgs[1],strrpos($imgs[1],"/")+1)."</a>")."[links-manager-separator]".preg_replace("/\s+rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$link_number][0])); 106 }else{ 107 echo(preg_replace("/\s+rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$link_number][0])."[links-manager-separator]".preg_replace("/\s+rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$link_number][0])); 108 } 109 110 $outbound_link_manager_options = get_option("outbound_link_manager_options"); 111 112 if(isset($_POST["add_to_the_list"])){ 113 $add_to_the_list = trim($_POST["add_to_the_list"]); 114 115 if(!empty($add_to_the_list)){ 116 if(is_array($outbound_link_manager_options["whitelist"])){ 117 $outbound_link_manager_options["whitelist"] = array_unique(array_merge($outbound_link_manager_options["whitelist"],array($add_to_the_list))); 118 }else{ 119 $outbound_link_manager_options["whitelist"] = array($add_to_the_list); 120 } 121 122 update_option("outbound_link_manager_options",$outbound_link_manager_options); 123 124 links_manager_check_posts_white_black_lists(); 125 } 126 }else{ 127 if(preg_match("/href\s*=\s*[\'|\"]\s*(.[^\'|\"]*)\s*[\'|\"]/i",$matches[$link_number][1],$href)){ 128 $domain = preg_replace("/^http:\/\/|https:\/\//i","",$href[1]); 129 130 $outbound_link_manager_options["ignored_list"][$post->post_name][] = $domain; 131 $outbound_link_manager_options["ignored_list"][$post->post_name] = array_unique($outbound_link_manager_options["ignored_list"][$post->post_name]); 132 133 update_option("outbound_link_manager_options",$outbound_link_manager_options); 134 } 135 } 76 136 77 137 wp_update_post($new_post); 78 79 if(preg_match("/<img\s*.*src\s*=\s*[\"|\']([a-zA-Z0-9\.\-;:\/\?&=_|\r|\n]{1,})[\"|\']/isxmU",$matches[$link_number][0],$imgs)){80 echo(preg_replace("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$link_number][1].substr($imgs[1],strrpos($imgs[1],"/")+1)."</a>")."[links-manager-separator]".preg_replace("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$link_number][0]));81 }else{82 echo(preg_replace("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$link_number][0])."[links-manager-separator]".preg_replace("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$link_number][0]));83 }84 138 85 139 break; … … 88 142 $edited_link = stripslashes($_POST["edited_link"]); 89 143 90 if(!preg_match("/(<a. *>)(.*)(<\/a>)/ismU",$edited_link)){144 if(!preg_match("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$edited_link)){ 91 145 echo("invalid_link"); 92 146 }else{ 93 147 $post = get_post($post_id); 94 preg_match_all("/((<a. *>))(.*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER);148 preg_match_all("/((<a.[^>]*>))(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 95 149 96 150 $new_post = array(); … … 100 154 wp_update_post($new_post); 101 155 102 if(preg_match("/<img\s*. *src\s*=\s*[\"|\']([a-zA-Z0-9\.\-;:\/\?&=_|\r|\n]{1,})[\"|\']/isxmU",$edited_link,$imgs)){156 if(preg_match("/<img\s*.[^>]*src\s*=\s*[\"|\']([a-z0-9\.\-;:\/\?&=_|\r|\n]{1,})[\"|\']/isxmU",$edited_link,$imgs)){ 103 157 $the_link = $matches[$link_number][1].substr($imgs[1],strrpos($imgs[1],"/")+1)."</a>"; 104 158 }else{ -
outbound-link-manager/trunk/links-manager-manage.php
r366142 r557158 4 4 } 5 5 6 if(isset($_POST["action"]) && !empty($_POST["links-manager-checked-links"])){ 7 $links_manager_checked_links = array(); 8 9 foreach($_POST["links-manager-checked-links"] as $checked_link){ 10 $post_id = intval(substr($checked_link,5,strpos($checked_link,"_link_number_")-5)); 11 $link_number = intval(substr($checked_link,strpos($checked_link,"_link_number_")+13)); 12 13 $links_manager_checked_links[$post_id][] = $link_number; 6 if(isset($_POST["action"])){ 7 if(!empty($_POST["links-manager-checked-links"])){ 8 $links_manager_checked_links = array(); 9 10 foreach($_POST["links-manager-checked-links"] as $checked_link){ 11 $post_id = intval(substr($checked_link,5,strpos($checked_link,"_link_number_")-5)); 12 $link_number = intval(substr($checked_link,strpos($checked_link,"_link_number_")+13)); 13 14 $links_manager_checked_links[$post_id][] = $link_number; 15 } 16 17 switch($_POST["action"]){ 18 case "remove": 19 20 foreach($links_manager_checked_links as $the_post_id => $link_numbers){ 21 $post = get_post($the_post_id); 22 preg_match_all("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 23 24 $new_post = array(); 25 $new_post['ID'] = $the_post_id; 26 $new_post['post_content'] = $post->post_content; 27 28 foreach($link_numbers as $the_link_number){ 29 $new_post['post_content'] = str_replace($matches[$the_link_number][0],$matches[$the_link_number][2],$new_post['post_content']); 30 } 31 32 wp_update_post($new_post); 33 } 34 35 break; 36 case "add_nofollow": 37 38 foreach($links_manager_checked_links as $the_post_id => $link_numbers){ 39 $post = get_post($the_post_id); 40 preg_match_all("/((<a)(.[^>]*>))(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 41 42 $new_post = array(); 43 $new_post['ID'] = $the_post_id; 44 $new_post['post_content'] = $post->post_content; 45 46 foreach($link_numbers as $the_link_number){ 47 if(!preg_match("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i",$matches[$the_link_number][1])){ 48 $new_post['post_content'] = str_replace($matches[$the_link_number][0],$matches[$the_link_number][2].' rel="nofollow"'.$matches[$the_link_number][3].$matches[$the_link_number][4].$matches[$the_link_number][5],$new_post['post_content']); 49 } 50 } 51 52 wp_update_post($new_post); 53 } 54 55 break; 56 case "remove_nofollow": 57 58 foreach($links_manager_checked_links as $the_post_id => $link_numbers){ 59 $post = get_post($the_post_id); 60 preg_match_all("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 61 62 $new_post = array(); 63 $new_post['ID'] = $the_post_id; 64 $new_post['post_content'] = $post->post_content; 65 66 foreach($link_numbers as $the_link_number){ 67 if(preg_match("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i",$matches[$the_link_number][0])){ 68 $new_post['post_content'] = str_replace($matches[$the_link_number][0],preg_replace("/\s+rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$the_link_number][0]),$new_post['post_content']); 69 } 70 } 71 72 wp_update_post($new_post); 73 } 74 75 break; 76 case "save": 77 78 foreach($links_manager_checked_links as $the_post_id => $link_numbers){ 79 $post = get_post($the_post_id); 80 preg_match_all("/((<a.[^>]*>))(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 81 82 $new_post = array(); 83 $new_post['ID'] = $the_post_id; 84 $new_post['post_content'] = $post->post_content; 85 86 foreach($link_numbers as $the_link_number){ 87 $edited_link = stripslashes($_POST["post_".$the_post_id."_link_number_".$the_link_number."_edited_link"]); 88 89 if(preg_match("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$edited_link)){ 90 $new_post['post_content'] = str_replace($matches[$the_link_number][0],$edited_link,$new_post['post_content']); 91 } 92 } 93 94 wp_update_post($new_post); 95 } 96 97 break; 98 } 14 99 } 15 100 16 switch($_POST["action"]){ 17 case "remove": 18 19 foreach($links_manager_checked_links as $the_post_id => $link_numbers){ 20 $post = get_post($the_post_id); 21 preg_match_all("/(<a.*>)(.*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 22 23 $new_post = array(); 24 $new_post['ID'] = $the_post_id; 25 $new_post['post_content'] = $post->post_content; 26 27 foreach($link_numbers as $the_link_number){ 28 $new_post['post_content'] = str_replace($matches[$the_link_number][0],$matches[$the_link_number][2],$new_post['post_content']); 29 } 30 31 wp_update_post($new_post); 101 if(isset($_POST["posts"]) && !empty($_POST["posts"])){ 102 switch($_POST["action"]){ 103 case "ignore": 104 105 $ignored_posts = get_option("olm_ignored_posts"); 106 107 if(!empty($ignored_posts)){ 108 $ignored_posts = array_unique(array_merge($ignored_posts,$_POST["posts"])); 109 }else{ 110 $ignored_posts = $_POST["posts"]; 111 } 112 113 update_option("olm_ignored_posts",$ignored_posts); 114 115 break; 116 case "remove_ignored": 117 118 $ignored_posts = get_option("olm_ignored_posts"); 119 120 $ignored_posts = array_diff($ignored_posts,$_POST["posts"]); 121 122 update_option("olm_ignored_posts",$ignored_posts); 123 124 break; 125 case "remove": 126 127 foreach($_POST["posts"] as $post_id){ 128 $post = get_post($post_id); 129 preg_match_all("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 130 131 $new_post = array(); 132 $new_post['ID'] = $post_id; 133 $new_post['post_content'] = $post->post_content; 134 135 foreach($matches as $match){ 136 $new_post['post_content'] = str_replace($match[0],$match[2],$new_post['post_content']); 137 } 138 139 wp_update_post($new_post); 140 } 141 142 break; 143 case "add_nofollow": 144 145 foreach($_POST["posts"] as $post_id){ 146 $post = get_post($post_id); 147 preg_match_all("/((<a)(.[^>]*>))(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 148 149 $new_post = array(); 150 $new_post['ID'] = $post_id; 151 $new_post['post_content'] = $post->post_content; 152 153 foreach($matches as $match){ 154 if(!preg_match("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i",$match[1])){ 155 $new_post['post_content'] = str_replace($match[0],$match[2].' rel="nofollow"'.$match[3].$match[4].$match[5],$new_post['post_content']); 156 } 157 } 158 159 wp_update_post($new_post); 160 } 161 162 break; 163 case "remove_nofollow": 164 165 foreach($_POST["posts"] as $post_id){ 166 $post = get_post($post_id); 167 preg_match_all("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 168 169 $new_post = array(); 170 $new_post['ID'] = $post_id; 171 $new_post['post_content'] = $post->post_content; 172 173 foreach($matches as $match){ 174 if(preg_match("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i",$match[0])){ 175 $new_post['post_content'] = str_replace($match[0],preg_replace("/\s+rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$match[0]),$new_post['post_content']); 176 } 177 } 178 179 wp_update_post($new_post); 180 } 181 182 break; 183 case "save": 184 185 foreach($_POST["posts"] as $post_id){ 186 $post = get_post($post_id); 187 preg_match_all("/((<a.[^>]*>))(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 188 189 $new_post = array(); 190 $new_post['ID'] = $post_id; 191 $new_post['post_content'] = $post->post_content; 192 193 $the_link_number = 0; 194 195 foreach($matches as $match){ 196 if(!isset($_POST["post_".$post_id."_link_number_".$the_link_number."_edited_link"])){ 197 $the_link_number++; 198 199 continue; 200 } 201 202 $edited_link = stripslashes($_POST["post_".$post_id."_link_number_".$the_link_number."_edited_link"]); 203 204 if(preg_match("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$edited_link)){ 205 $new_post['post_content'] = str_replace($match[0],$edited_link,$new_post['post_content']); 206 } 207 208 $the_link_number++; 209 } 210 211 wp_update_post($new_post); 212 } 213 214 break; 215 32 216 } 33 34 break;35 case "add_nofollow":36 37 foreach($links_manager_checked_links as $the_post_id => $link_numbers){38 $post = get_post($the_post_id);39 preg_match_all("/((<a)(.*>))(.*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER);40 41 $new_post = array();42 $new_post['ID'] = $the_post_id;43 $new_post['post_content'] = $post->post_content;44 45 foreach($link_numbers as $the_link_number){46 if(!preg_match("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i",$matches[$the_link_number][1])){47 $new_post['post_content'] = str_replace($matches[$the_link_number][0],$matches[$the_link_number][2].' rel="nofollow" '.$matches[$the_link_number][3].$matches[$the_link_number][4].$matches[$the_link_number][5],$new_post['post_content']);48 }49 }50 51 wp_update_post($new_post);52 }53 54 break;55 case "remove_nofollow":56 57 foreach($links_manager_checked_links as $the_post_id => $link_numbers){58 $post = get_post($the_post_id);59 preg_match_all("/(<a.*>)(.*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER);60 61 $new_post = array();62 $new_post['ID'] = $the_post_id;63 $new_post['post_content'] = $post->post_content;64 65 foreach($link_numbers as $the_link_number){66 if(preg_match("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i",$matches[$the_link_number][0])){67 $new_post['post_content'] = str_replace($matches[$the_link_number][0],preg_replace("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i","",$matches[$the_link_number][0]),$new_post['post_content']);68 }69 }70 71 wp_update_post($new_post);72 }73 74 break;75 case "save":76 77 foreach($links_manager_checked_links as $the_post_id => $link_numbers){78 $post = get_post($the_post_id);79 preg_match_all("/((<a.*>))(.*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER);80 81 $new_post = array();82 $new_post['ID'] = $the_post_id;83 $new_post['post_content'] = $post->post_content;84 85 foreach($link_numbers as $the_link_number){86 $edited_link = stripslashes($_POST["post_".$the_post_id."_link_number_".$the_link_number."_edited_link"]);87 88 if(preg_match("/(<a.*>)(.*)(<\/a>)/ismU",$edited_link)){89 $new_post['post_content'] = str_replace($matches[$the_link_number][0],$edited_link,$new_post['post_content']);90 }91 }92 93 wp_update_post($new_post);94 }95 96 break;97 217 } 218 98 219 } 99 220 ?> … … 164 285 request = new XMLHttpRequest(); 165 286 params = "action=add_nofollow&post_id="+post_id+"&link_number="+link_number+"&removed_links="+document.getElementById("links_manager_post_"+post_id+"_removed_links").innerHTML; 287 288 var blacklist_website = jQuery("#post_"+post_id+"_link_number_"+link_number+"_link_div a").attr("href").replace(/^http:\/\/|https:\/\//i, ""); 289 290 if(confirm("Would you like to add "+blacklist_website+" to the blacklist?")){ 291 params += "&add_to_the_list="+blacklist_website; 292 } 293 166 294 request.open("POST", "<?php echo($links_manager_plugin_url); ?>links-manager-actions.php", true); 167 295 request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); … … 205 333 request = new XMLHttpRequest(); 206 334 params = "action=remove_nofollow&post_id="+post_id+"&link_number="+link_number+"&removed_links="+document.getElementById("links_manager_post_"+post_id+"_removed_links").innerHTML; 335 336 var whitelist_website = jQuery("#post_"+post_id+"_link_number_"+link_number+"_link_div a").attr("href").replace(/^http:\/\/|https:\/\//i, ""); 337 338 if(confirm("Would you like to add "+whitelist_website+" to the whitelist?")){ 339 params += "&add_to_the_list="+whitelist_website; 340 } 341 207 342 request.open("POST", "<?php echo($links_manager_plugin_url); ?>links-manager-actions.php", true); 208 343 request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); … … 302 437 </script> 303 438 <br /> 439 <?php 440 $show_ignored = false; 441 $ignored_posts = array(); 442 443 if(isset($_REQUEST["show_ignored"]) && $_REQUEST["show_ignored"]=="yes"){ 444 $show_ignored = true; 445 }else{ 446 $ignored_posts = get_option("olm_ignored_posts"); 447 448 if($ignored_posts===false){ 449 $ignored_posts = array(); 450 } 451 } 452 453 switch($_REQUEST["sel_links_type"]){ 454 case "all": 455 $meta_query = array("relation"=>"OR",array("key"=>"_outbound_link_exist","value"=>"yes"),array("key"=>"_internal_link_exist","value"=>"yes")); 456 $sel_links_type = "all"; 457 break; 458 case "internal": 459 $meta_query = array(array("key"=>"_internal_link_exist","value"=>"yes")); 460 $sel_links_type = "internal"; 461 break; 462 default: 463 $meta_query = array(array("key"=>"_outbound_link_exist","value"=>"yes")); 464 $sel_links_type = "outbound"; 465 } 466 ?> 304 467 <form action="admin.php?page=outbound-link-manager/links-manager-manage.php" method="post"> 305 468 <div> … … 308 471 <option value="pages"<?php if($_REQUEST["sel_posts_type"]=="pages"){ echo(' selected="selected"'); }; ?>>Pages</option> 309 472 </select> 473 <select name="sel_links_type"> 474 <option value="all"<?php if($_REQUEST["sel_links_type"]=="all"){ echo(' selected="selected"'); }; ?>>All Links</option> 475 <option value="outbound"<?php if(!isset($_REQUEST["sel_links_type"]) || $_REQUEST["sel_links_type"]=="outbound"){ echo(' selected="selected"'); }; ?>>Outbound Links</option> 476 <option value="internal"<?php if($_REQUEST["sel_links_type"]=="internal"){ echo(' selected="selected"'); }; ?>>Internal Links</option> 477 </select> 478 <label style="margin: 0 15px;">Show ignored <input type="checkbox" name="show_ignored" value="yes" <?php if($show_ignored){ echo('checked="checked"'); } ?> /></label> 310 479 <input type="submit" value="Apply" name="showtype" id="showtype" class="button-secondary action" /> 311 480 </div> 312 </form> 313 <br /> 314 <form action="admin.php?page=outbound-link-manager/links-manager-manage.php" method="post"> 481 <br /> 315 482 <?php 316 483 $numberposts = 10; … … 335 502 <option value="add_nofollow">Add NoFollow</option> 336 503 <option value="remove_nofollow">Remove NoFollow</option> 504 <option value="ignore">Ignore Pages</option> 505 <?php if($show_ignored){ ?><option value="remove_ignored">Remove Ignored From Pages</option><?php } ?> 337 506 </select> 338 <input type="hidden" name="sel_posts_type" value="pages" />339 507 <input type="submit" value="Apply" name="doaction" id="doaction" class="button-secondary action" /> 340 508 </div> 341 509 <?php 342 $posts = get_pages('meta_key=_outbound_link_exist&meta_value=yes&number='.$numberposts.'&offset='.$offset); 343 344 $all_posts = get_pages('meta_key=_outbound_link_exist&meta_value=yes'); 510 $args = 511 $posts = get_posts(array("meta_query"=>$meta_query,"post_type"=>"page","numberposts"=>$numberposts,"offset"=>$offset,"post__not_in"=>$ignored_posts)); 512 513 $all_posts = get_posts(array("meta_query"=>$meta_query,"post_type"=>"page","numberposts"=>-1,"post__not_in"=>$ignored_posts)); 345 514 break; 346 515 default: … … 392 561 } 393 562 394 $posts = get_posts( 'cat='.$cat.'&m='.$m.'&meta_key=_outbound_link_exist&meta_value=yes&numberposts='.$numberposts.'&offset='.$offset);395 396 $all_posts = get_posts( 'cat='.$cat.'&m='.$m.'&meta_key=_outbound_link_exist&meta_value=yes&numberposts=-1');563 $posts = get_posts(array("cat"=>$cat,"m"=>$m,"meta_query"=>$meta_query,"numberposts"=>$numberposts,"offset"=>$offset,"post__not_in"=>$ignored_posts)); 564 565 $all_posts = get_posts(array("cat"=>$cat,"m"=>$m,"meta_query"=>$meta_query,"numberposts"=>-1,"post__not_in"=>$ignored_posts)); 397 566 ?> 398 567 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" /> … … 404 573 <option value="add_nofollow">Add NoFollow</option> 405 574 <option value="remove_nofollow">Remove NoFollow</option> 575 <option value="ignore">Ignore Posts</option> 576 <?php if($show_ignored){ ?><option value="remove_ignored">Remove Ignored From Posts</option><?php } ?> 406 577 </select> 407 578 <input type="submit" value="Apply" name="doaction" id="doaction" class="button-secondary action" /> … … 410 581 } 411 582 ?> 412 <table class="widefat fixed" cellspacing="0" style="margin-top: 10px"> 583 <br /><br /> 584 <table class="widefat fixed" cellspacing="0"> 413 585 <thead> 414 586 <tr> 587 <th scope="col" id="cb" class="check-column" style=""><input type="checkbox" /></th> 415 588 <th scope="col" style="width: 15%">Post</th> 416 589 <?php … … 435 608 <tfoot> 436 609 <tr> 610 <th scope="col" class="check-column"><input type="checkbox" /></th> 437 611 <th scope="col">Post</th> 438 612 <th scope="col">Author</th> … … 453 627 <?php 454 628 foreach($posts as $post){ 455 !preg_match_all("/(<a. *>)(.*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER);629 !preg_match_all("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER); 456 630 457 631 foreach($matches as $key => $value){ 458 632 preg_match("/href\s*=\s*[\'|\"]\s*([^\"|\']*)\s*[\'|\"]/i",$value[1],$href); 459 633 460 if((substr($href[1],0,7)!="http://" && substr($href[1],0,8)!="https://") || substr($href[1],0,strlen(get_bloginfo("url")))==get_bloginfo("url")){ 461 unset($matches[$key]); 634 if($sel_links_type!="all"){ 635 if((substr($href[1],0,7)!="http://" && substr($href[1],0,8)!="https://") || substr($href[1],0,strlen(get_bloginfo("url")))==get_bloginfo("url")){ 636 if($sel_links_type=="outbound"){ 637 unset($matches[$key]); 638 } 639 }else{ 640 if($sel_links_type=="internal"){ 641 unset($matches[$key]); 642 } 643 } 462 644 } 463 645 } 464 646 ?> 465 647 <tr class='alternate' valign="top"> 648 <td align="center" scope="row" class="check-column" style="vertical-align: middle; padding: 0px;"><input type="checkbox" name="posts[]" value="<?php echo($post->ID); ?>" /></td> 466 649 <td> 467 650 <div> … … 526 709 foreach($matches as $link_number => $match){ 527 710 ?> 528 <div id="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>_link_div"><div style="display: inline;"><input type="checkbox" name="links-manager-checked-links[]" value="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>" /></div> <div id="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>_link" style="display: inline"><div id="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>_the_link" style="display: inline"><?php if(preg_match("/<img\s*. *src\s*=\s*[\"|\']([a-zA-Z0-9\.\-;:\/\?&=_|\r|\n]{1,})[\"|\']/isxmU",$match[0],$imgs)){ echo($match[1].substr($imgs[1],strrpos($imgs[1],"/")+1)."</a>"); }else{ echo($match[0]); } ?></div><?php if(preg_match("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i",$match[1])){ echo(' <span style="font-size: 10px; color: #999999">nofollow</span>'); }else{ echo(' <span style="font-size: 10px; color: #999999">follow</span>'); } ?></div><div id="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>_the_full_link" style="display: none"><?php echo($match[0]); ?></div><div id="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>_displaying_link_content" style="display: none"><?php if(preg_match("/<img\s*.*src\s*=\s*[\"|\']([a-zA-Z0-9\.\-;:\/\?&=_|\r|\n]{1,})[\"|\']/isxmU",$match[2],$imgs)){ echo(substr($imgs[1],strrpos($imgs[1],"/")+1)); }else{ echo($match[2]); } ?></div></div>711 <div id="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>_link_div"><div style="display: inline;"><input type="checkbox" name="links-manager-checked-links[]" value="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>" /></div> <div id="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>_link" style="display: inline"><div id="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>_the_link" style="display: inline"><?php if(preg_match("/<img\s*.[^>]*src\s*=\s*[\"|\']([a-z0-9\.\-;:\/\?&=_|\r|\n]{1,})[\"|\']/isxmU",$match[0],$imgs)){ echo($match[1].substr($imgs[1],strrpos($imgs[1],"/")+1)."</a>"); }else{ echo($match[0]); } ?></div><?php if(preg_match("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i",$match[1])){ echo(' <span style="font-size: 10px; color: #999999">nofollow</span>'); }else{ echo(' <span style="font-size: 10px; color: #999999">follow</span>'); } ?></div><div id="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>_the_full_link" style="display: none"><?php echo($match[0]); ?></div><div id="post_<?php echo($post->ID); ?>_link_number_<?php echo($link_number); ?>_displaying_link_content" style="display: none"><?php if(preg_match("/<img\s*.[^>]*src\s*=\s*[\"|\']([a-z0-9\.\-;:\/\?&=_|\r|\n]{1,})[\"|\']/isxmU",$match[2],$imgs)){ echo(substr($imgs[1],strrpos($imgs[1],"/")+1)); }else{ echo($match[2]); } ?></div></div> 529 712 <?php 530 713 } … … 564 747 $vars_query = ""; 565 748 $vars_query .= (isset($sel_posts_type) && $sel_posts_type!="") ? "&sel_posts_type=".$sel_posts_type : ""; 749 $vars_query .= (isset($sel_links_type) && $sel_links_type!="") ? "&sel_links_type=".$sel_links_type : ""; 750 $vars_query .= ($show_ignored) ? "&show_ignored=yes" : ""; 566 751 $vars_query .= (isset($cat) && $cat!="") ? "&cat=".$cat : ""; 567 752 $vars_query .= (isset($m) && $m!="") ? "&m=".$m : ""; -
outbound-link-manager/trunk/links-manager.php
r366149 r557158 4 4 Plugin URI: http://www.searchmatters.com.au/wp-plugins/outbound-link-manager/ 5 5 Description: The Outbound Link Manager monitors outbound links in your posts and pages, easily allowing you to add or remove a nofollow tag, update anchor texts, or remove links altogether. 6 Version: 1. 116 Version: 1.2 7 7 Author: Morris Bryant, Ruben Sargsyan 8 8 Author URI: http://www.searchmatters.com.au … … 31 31 32 32 function links_manager_menu(){ 33 if(function_exists( "add_menu_page")){34 add_menu_page(__("Manage", "links-manager"), __("Links Manager", "links-manager"), "manage_options", "outbound-link-manager/links-manager-manage.php");33 if(function_exists('add_menu_page')){ 34 add_menu_page("Manage", "Links Manager", "manage_options", "outbound-link-manager/links-manager-manage.php"); 35 35 } 36 if(function_exists('add_submenu_page')){ 37 add_submenu_page('outbound-link-manager/links-manager-manage.php', 'Manage', 'Manage', 'manage_options', 'outbound-link-manager/links-manager-manage.php'); 38 add_submenu_page('outbound-link-manager/links-manager-manage.php', 'Options', 'Options', 'manage_options', 'outbound-link-manager/links-manager-options.php'); 39 } 36 40 } 37 41 38 42 function links_manager_scan_posts(){ 39 $posts = get_posts( 'numberposts=-1');43 $posts = get_posts(array("post_type"=>array("post","page"),"numberposts"=>-1)); 40 44 41 45 foreach($posts as $post){ 42 if(!preg_match_all("/(<a .*>)(.*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER)){46 if(!preg_match_all("/(<a(.[^>]*)>)(.[^<]*)(<\/a>)/ismU",$post->post_content,$matches,PREG_SET_ORDER)){ 43 47 continue; 44 48 } 45 49 46 foreach($matches as $key => $value){ 47 preg_match("/href\s*=\s*[\'|\"]\s*(.*)\s*[\'|\"]/i",$value[1],$href); 48 49 if((substr($href[1],0,7)!="http://" && substr($href[1],0,8)!="https://") || substr($href[1],0,strlen(get_bloginfo("url")))==get_bloginfo("url")){ 50 unset($matches[$key]); 51 } 52 } 53 54 if(empty($matches)){ 55 continue; 56 } 57 58 add_post_meta($post->ID, "_outbound_link_exist", "yes", true); 59 } 60 } 61 62 function links_manager_scan_pages(){ 63 $pages = get_pages(); 64 65 foreach($pages as $page){ 66 if(!preg_match_all("/(<a.*>)(.*)(<\/a>)/ismU",$page->post_content,$matches,PREG_SET_ORDER)){ 67 continue; 68 } 69 70 foreach($matches as $key => $value){ 71 preg_match("/href\s*=\s*[\'|\"]\s*(.*)\s*[\'|\"]/i",$value[1],$href); 72 73 if((substr($href[1],0,7)!="http://" && substr($href[1],0,8)!="https://") || substr($href[1],0,strlen(get_bloginfo("url")))==get_bloginfo("url")){ 74 unset($matches[$key]); 75 } 76 } 77 78 if(empty($matches)){ 79 continue; 80 } 81 82 add_post_meta($post->ID, "_outbound_link_exist", "yes", true); 50 $does_outbound_link_exist = false; 51 $does_internal_link_exist = false; 52 53 foreach($matches as $key => $value){ 54 preg_match("/href\s*=\s*[\'|\"]\s*(.[^\'|\"]*)\s*[\'|\"]/i",$value[1],$href); 55 56 if((substr($href[1],0,7)!="http://" && substr($href[1],0,8)!="https://") || substr($href[1],0,strlen(get_bloginfo("url")))==get_bloginfo("url")){ 57 $does_internal_link_exist = true; 58 }else{ 59 $does_outbound_link_exist = true; 60 } 61 } 62 63 if($does_outbound_link_exist){ 64 add_post_meta($post->ID, "_outbound_link_exist", "yes", true); 65 } 66 67 if($does_internal_link_exist){ 68 add_post_meta($post->ID, "_internal_link_exist", "yes", true); 69 } 83 70 } 84 71 } … … 89 76 foreach($posts as $post){ 90 77 delete_post_meta($post->ID, "_outbound_link_exist"); 78 delete_post_meta($post->ID, "_internal_link_exist"); 91 79 } 92 80 … … 95 83 foreach($pages as $page){ 96 84 delete_post_meta($page->ID, "_outbound_link_exist"); 97 } 85 delete_post_meta($page->ID, "_internal_link_exist"); 86 } 87 } 88 89 function links_manager_check_posts_white_black_lists(){ 90 $meta_query = array("relation"=>"OR",array("key"=>"_outbound_link_exist","value"=>"yes"),array("key"=>"_internal_link_exist","value"=>"yes")); 91 92 $posts = get_posts(array("meta_query"=>$meta_query,"post_type"=>array("post","page"),"numberposts"=>-1)); 93 94 foreach($posts as $post){ 95 wp_update_post($post); 96 } 97 } 98 99 function links_manager_check_post_white_black_lists($post){ 100 $post["post_content"] = stripslashes($post["post_content"]); 101 102 $outbound_link_manager_options = get_option("outbound_link_manager_options"); 103 104 $whitelist_websites = array(); 105 106 if(isset($outbound_link_manager_options["whitelist"])){ 107 $whitelist_websites = $outbound_link_manager_options["whitelist"]; 108 } 109 110 $blacklist_websites = array(); 111 112 if(isset($outbound_link_manager_options["blacklist"])){ 113 $blacklist_websites = $outbound_link_manager_options["blacklist"]; 114 } 115 116 $ignored_list = array(); 117 118 if(isset($outbound_link_manager_options["ignored_list"])){ 119 $ignored_list = $outbound_link_manager_options["ignored_list"]; 120 } 121 122 if(preg_match_all("/(<a(.[^>]*)>)(.[^<]*)(<\/a>)/ismU",$post["post_content"],$matches,PREG_SET_ORDER)){ 123 foreach($matches as $key => $value){ 124 preg_match("/href\s*=\s*[\'|\"]\s*(.[^\'|\"]*)\s*[\'|\"]/i",$value[1],$href); 125 126 if(isset($ignored_list[$post["post_name"]]) && in_array(preg_replace("/^http(s*):\/\//i","",$href[1]),$ignored_list[$post["post_name"]])){ 127 continue; 128 } 129 130 if((substr($href[1],0,7)!="http://" && substr($href[1],0,8)!="https://") || substr($href[1],0,strlen(get_bloginfo("url")))==get_bloginfo("url")){ 131 continue; 132 } 133 134 if(!empty($whitelist_websites)){ 135 $whitelist_websites_pattern = array(); 136 137 foreach($whitelist_websites as $whitelist_website){ 138 $whitelist_websites_pattern[] = "(^http(s*):\/\/".str_replace("/","\/",$whitelist_website).")"; 139 } 140 141 if(!preg_match("/".implode("|",$whitelist_websites_pattern)."/ismU",$href[1])){ 142 if(!isset($outbound_link_manager_options["whitelist_action"]) || $outbound_link_manager_options["whitelist_action"]=="add_nofollow"){ 143 if(!preg_match("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i",$value[0])){ 144 $post["post_content"] = str_replace($value[0],preg_replace('/<a/i','$0'.' rel="nofollow"',$value[0]),$post["post_content"]); 145 } 146 }else{ 147 $post["post_content"] = str_replace($value[0],$value[3],$post["post_content"]); 148 } 149 } 150 } 151 152 if(!empty($blacklist_websites)){ 153 foreach($blacklist_websites as $blacklist_website){ 154 if(preg_match("/^http(s*):\/\/".str_replace("/","\/",$blacklist_website)."/ismU",$href[1])){ 155 if(!isset($outbound_link_manager_options["blacklist_action"]) || $outbound_link_manager_options["blacklist_action"]=="add_nofollow"){ 156 if(!preg_match("/rel\s*=\s*[\'|\"]\s*nofollow\s*[\'|\"]/i",$value[0])){ 157 $post["post_content"] = str_replace($value[0],preg_replace('/<a/i','$0'.' rel="nofollow"',$value[0]),$post["post_content"]); 158 } 159 }else{ 160 $post["post_content"] = str_replace($value[0],$value[3],$post["post_content"]); 161 } 162 } 163 } 164 } 165 } 166 } 167 168 return $post; 98 169 } 99 170 100 171 function links_manager_scan_post($post){ 101 172 $the_post = get_post($post); 102 $outbound_link_exist = true; 103 104 if(!preg_match_all("/(<a.*>)(.*)(<\/a>)/ismU",$the_post->post_content,$matches,PREG_SET_ORDER)){ 105 $outbound_link_exist = false; 106 }else{ 107 foreach($matches as $key => $value){ 108 preg_match("/href\s*=\s*[\'|\"]\s*(.*)\s*[\'|\"]/i",$value[1],$href); 109 110 if((substr($href[1],0,7)!="http://" && substr($href[1],0,8)!="https://") || substr($href[1],0,strlen(get_bloginfo("url")))==get_bloginfo("url")){ 111 unset($matches[$key]); 112 } 113 } 114 115 if(empty($matches)){ 116 $outbound_link_exist = false; 117 } 118 } 119 120 if($outbound_link_exist){ 173 $does_outbound_link_exist = false; 174 $does_internal_link_exist = false; 175 176 if(preg_match_all("/(<a(.[^>]*)>)(.[^<]*)(<\/a>)/ismU",$the_post->post_content,$matches,PREG_SET_ORDER)){ 177 foreach($matches as $key => $value){ 178 preg_match("/href\s*=\s*[\'|\"]\s*(.[^\'|\"]*)\s*[\'|\"]/i",$value[1],$href); 179 180 if((substr($href[1],0,7)!="http://" && substr($href[1],0,8)!="https://") || substr($href[1],0,strlen(get_bloginfo("url")))==get_bloginfo("url")){ 181 $does_internal_link_exist = true; 182 }else{ 183 $does_outbound_link_exist = true; 184 } 185 } 186 } 187 188 if($does_outbound_link_exist){ 121 189 add_post_meta($the_post->ID, "_outbound_link_exist", "yes", true); 122 190 }else{ 123 191 delete_post_meta($the_post->ID, "_outbound_link_exist"); 192 } 193 194 if($does_internal_link_exist){ 195 add_post_meta($the_post->ID, "_internal_link_exist", "yes", true); 196 }else{ 197 delete_post_meta($the_post->ID, "_internal_link_exist"); 124 198 } 125 199 } … … 127 201 function links_manager_scan_page($page){ 128 202 $the_page = get_page($page); 129 $outbound_link_exist = true; 130 131 if(!preg_match_all("/(<a.*>)(.*)(<\/a>)/ismU",$the_page->post_content,$matches,PREG_SET_ORDER)){ 132 $outbound_link_exist = false; 133 }else{ 134 foreach($matches as $key => $value){ 135 preg_match("/href\s*=\s*[\'|\"]\s*(.*)\s*[\'|\"]/i",$value[1],$href); 136 137 if((substr($href[1],0,7)!="http://" && substr($href[1],0,8)!="https://") || substr($href[1],0,strlen(get_bloginfo("url")))==get_bloginfo("url")){ 138 unset($matches[$key]); 139 } 140 } 141 142 if(empty($matches)){ 143 $outbound_link_exist = false; 144 } 145 } 146 147 if($outbound_link_exist){ 203 204 $does_outbound_link_exist = false; 205 $does_internal_link_exist = false; 206 207 if(preg_match_all("/(<a(.[^>]*)>)(.[^<]*)(<\/a>)/ismU",$the_page->post_content,$matches,PREG_SET_ORDER)){ 208 foreach($matches as $key => $value){ 209 preg_match("/href\s*=\s*[\'|\"]\s*(.[^\'|\"]*)\s*[\'|\"]/i",$value[1],$href); 210 211 if((substr($href[1],0,7)!="http://" && substr($href[1],0,8)!="https://") || substr($href[1],0,strlen(get_bloginfo("url")))==get_bloginfo("url")){ 212 $does_internal_link_exist = true; 213 }else{ 214 $does_outbound_link_exist = true; 215 } 216 } 217 } 218 219 if($does_outbound_link_exist){ 148 220 add_post_meta($the_page->ID, "_outbound_link_exist", "yes", true); 149 221 }else{ 150 222 delete_post_meta($the_page->ID, "_outbound_link_exist"); 151 223 } 152 } 153 224 225 if($does_internal_link_exist){ 226 add_post_meta($the_page->ID, "_internal_link_exist", "yes", true); 227 }else{ 228 delete_post_meta($the_page->ID, "_internal_link_exist"); 229 } 230 } 231 232 wp_enqueue_script("jquery"); 154 233 add_action("admin_menu", "links_manager_menu"); 155 234 register_activation_hook(__FILE__, "links_manager_scan_posts"); 156 register_activation_hook(__FILE__, "links_manager_scan_pages");157 235 register_deactivation_hook(__FILE__, "links_manager_delete_meta_keys"); 158 add_action('publish_post','links_manager_scan_post'); 159 add_action('edit_post','links_manager_scan_post'); 160 add_action('publish_page','links_manager_scan_page'); 161 add_action('edit_page_form','links_manager_scan_page'); 236 add_filter("wp_insert_post_data","links_manager_check_post_white_black_lists",99); 237 add_action("publish_post","links_manager_scan_post"); 238 add_action("edit_post","links_manager_scan_post"); 239 add_action("publish_page","links_manager_scan_page"); 240 add_action("edit_page_form","links_manager_scan_page"); 162 241 ?> -
outbound-link-manager/trunk/readme.txt
r366149 r557158 11 11 The Outbound Link Manager monitors outbound links in your posts and pages, easily allowing you to add or remove a nofollow tag, update anchor texts, or remove links altogether. 12 12 13 The whitelist + blacklist functions mean you can also set rules around when a nofollow tag should be added. 14 13 15 = Here's what you can do: = 14 16 15 17 1. Remove links. The original anchor text is kept in tact. 16 18 1. Add or remove the NoFollow tag. 17 1. Achieve the above in bulk by selecting numerous posts .19 1. Achieve the above in bulk by selecting numerous posts/pages or links. 18 20 1. Edit links. This gives you instant access to the whole link code, allowing you to add styles, targets or change the anchor text. 21 1. Add domains to the whitelist: all other links will be removed or nofollow will be added. 22 1. Add domains to the blacklist: all links to these domains will be removed or nofollowed, other links will not change. 23 1. Ignore posts/pages so that they won't show up in the link list again. You can remove these from the ignore list through the options page. 19 24 20 25 This plugin is aimed at SEO managers who would like to monitor external links. It is also helpful to monitor external links if you are outsourcing your content creation. 21 26 22 Read more about the [Outbound Link Manager](http://www.searchmatters.com.au/wp-plugins/outbound-link-manager.php).27 Send your questions or feature requests to Morris Bryant and Ruben Sargsyan at [Sparro](http://sparro.com.au). We can complete any custom plugin project. 23 28 24 29 == Screenshots == … … 35 40 == Frequently Asked Questions == 36 41 37 Send your questions to Morris Bryant and Ruben Sargsyan at [S earch Matters](http://www.searchmatters.com.au).42 Send your questions to Morris Bryant and Ruben Sargsyan at [Sparro](http://sparro.com.au). 38 43 39 44 == Changelog == … … 45 50 * The Outbound Link Manager now also scans pages. 46 51 * Some bulk editing bugs were fixed. 52 53 = 1.20 = 54 * Blacklist / whitelist functions added. 55 * Ignore function added. 56 * Some bugs resolved. 57 * Additional bulk options.
Note: See TracChangeset
for help on using the changeset viewer.