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broken-link-checker / highlighter-class.php
broken-link-checker Last commit date
images 17 years ago JSON.php 17 years ago broken-link-checker.php 16 years ago config-manager.php 16 years ago core.php 16 years ago highlighter-class.php 16 years ago instance-classes.php 17 years ago link-classes.php 16 years ago readme.txt 16 years ago uninstall.php 16 years ago utility-class.php 16 years ago
highlighter-class.php
76 lines
1 <?php
2
3 /**
4 * @author W-Shadow
5 * @copyright 2009
6 *
7 * @requires blcUtility
8 */
9
10 class blcLinkHighlighter {
11
12 var $links_to_remove;
13 var $broken_link_css;
14 var $current_permalink;
15
16 function blcLinkHighlighter( $broken_link_css = '' ) {
17 if ( !empty( $broken_link_css ) ){
18 $this->broken_link_css = $broken_link_css;
19 add_action( 'wp_head', array(&$this,'hook_wp_head') );
20 }
21
22 add_filter( 'the_content', array(&$this,'hook_the_content') );
23 $this->current_permalink = '';
24 }
25
26 function hook_the_content($content){
27 global $post, $wpdb;
28 if ( empty($post) ) return $content;
29
30 //Get the post permalink - it's used to resolve relative URLs
31 $this->current_permalink = get_permalink( $post->ID );
32
33 $q = "
34 SELECT instances.link_text, links.*
35
36 FROM {$wpdb->prefix}blc_instances AS instances, {$wpdb->prefix}blc_links AS links
37
38 WHERE
39 instances.source_id = %d
40 AND instances.source_type = 'post'
41 AND instances.instance_type = 'link'
42
43 AND instances.link_id = links.link_id
44 AND links.check_count > 0
45 AND ( links.http_code < 200 OR links.http_code >= 400 OR links.timeout = 1 )
46 AND links.http_code <> " . BLC_CHECKING;
47
48 $rows = $wpdb->get_results( $wpdb->prepare( $q, $post->ID ), ARRAY_A );
49 if( $rows ){
50 $this->links_to_remove = array();
51 foreach($rows as $row){
52 $this->links_to_remove[$row['url']] = $row;
53 }
54 $content = preg_replace_callback( blcUtility::link_pattern(), array(&$this,'mark_broken_links'), $content );
55 };
56
57 return $content;
58 }
59
60 function mark_broken_links($matches){
61 //TODO: Tooltip-style popups with more info
62 $url = blcUtility::normalize_url( html_entity_decode( $matches[3] ), $this->current_permalink );
63 if( isset( $this->links_to_remove[$url] ) ){
64 return $matches[1].$matches[2].$matches[3].$matches[2].' class="broken_link" '.$matches[4].
65 $matches[5].$matches[6];
66 } else {
67 return $matches[0];
68 }
69 }
70
71 function hook_wp_head(){
72 echo '<style type="text/css">',$this->broken_link_css,'</style>';
73 }
74 }
75
76 ?>