fork download
  1. <?
  2. function links_remove () {
  3. $args = array ('numberposts' => 9999);
  4. $allposts = get_posts( $args );
  5. foreach( $allposts as $post ) {
  6. $id = $post->ID;
  7. $content = $post->post_content;
  8. $links_mass=array(
  9. 'www.evro-posuda.ru/',
  10. 'ostrovok.ru/hotel/czech_republic/prague/id10305/hotel_askania/'
  11. );
  12. foreach($links_mass as $link) {
  13. $pattern = '/<a.*href="http:\/\/' . preg_quote($link, '/') . '>.*<\/a>';
  14. $new_content = preg_replace ($pattern, "", $content);
  15. }
  16.  
  17. $new_post = array();
  18. $new_post['ID'] = $id;
  19. $new_post['post_content'] = $new_content;
  20. wp_update_post( $new_post );
  21. }
  22. }
  23. add_action ('init', 'links_remove');
  24.  
  25. ?>
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
<? 
function links_remove () {
    $args = array ('numberposts' => 9999);
        $allposts = get_posts( $args );
        foreach( $allposts as $post ) {
            $id = $post->ID;
            $content = $post->post_content;
            $links_mass=array(
            'www.evro-posuda.ru/',
            'ostrovok.ru/hotel/czech_republic/prague/id10305/hotel_askania/'
            );
            foreach($links_mass as $link) {
            $pattern = '/<a.*href="http:\/\/' . preg_quote($link, '/') . '>.*<\/a>';
            $new_content = preg_replace ($pattern, "", $content);
        }   
        
        $new_post = array();
        $new_post['ID'] = $id;
        $new_post['post_content'] = $new_content;
        wp_update_post( $new_post );
    }
}
add_action ('init', 'links_remove');

?>