Plugin Directory

Changeset 557158


Ignore:
Timestamp:
06/13/2012 08:57:20 AM (14 years ago)
Author:
s_ruben
Message:
 
Location:
outbound-link-manager/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • outbound-link-manager/trunk/links-manager-actions.php

    r303980 r557158  
    3939
    4040    $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);
    4242
    4343    $new_post = array();
     
    5151
    5252    $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);
    5454
    5555    $new_post = array();
    5656    $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    }
    5891
    5992    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     }
    6693
    6794    break;
     
    6996
    7097    $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);
    7299
    73100    $new_post = array();
    74101    $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    }
    76136
    77137    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     }
    84138
    85139    break;
     
    88142    $edited_link = stripslashes($_POST["edited_link"]);
    89143
    90     if(!preg_match("/(<a.*>)(.*)(<\/a>)/ismU",$edited_link)){
     144    if(!preg_match("/(<a.[^>]*>)(.[^<]*)(<\/a>)/ismU",$edited_link)){
    91145        echo("invalid_link");
    92146    }else{
    93147        $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);
    95149
    96150        $new_post = array();
     
    100154        wp_update_post($new_post);
    101155
    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)){
    103157            $the_link = $matches[$link_number][1].substr($imgs[1],strrpos($imgs[1],"/")+1)."</a>";
    104158        }else{
  • outbound-link-manager/trunk/links-manager-manage.php

    r366142 r557158  
    44    }
    55
    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            }
    1499        }
    15100
    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
    32216            }
    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;
    97217        }
     218
    98219    }
    99220    ?>
     
    164285              request = new XMLHttpRequest();
    165286              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
    166294              request.open("POST", "<?php echo($links_manager_plugin_url); ?>links-manager-actions.php", true);
    167295              request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     
    205333              request = new XMLHttpRequest();
    206334              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
    207342              request.open("POST", "<?php echo($links_manager_plugin_url); ?>links-manager-actions.php", true);
    208343              request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     
    302437      </script>
    303438      <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      ?>
    304467      <form action="admin.php?page=outbound-link-manager/links-manager-manage.php" method="post">
    305468        <div>
     
    308471                <option value="pages"<?php if($_REQUEST["sel_posts_type"]=="pages"){ echo(' selected="selected"'); }; ?>>Pages</option>
    309472            </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>
    310479            <input type="submit" value="Apply" name="showtype" id="showtype" class="button-secondary action" />
    311480        </div>
    312       </form>
    313       <br />
    314       <form action="admin.php?page=outbound-link-manager/links-manager-manage.php" method="post">
     481        <br />
    315482        <?php
    316483        $numberposts = 10;
     
    335502                        <option value="add_nofollow">Add NoFollow</option>
    336503                        <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 } ?>
    337506                    </select>
    338                     <input type="hidden" name="sel_posts_type" value="pages" />
    339507                    <input type="submit" value="Apply" name="doaction" id="doaction" class="button-secondary action" />
    340508                </div>
    341509                <?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));
    345514            break;
    346515            default:
     
    392561                    }
    393562
    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));
    397566                    ?>
    398567                    <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
     
    404573                        <option value="add_nofollow">Add NoFollow</option>
    405574                        <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 } ?>
    406577                    </select>
    407578                    <input type="submit" value="Apply" name="doaction" id="doaction" class="button-secondary action" />
     
    410581        }
    411582        ?>
    412         <table class="widefat fixed" cellspacing="0" style="margin-top: 10px">
     583        <br /><br />
     584        <table class="widefat fixed" cellspacing="0">
    413585            <thead>
    414586            <tr>
     587            <th scope="col" id="cb" class="check-column" style=""><input type="checkbox" /></th>
    415588            <th scope="col" style="width: 15%">Post</th>
    416589            <?php
     
    435608            <tfoot>
    436609            <tr>
     610            <th scope="col" class="check-column"><input type="checkbox" /></th>
    437611            <th scope="col">Post</th>
    438612            <th scope="col">Author</th>
     
    453627            <?php
    454628            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);
    456630
    457631            foreach($matches as $key => $value){
    458632                preg_match("/href\s*=\s*[\'|\"]\s*([^\"|\']*)\s*[\'|\"]/i",$value[1],$href);
    459633
    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                    }
    462644                }
    463645            }
    464646            ?>
    465647            <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>
    466649                <td>
    467650                    <div>
     
    526709                            foreach($matches as $link_number => $match){
    527710                            ?>
    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>
    529712                            <?php
    530713                            }
     
    564747                $vars_query = "";
    565748                $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" : "";
    566751                $vars_query .= (isset($cat) && $cat!="") ? "&cat=".$cat : "";
    567752                $vars_query .= (isset($m) && $m!="") ? "&m=".$m : "";
  • outbound-link-manager/trunk/links-manager.php

    r366149 r557158  
    44Plugin URI: http://www.searchmatters.com.au/wp-plugins/outbound-link-manager/
    55Description: 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.11
     6Version: 1.2
    77Author: Morris Bryant, Ruben Sargsyan
    88Author URI: http://www.searchmatters.com.au
     
    3131
    3232function 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");
    3535    }
     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    }   
    3640}
    3741
    3842function links_manager_scan_posts(){
    39     $posts = get_posts('numberposts=-1');
     43    $posts = get_posts(array("post_type"=>array("post","page"),"numberposts"=>-1));
    4044
    4145    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)){
    4347            continue;
    4448        }
    4549
    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        }
    8370    }
    8471}
     
    8976    foreach($posts as $post){
    9077        delete_post_meta($post->ID, "_outbound_link_exist");
     78        delete_post_meta($post->ID, "_internal_link_exist");
    9179    }
    9280
     
    9583    foreach($pages as $page){
    9684        delete_post_meta($page->ID, "_outbound_link_exist");
    97     }
     85        delete_post_meta($page->ID, "_internal_link_exist");
     86    }
     87}
     88
     89function 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
     99function 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;
    98169}
    99170
    100171function links_manager_scan_post($post){
    101172    $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){
    121189        add_post_meta($the_post->ID, "_outbound_link_exist", "yes", true);
    122190    }else{
    123191        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");
    124198    }
    125199}
     
    127201function links_manager_scan_page($page){
    128202    $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){
    148220        add_post_meta($the_page->ID, "_outbound_link_exist", "yes", true);
    149221    }else{
    150222        delete_post_meta($the_page->ID, "_outbound_link_exist");
    151223    }
    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
     232wp_enqueue_script("jquery");
    154233add_action("admin_menu", "links_manager_menu");
    155234register_activation_hook(__FILE__, "links_manager_scan_posts");
    156 register_activation_hook(__FILE__, "links_manager_scan_pages");
    157235register_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');
     236add_filter("wp_insert_post_data","links_manager_check_post_white_black_lists",99);
     237add_action("publish_post","links_manager_scan_post");
     238add_action("edit_post","links_manager_scan_post");
     239add_action("publish_page","links_manager_scan_page");
     240add_action("edit_page_form","links_manager_scan_page");
    162241?>
  • outbound-link-manager/trunk/readme.txt

    r366149 r557158  
    1111The 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.
    1212
     13The whitelist + blacklist functions mean you can also set rules around when a nofollow tag should be added.
     14
    1315= Here's what you can do: =
    1416
    15171. Remove links. The original anchor text is kept in tact.
    16181. Add or remove the NoFollow tag.
    17 1. Achieve the above in bulk by selecting numerous posts.
     191. Achieve the above in bulk by selecting numerous posts/pages or links.
    18201. Edit links. This gives you instant access to the whole link code, allowing you to add styles, targets or change the anchor text.
     211. Add domains to the whitelist: all other links will be removed or nofollow will be added.
     221. Add domains to the blacklist: all links to these domains will be removed or nofollowed, other links will not change.
     231. 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.
    1924
    2025This 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.
    2126
    22 Read more about the [Outbound Link Manager](http://www.searchmatters.com.au/wp-plugins/outbound-link-manager.php).
     27Send your questions or feature requests to Morris Bryant and Ruben Sargsyan at [Sparro](http://sparro.com.au). We can complete any custom plugin project.
    2328
    2429== Screenshots ==
     
    3540== Frequently Asked Questions ==
    3641
    37 Send your questions to Morris Bryant and Ruben Sargsyan at [Search Matters](http://www.searchmatters.com.au).
     42Send your questions to Morris Bryant and Ruben Sargsyan at [Sparro](http://sparro.com.au).
    3843
    3944== Changelog ==
     
    4550* The Outbound Link Manager now also scans pages.
    4651* 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.