Version Description
Download this release
Release Info
| Developer | whiteshadow |
| Plugin | |
| Version | 0.5.15 |
| Comparing to | |
| See all releases | |
Code changes from version 0.5.14 to 0.5.15
- broken-link-checker.php +1 -1
- core.php +2 -0
- instance-classes.php +57 -9
- readme.txt +1 -1
broken-link-checker.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
Plugin Name: Broken Link Checker
|
| 5 |
Plugin URI: http://w-shadow.com/blog/2007/08/05/broken-link-checker-for-wordpress/
|
| 6 |
Description: Checks your posts for broken links and missing images and notifies you on the dashboard if any are found.
|
| 7 |
-
Version: 0.5.
|
| 8 |
Author: Janis Elsts
|
| 9 |
Author URI: http://w-shadow.com/blog/
|
| 10 |
*/
|
| 4 |
Plugin Name: Broken Link Checker
|
| 5 |
Plugin URI: http://w-shadow.com/blog/2007/08/05/broken-link-checker-for-wordpress/
|
| 6 |
Description: Checks your posts for broken links and missing images and notifies you on the dashboard if any are found.
|
| 7 |
+
Version: 0.5.15
|
| 8 |
Author: Janis Elsts
|
| 9 |
Author URI: http://w-shadow.com/blog/
|
| 10 |
*/
|
core.php
CHANGED
|
@@ -1172,6 +1172,8 @@ jQuery(function($){
|
|
| 1172 |
if ( !$(editor).is(':visible') ){
|
| 1173 |
//Begin editing
|
| 1174 |
url_el.hide();
|
|
|
|
|
|
|
| 1175 |
editor.show();
|
| 1176 |
cancel_button_container.show();
|
| 1177 |
editor.focus();
|
| 1172 |
if ( !$(editor).is(':visible') ){
|
| 1173 |
//Begin editing
|
| 1174 |
url_el.hide();
|
| 1175 |
+
//Reset the edit box to the actual URL value in case the user has already tried and failed to edit this link.
|
| 1176 |
+
editor.val( url_el.attr('href') );
|
| 1177 |
editor.show();
|
| 1178 |
cancel_button_container.show();
|
| 1179 |
editor.focus();
|
instance-classes.php
CHANGED
|
@@ -209,6 +209,9 @@ class blcLinkInstance {
|
|
| 209 |
|
| 210 |
class blcLinkInstance_post_link extends blcLinkInstance {
|
| 211 |
|
|
|
|
|
|
|
|
|
|
| 212 |
function edit($old_url, $new_url){
|
| 213 |
global $wpdb;
|
| 214 |
|
|
@@ -228,21 +231,35 @@ class blcLinkInstance_post_link extends blcLinkInstance {
|
|
| 228 |
return false;
|
| 229 |
}
|
| 230 |
//FB::info('Post ' . $this->source_id . ' loaded successfully');
|
|
|
|
|
|
|
| 231 |
|
| 232 |
$this->old_url = $old_url;
|
| 233 |
$this->new_url = $new_url;
|
| 234 |
|
|
|
|
|
|
|
|
|
|
| 235 |
//Find all links and replace those that match $old_url.
|
| 236 |
$content = preg_replace_callback(blcUtility::link_pattern(), array(&$this, 'edit_callback'), $post['post_content']);
|
| 237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
|
|
|
|
|
|
|
| 239 |
return $wpdb->query($q) !== false;
|
| 240 |
}
|
| 241 |
|
| 242 |
function edit_callback($matches){
|
| 243 |
-
$url = blcUtility::normalize_url($matches[3]);
|
|
|
|
| 244 |
|
| 245 |
if ($url == $this->old_url){
|
|
|
|
|
|
|
| 246 |
return $matches[1].$matches[2].$this->new_url.$matches[2].$matches[4].$matches[5].$matches[6];
|
| 247 |
} else {
|
| 248 |
return $matches[0];
|
|
@@ -268,12 +285,21 @@ class blcLinkInstance_post_link extends blcLinkInstance {
|
|
| 268 |
return false;
|
| 269 |
}
|
| 270 |
//FB::info('Post ' . $this->source_id . ' loaded successfully');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
|
| 272 |
//Find all links and remove those that match $url.
|
| 273 |
$this->old_url = $url; //used by the callback
|
| 274 |
$content = preg_replace_callback(blcUtility::link_pattern(), array(&$this, 'unlink_callback'), $post['post_content']);
|
| 275 |
-
$q = $wpdb->prepare("UPDATE $wpdb->posts SET post_content = %s WHERE id = %d", $content, $this->source_id);
|
| 276 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
if ( $wpdb->query($q) !== false ){
|
| 278 |
//Delete the instance record
|
| 279 |
//FB::info("Post updated, deleting instance from DB");
|
|
@@ -285,9 +311,10 @@ class blcLinkInstance_post_link extends blcLinkInstance {
|
|
| 285 |
}
|
| 286 |
|
| 287 |
function unlink_callback($matches){
|
| 288 |
-
$url = blcUtility::normalize_url($matches[3]);
|
| 289 |
|
| 290 |
if ($url == $this->old_url){
|
|
|
|
| 291 |
return $matches[5]; //just the anchor text
|
| 292 |
} else {
|
| 293 |
return $matches[0]; //return the link unchanged
|
|
@@ -298,6 +325,9 @@ class blcLinkInstance_post_link extends blcLinkInstance {
|
|
| 298 |
|
| 299 |
class blcLinkInstance_post_image extends blcLinkInstance {
|
| 300 |
|
|
|
|
|
|
|
|
|
|
| 301 |
function edit($old_url, $new_url){
|
| 302 |
global $wpdb;
|
| 303 |
|
|
@@ -315,24 +345,33 @@ class blcLinkInstance_post_image extends blcLinkInstance {
|
|
| 315 |
if (!$post){
|
| 316 |
return false;
|
| 317 |
}
|
|
|
|
|
|
|
| 318 |
|
| 319 |
$this->old_url = $old_url;
|
| 320 |
$this->new_url = $new_url;
|
| 321 |
|
| 322 |
//Find all images and change the URL of those that match $old_url.
|
| 323 |
-
//Note : this might be inefficient if there's more than one instance of the
|
| 324 |
//in one post, as each instances would be called when editing the link.
|
| 325 |
-
//Either way, I thing the overhead is small enough to ignore for now.
|
|
|
|
| 326 |
$content = preg_replace_callback(blcUtility::img_pattern(), array(&$this, 'edit_callback'), $post['post_content']);
|
| 327 |
-
$q = $wpdb->prepare("UPDATE $wpdb->posts SET post_content = %s WHERE id = %d", $content, $this->source_id);
|
| 328 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
return $wpdb->query($q) !== false;
|
| 330 |
}
|
| 331 |
|
| 332 |
function edit_callback($matches){
|
| 333 |
-
$url = blcUtility::normalize_url($matches[3]);
|
| 334 |
|
| 335 |
if ($url == $this->old_url){
|
|
|
|
| 336 |
return $matches[1].$matches[2].$this->new_url.$matches[2].$matches[4].$matches[5];
|
| 337 |
} else {
|
| 338 |
return $matches[0];
|
|
@@ -358,10 +397,18 @@ class blcLinkInstance_post_image extends blcLinkInstance {
|
|
| 358 |
return false;
|
| 359 |
}
|
| 360 |
//FB::info('Post ' . $this->source_id . ' loaded successfully');
|
|
|
|
|
|
|
| 361 |
|
| 362 |
//Find all links and remove those that match $url.
|
| 363 |
$this->old_url = $url; //used by the callback
|
|
|
|
| 364 |
$content = preg_replace_callback(blcUtility::img_pattern(), array(&$this, 'unlink_callback'), $post['post_content']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
$q = $wpdb->prepare("UPDATE $wpdb->posts SET post_content = %s WHERE id = %d", $content, $this->source_id);
|
| 366 |
|
| 367 |
if ( $wpdb->query($q) !== false ){
|
|
@@ -375,9 +422,10 @@ class blcLinkInstance_post_image extends blcLinkInstance {
|
|
| 375 |
}
|
| 376 |
|
| 377 |
function unlink_callback($matches){
|
| 378 |
-
$url = blcUtility::normalize_url($matches[3]);
|
| 379 |
|
| 380 |
if ($url == $this->old_url){
|
|
|
|
| 381 |
return ''; //remove the image completely
|
| 382 |
} else {
|
| 383 |
return $matches[0]; //return the image unchanged
|
| 209 |
|
| 210 |
class blcLinkInstance_post_link extends blcLinkInstance {
|
| 211 |
|
| 212 |
+
var $post_permalink = '';
|
| 213 |
+
var $changed_links = 0;
|
| 214 |
+
|
| 215 |
function edit($old_url, $new_url){
|
| 216 |
global $wpdb;
|
| 217 |
|
| 231 |
return false;
|
| 232 |
}
|
| 233 |
//FB::info('Post ' . $this->source_id . ' loaded successfully');
|
| 234 |
+
//Figure out the post's permalink - it'll be needed when normalizing relative URLs
|
| 235 |
+
$this->post_permalink = get_permalink( $post['ID'] );
|
| 236 |
|
| 237 |
$this->old_url = $old_url;
|
| 238 |
$this->new_url = $new_url;
|
| 239 |
|
| 240 |
+
//Track how many links in the post are successfully edited so that we can report an error if none are.
|
| 241 |
+
$this->changed_links = 0;
|
| 242 |
+
|
| 243 |
//Find all links and replace those that match $old_url.
|
| 244 |
$content = preg_replace_callback(blcUtility::link_pattern(), array(&$this, 'edit_callback'), $post['post_content']);
|
| 245 |
+
|
| 246 |
+
if ( $this->changed_links <= 0 ){
|
| 247 |
+
//FB::error("Didn't find any links to edit in this post!");
|
| 248 |
+
return false;
|
| 249 |
+
}
|
| 250 |
|
| 251 |
+
//Save the modified post
|
| 252 |
+
$q = $wpdb->prepare("UPDATE $wpdb->posts SET post_content = %s WHERE id = %d", $content, $this->source_id);
|
| 253 |
return $wpdb->query($q) !== false;
|
| 254 |
}
|
| 255 |
|
| 256 |
function edit_callback($matches){
|
| 257 |
+
$url = blcUtility::normalize_url($matches[3], $this->post_permalink);
|
| 258 |
+
//FB::log('Found an link with URL "' . $matches[3] . '", normalized URL = "' . $url . '"');
|
| 259 |
|
| 260 |
if ($url == $this->old_url){
|
| 261 |
+
//FB::log('Changing this link');
|
| 262 |
+
$this->changed_links++;
|
| 263 |
return $matches[1].$matches[2].$this->new_url.$matches[2].$matches[4].$matches[5].$matches[6];
|
| 264 |
} else {
|
| 265 |
return $matches[0];
|
| 285 |
return false;
|
| 286 |
}
|
| 287 |
//FB::info('Post ' . $this->source_id . ' loaded successfully');
|
| 288 |
+
//Figure out the post's permalink - it'll be needed when normalizing relative URLs
|
| 289 |
+
$this->post_permalink = get_permalink( $post['ID'] );
|
| 290 |
+
|
| 291 |
+
//Track how many links in the post are successfully removed so that we can report an error if none are.
|
| 292 |
+
$this->changed_links = 0;
|
| 293 |
|
| 294 |
//Find all links and remove those that match $url.
|
| 295 |
$this->old_url = $url; //used by the callback
|
| 296 |
$content = preg_replace_callback(blcUtility::link_pattern(), array(&$this, 'unlink_callback'), $post['post_content']);
|
|
|
|
| 297 |
|
| 298 |
+
if ( $this->changed_links <= 0 ){
|
| 299 |
+
return false;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
$q = $wpdb->prepare("UPDATE $wpdb->posts SET post_content = %s WHERE id = %d", $content, $this->source_id);
|
| 303 |
if ( $wpdb->query($q) !== false ){
|
| 304 |
//Delete the instance record
|
| 305 |
//FB::info("Post updated, deleting instance from DB");
|
| 311 |
}
|
| 312 |
|
| 313 |
function unlink_callback($matches){
|
| 314 |
+
$url = blcUtility::normalize_url($matches[3], $this->post_permalink);
|
| 315 |
|
| 316 |
if ($url == $this->old_url){
|
| 317 |
+
$this->changed_links++;
|
| 318 |
return $matches[5]; //just the anchor text
|
| 319 |
} else {
|
| 320 |
return $matches[0]; //return the link unchanged
|
| 325 |
|
| 326 |
class blcLinkInstance_post_image extends blcLinkInstance {
|
| 327 |
|
| 328 |
+
var $post_permalink = '';
|
| 329 |
+
var $changed_images = 0;
|
| 330 |
+
|
| 331 |
function edit($old_url, $new_url){
|
| 332 |
global $wpdb;
|
| 333 |
|
| 345 |
if (!$post){
|
| 346 |
return false;
|
| 347 |
}
|
| 348 |
+
//Figure out the post's permalink - it'll be needed when normalizing relative URLs
|
| 349 |
+
$this->post_permalink = get_permalink( $post['ID'] );
|
| 350 |
|
| 351 |
$this->old_url = $old_url;
|
| 352 |
$this->new_url = $new_url;
|
| 353 |
|
| 354 |
//Find all images and change the URL of those that match $old_url.
|
| 355 |
+
//Note : this might be inefficient if there's more than one instance of the same link
|
| 356 |
//in one post, as each instances would be called when editing the link.
|
| 357 |
+
//Either way, I thing the overhead is small enough to ignore for now.
|
| 358 |
+
$this->changed_images = 0;
|
| 359 |
$content = preg_replace_callback(blcUtility::img_pattern(), array(&$this, 'edit_callback'), $post['post_content']);
|
|
|
|
| 360 |
|
| 361 |
+
if ( $this->changed_images <= 0 ){
|
| 362 |
+
return false;
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
//Save the modified post
|
| 366 |
+
$q = $wpdb->prepare("UPDATE $wpdb->posts SET post_content = %s WHERE id = %d", $content, $this->source_id);
|
| 367 |
return $wpdb->query($q) !== false;
|
| 368 |
}
|
| 369 |
|
| 370 |
function edit_callback($matches){
|
| 371 |
+
$url = blcUtility::normalize_url($matches[3], $this->post_permalink);
|
| 372 |
|
| 373 |
if ($url == $this->old_url){
|
| 374 |
+
$this->changed_images++;
|
| 375 |
return $matches[1].$matches[2].$this->new_url.$matches[2].$matches[4].$matches[5];
|
| 376 |
} else {
|
| 377 |
return $matches[0];
|
| 397 |
return false;
|
| 398 |
}
|
| 399 |
//FB::info('Post ' . $this->source_id . ' loaded successfully');
|
| 400 |
+
//Figure out the post's permalink - it'll be needed when normalizing relative URLs
|
| 401 |
+
$this->post_permalink = get_permalink( $post['ID'] );
|
| 402 |
|
| 403 |
//Find all links and remove those that match $url.
|
| 404 |
$this->old_url = $url; //used by the callback
|
| 405 |
+
$this->changed_images = 0;
|
| 406 |
$content = preg_replace_callback(blcUtility::img_pattern(), array(&$this, 'unlink_callback'), $post['post_content']);
|
| 407 |
+
|
| 408 |
+
if ( $this->changed_images <= 0 ){
|
| 409 |
+
return false;
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
$q = $wpdb->prepare("UPDATE $wpdb->posts SET post_content = %s WHERE id = %d", $content, $this->source_id);
|
| 413 |
|
| 414 |
if ( $wpdb->query($q) !== false ){
|
| 422 |
}
|
| 423 |
|
| 424 |
function unlink_callback($matches){
|
| 425 |
+
$url = blcUtility::normalize_url($matches[3], $this->post_permalink);
|
| 426 |
|
| 427 |
if ($url == $this->old_url){
|
| 428 |
+
$this->changed_images++;
|
| 429 |
return ''; //remove the image completely
|
| 430 |
} else {
|
| 431 |
return $matches[0]; //return the image unchanged
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: whiteshadow
|
|
| 3 |
Tags: links, broken, maintenance, blogroll, custom fields, admin
|
| 4 |
Requires at least: 2.7.0
|
| 5 |
Tested up to: 2.9
|
| 6 |
-
Stable tag: 0.5.
|
| 7 |
|
| 8 |
This plugin will check your posts, custom fields and the blogroll for broken links and missing images and notify you if any are found.
|
| 9 |
|
| 3 |
Tags: links, broken, maintenance, blogroll, custom fields, admin
|
| 4 |
Requires at least: 2.7.0
|
| 5 |
Tested up to: 2.9
|
| 6 |
+
Stable tag: 0.5.15
|
| 7 |
|
| 8 |
This plugin will check your posts, custom fields and the blogroll for broken links and missing images and notify you if any are found.
|
| 9 |
|
