Version Description
- Fixed "Edit URL" and "Unlink" not working on PHP4 servers.
Download this release
Release Info
| Developer | whiteshadow |
| Plugin | |
| Version | 0.9.4.4 |
| Comparing to | |
| See all releases | |
Code changes from version 0.9.4.3 to 0.9.4.4
- broken-link-checker.php +8 -7
- core.php +93 -20
- includes/admin/links-page-js.php +16 -2
- includes/admin/search-form.php +1 -1
- includes/checkers.php +2 -2
- includes/checkers/http.php +2 -2
- includes/containers.php +19 -14
- includes/containers/blogroll.php +2 -2
- includes/containers/comment.php +3 -2
- includes/containers/custom_field.php +2 -2
- includes/containers/post.php +5 -5
- includes/instances.php +11 -11
- includes/links.php +5 -5
- includes/parsers.php +7 -7
- includes/parsers/html_link.php +1 -1
- readme.txt +25 -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 blog for broken links and missing images and notifies you on the dashboard if any are found.
|
| 7 |
-
Version: 0.9.4.
|
| 8 |
Author: Janis Elsts
|
| 9 |
Author URI: http://w-shadow.com/blog/
|
| 10 |
Text Domain: broken-link-checker
|
|
@@ -86,7 +86,8 @@ $blc_config_manager = new blcConfigurationManager(
|
|
| 86 |
'custom_fields' => array(), //List of custom fields that can contain URLs and should be checked.
|
| 87 |
'check_comment_links' => true, //Whether to check links found in comments
|
| 88 |
|
| 89 |
-
'autoexpand_widget' => true, //Autoexpand the Dashboard widget if broken links are detected
|
|
|
|
| 90 |
|
| 91 |
'need_resynch' => false, //[Internal flag] True if there are unparsed items.
|
| 92 |
'current_db_version' => 0, //The currently set-up version of the plugin's tables
|
|
@@ -119,7 +120,7 @@ $blclog = new blcDummyLogger;
|
|
| 119 |
|
| 120 |
|
| 121 |
/*
|
| 122 |
-
if ( constant('BLC_DEBUG') ){
|
| 123 |
//Load FirePHP for debug logging
|
| 124 |
if ( !class_exists('FB') ) {
|
| 125 |
require_once 'FirePHPCore/fb.php4';
|
|
@@ -158,7 +159,7 @@ function blc_init_containers(){
|
|
| 158 |
require $blc_directory . '/includes/containers/custom_field.php';
|
| 159 |
require $blc_directory . '/includes/containers/dummy.php';
|
| 160 |
|
| 161 |
-
$conf = blc_get_configuration();
|
| 162 |
if ( $conf->options['check_comment_links'] ){
|
| 163 |
require $blc_directory . '/includes/containers/comment.php';
|
| 164 |
}
|
|
@@ -237,7 +238,7 @@ function blc_init_all_components(){
|
|
| 237 |
*
|
| 238 |
* @return blcConfigurationManager
|
| 239 |
*/
|
| 240 |
-
function blc_get_configuration(){
|
| 241 |
return $GLOBALS['blc_config_manager'];
|
| 242 |
}
|
| 243 |
|
|
@@ -248,7 +249,7 @@ function blc_get_configuration(){
|
|
| 248 |
* @return void
|
| 249 |
*/
|
| 250 |
function blc_got_unsynched_items(){
|
| 251 |
-
$conf = blc_get_configuration();
|
| 252 |
|
| 253 |
if ( !$conf->options['need_resynch'] ){
|
| 254 |
$conf->options['need_resynch'] = true;
|
|
@@ -332,7 +333,7 @@ add_filter('cron_schedules', 'blc_cron_schedules');
|
|
| 332 |
* @return void
|
| 333 |
*/
|
| 334 |
function blc_print_installation_errors(){
|
| 335 |
-
$conf = blc_get_configuration();
|
| 336 |
if ( !$conf->options['installation_failed'] ){
|
| 337 |
return;
|
| 338 |
}
|
| 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 blog for broken links and missing images and notifies you on the dashboard if any are found.
|
| 7 |
+
Version: 0.9.4.4
|
| 8 |
Author: Janis Elsts
|
| 9 |
Author URI: http://w-shadow.com/blog/
|
| 10 |
Text Domain: broken-link-checker
|
| 86 |
'custom_fields' => array(), //List of custom fields that can contain URLs and should be checked.
|
| 87 |
'check_comment_links' => true, //Whether to check links found in comments
|
| 88 |
|
| 89 |
+
'autoexpand_widget' => true, //Autoexpand the Dashboard widget if broken links are detected
|
| 90 |
+
'show_link_count_bubble' => true, //Display a notification bubble in the menu when broken links are found
|
| 91 |
|
| 92 |
'need_resynch' => false, //[Internal flag] True if there are unparsed items.
|
| 93 |
'current_db_version' => 0, //The currently set-up version of the plugin's tables
|
| 120 |
|
| 121 |
|
| 122 |
/*
|
| 123 |
+
if ( defined('BLC_DEBUG') && constant('BLC_DEBUG') ){
|
| 124 |
//Load FirePHP for debug logging
|
| 125 |
if ( !class_exists('FB') ) {
|
| 126 |
require_once 'FirePHPCore/fb.php4';
|
| 159 |
require $blc_directory . '/includes/containers/custom_field.php';
|
| 160 |
require $blc_directory . '/includes/containers/dummy.php';
|
| 161 |
|
| 162 |
+
$conf = & blc_get_configuration();
|
| 163 |
if ( $conf->options['check_comment_links'] ){
|
| 164 |
require $blc_directory . '/includes/containers/comment.php';
|
| 165 |
}
|
| 238 |
*
|
| 239 |
* @return blcConfigurationManager
|
| 240 |
*/
|
| 241 |
+
function &blc_get_configuration(){
|
| 242 |
return $GLOBALS['blc_config_manager'];
|
| 243 |
}
|
| 244 |
|
| 249 |
* @return void
|
| 250 |
*/
|
| 251 |
function blc_got_unsynched_items(){
|
| 252 |
+
$conf = & blc_get_configuration();
|
| 253 |
|
| 254 |
if ( !$conf->options['need_resynch'] ){
|
| 255 |
$conf->options['need_resynch'] = true;
|
| 333 |
* @return void
|
| 334 |
*/
|
| 335 |
function blc_print_installation_errors(){
|
| 336 |
+
$conf = & blc_get_configuration();
|
| 337 |
if ( !$conf->options['installation_failed'] ){
|
| 338 |
return;
|
| 339 |
}
|
core.php
CHANGED
|
@@ -32,10 +32,10 @@ class wsBrokenLinkChecker {
|
|
| 32 |
* @param blcConfigurationManager $conf An instance of the configuration manager
|
| 33 |
* @return void
|
| 34 |
*/
|
| 35 |
-
function wsBrokenLinkChecker ( $loader,
|
| 36 |
global $wpdb;
|
| 37 |
|
| 38 |
-
$this->conf =
|
| 39 |
$this->loader = $loader;
|
| 40 |
$this->my_basename = plugin_basename( $this->loader );
|
| 41 |
|
|
@@ -476,7 +476,12 @@ class wsBrokenLinkChecker {
|
|
| 476 |
//Use the character set and collation that's configured for WP tables
|
| 477 |
$charset_collate = '';
|
| 478 |
if ( !empty($wpdb->charset) ){
|
| 479 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
}
|
| 481 |
if ( !empty($wpdb->collate) ){
|
| 482 |
$charset_collate = " COLLATE {$wpdb->collate}";
|
|
@@ -527,7 +532,8 @@ EOD;
|
|
| 527 |
|
| 528 |
PRIMARY KEY (`instance_id`),
|
| 529 |
KEY `link_id` (`link_id`),
|
| 530 |
-
KEY `source_id` (`
|
|
|
|
| 531 |
) {$charset_collate};
|
| 532 |
EOT;
|
| 533 |
if ( $wpdb->query($q) === false ){
|
|
@@ -663,6 +669,12 @@ EOZ;
|
|
| 663 |
$this->optimize_database();
|
| 664 |
}
|
| 665 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 666 |
function admin_menu(){
|
| 667 |
if (current_user_can('manage_options'))
|
| 668 |
add_filter('plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2);
|
|
@@ -674,9 +686,24 @@ EOZ;
|
|
| 674 |
'link-checker-settings',array(&$this, 'options_page')
|
| 675 |
);
|
| 676 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 677 |
$links_page_hook = add_management_page(
|
| 678 |
__('View Broken Links', 'broken-link-checker'),
|
| 679 |
-
|
| 680 |
'edit_others_posts',
|
| 681 |
'view-broken-links',array(&$this, 'links_page')
|
| 682 |
);
|
|
@@ -832,7 +859,7 @@ EOZ;
|
|
| 832 |
}
|
| 833 |
$this->conf->options['send_email_notifications'] = $email_notifications;
|
| 834 |
|
| 835 |
-
//
|
| 836 |
$old_setting = $this->conf->options['check_comment_links'];
|
| 837 |
$this->conf->options['check_comment_links'] = !empty($_POST['check_comment_links']);
|
| 838 |
//If comment link checking was just turned on we need to load the comment manager
|
|
@@ -840,7 +867,7 @@ EOZ;
|
|
| 840 |
//TODO: More elegant handling of freshly enabled/disabled container types
|
| 841 |
if ( !$old_setting && $this->conf->options['check_comment_links'] ){
|
| 842 |
include $blc_directory . '/includes/containers/comment.php';
|
| 843 |
-
$containerRegistry = blcContainerRegistry::getInstance();
|
| 844 |
$comment_manager = $containerRegistry->get_manager('comment');
|
| 845 |
if ( $comment_manager ){
|
| 846 |
$comment_manager->resynch();
|
|
@@ -859,7 +886,7 @@ EOZ;
|
|
| 859 |
inefficient.
|
| 860 |
*/
|
| 861 |
if ( ( count($diff1) > 0 ) || ( count($diff2) > 0 ) ){
|
| 862 |
-
$containerRegistry = blcContainerRegistry::getInstance();
|
| 863 |
$manager = $containerRegistry->get_manager('custom_field');
|
| 864 |
if ( !is_null($manager) ){
|
| 865 |
$manager->resynch();
|
|
@@ -1270,7 +1297,7 @@ EOZ;
|
|
| 1270 |
|
| 1271 |
function links_page(){
|
| 1272 |
global $wpdb, $blclog;
|
| 1273 |
-
$blc_link_query = blcLinkQuery::getInstance();
|
| 1274 |
|
| 1275 |
//Sanity check : Make sure the plugin's tables are all set up.
|
| 1276 |
if ( $this->db_version != $this->conf->options['current_db_version'] ) {
|
|
@@ -1390,11 +1417,12 @@ EOZ;
|
|
| 1390 |
<script type='text/javascript'>
|
| 1391 |
var blc_current_filter = '<?php echo $filter_id; ?>';
|
| 1392 |
var blc_is_broken_filter = <?php
|
| 1393 |
-
|
| 1394 |
-
|
| 1395 |
-
|
| 1396 |
-
|
| 1397 |
-
|
|
|
|
| 1398 |
?>;
|
| 1399 |
</script>
|
| 1400 |
|
|
@@ -1694,7 +1722,7 @@ EOZ;
|
|
| 1694 |
$msg_class = 'error';
|
| 1695 |
} else {
|
| 1696 |
//Save the new filter
|
| 1697 |
-
$blc_link_query = blcLinkQuery::getInstance();
|
| 1698 |
$filter_id = $blc_link_query->create_custom_filter($_POST['name'], $_POST['params']);
|
| 1699 |
|
| 1700 |
if ( $filter_id ){
|
|
@@ -1730,7 +1758,7 @@ EOZ;
|
|
| 1730 |
$msg_class = 'error';
|
| 1731 |
} else {
|
| 1732 |
//Try to delete the filter
|
| 1733 |
-
$blc_link_query = blcLinkQuery::getInstance();
|
| 1734 |
if ( $blc_link_query->delete_custom_filter($_POST['filter_id']) ){
|
| 1735 |
//Success
|
| 1736 |
$message = __('Filter deleted', 'broken-link-checker');
|
|
@@ -1881,7 +1909,7 @@ EOZ;
|
|
| 1881 |
* @return array Confirmation message and its CSS class.
|
| 1882 |
*/
|
| 1883 |
function do_bulk_delete_sources($selected_links){
|
| 1884 |
-
$blc_container_registry = blcContainerRegistry::getInstance();
|
| 1885 |
|
| 1886 |
$message = '';
|
| 1887 |
$msg_class = 'updated';
|
|
@@ -2461,12 +2489,12 @@ EOZ;
|
|
| 2461 |
|
| 2462 |
//Only check links that have at least one valid instance (i.e. an instance exists and
|
| 2463 |
//it corresponds to one of the currently loaded container/parser types).
|
| 2464 |
-
$containerRegistry = blcContainerRegistry::getInstance();
|
| 2465 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 2466 |
$loaded_containers = array_map(array(&$wpdb, 'escape'), $loaded_containers);
|
| 2467 |
$loaded_containers = "'" . implode("', '", $loaded_containers) . "'";
|
| 2468 |
|
| 2469 |
-
$parserRegistry = blcParserRegistry::getInstance();
|
| 2470 |
$loaded_parsers = array_keys($parserRegistry->get_registered_parsers());
|
| 2471 |
$loaded_parsers = array_map(array(&$wpdb, 'escape'), $loaded_parsers);
|
| 2472 |
$loaded_parsers = "'" . implode("', '", $loaded_parsers) . "'";
|
|
@@ -2647,7 +2675,7 @@ EOZ;
|
|
| 2647 |
*/
|
| 2648 |
function get_status(){
|
| 2649 |
global $wpdb;
|
| 2650 |
-
$blc_link_query = blcLinkQuery::getInstance();
|
| 2651 |
|
| 2652 |
$check_threshold=date('Y-m-d H:i:s', strtotime('-'.$this->conf->options['check_threshold'].' hours'));
|
| 2653 |
$recheck_threshold=date('Y-m-d H:i:s', time() - $this->conf->options['recheck_threshold']);
|
|
@@ -3193,6 +3221,51 @@ EOZ;
|
|
| 3193 |
'value' => sprintf(__('%s seconds'), ini_get('max_execution_time')),
|
| 3194 |
);
|
| 3195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3196 |
return $debug;
|
| 3197 |
}
|
| 3198 |
|
| 32 |
* @param blcConfigurationManager $conf An instance of the configuration manager
|
| 33 |
* @return void
|
| 34 |
*/
|
| 35 |
+
function wsBrokenLinkChecker ( $loader, &$conf ) {
|
| 36 |
global $wpdb;
|
| 37 |
|
| 38 |
+
$this->conf = &$conf;
|
| 39 |
$this->loader = $loader;
|
| 40 |
$this->my_basename = plugin_basename( $this->loader );
|
| 41 |
|
| 476 |
//Use the character set and collation that's configured for WP tables
|
| 477 |
$charset_collate = '';
|
| 478 |
if ( !empty($wpdb->charset) ){
|
| 479 |
+
//Some German installs use "utf-8" (invalid) instead of "utf8" (valid). None of
|
| 480 |
+
//the charset ids supported by MySQL contain dashes, so we can safely strip them.
|
| 481 |
+
//See http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html
|
| 482 |
+
$charset = str_replace('-', '', $wpdb->charset);
|
| 483 |
+
|
| 484 |
+
$charset_collate = "DEFAULT CHARACTER SET {$charset}";
|
| 485 |
}
|
| 486 |
if ( !empty($wpdb->collate) ){
|
| 487 |
$charset_collate = " COLLATE {$wpdb->collate}";
|
| 532 |
|
| 533 |
PRIMARY KEY (`instance_id`),
|
| 534 |
KEY `link_id` (`link_id`),
|
| 535 |
+
KEY `source_id` (`container_type`, `container_id`),
|
| 536 |
+
KEY `parser_type` (`parser_type`)
|
| 537 |
) {$charset_collate};
|
| 538 |
EOT;
|
| 539 |
if ( $wpdb->query($q) === false ){
|
| 669 |
$this->optimize_database();
|
| 670 |
}
|
| 671 |
|
| 672 |
+
/**
|
| 673 |
+
* Create the plugin's menu items and enqueue their scripts and CSS.
|
| 674 |
+
* Callback for the 'admin_menu' action.
|
| 675 |
+
*
|
| 676 |
+
* @return void
|
| 677 |
+
*/
|
| 678 |
function admin_menu(){
|
| 679 |
if (current_user_can('manage_options'))
|
| 680 |
add_filter('plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2);
|
| 686 |
'link-checker-settings',array(&$this, 'options_page')
|
| 687 |
);
|
| 688 |
|
| 689 |
+
$menu_title = __('Broken Links', 'broken-link-checker');
|
| 690 |
+
if ( $this->conf->options['show_link_count_bubble'] ){
|
| 691 |
+
//To make it easier to notice when broken links appear, display the current number of
|
| 692 |
+
//broken links in a little bubble notification in the "Broken Links" menu.
|
| 693 |
+
//(Similar to how the number of plugin updates and unmoderated comments is displayed).
|
| 694 |
+
$blc_link_query = & blcLinkQuery::getInstance();
|
| 695 |
+
$broken_links = $blc_link_query->get_filter_links('broken', array('count_only' => true));
|
| 696 |
+
if ( $broken_links > 0 ){
|
| 697 |
+
//TODO: Appropriating existing CSS classes for my own purposes is hacky. Fix eventually.
|
| 698 |
+
$menu_title .= sprintf(
|
| 699 |
+
' <span class="update-plugins"><span class="update-count blc-menu-bubble">%d</span></span>',
|
| 700 |
+
$broken_links
|
| 701 |
+
);
|
| 702 |
+
}
|
| 703 |
+
}
|
| 704 |
$links_page_hook = add_management_page(
|
| 705 |
__('View Broken Links', 'broken-link-checker'),
|
| 706 |
+
$menu_title,
|
| 707 |
'edit_others_posts',
|
| 708 |
'view-broken-links',array(&$this, 'links_page')
|
| 709 |
);
|
| 859 |
}
|
| 860 |
$this->conf->options['send_email_notifications'] = $email_notifications;
|
| 861 |
|
| 862 |
+
//Comment link checking on/off
|
| 863 |
$old_setting = $this->conf->options['check_comment_links'];
|
| 864 |
$this->conf->options['check_comment_links'] = !empty($_POST['check_comment_links']);
|
| 865 |
//If comment link checking was just turned on we need to load the comment manager
|
| 867 |
//TODO: More elegant handling of freshly enabled/disabled container types
|
| 868 |
if ( !$old_setting && $this->conf->options['check_comment_links'] ){
|
| 869 |
include $blc_directory . '/includes/containers/comment.php';
|
| 870 |
+
$containerRegistry = & blcContainerRegistry::getInstance();
|
| 871 |
$comment_manager = $containerRegistry->get_manager('comment');
|
| 872 |
if ( $comment_manager ){
|
| 873 |
$comment_manager->resynch();
|
| 886 |
inefficient.
|
| 887 |
*/
|
| 888 |
if ( ( count($diff1) > 0 ) || ( count($diff2) > 0 ) ){
|
| 889 |
+
$containerRegistry = & blcContainerRegistry::getInstance();
|
| 890 |
$manager = $containerRegistry->get_manager('custom_field');
|
| 891 |
if ( !is_null($manager) ){
|
| 892 |
$manager->resynch();
|
| 1297 |
|
| 1298 |
function links_page(){
|
| 1299 |
global $wpdb, $blclog;
|
| 1300 |
+
$blc_link_query = & blcLinkQuery::getInstance();
|
| 1301 |
|
| 1302 |
//Sanity check : Make sure the plugin's tables are all set up.
|
| 1303 |
if ( $this->db_version != $this->conf->options['current_db_version'] ) {
|
| 1417 |
<script type='text/javascript'>
|
| 1418 |
var blc_current_filter = '<?php echo $filter_id; ?>';
|
| 1419 |
var blc_is_broken_filter = <?php
|
| 1420 |
+
//TODO: Simplify this. Maybe overhaul the filter system to let us query the effective filter.
|
| 1421 |
+
$is_broken_filter =
|
| 1422 |
+
($filter_id == 'broken')
|
| 1423 |
+
|| ( isset($current_filter['params']['s_filter']) && ($current_filter['params']['s_filter'] == 'broken') )
|
| 1424 |
+
|| ( isset($_GET['s_filter']) && ($_GET['s_filter'] == 'broken') );
|
| 1425 |
+
echo $is_broken_filter ? 'true' : 'false';
|
| 1426 |
?>;
|
| 1427 |
</script>
|
| 1428 |
|
| 1722 |
$msg_class = 'error';
|
| 1723 |
} else {
|
| 1724 |
//Save the new filter
|
| 1725 |
+
$blc_link_query = & blcLinkQuery::getInstance();
|
| 1726 |
$filter_id = $blc_link_query->create_custom_filter($_POST['name'], $_POST['params']);
|
| 1727 |
|
| 1728 |
if ( $filter_id ){
|
| 1758 |
$msg_class = 'error';
|
| 1759 |
} else {
|
| 1760 |
//Try to delete the filter
|
| 1761 |
+
$blc_link_query = & blcLinkQuery::getInstance();
|
| 1762 |
if ( $blc_link_query->delete_custom_filter($_POST['filter_id']) ){
|
| 1763 |
//Success
|
| 1764 |
$message = __('Filter deleted', 'broken-link-checker');
|
| 1909 |
* @return array Confirmation message and its CSS class.
|
| 1910 |
*/
|
| 1911 |
function do_bulk_delete_sources($selected_links){
|
| 1912 |
+
$blc_container_registry = & blcContainerRegistry::getInstance();
|
| 1913 |
|
| 1914 |
$message = '';
|
| 1915 |
$msg_class = 'updated';
|
| 2489 |
|
| 2490 |
//Only check links that have at least one valid instance (i.e. an instance exists and
|
| 2491 |
//it corresponds to one of the currently loaded container/parser types).
|
| 2492 |
+
$containerRegistry = & blcContainerRegistry::getInstance();
|
| 2493 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 2494 |
$loaded_containers = array_map(array(&$wpdb, 'escape'), $loaded_containers);
|
| 2495 |
$loaded_containers = "'" . implode("', '", $loaded_containers) . "'";
|
| 2496 |
|
| 2497 |
+
$parserRegistry = & blcParserRegistry::getInstance();
|
| 2498 |
$loaded_parsers = array_keys($parserRegistry->get_registered_parsers());
|
| 2499 |
$loaded_parsers = array_map(array(&$wpdb, 'escape'), $loaded_parsers);
|
| 2500 |
$loaded_parsers = "'" . implode("', '", $loaded_parsers) . "'";
|
| 2675 |
*/
|
| 2676 |
function get_status(){
|
| 2677 |
global $wpdb;
|
| 2678 |
+
$blc_link_query = & blcLinkQuery::getInstance();
|
| 2679 |
|
| 2680 |
$check_threshold=date('Y-m-d H:i:s', strtotime('-'.$this->conf->options['check_threshold'].' hours'));
|
| 2681 |
$recheck_threshold=date('Y-m-d H:i:s', time() - $this->conf->options['recheck_threshold']);
|
| 3221 |
'value' => sprintf(__('%s seconds'), ini_get('max_execution_time')),
|
| 3222 |
);
|
| 3223 |
|
| 3224 |
+
//Resynch flag.
|
| 3225 |
+
$debug['Resynch. flag'] = array(
|
| 3226 |
+
'state' => 'ok',
|
| 3227 |
+
'value' => sprintf('%d', $this->conf->options['need_resynch']),
|
| 3228 |
+
);
|
| 3229 |
+
|
| 3230 |
+
//Synch records
|
| 3231 |
+
$synch_records = intval($wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}blc_synch"));
|
| 3232 |
+
$data = array(
|
| 3233 |
+
'state' => 'ok',
|
| 3234 |
+
'value' => sprintf('%d', $synch_records),
|
| 3235 |
+
);
|
| 3236 |
+
if ( $synch_records == 0 ){
|
| 3237 |
+
$data['state'] = 'warning';
|
| 3238 |
+
$data['message'] = __('If this value is zero even after several page reloads you have probably encountered a bug.', 'broken-link-checker');
|
| 3239 |
+
}
|
| 3240 |
+
$debug['Synch. records'] = $data;
|
| 3241 |
+
|
| 3242 |
+
//Total links and instances (including invalid ones)
|
| 3243 |
+
$all_links = intval($wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}blc_links"));
|
| 3244 |
+
$all_instances = intval($wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}blc_instances"));
|
| 3245 |
+
|
| 3246 |
+
//Show the number of unparsed containers. Useful for debugging. For performance,
|
| 3247 |
+
//this is only shown when we have no links/instances yet.
|
| 3248 |
+
if( ($all_links == 0) && ($all_instances == 0) ){
|
| 3249 |
+
$unparsed_items = intval($wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}blc_synch WHERE synched=0"));
|
| 3250 |
+
$debug['Unparsed items'] = array(
|
| 3251 |
+
'state' => 'warning',
|
| 3252 |
+
'value' => $unparsed_items,
|
| 3253 |
+
);
|
| 3254 |
+
}
|
| 3255 |
+
|
| 3256 |
+
//Links & instances
|
| 3257 |
+
if ( ($all_links > 0) && ($all_instances > 0) ){
|
| 3258 |
+
$debug['Link records'] = array(
|
| 3259 |
+
'state' => 'ok',
|
| 3260 |
+
'value' => sprintf('%d (%d)', $all_links, $all_instances),
|
| 3261 |
+
);
|
| 3262 |
+
} else {
|
| 3263 |
+
$debug['Link records'] = array(
|
| 3264 |
+
'state' => 'warning',
|
| 3265 |
+
'value' => sprintf('%d (%d)', $all_links, $all_instances),
|
| 3266 |
+
);
|
| 3267 |
+
}
|
| 3268 |
+
|
| 3269 |
return $debug;
|
| 3270 |
}
|
| 3271 |
|
includes/admin/links-page-js.php
CHANGED
|
@@ -1,9 +1,23 @@
|
|
| 1 |
<script type='text/javascript'>
|
| 2 |
|
| 3 |
function alterLinkCounter(factor){
|
| 4 |
-
cnt = parseInt(jQuery('.current-link-count').eq(0).html());
|
| 5 |
cnt = cnt + factor;
|
| 6 |
jQuery('.current-link-count').html(cnt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
}
|
| 8 |
|
| 9 |
function replaceLinkId(old_id, new_id){
|
|
@@ -385,7 +399,7 @@ jQuery(function($){
|
|
| 385 |
|
| 386 |
//Update the checkbox depending on current settings.
|
| 387 |
<?php
|
| 388 |
-
$conf = blc_get_configuration();
|
| 389 |
if ( $conf->options['highlight_permanent_failures'] ){
|
| 390 |
echo 'highlight_permanent_failures_checkbox.attr("checked", "checked");';
|
| 391 |
} else {
|
| 1 |
<script type='text/javascript'>
|
| 2 |
|
| 3 |
function alterLinkCounter(factor){
|
| 4 |
+
var cnt = parseInt(jQuery('.current-link-count').eq(0).html());
|
| 5 |
cnt = cnt + factor;
|
| 6 |
jQuery('.current-link-count').html(cnt);
|
| 7 |
+
|
| 8 |
+
if ( blc_is_broken_filter ){
|
| 9 |
+
//Update the broken link count displayed beside the "Broken Links" menu
|
| 10 |
+
var menuBubble = jQuery('span.blc-menu-bubble');
|
| 11 |
+
if ( menuBubble.length > 0 ){
|
| 12 |
+
cnt = parseInt(menuBubble.eq(0).html());
|
| 13 |
+
cnt = cnt + factor;
|
| 14 |
+
if ( cnt > 0 ){
|
| 15 |
+
menuBubble.html(cnt);
|
| 16 |
+
} else {
|
| 17 |
+
menuBubble.parent().hide();
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
}
|
| 22 |
|
| 23 |
function replaceLinkId(old_id, new_id){
|
| 399 |
|
| 400 |
//Update the checkbox depending on current settings.
|
| 401 |
<?php
|
| 402 |
+
$conf = & blc_get_configuration();
|
| 403 |
if ( $conf->options['highlight_permanent_failures'] ){
|
| 404 |
echo 'highlight_permanent_failures_checkbox.attr("checked", "checked");';
|
| 405 |
} else {
|
includes/admin/search-form.php
CHANGED
|
@@ -54,7 +54,7 @@
|
|
| 54 |
$search_subfilter = $filter_id;
|
| 55 |
}
|
| 56 |
|
| 57 |
-
$linkQuery = blcLinkQuery::getInstance();
|
| 58 |
foreach ($linkQuery->native_filters as $filter => $data){
|
| 59 |
$selected = ($search_subfilter == $filter)?' selected="selected"':'';
|
| 60 |
printf('<option value="%s"%s>%s</option>', $filter, $selected, $data['name']);
|
| 54 |
$search_subfilter = $filter_id;
|
| 55 |
}
|
| 56 |
|
| 57 |
+
$linkQuery = & blcLinkQuery::getInstance();
|
| 58 |
foreach ($linkQuery->native_filters as $filter => $data){
|
| 59 |
$selected = ($search_subfilter == $filter)?' selected="selected"':'';
|
| 60 |
printf('<option value="%s"%s>%s</option>', $filter, $selected, $data['name']);
|
includes/checkers.php
CHANGED
|
@@ -98,7 +98,7 @@ class blcCheckerRegistry {
|
|
| 98 |
* @param string $url
|
| 99 |
* @return blcChecker|null
|
| 100 |
*/
|
| 101 |
-
function get_checker_for($url){
|
| 102 |
$parsed = @parse_url($url);
|
| 103 |
|
| 104 |
foreach($this->registered_checkers as $checker){
|
|
@@ -129,7 +129,7 @@ function blc_register_checker($class_name){
|
|
| 129 |
* @param string $url The URL that needs to be checked.
|
| 130 |
* @return blcChecker|null
|
| 131 |
*/
|
| 132 |
-
function blc_get_checker_for($url){
|
| 133 |
return $GLOBALS['blc_checker_registry']->get_checker_for($url);
|
| 134 |
}
|
| 135 |
|
| 98 |
* @param string $url
|
| 99 |
* @return blcChecker|null
|
| 100 |
*/
|
| 101 |
+
function &get_checker_for($url){
|
| 102 |
$parsed = @parse_url($url);
|
| 103 |
|
| 104 |
foreach($this->registered_checkers as $checker){
|
| 129 |
* @param string $url The URL that needs to be checked.
|
| 130 |
* @return blcChecker|null
|
| 131 |
*/
|
| 132 |
+
function &blc_get_checker_for($url){
|
| 133 |
return $GLOBALS['blc_checker_registry']->get_checker_for($url);
|
| 134 |
}
|
| 135 |
|
includes/checkers/http.php
CHANGED
|
@@ -81,7 +81,7 @@ class blcCurlHttp extends blcHttpChecker {
|
|
| 81 |
$log = '';
|
| 82 |
|
| 83 |
//Get the BLC configuration. It's used below to set the right timeout values and such.
|
| 84 |
-
$conf = blc_get_configuration();
|
| 85 |
|
| 86 |
//Init curl.
|
| 87 |
$ch = curl_init();
|
|
@@ -235,7 +235,7 @@ class blcSnoopyHttp extends blcHttpChecker {
|
|
| 235 |
$log = '';
|
| 236 |
|
| 237 |
//Get the timeout setting from the BLC configuration.
|
| 238 |
-
$conf = blc_get_configuration();
|
| 239 |
$timeout = $conf->options['timeout'];
|
| 240 |
|
| 241 |
$start_time = microtime_float();
|
| 81 |
$log = '';
|
| 82 |
|
| 83 |
//Get the BLC configuration. It's used below to set the right timeout values and such.
|
| 84 |
+
$conf = & blc_get_configuration();
|
| 85 |
|
| 86 |
//Init curl.
|
| 87 |
$ch = curl_init();
|
| 235 |
$log = '';
|
| 236 |
|
| 237 |
//Get the timeout setting from the BLC configuration.
|
| 238 |
+
$conf = & blc_get_configuration();
|
| 239 |
$timeout = $conf->options['timeout'];
|
| 240 |
|
| 241 |
$start_time = microtime_float();
|
includes/containers.php
CHANGED
|
@@ -35,7 +35,12 @@ class blcContainerRegistry {
|
|
| 35 |
$this->__construct();
|
| 36 |
}
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
static $instance = null;
|
| 40 |
if ( is_null($instance) ){
|
| 41 |
$instance = new blcContainerRegistry;
|
|
@@ -89,7 +94,7 @@ class blcContainerRegistry {
|
|
| 89 |
* @param string $fallback If there is no manager associated with $container_type, return the manager of this container type instead.
|
| 90 |
* @return blcContainerManager|null
|
| 91 |
*/
|
| 92 |
-
function get_manager( $container_type, $fallback = '' ){
|
| 93 |
if ( isset($this->registered_managers[$container_type]) ){
|
| 94 |
return $this->registered_managers[$container_type];
|
| 95 |
} elseif ( !empty($fallback) && isset($this->registered_managers[$fallback]) ) {
|
|
@@ -217,7 +222,7 @@ class blcContainerRegistry {
|
|
| 217 |
|
| 218 |
$results = array();
|
| 219 |
foreach($by_type as $container_type => $entries){
|
| 220 |
-
$manager = $this->get_manager($container_type, $fallback);
|
| 221 |
if ( !is_null($manager) ){
|
| 222 |
$partial_results = $manager->get_containers($entries, $purpose, $load_wrapped_objects);
|
| 223 |
$results = array_merge($results, $partial_results);
|
|
@@ -274,7 +279,7 @@ class blcContainerRegistry {
|
|
| 274 |
* @return string A delete confirmation message, e.g. "5 posts were moved to trash"
|
| 275 |
*/
|
| 276 |
function ui_bulk_delete_message($container_type, $n){
|
| 277 |
-
$manager = $this->get_manager($container_type);
|
| 278 |
if ( is_null($manager) ){
|
| 279 |
return sprintf(__("Container type '%s' not recognized", 'broken-link-checker'), $container_type);
|
| 280 |
} else {
|
|
@@ -284,7 +289,7 @@ class blcContainerRegistry {
|
|
| 284 |
}
|
| 285 |
|
| 286 |
//Init the container registry & make it global
|
| 287 |
-
$GLOBALS['blc_container_registry'] = blcContainerRegistry::getInstance();
|
| 288 |
|
| 289 |
|
| 290 |
|
|
@@ -346,7 +351,7 @@ class blcContainer {
|
|
| 346 |
$field = $this->default_field;
|
| 347 |
}
|
| 348 |
|
| 349 |
-
$w =
|
| 350 |
return $w->$field;
|
| 351 |
}
|
| 352 |
|
|
@@ -362,7 +367,7 @@ class blcContainer {
|
|
| 362 |
* @return bool|WP_Error True on success, an error object if something went wrong.
|
| 363 |
*/
|
| 364 |
function update_field($field, $new_value, $old_value = ''){
|
| 365 |
-
$w =
|
| 366 |
$w->$field = $new_value;
|
| 367 |
return $this->update_wrapped_object();
|
| 368 |
}
|
|
@@ -376,7 +381,7 @@ class blcContainer {
|
|
| 376 |
* @param bool $ensure_consistency Set this to true to ignore the cached $wrapped_object value and retrieve an up-to-date copy of the wrapped object from the DB (or WP's internal cache).
|
| 377 |
* @return object The wrapped object.
|
| 378 |
*/
|
| 379 |
-
function get_wrapped_object($ensure_consistency = false){
|
| 380 |
trigger_error('Function blcContainer::get_wrapped_object() must be over-ridden in a sub-class', E_USER_ERROR);
|
| 381 |
}
|
| 382 |
|
|
@@ -834,7 +839,7 @@ class blcContainerManager {
|
|
| 834 |
* @return bool True if the container was successfully registered, false otherwise.
|
| 835 |
*/
|
| 836 |
function blc_register_container( $container_type, $manager_class ){
|
| 837 |
-
$instance = blcContainerRegistry::getInstance();
|
| 838 |
return $instance->register_container($container_type, $manager_class);
|
| 839 |
}
|
| 840 |
|
|
@@ -845,7 +850,7 @@ function blc_register_container( $container_type, $manager_class ){
|
|
| 845 |
* @return blcContainer|null Returns null if the container type is unrecognized.
|
| 846 |
*/
|
| 847 |
function blc_get_container($container){
|
| 848 |
-
$instance = blcContainerRegistry::getInstance();
|
| 849 |
return $instance->get_container($container);
|
| 850 |
}
|
| 851 |
|
|
@@ -873,7 +878,7 @@ function blc_get_container($container){
|
|
| 873 |
* @return array of blcContainer indexed by 'container_type|container_id'
|
| 874 |
*/
|
| 875 |
function blc_get_containers( $containers, $purpose = '', $load_wrapped_objects = false ){
|
| 876 |
-
$instance = blcContainerRegistry::getInstance();
|
| 877 |
return $instance->get_containers($containers, $purpose, '', $load_wrapped_objects);
|
| 878 |
}
|
| 879 |
|
|
@@ -884,7 +889,7 @@ function blc_get_containers( $containers, $purpose = '', $load_wrapped_objects =
|
|
| 884 |
* @return array of blcContainer
|
| 885 |
*/
|
| 886 |
function blc_get_unsynched_containers($max_results = 0){
|
| 887 |
-
$instance = blcContainerRegistry::getInstance();
|
| 888 |
return $instance->get_unsynched_containers($max_results);
|
| 889 |
}
|
| 890 |
|
|
@@ -896,7 +901,7 @@ function blc_get_unsynched_containers($max_results = 0){
|
|
| 896 |
* @return void
|
| 897 |
*/
|
| 898 |
function blc_resynch_containers($forced = false){
|
| 899 |
-
$instance = blcContainerRegistry::getInstance();
|
| 900 |
$instance->resynch($forced);
|
| 901 |
}
|
| 902 |
|
|
@@ -908,7 +913,7 @@ function blc_resynch_containers($forced = false){
|
|
| 908 |
function blc_cleanup_containers(){
|
| 909 |
global $wpdb;
|
| 910 |
|
| 911 |
-
$containerRegistry = blcContainerRegistry::getInstance();
|
| 912 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 913 |
$loaded_containers = array_map(array(&$wpdb, 'escape'), $loaded_containers);
|
| 914 |
$loaded_containers = "'" . implode("', '", $loaded_containers) . "'";
|
| 35 |
$this->__construct();
|
| 36 |
}
|
| 37 |
|
| 38 |
+
/**
|
| 39 |
+
* Return a singleton instance of this class.
|
| 40 |
+
*
|
| 41 |
+
* @return blcContainerRegistry
|
| 42 |
+
*/
|
| 43 |
+
function &getInstance(){
|
| 44 |
static $instance = null;
|
| 45 |
if ( is_null($instance) ){
|
| 46 |
$instance = new blcContainerRegistry;
|
| 94 |
* @param string $fallback If there is no manager associated with $container_type, return the manager of this container type instead.
|
| 95 |
* @return blcContainerManager|null
|
| 96 |
*/
|
| 97 |
+
function &get_manager( $container_type, $fallback = '' ){
|
| 98 |
if ( isset($this->registered_managers[$container_type]) ){
|
| 99 |
return $this->registered_managers[$container_type];
|
| 100 |
} elseif ( !empty($fallback) && isset($this->registered_managers[$fallback]) ) {
|
| 222 |
|
| 223 |
$results = array();
|
| 224 |
foreach($by_type as $container_type => $entries){
|
| 225 |
+
$manager = & $this->get_manager($container_type, $fallback);
|
| 226 |
if ( !is_null($manager) ){
|
| 227 |
$partial_results = $manager->get_containers($entries, $purpose, $load_wrapped_objects);
|
| 228 |
$results = array_merge($results, $partial_results);
|
| 279 |
* @return string A delete confirmation message, e.g. "5 posts were moved to trash"
|
| 280 |
*/
|
| 281 |
function ui_bulk_delete_message($container_type, $n){
|
| 282 |
+
$manager = & $this->get_manager($container_type);
|
| 283 |
if ( is_null($manager) ){
|
| 284 |
return sprintf(__("Container type '%s' not recognized", 'broken-link-checker'), $container_type);
|
| 285 |
} else {
|
| 289 |
}
|
| 290 |
|
| 291 |
//Init the container registry & make it global
|
| 292 |
+
$GLOBALS['blc_container_registry'] = & blcContainerRegistry::getInstance();
|
| 293 |
|
| 294 |
|
| 295 |
|
| 351 |
$field = $this->default_field;
|
| 352 |
}
|
| 353 |
|
| 354 |
+
$w = &$this->get_wrapped_object();
|
| 355 |
return $w->$field;
|
| 356 |
}
|
| 357 |
|
| 367 |
* @return bool|WP_Error True on success, an error object if something went wrong.
|
| 368 |
*/
|
| 369 |
function update_field($field, $new_value, $old_value = ''){
|
| 370 |
+
$w = &$this->get_wrapped_object();
|
| 371 |
$w->$field = $new_value;
|
| 372 |
return $this->update_wrapped_object();
|
| 373 |
}
|
| 381 |
* @param bool $ensure_consistency Set this to true to ignore the cached $wrapped_object value and retrieve an up-to-date copy of the wrapped object from the DB (or WP's internal cache).
|
| 382 |
* @return object The wrapped object.
|
| 383 |
*/
|
| 384 |
+
function &get_wrapped_object($ensure_consistency = false){
|
| 385 |
trigger_error('Function blcContainer::get_wrapped_object() must be over-ridden in a sub-class', E_USER_ERROR);
|
| 386 |
}
|
| 387 |
|
| 839 |
* @return bool True if the container was successfully registered, false otherwise.
|
| 840 |
*/
|
| 841 |
function blc_register_container( $container_type, $manager_class ){
|
| 842 |
+
$instance = & blcContainerRegistry::getInstance();
|
| 843 |
return $instance->register_container($container_type, $manager_class);
|
| 844 |
}
|
| 845 |
|
| 850 |
* @return blcContainer|null Returns null if the container type is unrecognized.
|
| 851 |
*/
|
| 852 |
function blc_get_container($container){
|
| 853 |
+
$instance = & blcContainerRegistry::getInstance();
|
| 854 |
return $instance->get_container($container);
|
| 855 |
}
|
| 856 |
|
| 878 |
* @return array of blcContainer indexed by 'container_type|container_id'
|
| 879 |
*/
|
| 880 |
function blc_get_containers( $containers, $purpose = '', $load_wrapped_objects = false ){
|
| 881 |
+
$instance = & blcContainerRegistry::getInstance();
|
| 882 |
return $instance->get_containers($containers, $purpose, '', $load_wrapped_objects);
|
| 883 |
}
|
| 884 |
|
| 889 |
* @return array of blcContainer
|
| 890 |
*/
|
| 891 |
function blc_get_unsynched_containers($max_results = 0){
|
| 892 |
+
$instance = & blcContainerRegistry::getInstance();
|
| 893 |
return $instance->get_unsynched_containers($max_results);
|
| 894 |
}
|
| 895 |
|
| 901 |
* @return void
|
| 902 |
*/
|
| 903 |
function blc_resynch_containers($forced = false){
|
| 904 |
+
$instance = & blcContainerRegistry::getInstance();
|
| 905 |
$instance->resynch($forced);
|
| 906 |
}
|
| 907 |
|
| 913 |
function blc_cleanup_containers(){
|
| 914 |
global $wpdb;
|
| 915 |
|
| 916 |
+
$containerRegistry = & blcContainerRegistry::getInstance();
|
| 917 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 918 |
$loaded_containers = array_map(array(&$wpdb, 'escape'), $loaded_containers);
|
| 919 |
$loaded_containers = "'" . implode("', '", $loaded_containers) . "'";
|
includes/containers/blogroll.php
CHANGED
|
@@ -54,9 +54,9 @@ class blcBookmark extends blcContainer{
|
|
| 54 |
* @param bool $ensure_consistency Set this to true to ignore the cached $wrapped_object value and retrieve an up-to-date copy of the wrapped object from the DB (or WP's internal cache).
|
| 55 |
* @return object Bookmark data.
|
| 56 |
*/
|
| 57 |
-
function get_wrapped_object($ensure_consistency = false){
|
| 58 |
if( $ensure_consistency || is_null($this->wrapped_object) ){
|
| 59 |
-
$this->wrapped_object = get_bookmark($this->container_id);
|
| 60 |
}
|
| 61 |
return $this->wrapped_object;
|
| 62 |
}
|
| 54 |
* @param bool $ensure_consistency Set this to true to ignore the cached $wrapped_object value and retrieve an up-to-date copy of the wrapped object from the DB (or WP's internal cache).
|
| 55 |
* @return object Bookmark data.
|
| 56 |
*/
|
| 57 |
+
function &get_wrapped_object($ensure_consistency = false){
|
| 58 |
if( $ensure_consistency || is_null($this->wrapped_object) ){
|
| 59 |
+
$this->wrapped_object = &get_bookmark($this->container_id);
|
| 60 |
}
|
| 61 |
return $this->wrapped_object;
|
| 62 |
}
|
includes/containers/comment.php
CHANGED
|
@@ -15,9 +15,9 @@ class blcComment extends blcContainer{
|
|
| 15 |
* @param bool $ensure_consistency
|
| 16 |
* @return object The comment.
|
| 17 |
*/
|
| 18 |
-
function get_wrapped_object($ensure_consistency = false){
|
| 19 |
if( $ensure_consistency || is_null($this->wrapped_object) ){
|
| 20 |
-
$this->wrapped_object = get_comment($this->container_id);
|
| 21 |
}
|
| 22 |
return $this->wrapped_object;
|
| 23 |
}
|
|
@@ -38,6 +38,7 @@ class blcComment extends blcContainer{
|
|
| 38 |
}
|
| 39 |
|
| 40 |
$data = (array)$this->wrapped_object;
|
|
|
|
| 41 |
if ( wp_update_comment($data) ){
|
| 42 |
return true;
|
| 43 |
} else {
|
| 15 |
* @param bool $ensure_consistency
|
| 16 |
* @return object The comment.
|
| 17 |
*/
|
| 18 |
+
function &get_wrapped_object($ensure_consistency = false){
|
| 19 |
if( $ensure_consistency || is_null($this->wrapped_object) ){
|
| 20 |
+
$this->wrapped_object = &get_comment($this->container_id);
|
| 21 |
}
|
| 22 |
return $this->wrapped_object;
|
| 23 |
}
|
| 38 |
}
|
| 39 |
|
| 40 |
$data = (array)$this->wrapped_object;
|
| 41 |
+
//FB::info($data, sprintf("Attempting to update comment %d with data", $this->container_id));
|
| 42 |
if ( wp_update_comment($data) ){
|
| 43 |
return true;
|
| 44 |
} else {
|
includes/containers/custom_field.php
CHANGED
|
@@ -347,7 +347,7 @@ class blcPostMetaManager extends blcContainerManager {
|
|
| 347 |
//Set up the parseable fields
|
| 348 |
$fields = array();
|
| 349 |
|
| 350 |
-
$conf = blc_get_configuration();
|
| 351 |
if ( is_array($conf->options['custom_fields']) ){
|
| 352 |
foreach($conf->options['custom_fields'] as $meta_name){
|
| 353 |
$fields[$meta_name] = 'metadata';
|
|
@@ -481,7 +481,7 @@ class blcPostMetaManager extends blcContainerManager {
|
|
| 481 |
|
| 482 |
//Metadata changes only matter to us if the modified key
|
| 483 |
//is one that the user wants checked.
|
| 484 |
-
$conf = blc_get_configuration();
|
| 485 |
if ( !is_array($conf->options['custom_fields']) ){
|
| 486 |
return;
|
| 487 |
}
|
| 347 |
//Set up the parseable fields
|
| 348 |
$fields = array();
|
| 349 |
|
| 350 |
+
$conf = & blc_get_configuration();
|
| 351 |
if ( is_array($conf->options['custom_fields']) ){
|
| 352 |
foreach($conf->options['custom_fields'] as $meta_name){
|
| 353 |
$fields[$meta_name] = 'metadata';
|
| 481 |
|
| 482 |
//Metadata changes only matter to us if the modified key
|
| 483 |
//is one that the user wants checked.
|
| 484 |
+
$conf = & blc_get_configuration();
|
| 485 |
if ( !is_array($conf->options['custom_fields']) ){
|
| 486 |
return;
|
| 487 |
}
|
includes/containers/post.php
CHANGED
|
@@ -121,9 +121,9 @@ class blcPostContainer extends blcContainer {
|
|
| 121 |
* @param bool $ensure_consistency Set this to true to ignore the cached $wrapped_object value and retrieve an up-to-date copy of the wrapped object from the DB (or WP's internal cache).
|
| 122 |
* @return object Post data.
|
| 123 |
*/
|
| 124 |
-
function get_wrapped_object($ensure_consistency = false){
|
| 125 |
if( $ensure_consistency || is_null($this->wrapped_object) ){
|
| 126 |
-
$this->wrapped_object = get_post($this->container_id);
|
| 127 |
}
|
| 128 |
return $this->wrapped_object;
|
| 129 |
}
|
|
@@ -208,7 +208,7 @@ class blcPostContainerManager extends blcContainerManager {
|
|
| 208 |
add_action('untrash_post', array(&$this,'post_saved'));
|
| 209 |
|
| 210 |
//Highlight and nofollow broken links in posts & pages
|
| 211 |
-
$this->_conf = blc_get_configuration();
|
| 212 |
if ( $this->_conf->options['mark_broken_links'] || $this->_conf->options['nofollow_broken_links'] ){
|
| 213 |
add_filter( 'the_content', array(&$this,'hook_the_content') );
|
| 214 |
if ( $this->_conf->options['mark_broken_links'] && !empty( $this->_conf->options['broken_link_css'] ) ){
|
|
@@ -398,7 +398,7 @@ class blcPostContainerManager extends blcContainerManager {
|
|
| 398 |
}
|
| 399 |
|
| 400 |
//Iterate over all HTML links and modify the broken ones
|
| 401 |
-
$parser = blc_get_parser('link');
|
| 402 |
$content = $parser->multi_edit($content, array(&$this, 'highlight_broken_link'), $broken_link_urls);
|
| 403 |
|
| 404 |
return $content;
|
|
@@ -454,7 +454,7 @@ class blcPostContainerManager extends blcContainerManager {
|
|
| 454 |
* @return void
|
| 455 |
*/
|
| 456 |
function hook_wp_head(){
|
| 457 |
-
$conf = blc_get_configuration();
|
| 458 |
echo '<style type="text/css">',$conf->options['broken_link_css'],'</style>';
|
| 459 |
}
|
| 460 |
}
|
| 121 |
* @param bool $ensure_consistency Set this to true to ignore the cached $wrapped_object value and retrieve an up-to-date copy of the wrapped object from the DB (or WP's internal cache).
|
| 122 |
* @return object Post data.
|
| 123 |
*/
|
| 124 |
+
function &get_wrapped_object($ensure_consistency = false){
|
| 125 |
if( $ensure_consistency || is_null($this->wrapped_object) ){
|
| 126 |
+
$this->wrapped_object = &get_post($this->container_id);
|
| 127 |
}
|
| 128 |
return $this->wrapped_object;
|
| 129 |
}
|
| 208 |
add_action('untrash_post', array(&$this,'post_saved'));
|
| 209 |
|
| 210 |
//Highlight and nofollow broken links in posts & pages
|
| 211 |
+
$this->_conf = & blc_get_configuration();
|
| 212 |
if ( $this->_conf->options['mark_broken_links'] || $this->_conf->options['nofollow_broken_links'] ){
|
| 213 |
add_filter( 'the_content', array(&$this,'hook_the_content') );
|
| 214 |
if ( $this->_conf->options['mark_broken_links'] && !empty( $this->_conf->options['broken_link_css'] ) ){
|
| 398 |
}
|
| 399 |
|
| 400 |
//Iterate over all HTML links and modify the broken ones
|
| 401 |
+
$parser = &blc_get_parser('link');
|
| 402 |
$content = $parser->multi_edit($content, array(&$this, 'highlight_broken_link'), $broken_link_urls);
|
| 403 |
|
| 404 |
return $content;
|
| 454 |
* @return void
|
| 455 |
*/
|
| 456 |
function hook_wp_head(){
|
| 457 |
+
$conf = & blc_get_configuration();
|
| 458 |
echo '<style type="text/css">',$conf->options['broken_link_css'],'</style>';
|
| 459 |
}
|
| 460 |
}
|
includes/instances.php
CHANGED
|
@@ -310,9 +310,9 @@ class blcLinkInstance {
|
|
| 310 |
*
|
| 311 |
* @return blcContainer|null
|
| 312 |
*/
|
| 313 |
-
function get_container(){
|
| 314 |
if( is_null($this->_container) ){
|
| 315 |
-
$this->_container = blc_get_container( array($this->container_type, $this->container_id) );
|
| 316 |
}
|
| 317 |
|
| 318 |
return $this->_container;
|
|
@@ -344,9 +344,9 @@ class blcLinkInstance {
|
|
| 344 |
*
|
| 345 |
* @return blcParser|null
|
| 346 |
*/
|
| 347 |
-
function get_parser(){
|
| 348 |
if ( is_null($this->_parser) ){
|
| 349 |
-
$this->_parser = blc_get_parser($this->parser_type);
|
| 350 |
}
|
| 351 |
|
| 352 |
return $this->_parser;
|
|
@@ -373,7 +373,7 @@ class blcLinkInstance {
|
|
| 373 |
*
|
| 374 |
* @return blcLink|null
|
| 375 |
*/
|
| 376 |
-
function get_link(){
|
| 377 |
if ( !is_null($this->_link) ){
|
| 378 |
return $this->_link;
|
| 379 |
}
|
|
@@ -482,9 +482,9 @@ function blc_get_instances( $link_ids, $purpose = '', $load_containers = false,
|
|
| 482 |
|
| 483 |
//Skip instances that reference containers or parsers that aren't currently loaded
|
| 484 |
if ( !$include_invalid ){
|
| 485 |
-
$containerRegistry = blcContainerRegistry::getInstance();
|
| 486 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 487 |
-
$parserRegistry = blcParserRegistry::getInstance();
|
| 488 |
$loaded_parsers = array_keys($parserRegistry->get_registered_parsers());
|
| 489 |
|
| 490 |
$loaded_containers = array_map(array(&$wpdb, 'escape'), $loaded_containers);
|
|
@@ -550,9 +550,9 @@ function blc_get_usable_instance_count(){
|
|
| 550 |
$q = "SELECT COUNT(instance_id) FROM {$wpdb->prefix}blc_instances WHERE 1";
|
| 551 |
|
| 552 |
//Skip instances that reference containers or parsers that aren't currently loaded
|
| 553 |
-
$containerRegistry = blcContainerRegistry::getInstance();
|
| 554 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 555 |
-
$parserRegistry = blcParserRegistry::getInstance();
|
| 556 |
$loaded_parsers = array_keys($parserRegistry->get_registered_parsers());
|
| 557 |
|
| 558 |
$loaded_containers = array_map(array(&$wpdb, 'escape'), $loaded_containers);
|
|
@@ -581,9 +581,9 @@ function blc_cleanup_instances(){
|
|
| 581 |
synch.container_id IS NULL";
|
| 582 |
$rez = $wpdb->query($q);
|
| 583 |
|
| 584 |
-
$containerRegistry = blcContainerRegistry::getInstance();
|
| 585 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 586 |
-
$parserRegistry = blcParserRegistry::getInstance();
|
| 587 |
$loaded_parsers = array_keys($parserRegistry->get_registered_parsers());
|
| 588 |
|
| 589 |
$loaded_containers = array_map(array(&$wpdb, 'escape'), $loaded_containers);
|
| 310 |
*
|
| 311 |
* @return blcContainer|null
|
| 312 |
*/
|
| 313 |
+
function &get_container(){
|
| 314 |
if( is_null($this->_container) ){
|
| 315 |
+
$this->_container = & blc_get_container( array($this->container_type, $this->container_id) );
|
| 316 |
}
|
| 317 |
|
| 318 |
return $this->_container;
|
| 344 |
*
|
| 345 |
* @return blcParser|null
|
| 346 |
*/
|
| 347 |
+
function &get_parser(){
|
| 348 |
if ( is_null($this->_parser) ){
|
| 349 |
+
$this->_parser = & blc_get_parser($this->parser_type);
|
| 350 |
}
|
| 351 |
|
| 352 |
return $this->_parser;
|
| 373 |
*
|
| 374 |
* @return blcLink|null
|
| 375 |
*/
|
| 376 |
+
function &get_link(){
|
| 377 |
if ( !is_null($this->_link) ){
|
| 378 |
return $this->_link;
|
| 379 |
}
|
| 482 |
|
| 483 |
//Skip instances that reference containers or parsers that aren't currently loaded
|
| 484 |
if ( !$include_invalid ){
|
| 485 |
+
$containerRegistry = & blcContainerRegistry::getInstance();
|
| 486 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 487 |
+
$parserRegistry = & blcParserRegistry::getInstance();
|
| 488 |
$loaded_parsers = array_keys($parserRegistry->get_registered_parsers());
|
| 489 |
|
| 490 |
$loaded_containers = array_map(array(&$wpdb, 'escape'), $loaded_containers);
|
| 550 |
$q = "SELECT COUNT(instance_id) FROM {$wpdb->prefix}blc_instances WHERE 1";
|
| 551 |
|
| 552 |
//Skip instances that reference containers or parsers that aren't currently loaded
|
| 553 |
+
$containerRegistry = & blcContainerRegistry::getInstance();
|
| 554 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 555 |
+
$parserRegistry = & blcParserRegistry::getInstance();
|
| 556 |
$loaded_parsers = array_keys($parserRegistry->get_registered_parsers());
|
| 557 |
|
| 558 |
$loaded_containers = array_map(array(&$wpdb, 'escape'), $loaded_containers);
|
| 581 |
synch.container_id IS NULL";
|
| 582 |
$rez = $wpdb->query($q);
|
| 583 |
|
| 584 |
+
$containerRegistry = & blcContainerRegistry::getInstance();
|
| 585 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 586 |
+
$parserRegistry = & blcParserRegistry::getInstance();
|
| 587 |
$loaded_parsers = array_keys($parserRegistry->get_registered_parsers());
|
| 588 |
|
| 589 |
$loaded_containers = array_map(array(&$wpdb, 'escape'), $loaded_containers);
|
includes/links.php
CHANGED
|
@@ -186,7 +186,7 @@ class blcLink {
|
|
| 186 |
);
|
| 187 |
|
| 188 |
|
| 189 |
-
$checker = blc_get_checker_for($this->url);
|
| 190 |
|
| 191 |
if ( is_null($checker) ){
|
| 192 |
//Oops, there are no checker implementations that can handle this link.
|
|
@@ -823,7 +823,7 @@ class blcLinkQuery {
|
|
| 823 |
$this->__construct();
|
| 824 |
}
|
| 825 |
|
| 826 |
-
function getInstance(){
|
| 827 |
static $instance = null;
|
| 828 |
if ( is_null($instance) ){
|
| 829 |
$instance = new blcLinkQuery;
|
|
@@ -1011,9 +1011,9 @@ class blcLinkQuery {
|
|
| 1011 |
if ( empty($params['include_invalid']) ){
|
| 1012 |
$join_instances = true;
|
| 1013 |
|
| 1014 |
-
$containerRegistry = blcContainerRegistry::getInstance();
|
| 1015 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 1016 |
-
$parserRegistry = blcParserRegistry::getInstance();
|
| 1017 |
$loaded_parsers = array_keys($parserRegistry->get_registered_parsers());
|
| 1018 |
|
| 1019 |
if ( empty($s_parser_type) ){
|
|
@@ -1379,7 +1379,7 @@ class blcLinkQuery {
|
|
| 1379 |
* @return int|array Either an array of blcLink objects, or the number of results for the query.
|
| 1380 |
*/
|
| 1381 |
function blc_get_links($params = null){
|
| 1382 |
-
$instance = blcLinkQuery::getInstance();
|
| 1383 |
return $instance->get_links($params, $purpose);
|
| 1384 |
}
|
| 1385 |
|
| 186 |
);
|
| 187 |
|
| 188 |
|
| 189 |
+
$checker = & blc_get_checker_for($this->url);
|
| 190 |
|
| 191 |
if ( is_null($checker) ){
|
| 192 |
//Oops, there are no checker implementations that can handle this link.
|
| 823 |
$this->__construct();
|
| 824 |
}
|
| 825 |
|
| 826 |
+
function &getInstance(){
|
| 827 |
static $instance = null;
|
| 828 |
if ( is_null($instance) ){
|
| 829 |
$instance = new blcLinkQuery;
|
| 1011 |
if ( empty($params['include_invalid']) ){
|
| 1012 |
$join_instances = true;
|
| 1013 |
|
| 1014 |
+
$containerRegistry = & blcContainerRegistry::getInstance();
|
| 1015 |
$loaded_containers = array_keys($containerRegistry->get_registered_containers());
|
| 1016 |
+
$parserRegistry = & blcParserRegistry::getInstance();
|
| 1017 |
$loaded_parsers = array_keys($parserRegistry->get_registered_parsers());
|
| 1018 |
|
| 1019 |
if ( empty($s_parser_type) ){
|
| 1379 |
* @return int|array Either an array of blcLink objects, or the number of results for the query.
|
| 1380 |
*/
|
| 1381 |
function blc_get_links($params = null){
|
| 1382 |
+
$instance = & blcLinkQuery::getInstance();
|
| 1383 |
return $instance->get_links($params, $purpose);
|
| 1384 |
}
|
| 1385 |
|
includes/parsers.php
CHANGED
|
@@ -20,7 +20,7 @@ class blcParserRegistry {
|
|
| 20 |
*
|
| 21 |
* @return blcParserRegistry
|
| 22 |
*/
|
| 23 |
-
function getInstance(){
|
| 24 |
static $instance = null;
|
| 25 |
if ( is_null($instance) ){
|
| 26 |
$instance = new blcParserRegistry;
|
|
@@ -61,7 +61,7 @@ class blcParserRegistry {
|
|
| 61 |
* @param string $parser_type
|
| 62 |
* @return blcParser|null
|
| 63 |
*/
|
| 64 |
-
function get_parser( $parser_type ){
|
| 65 |
if ( isset($this->registered_parsers[$parser_type]) ){
|
| 66 |
return $this->registered_parsers[$parser_type];
|
| 67 |
} else {
|
|
@@ -92,7 +92,7 @@ class blcParserRegistry {
|
|
| 92 |
}
|
| 93 |
|
| 94 |
//Create the parser registry singleton.
|
| 95 |
-
$GLOBALS['blc_parser_registry'] = blcParserRegistry::getInstance();
|
| 96 |
|
| 97 |
|
| 98 |
/**
|
|
@@ -343,7 +343,7 @@ class blcParser {
|
|
| 343 |
* @return bool
|
| 344 |
*/
|
| 345 |
function blc_register_parser( $parser_type, $class_name ) {
|
| 346 |
-
$instance = blcParserRegistry::getInstance();
|
| 347 |
return $instance->register_parser($parser_type, $class_name);
|
| 348 |
}
|
| 349 |
|
|
@@ -355,8 +355,8 @@ function blc_register_parser( $parser_type, $class_name ) {
|
|
| 355 |
* @param string $parser_type
|
| 356 |
* @return blcParser|null
|
| 357 |
*/
|
| 358 |
-
function blc_get_parser( $parser_type ){
|
| 359 |
-
$instance = blcParserRegistry::getInstance();
|
| 360 |
return $instance->get_parser($parser_type);
|
| 361 |
}
|
| 362 |
|
|
@@ -370,7 +370,7 @@ function blc_get_parser( $parser_type ){
|
|
| 370 |
* @return array of blcParser
|
| 371 |
*/
|
| 372 |
function blc_get_parsers( $format, $container_type ){
|
| 373 |
-
$instance = blcParserRegistry::getInstance();
|
| 374 |
return $instance->get_parsers($format, $container_type);
|
| 375 |
}
|
| 376 |
|
| 20 |
*
|
| 21 |
* @return blcParserRegistry
|
| 22 |
*/
|
| 23 |
+
function &getInstance(){
|
| 24 |
static $instance = null;
|
| 25 |
if ( is_null($instance) ){
|
| 26 |
$instance = new blcParserRegistry;
|
| 61 |
* @param string $parser_type
|
| 62 |
* @return blcParser|null
|
| 63 |
*/
|
| 64 |
+
function &get_parser( $parser_type ){
|
| 65 |
if ( isset($this->registered_parsers[$parser_type]) ){
|
| 66 |
return $this->registered_parsers[$parser_type];
|
| 67 |
} else {
|
| 92 |
}
|
| 93 |
|
| 94 |
//Create the parser registry singleton.
|
| 95 |
+
$GLOBALS['blc_parser_registry'] = & blcParserRegistry::getInstance();
|
| 96 |
|
| 97 |
|
| 98 |
/**
|
| 343 |
* @return bool
|
| 344 |
*/
|
| 345 |
function blc_register_parser( $parser_type, $class_name ) {
|
| 346 |
+
$instance = & blcParserRegistry::getInstance();
|
| 347 |
return $instance->register_parser($parser_type, $class_name);
|
| 348 |
}
|
| 349 |
|
| 355 |
* @param string $parser_type
|
| 356 |
* @return blcParser|null
|
| 357 |
*/
|
| 358 |
+
function &blc_get_parser( $parser_type ){
|
| 359 |
+
$instance = & blcParserRegistry::getInstance();
|
| 360 |
return $instance->get_parser($parser_type);
|
| 361 |
}
|
| 362 |
|
| 370 |
* @return array of blcParser
|
| 371 |
*/
|
| 372 |
function blc_get_parsers( $format, $container_type ){
|
| 373 |
+
$instance = & blcParserRegistry::getInstance();
|
| 374 |
return $instance->get_parsers($format, $container_type);
|
| 375 |
}
|
| 376 |
|
includes/parsers/html_link.php
CHANGED
|
@@ -166,7 +166,7 @@ class blcHTMLLink extends blcParser {
|
|
| 166 |
return $link['#raw'];
|
| 167 |
}
|
| 168 |
|
| 169 |
-
$config = blc_get_configuration();
|
| 170 |
if ( $config->options['mark_removed_links'] ){
|
| 171 |
//Leave only the anchor text + the removed_link CSS class
|
| 172 |
return '<span class="removed_link">' . $link['#link_text'] . '</span>';
|
| 166 |
return $link['#raw'];
|
| 167 |
}
|
| 168 |
|
| 169 |
+
$config = & blc_get_configuration();
|
| 170 |
if ( $config->options['mark_removed_links'] ){
|
| 171 |
//Leave only the anchor text + the removed_link CSS class
|
| 172 |
return '<span class="removed_link">' . $link['#link_text'] . '</span>';
|
readme.txt
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
=== Broken Link Checker ===
|
| 2 |
Contributors: whiteshadow
|
|
|
|
| 3 |
Tags: links, broken, maintenance, blogroll, custom fields, admin, comments, posts
|
| 4 |
Requires at least: 2.9.0
|
| 5 |
Tested up to: 3.0
|
| 6 |
-
Stable tag: 0.9.4.
|
| 7 |
|
| 8 |
This plugin will check your posts, comments and other places for broken links and missing images and notify you if any are found.
|
| 9 |
|
|
@@ -78,6 +79,25 @@ To upgrade your installation
|
|
| 78 |
|
| 79 |
*This is an automatically generated changelog*
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
= 0.9.4 =
|
| 82 |
* Fixed missing post and comment edit links in email notifications.
|
| 83 |
* Updated Danish translation.
|
|
@@ -405,3 +425,7 @@ To upgrade your installation
|
|
| 405 |
= 0.1 =
|
| 406 |
* *There are no release notes for this version*
|
| 407 |
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
=== Broken Link Checker ===
|
| 2 |
Contributors: whiteshadow
|
| 3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A6P9S6CE3SRSW
|
| 4 |
Tags: links, broken, maintenance, blogroll, custom fields, admin, comments, posts
|
| 5 |
Requires at least: 2.9.0
|
| 6 |
Tested up to: 3.0
|
| 7 |
+
Stable tag: 0.9.4.4
|
| 8 |
|
| 9 |
This plugin will check your posts, comments and other places for broken links and missing images and notify you if any are found.
|
| 10 |
|
| 79 |
|
| 80 |
*This is an automatically generated changelog*
|
| 81 |
|
| 82 |
+
= 0.9.4.4 =
|
| 83 |
+
* Fixed "Edit URL" and "Unlink" not working on PHP4 servers.
|
| 84 |
+
|
| 85 |
+
= 0.9.4.3 =
|
| 86 |
+
* Another PHP 4 fix. Considering dropping support for PHP4 in light of the counterintuitive workarounds required to make perfectly valid PHP5 code work in that ghastly thing.
|
| 87 |
+
* Added a partial workaround for sites that have use strange DB\_CHARSET settings.
|
| 88 |
+
|
| 89 |
+
= 0.9.4.2 =
|
| 90 |
+
* Added more debugging data to the "Show debug info" table.
|
| 91 |
+
* Added missing indexes to the instance table.
|
| 92 |
+
* Yet more PHP4 compatibility fixes.
|
| 93 |
+
* Added a notification bubble with the current number of broken links to the Tools -> Broken Links menu item.
|
| 94 |
+
|
| 95 |
+
= 0.9.4.1 =
|
| 96 |
+
* Fixed PHP 4 incompatibilities introduced in the previous release.
|
| 97 |
+
* Fixed bulk unlink.
|
| 98 |
+
* Updated Italian translation.
|
| 99 |
+
* Updated Danish translation.
|
| 100 |
+
|
| 101 |
= 0.9.4 =
|
| 102 |
* Fixed missing post and comment edit links in email notifications.
|
| 103 |
* Updated Danish translation.
|
| 425 |
= 0.1 =
|
| 426 |
* *There are no release notes for this version*
|
| 427 |
|
| 428 |
+
== Upgrade Notice ==
|
| 429 |
+
|
| 430 |
+
= 0.9.4.2 =
|
| 431 |
+
Fixes a major PHP4 compatibility problem introduced in version 0.9.4 and adds a notification bubble with the current broken link count to the "Broken Links" menu.
|
