Broken Link Checker - Version 1.5.2

Version Description

  • A few minor comment fixes.
  • Move certain styles to a separate CSS file, which is where they belong.
  • Replace the ThemeFuse banner with one from ManageWP (will go live on June 5).
  • Instead of displaying several plugins in the "More plugins by Janis Elsts" box, sometimes display just one plugin (AME).
Download this release

Release Info

Developer whiteshadow
Plugin Icon 128x128 Broken Link Checker
Version 1.5.2
Comparing to
See all releases

Code changes from version 1.5.1 to 1.5.2

broken-link-checker.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Broken Link Checker
4
  Plugin URI: http://w-shadow.com/blog/2007/08/05/broken-link-checker-for-wordpress/
5
  Description: Checks your blog for broken links and missing images and notifies you on the dashboard if any are found.
6
- Version: 1.5.1
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/blog/
9
  Text Domain: broken-link-checker
3
  Plugin Name: Broken Link Checker
4
  Plugin URI: http://w-shadow.com/blog/2007/08/05/broken-link-checker-for-wordpress/
5
  Description: Checks your blog for broken links and missing images and notifies you on the dashboard if any are found.
6
+ Version: 1.5.2
7
  Author: Janis Elsts
8
  Author URI: http://w-shadow.com/blog/
9
  Text Domain: broken-link-checker
core/core.php CHANGED
@@ -1149,7 +1149,7 @@ class wsBrokenLinkChecker {
1149
  * @return void
1150
  */
1151
  function options_page_css(){
1152
- wp_enqueue_style('blc-options-page', plugins_url('css/options-page.css', BLC_PLUGIN_FILE), array(), '0.9.7' );
1153
  wp_enqueue_style('dashboard');
1154
  }
1155
 
1149
  * @return void
1150
  */
1151
  function options_page_css(){
1152
+ wp_enqueue_style('blc-options-page', plugins_url('css/options-page.css', BLC_PLUGIN_FILE), array(), '20120527' );
1153
  wp_enqueue_style('dashboard');
1154
  }
1155
 
core/init.php CHANGED
@@ -108,7 +108,7 @@ $blc_config_manager = new blcConfigurationManager(
108
  //recovered after this many days.
109
 
110
  'installation_complete' => false,
111
- 'user_has_donated' => true, //Whether the user has donated to the plugin.
112
  )
113
  );
114
 
108
  //recovered after this many days.
109
 
110
  'installation_complete' => false,
111
+ 'user_has_donated' => false, //Whether the user has donated to the plugin.
112
  )
113
  );
114
 
css/options-page.css CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  #blc-sidebar {
2
  clear: right;
3
  float: right;
@@ -25,6 +29,28 @@
25
  color: green;
26
  }
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  #link_checker_options .form-table th {
30
  width: 25%;
1
+ /*
2
+ Sidebar
3
+ */
4
+
5
  #blc-sidebar {
6
  clear: right;
7
  float: right;
29
  color: green;
30
  }
31
 
32
+ #advertising .inside {
33
+ text-align: left;
34
+ }
35
+
36
+ .ws-ame-ad-copy {
37
+ font-size: 1.2em;
38
+ font-style: italic;
39
+ }
40
+ .ws-ame-ad-link {
41
+ font-size: 1.1em;
42
+ font-weight: bold;
43
+ }
44
+
45
+ #themefuse-ad .inside,
46
+ #managewp-ad .inside
47
+ {
48
+ padding: 2px 0 0 0;
49
+ margin: 0;
50
+ text-align: center;
51
+ }
52
+
53
+
54
 
55
  #link_checker_options .form-table th {
56
  width: 25%;
