Hey,
stworzyłem plugin, który szuka w Postach użytkowników nie działające linki.
Mam problem ponieważ u mnie loklanie dla 6 Postów, ładnie znajduje nie działające linki.
Nie stety podesłałem go do klienta i okazało się że dla 500 postów plugin coś zamula wogule nie wyświetla wyniku, nie jestem pewien czy to problem z większą ilości danych czy może coś innego.

Podaje link do Plugina: http://szymoon.nazwa.pl/plugins/BrokenLinksChecker.zip

Oraz tutaj kod:
  1. if ( is_admin() ) {
  2. add_action('admin_menu', 'broken_links_checker_options');
  3. function broken_links_checker_options() {
  4. add_options_page('Broken-links-checker-options', 'Broken-links-checker', 'manage_options', 'broken_links_checker', 'broken_links_options');
  5. }
  6. }
  7. ?>
  8. <?php
  9. function check_url($nodes) {
  10. $curl_arr = array();
  11. $master = curl_multi_init();
  12. for($i = 0, $count=count($nodes); $i < $count; $i++)
  13. {
  14. $url = $nodes[$i];
  15. $curl_arr[$i] = curl_init();
  16. curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true);
  17. curl_setopt($curl_arr[$i], CURLOPT_URL, $nodes[$i] );
  18. curl_setopt($curl_arr[$i], CURLOPT_CONNECTTIMEOUT, 20);
  19. curl_setopt($curl_arr[$i], CURLOPT_NOBODY, true);
  20. curl_setopt($curl_arr[$i], CURLOPT_HEADER, true);
  21. curl_multi_add_handle($master, $curl_arr[$i]);
  22. }
  23. do {
  24. curl_multi_exec($master,$running);
  25. } while($running > 0);
  26. $szymon = array();
  27. for($i = 0; $i < $count; $i++)
  28. {
  29. $results = curl_multi_getcontent ( $curl_arr[$i] );
  30. //var_dump();
  31. if($results == null) {
  32. $szymon[] = '0 ';
  33. } else {
  34. $replace = substr($results, 0, 13);
  35. $szymon[]= $text = str_replace('HTTP/1.1', '', $replace);
  36. }
  37. }
  38. return $szymon;
  39. $end = microtime(true);
  40. }
  41. ?>
  42. <?php function broken_links_options() {
  43. $pass = $_GET['url'];
  44. ?>
  45. <a href="<?php bloginfo('wpurl');?>/wp-admin/options-general.php?page=broken_links_checker&url=find" class="button-primary" style="margin:10px 0 0 0;float:left;">Check Links</a>
  46. <?php
  47. global $title;
  48. global $wpdb; ?>
  49. <?php if($pass == 'find') : ?>
  50. <?php $myrows = $wpdb->get_results( "SELECT * FROM wp_posts where post_status = 'publish'" );?>
  51. <table style="float:left;clear:both;">
  52. <tr>
  53. <th>Title post</th>
  54. <th>URL in post</th>
  55. <th>Link too edit</th>
  56. <th>Status</th>
  57. </tr>
  58. <?php
  59. $good = 0;
  60. $bad = 0;
  61. ?>
  62. <?php foreach($myrows as $a):?>
  63. <?php $qwe = $a->post_content ?>
  64. <?php preg_match_all("/<a.*?href\s*=\s*['\"](.*?)['\"]/", $qwe, $res, PREG_SET_ORDER);?>
  65. <?php
  66. foreach($res as $key => $val):?>
  67. <?php
  68. $nodes[links][] = $val[1];
  69. $nodes[title][] = $a->post_title;
  70. $nodes[id][] = $a->ID;
  71. ?>
  72. <?php endforeach ?>
  73. <?php endforeach ?>
  74. <?php foreach (check_url($nodes[links]) as $h): ?>
  75. <?php $nodes[status][] = $h;?>
  76. <?php endforeach ?>
  77.  
  78. <?php for($i=0; $i < count($nodes['status']); $i++) : ?>
  79. <tr>
  80. <?php $good++;?>
  81. <?php if(trim($nodes['status'][$i]) != 200) : ?>
  82. <?php $bad++?>
  83. <td>
  84. <?php
  85. echo $nodes['title'][$i];
  86. ?>
  87. </td>
  88. <td>
  89. <?php
  90. echo $nodes['links'][$i];
  91. ?>
  92. </td>
  93. <td>
  94. <a href="<?php bloginfo('wpurl');?>/wp-admin/post.php?post=<?php echo $nodes['id'][$i]; ?>&action=edit" target="_blank" >Edit Post</a>
  95. </td>
  96. <td>
  97. <?php echo $nodes['status'][$i]; ?>
  98. </td>
  99. <?php endif ?>
  100. </tr>
  101. <?php endfor ?>
  102. </table>
  103.  
  104. <br />
  105. <p style="float:left;clear:both;">Good links <?php echo $good-$bad ?></p>
  106. <p style="float:left;clear:both;">Bad links <?php echo $bad;?></p>
  107. <?php endif ?>
  108. <?php } ?>