public
Description: A Wordpress plugin for blocking the DiggBar and all Digg users from viewing your content. Idea stolen from http://daringfireball.net/2009/04/how_to_block_the_diggbar
Homepage: http://extrafuture.com/
Clone URL: git://github.com/philnelson/diggbarred.git
Click here to lend your support to: diggbarred and make a donation at www.pledgie.com !
diggbarred / diggbarred.php
100644 66 lines (52 sloc) 2.336 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/*
Plugin Name: Diggbarred
Author: Phil Nelson
Author URI: http://extrafuture.com/
Version: 1.6
Description: Blocks all traffic from Digg from viewing your content, replacing it with a message to users. Idea and DiggBar blocking regex taken from <a href="http://daringfireball.net/2009/04/how_to_block_the_diggbar" title="Daring Fireball: How to Block the DiggBar">Daring Fireball</a>.
Plugin URI: http://extrafuture.com/projects/diggbarred
 
*/
 
add_option("diggbarred_version", "1.6");
add_option("diggbarred_message", 'Dear Digg,<br> Your DiggBar sucks, and is <a href="http://daringfireball.net/2009/04/how_to_block_the_diggbar">harming the internet</a>. We\'re blocking it.');
add_option("diggbarred_style","width: 30%; line-height: 17px; text-align: justify; margin: 20% auto 0 auto; font-family: verdana, sans-serif; font-size: 13px;");
 
add_action('init', 'diggbarred_do_the_shit');
 
function diggbarred_do_the_shit()
{
 
if(preg_match('#http://digg.com/\w{1,8}/*(\?.*)?$#', $_SERVER['HTTP_REFERER']))
{
// Header calls thanks to Aristotle Pagaltzis http://plasmasturm.org/log/538/ and AJ Sutton http://github.com/ajsutton
header("HTTP/1.0 403 Digg bar is blocked in protest", true, 403);
header("Vary: Referer");
echo '<div style="'.get_option('diggbarred_style').'"><p>' . get_option('diggbarred_message') . '</p></div>';
exit;
}
 
}
 
// Thanks to http://wpengineer.com/how-to-improve-wordpress-plugins/ for instructions on adding the Settings link
 
function diggbarred_plugin_actions($links, $file)
{
static $this_plugin;
 
if( !$this_plugin ) $this_plugin = plugin_basename(__FILE__);
 
if( $file == $this_plugin )
{
$settings_link = '<a href="index.php?page=diggbarred/diggbarred-options.php">' . __('Settings') . '</a>';
$links = array_merge( array($settings_link), $links); // before other links
}
return $links;
}
 
function diggbarred_settings()
{
require_once('diggbarred-options.php');
}
 
function diggbarred_admin_panel()
{
add_options_page('Diggbarred Options', 'Diggbarred', 8, 'diggbarred/diggbarred-options.php', 'diggbarred_settings');
if ( current_user_can('edit_posts') && function_exists('add_submenu_page') ) {
add_filter( 'plugin_action_links', 'diggbarred_plugin_actions', 10, 2 );
}
}
 
if(is_admin())
{
add_action('admin_menu', 'diggbarred_admin_panel');
}
 
?>