includes/admin/db-upgrade.php CHANGED
@@ -7,7 +7,7 @@ class blcDatabaseUpgrader {
7
  *
8
  * @return bool
9
  */
10
- function upgrade_database(){
11
  global $wpdb, $blclog;
12
 
13
  $conf = blc_get_configuration();
@@ -162,7 +162,7 @@ class blcTableDelta {
162
  * @param bool $drop_indexes Whether to drop indexes not present in the input. Defaults to true.
163
  * @return array
164
  */
165
- function delta($queries, $execute = true, $drop_columns = true, $drop_indexes = true){
166
  global $wpdb;
167
 
168
  // Separate individual queries into an array
7
  *
8
  * @return bool
9
  */
10
+ public static function upgrade_database(){
11
  global $wpdb, $blclog;
12
 
13
  $conf = blc_get_configuration();
162
  * @param bool $drop_indexes Whether to drop indexes not present in the input. Defaults to true.
163
  * @return array
164
  */
165
+ static function delta($queries, $execute = true, $drop_columns = true, $drop_indexes = true){
166
  global $wpdb;
167
 
168
  // Separate individual queries into an array
includes/admin/sidebar.php CHANGED
@@ -4,24 +4,32 @@ $configuration = blc_get_configuration();
4
  if ( !function_exists('fetch_feed') ){
5
  include_once(ABSPATH . WPINC . '/feed.php');
6
  }
7
- if ( !$configuration->get('user_has_donated', false) && function_exists('fetch_feed') ):
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  $feed_url = 'http://w-shadow.com/files/blc-plugin-links.rss';
9
  $num_items = 3;
10
 
11
  $feed = fetch_feed($feed_url);
12
  if ( !is_wp_error($feed) ):
13
  ?>
14
- <style type="text/css">
15
- #advertising .inside {
16
- text-align: left;
17
- }
18
- </style>
19
  <div id="advertising" class="postbox">
20
  <h3 class="hndle"><?php _e('More plugins by Janis Elsts', 'broken-link-checker'); ?></h3>
21
  <div class="inside">
22
  <ul>
23
  <?php
24
- foreach($feed->get_items(0, $num_items) as $item) {
25
  printf(
26
  '<li><a href="%1$s" title="%2$s">%3$s</a></li>',
27
  esc_url( $item->get_link() ),
@@ -38,6 +46,41 @@ if ( !$configuration->get('user_has_donated', false) && function_exists('fetch_f
38
  endif;
39
  ?>
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  <div id="donate" class="postbox">
42
  <h3 class="hndle"><?php _e('Donate $10, $20 or $50!', 'broken-link-checker'); ?></h3>
43
  <div class="inside">
@@ -66,25 +109,35 @@ endif;
66
  echo esc_attr(admin_url('options-general.php?page=link-checker-settings&donation_canceled=1'));
67
  ?>" />
68
 
69
- <input type="image" src="https://www.sandbox.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online." style="max-width:170px;height:47px;">
70
  </form>
71
  </div>
72
  </div>
73
 
74
- <?php if ( !$configuration->get('user_has_donated') ): ?>
75
- <style type="text/css">
76
- #themefuse-ad .inside {
77
- padding: 2px 0 0 0;
78
- margin: 0;
79
- text-align: center;
80
- }
81
- </style>
82
- <div id="themefuse-ad" class="postbox">
83
- <!--<h3 class="hndle">ThemeFuse</h3> -->
84
- <div class="inside">
85
- <a href="http://themefuse.com/wp-themes-shop/?plugin=broken-link-checker" title="ThemeFuse themes">
86
- <img src="<?php echo plugins_url('images/themefuse-250x250.jpg', BLC_PLUGIN_FILE) ?>" width="250" height="250" alt="ThemeFuse">
87
- </a>
88
- </div>
89
- </div>
90
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
4
  if ( !function_exists('fetch_feed') ){
5
  include_once(ABSPATH . WPINC . '/feed.php');
6
  }
7
+
8
+ $show_plugin_feed = $show_ame_ad = false;
9
+ if ( !$configuration->get('user_has_donated', false) ) {
10
+ if ( (blcUtility::constrained_hash(get_site_url() . 'y', 0, 100) < 40) && function_exists('fetch_feed') ) {
11
+ $show_plugin_feed = true;
12
+ } else {
13
+ $show_ame_ad = true;
14
+ }
15
+ }
16
+ ?>
17
+
18
+ <!-- "More plugins" RSS feed -->
19
+ <?php
20
+ if ( $show_plugin_feed ):
21
  $feed_url = 'http://w-shadow.com/files/blc-plugin-links.rss';
22
  $num_items = 3;
23
 
24
  $feed = fetch_feed($feed_url);
25
  if ( !is_wp_error($feed) ):
26
  ?>
 
 
 
 
 
27
  <div id="advertising" class="postbox">
28
  <h3 class="hndle"><?php _e('More plugins by Janis Elsts', 'broken-link-checker'); ?></h3>
29
  <div class="inside">
30
  <ul>
31
  <?php
32
+ foreach($feed->get_items(0, $num_items) as $item) { /** @var SimplePie_Item $item */
33
  printf(
34
  '<li><a href="%1$s" title="%2$s">%3$s</a></li>',
35
  esc_url( $item->get_link() ),
46
  endif;
47
  ?>
48
 
49
+ <!-- Admin Menu Editor Pro ad -->
50
+ <?php
51
+ if ( $show_ame_ad ):
52
+ //Display an ad for Admin Menu Editor.
53
+ //We're A/B testing a bunch of different ad copies.
54
+ $ame_copy_variants = array(
55
+ array('a', "Add, delete, hide, or move any admin menu item."),
56
+ array('b', "Organize your admin menu the way you want it."),
57
+ array('c', "Hide, move or customize admin menus. Perfect for client sites."),
58
+ );
59
+ $ad_copy_index = intval(blcUtility::constrained_hash(get_site_url(), 0, count($ame_copy_variants)));
60
+ $ad_copy = $ame_copy_variants[$ad_copy_index];
61
+
62
+ $ad_url = sprintf(
63
+ 'http://w-shadow.com/admin-menu-editor-pro/?utm_source=broken_link_checker&utm_medium=text_link&utm_campaign=Plugins&utm_content=%s',
64
+ urlencode('ad_copy_') . $ad_copy[0]
65
+ );
66
+ ?>
67
+ <div class="postbox" id="advertising">
68
+ <h3 class="hndle"><?php _e('More plugins by Janis Elsts', 'broken-link-checker'); ?></h3>
69
+ <div class="inside">
70
+ <p class="ws-ame-ad-copy"><?php echo $ad_copy[1]; ?></p>
71
+ <p class="ws-ame-ad-link">
72
+ <a href="<?php echo esc_attr($ad_url); ?>" title="Admin Menu Editor">
73
+ Admin Menu Editor
74
+ </a>
75
+ </p>
76
+ </div>
77
+ </div>
78
+
79
+ <?php
80
+ endif;
81
+ ?>
82
+
83
+ <!-- Donation button -->
84
  <div id="donate" class="postbox">
85
  <h3 class="hndle"><?php _e('Donate $10, $20 or $50!', 'broken-link-checker'); ?></h3>
86
  <div class="inside">
109
  echo esc_attr(admin_url('options-general.php?page=link-checker-settings&donation_canceled=1'));
110
  ?>" />
111
 
112
+ <input type="image" src="https://www.sandbox.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online." style="max-width:170px;height:47px;border:0;">
113
  </form>
114
  </div>
115
  </div>
116
 
117
+ <!-- Other advertising -->
118
+ <?php
119
+ if ( !$configuration->get('user_has_donated') ):
120
+ $ad_switch_time = strtotime('2012-06-05 12:00');
121
+ if ( time() < $ad_switch_time ):
122
+ ?>
123
+ <div id="themefuse-ad" class="postbox">
124
+ <!--<h3 class="hndle">ThemeFuse</h3> -->
125
+ <div class="inside">
126
+ <a href="http://themefuse.com/wp-themes-shop/?plugin=broken-link-checker" title="ThemeFuse themes">
127
+ <img src="<?php echo plugins_url('images/themefuse-250x250.jpg', BLC_PLUGIN_FILE) ?>" width="250" height="250" alt="ThemeFuse">
128
+ </a>
129
+ </div>
130
+ </div>
131
+ <?php
132
+ else:
133
+ ?>
134
+ <div id="managewp-ad" class="postbox">
135
+ <div class="inside">
136
+ <a href="http://managewp.com/?utm_source=broken_link_checker&utm_medium=Banner&utm_content=mwp250_2&utm_campaign=Plugins" title="ManageWP">
137
+ <img src="<?php echo plugins_url('images/mwp250_2.png', BLC_PLUGIN_FILE) ?>" width="250" height="250" alt="ManageWP">
138
+ </a>
139
+ </div>
140
+ </div>
141
+ <?php
142
+ endif;
143
+ endif; ?>
includes/link-query.php CHANGED
@@ -86,7 +86,7 @@ class blcLinkQuery {
86
  * @return array An array of custom filter definitions. If there are no custom filters defined returns an empty array.
87
  */
88
  function load_custom_filters(){
89
- global $wpdb;
90
 
91
  $filter_data = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}blc_filters ORDER BY name ASC", ARRAY_A);
92
  $filters = array();
@@ -118,7 +118,7 @@ class blcLinkQuery {
118
  * @return string|bool The ID of the newly added filter, or False.
119
  */
120
  function create_custom_filter($name, $params){
121
- global $wpdb;
122
 
123
  if ( is_array($params) ){
124
  $params = http_build_query($params, null, '&');
@@ -145,7 +145,7 @@ class blcLinkQuery {
145
  * @return bool True on success, False if a database error occured.
146
  */
147
  function delete_custom_filter($filter_id){
148
- global $wpdb;
149
 
150
  //Remove the "f" character from the filter ID to get its database key
151
  $filter_id = intval(ltrim($_POST['filter_id'], 'f'));
@@ -230,7 +230,7 @@ class blcLinkQuery {
230
  * @return array 'where_exprs' - an array of search expressions, 'join_instances' - whether joining the instance table is required.
231
  */
232
  function compile_search_params($params){
233
- global $wpdb;
234
 
235
  //Track whether we'll need to left-join the instance table to run the query.
236
  $join_instances = false;
@@ -462,7 +462,7 @@ class blcLinkQuery {
462
  * @return array|int
463
  */
464
  function get_links($params = null){
465
- global $wpdb;
466
 
467
  if( !is_array($params) ){
468
  $params = array();
86
  * @return array An array of custom filter definitions. If there are no custom filters defined returns an empty array.
87
  */
88
  function load_custom_filters(){
89
+ global $wpdb; /** @var wpdb $wpdb */
90
 
91
  $filter_data = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}blc_filters ORDER BY name ASC", ARRAY_A);
92
  $filters = array();
118
  * @return string|bool The ID of the newly added filter, or False.
119
  */
120
  function create_custom_filter($name, $params){
121
+ global $wpdb; /** @var wpdb $wpdb */
122
 
123
  if ( is_array($params) ){
124
  $params = http_build_query($params, null, '&');
145
  * @return bool True on success, False if a database error occured.
146
  */
147
  function delete_custom_filter($filter_id){
148
+ global $wpdb; /** @var wpdb $wpdb */
149
 
150
  //Remove the "f" character from the filter ID to get its database key
151
  $filter_id = intval(ltrim($_POST['filter_id'], 'f'));
230
  * @return array 'where_exprs' - an array of search expressions, 'join_instances' - whether joining the instance table is required.
231
  */
232
  function compile_search_params($params){
233
+ global $wpdb; /** @var wpdb $wpdb */
234
 
235
  //Track whether we'll need to left-join the instance table to run the query.
236
  $join_instances = false;
462
  * @return array|int
463
  */
464
  function get_links($params = null){
465
+ global $wpdb; /** @var wpdb $wpdb */
466
 
467
  if( !is_array($params) ){
468
  $params = array();
includes/utility-class.php CHANGED
@@ -15,6 +15,7 @@ if ( !function_exists('sys_get_temp_dir')) {
15
  unlink($tempfile);
16
  return realpath(dirname($tempfile));
17
  }
 
18
  }
19
  }
20
 
@@ -76,7 +77,7 @@ class blcUtility {
76
  * @param integer $max_characters Return no more than $max_characters
77
  * @param string $break Break on this character. Defaults to space.
78
  * @param string $pad Pad the truncated string with this string. Defaults to an HTML ellipsis.
79
- * @return
80
  */
81
  static function truncate($text, $max_characters = 0, $break = ' ', $pad = '&hellip;'){
82
  if ( strlen($text) <= $max_characters ){
@@ -299,7 +300,7 @@ class blcUtility {
299
  * @return void
300
  */
301
  static function optimize_database(){
302
- global $wpdb;
303
 
304
  $wpdb->query("OPTIMIZE TABLE {$wpdb->prefix}blc_links, {$wpdb->prefix}blc_instances, {$wpdb->prefix}blc_synch");
305
  }
@@ -383,7 +384,7 @@ class blcUtility {
383
  /**
384
  * Get an instance of idna_converter
385
  *
386
- * @return object Either an instance of idna_converter, or NULL if the converter class is not available
387
  */
388
  static function get_idna_converter(){
389
  static $idn = null;
@@ -392,6 +393,23 @@ class blcUtility {
392
  }
393
  return $idn;
394
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
 
396
  }//class
397
 
15
  unlink($tempfile);
16
  return realpath(dirname($tempfile));
17
  }
18
+ return '';
19
  }
20
  }
21
 
77
  * @param integer $max_characters Return no more than $max_characters
78
  * @param string $break Break on this character. Defaults to space.
79
  * @param string $pad Pad the truncated string with this string. Defaults to an HTML ellipsis.
80
+ * @return string
81
  */
82
  static function truncate($text, $max_characters = 0, $break = ' ', $pad = '&hellip;'){
83
  if ( strlen($text) <= $max_characters ){
300
  * @return void
301
  */
302
  static function optimize_database(){
303
+ global $wpdb; /** @var wpdb $wpdb */
304
 
305
  $wpdb->query("OPTIMIZE TABLE {$wpdb->prefix}blc_links, {$wpdb->prefix}blc_instances, {$wpdb->prefix}blc_synch");
306
  }
384
  /**
385
  * Get an instance of idna_converter
386
  *
387
+ * @return idna_convert|null Either an instance of IDNA converter, or NULL if the converter class is not available
388
  */
389
  static function get_idna_converter(){
390
  static $idn = null;
393
  }
394
  return $idn;
395
  }
396
+
397
+ /**
398
+ * Generate a numeric hash from a string. The result will be constrained to the specified interval.
399
+ *
400
+ * @static
401
+ * @param string $input
402
+ * @param int $min
403
+ * @param int $max
404
+ * @return float
405
+ */
406
+ public static function constrained_hash($input, $min = 0, $max = 1) {
407
+ $bytes_to_use = 3;
408
+ $md5_char_count = 32;
409
+ $hash = substr(md5($input), $md5_char_count - $bytes_to_use*2);
410
+ $hash = intval(hexdec($hash));
411
+ return $min + (($max - $min) * ($hash / (pow(2, $bytes_to_use * 8) - 1)));
412
+ }
413
 
414
  }//class
415
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: links, broken, maintenance, blogroll, custom fields, admin, comments, posts
5
  Requires at least: 3.2
6
  Tested up to: 3.4-beta4
7
- Stable tag: 1.5.1
8
 
9
  This plugin will check your posts, comments and other content for broken links and missing images, and notify you if any are found.
10
 
@@ -90,6 +90,12 @@ To upgrade your installation
90
 
91
  == Changelog ==
92
 
 
 
 
 
 
 
93
  = 1.5.1 =
94
  * Updated Portuguese translation.
95
  * Updated German translation.
4
  Tags: links, broken, maintenance, blogroll, custom fields, admin, comments, posts
5
  Requires at least: 3.2
6
  Tested up to: 3.4-beta4
7
+ Stable tag: 1.5.2
8
 
9
  This plugin will check your posts, comments and other content for broken links and missing images, and notify you if any are found.
10
 
90
 
91
  == Changelog ==
92
 
93
+ = 1.5.2 =
94
+ * A few minor comment fixes.
95
+ * Move certain styles to a separate CSS file, which is where they belong.
96
+ * Replace the ThemeFuse banner with one from ManageWP (will go live on June 5).
97
+ * Instead of displaying several plugins in the "More plugins by Janis Elsts" box, sometimes display just one plugin (AME).
98
+
99
  = 1.5.1 =
100
  * Updated Portuguese translation.
101
  * Updated German translation.