Jan 30, 2009
5upport Wordpress Plugin
I've created a new plugin for ... well ... myself! :) Yeap it's for myself but ... funny thing is ... it's for your use. So, if you use it, I'll benefit from it :) Hehe ... got your attention. This is the only plugin available to unregistered subscribers! And the deed it does is very simple.
5upport Wordpress Plugin
<?php
/*
Plugin Name: 5upport
Plugin URI: http://blog.5ubliminal.com/topics/wordpress/plugins/
Description: 5upport will add/remove a link to blog.5ubliminal.com on activate/deactivate.
Version: 5.U.B
Author: 5ubliminal
Author URI: http://blog.5ubliminal.com/
Support URI: http://blog.5ubliminal.com/support/
*/
//-----------------------------------------------------------------------------
// Change this to nofollow if you wish
define('PLUGIN_5UPPORT_REL', "external");
// Change this as you wish
define('PLUGIN_5UPPORT_TITLE', "5ubliminal's 5pace");
// Don't change this ... it's the whole point of this plugin
define('PLUGIN_5UPPORT_URL', "http://blog.5ubliminal.com/");
// Open in new link. Use _top to open in current window
define('PLUGIN_5UPPORT_TARGET', "_blank");
// Change or empty this
define('PLUGIN_5UPPORT_EXCERPT', "5ubliminal's 5pace - Blackhat SEO & Coding Blog");
//-----------------------------------------------------------------------------
// Part of 5ubliminal's PHP ELIB
if(!function_exists('el_wp_injectBlogRoll')){
function el_wp_injectBlogRoll( $link, $title, $params = null ){
if(!isset($GLOBALS['wpdb']) || !function_exists('wp_insert_link')) return false;
global $wpdb; if($wpdb->get_var("SELECT COUNT(link_id) FROM {$wpdb->links}
WHERE link_url = '".mysql_escape_string($link)."' LIMIT 1")) return true;
if(!is_array($params)) $params = array();
$blog_roll_link = array( 'link_name' => $title, 'link_url' => $link);
$blog_roll_link = array_merge($params, $blog_roll_link);
wp_insert_link($blog_roll_link); return true;
}
function el_wp_ejectBlogRoll( $link ){
if(!isset($GLOBALS['wpdb']) || !function_exists('wp_delete_link')) return false;
global $wpdb; $link_id = (int)$wpdb->get_var("SELECT link_id FROM {$wpdb->links}
WHERE link_url = '".mysql_escape_string($link)."' LIMIT 1");
if(!$link_id) return true; wp_delete_link($link_id); return true;
}
}
//-----------------------------------------------------------------------------
// This adds the link to the default blogroll
function _5ubliminal_5upport_Activate(){
if(!function_exists('el_wp_injectBlogRoll')) return;
el_wp_injectBlogRoll(
PLUGIN_5UPPORT_URL, PLUGIN_5UPPORT_TITLE,
array( // More settings
'link_rel' => PLUGIN_5UPPORT_REL,
'link_target' => PLUGIN_5UPPORT_TARGET,
'link_description' => PLUGIN_5UPPORT_EXCERPT,
)
);
}
register_activation_hook(__FILE__, '_5ubliminal_5upport_Activate');
//-----------------------------------------------------------------------------
// This removes the link from the default blogroll
function _5ubliminal_5upport_Deactivate(){
if(!function_exists('el_wp_ejectBlogRoll')) return;
el_wp_ejectBlogRoll(PLUGIN_5UPPORT_URL);
}
register_deactivation_hook(__FILE__, '_5ubliminal_5upport_Deactivate');
//-----------------------------------------------------------------------------
/* THANKS! for your 5upport */
//-----------------------------------------------------------------------------
?>
You can only activate / deactivate this plugin. When you activate it, it will add a new link to your default blogroll pointing to me. When you deactivate it, it will remove that link. The new link will point to blog.5ubliminal.com and you can change the rel attribute, title attribute and inner text by editing the plugin and changing the top defines as you wish.
This is the easiest way to support my blog and my work. One click adds the link, another removes it. You can even change REL to nofollow and not leak any link juice but ... :(
PS: You'll find two cool functions inside you could use for yourself even if you don't put the plugin to work ;)

