* Added smarking.com support
*
* 03/09/2006 - 1.7 - Cal
* Rewrote the options read/write to be more database friendly.
*
* 03/12/2006 - 1.8 - Cal
* Fixed a problem with writing out the options to the database. Thanks to Perry
* for pointing it out to me.
*
* 03/13/2006 - 1.9 - Cal
* I left a bad function call in the version check routine.
*
* 03/16/2006 - 1.10 - Cal
* Removed the call on activate because it doesn't seem to be compatible with
* 1.5.x Put a check in the options page to make sure the array gets initalized
* properly.
*
* 03/17/2006 - 1.11 - Cal
* Added the icons_per_row property.
*
* 03/22/2006 - 1.12 - Cal
* Added support for ma.gnolia.com
*
* 03/23/2006 - 1.13 - Cal
* Fixed a couple of nagging errors and fulfiled requests made by Yaron
* Davidson. Many thanks to Yaron for helping with a couple of the graphics. I
* added support for activating the plugin. This way the build array is only
* called once. I may can move it into another file soon.
*
* 03/25/2006 - 1.14 - Cal
* Added support for segnalo. Thanks to Chiara for the code.
*
* 11/18/2006 - 1.15 - Cal
* Added support for gifttagging. Thanks to Jeremy Baines for the code and grapic.
*/
require_once('blogbling_functions.php');
function wp_notable($before='',$after='') {
global $wp_query,$notable_settings;
$output = '';
$icon_counter = 0;
if (!isset($notable_settings)) $notable_settings = notable_fetch_options();
foreach ($notable_settings['sites'] as $site=>$values_array) {
if($values_array['show']=='yes') {
if (isset($notable_settings['icons_per_row']) and
$notable_settings['icons_per_row']>0 and
$icon_counter>$notable_settings['icons_per_row']) {
$output .= '
';
$icon_counter = 0;
} // if ($icon_counter>$notable_settings['icons_per_row'])
$post = $wp_query->post;
$title = $post->post_title;
$image = '
';
$output .= !empty($output)?$notable_settings['spacer_string_array'][$notable_settings['spacer_string']][0]:'';
$output .= '';
$output .= $values_array['post_url'];
$output .= '';
$output = str_replace('{{url}}',urlencode(get_permalink($post->ID)),$output);
$output = str_replace('{{title}}',$title,$output);
$output = @str_replace('{{category}}',$values_array['category'],$output);
$output = str_replace('{{url_encoded_title}}',urlencode($title),$output);
$output = str_replace('{{prepend}}',$values_array['header'],$output);
$output = str_replace('{{image}}',$image,$output);
$icon_counter++;
} // if($values_array['show']=='yes')
} // foreach ($notable_settings['sites'] as $site=>$values_array)
$output = ''.$before.$output.$after.'';
echo $output;
return;
} // function wp_notable()
/*
* The options Page
*/
function notable_options_page()
{
/*
* Needed for the version check.
* I wish there was a way to pull that automatically but I can't find any
* plugin data.
*/
$version = blogbling_get_version(__file__);
/*
* Process a POSTED form.
*/
if (isset($_POST['info_update']))
{
$notable_settings = blogbling_fetch_options('notable');
foreach ($_POST['notable_settings'][sites] as $key=>$value_array) {
$notable_settings['sites'][$key]['show'] = isset($value_array['show'])?$value_array['show']:'no';
$notable_settings['sites'][$key]['header'] = !empty($value_array['header'])?$value_array['header']:$key;
} // foreach ($_POST['notable_settings'][sites] as $key=>$value_array)
$notable_settings['icons_per_row']=$_POST['notable_settings']['icons_per_row'];
$notable_settings['image_path']=$_POST['notable_settings']['image_path'];
$notable_settings['spacer_string']=$_POST['notable_settings']['spacer_string'];
$notable_settings['version_check_interval']=$_POST['notable_settings']['version_check_interval'];
blogbling_post_options('notable',$notable_settings);
} // if (isset($_POST['info_update']))
$notable_settings = notable_fetch_options();
// $notable_settings['spacer_string_array']=notable_build_spacer_string_array();
?>
0) {
$current_version = blogbling_version_check(basename(__FILE__,'.php'),$notable_settings['last_version_check'],$notable_settings['version_check_interval']);
if ($current_version!=-1) {
if ($version!=$current_version) {
?>
This is version =$version;?>. The current version of the plugin is =$current_version;?>. Click
here to go to the project page to find out more.
This is version is up to date.
0)
?>
Contact the
Author if you are having problems or read his
blog.
$values_array) {
if (!isset($notable_settings['sites'][$site])) {
$notable_settings['sites'][$site] = $values_array;
} // if (!defined($notable_settings['sites'][$site]))
} // for ($sites_array as $site=>$values_array)
/*
* Handle an upgrade. If this is an upgrade from 1.5 or earlier then the
* individual options are still there. We need to merge them into the
* master array and then get rid of them.
*/
$work = get_option('notable_options');
if (!is_array($work)) {
$work = '';
// For upgrading older installs.
foreach ($notable_settings['sites'] as $site=>$values_array) {
$work = get_option('notable_'.$site.'_show');
$notable_settings['sites'][$site]['show'] = !empty($work)?$work:$notable_settings['sites'][$site]['show'];
$work = get_option('notable_'.$site.'_header');
$notable_settings['sites'][$site]['header'] = !empty($work)?$work:$notable_settings['sites'][$site]['header'];
$work = get_option('notable_'.$site.'_post_url');
$notable_settings['sites'][$site]['post_url'] = !empty($work)?$work:$notable_settings['sites'][$site]['post_url'];
delete_option('notable_'.$site.'_show');
delete_option('notable_'.$site.'_header');
delete_option('notable_'.$site.'_post_url');
} // foreach ($notable_settings['sites'] as $site=>$values_array)
$notable_settings['sites']['fark']['category'] = get_option('notable_fark_category');
delete_option('notable_fark_category');
$notable_settings['image_path'] = get_option('notable_image_path');
$notable_settings['spacer_string'] = get_option('notable_spacer_string');
$notable_settings['last_version_check'] = get_option('notable_last_version_check');
$notable_settings['version_check_interval'] = get_option('notable_version_check_interval');
delete_option('notable_image_path');
delete_option('notable_spacer_string');
delete_option('notable_last_version_check');
delete_option('notable_version_check_interval');
} // if (!is_array($work))
/*
* Set reasonable defaults
*/
foreach ($notable_settings['sites'] as $site=>$values_array) {
$notable_settings['sites'][$site]['show'] = ($notable_settings['sites'][$site]['show']=='yes')?'yes':'no';
$notable_settings['sites'][$site]['header'] = empty($notable_settings['sites'][$site]['header'])?$site:$notable_settings['sites'][$site]['header'];
} // foreach ($notable_settings['sites'] as $site=>$values_array)
$notable_settings['icons_per_row'] = isset($notable_settings['icons_per_row'])?intval($notable_settings['icons_per_row']):0;
$notable_settings['image_path'] = empty($notable_settings['image_path'])?'/wp-content/plugins/blogbling/images/':$notable_settings['image_path'];
$notable_settings['spacer_string'] = empty($notable_settings['spacer_string'])?0:intval($notable_settings['spacer_string']);
$notable_settings['last_version_check'] = empty($notable_settings['last_version_check'])?0:$notable_settings['last_version_check'];
$notable_settings['version_check_interval'] = empty($notable_settings['version_check_interval'])?7:$notable_settings['version_check_interval'];
blogbling_post_options('notable',$notable_settings);
return;
} // function notable_install()
function notable_define_array() {
$output_array = array();
$output_array['delicious'] = array();
$output_array['delicious']['header'] = 'del.icio.us';
$output_array['delicious']['show'] = 'yes';
$output_array['delicious']['post_url'] = '{{image}}';
$output_array['digg'] = array();
$output_array['digg']['header'] = 'digg';
$output_array['digg']['show'] = 'yes';
$output_array['digg']['post_url'] = '{{image}}';
$output_array['spurl'] = array();
$output_array['spurl']['header']='spurl';
$output_array['spurl']['show']='yes';
$output_array['spurl']['post_url']='{{image}}';
$output_array['wists'] = array();
$output_array['wists']['header']='wists';
$output_array['wists']['show']='yes';
$output_array['wists']['post_url']='{{image}}';
$output_array['simpy'] = array();
$output_array['simpy']['header']='simpy';
$output_array['simpy']['show']='yes';
$output_array['simpy']['post_url']='{{image}}';
$output_array['newsvine'] = array();
$output_array['newsvine']['header']='newsvine';
$output_array['newsvine']['show']='yes';
$output_array['newsvine']['post_url']='{{image}}';
$output_array['blinklist'] = array();
$output_array['blinklist']['header']='blinklist';
$output_array['blinklist']['show']='yes';
$output_array['blinklist']['post_url']='{{image}}';
$output_array['furl'] = array();
$output_array['furl']['header']='furl';
$output_array['furl']['show']='yes';
$output_array['furl']['post_url']='{{image}}';
$output_array['reddit'] = array();
$output_array['reddit']['header']='reddit';
$output_array['reddit']['show']='yes';
$output_array['reddit']['post_url']='{{image}}';
$output_array['fark'] = array();
$output_array['fark']['header']='fark';
$output_array['fark']['show']='yes';
$output_array['fark']['post_url']='{{image}}';
$output_array['fark']['category']='';
$output_array['blogmarks'] = array();
$output_array['blogmarks']['header']='blogmarks';
$output_array['blogmarks']['show']='yes';
$output_array['blogmarks']['post_url']='{{image}}';
$output_array['yahoo'] = array();
$output_array['yahoo']['header']='Y!';
$output_array['yahoo']['show']='yes';
$output_array['yahoo']['post_url']='{{image}}';
$output_array['smarking'] = array();
$output_array['smarking']['header']='smarking';
$output_array['smarking']['show']='yes';
$output_array['smarking']['post_url']='{{image}}';
$output_array['magnolia'] = array();
$output_array['magnolia']['header'] = 'magnolia';
$output_array['magnolia']['show'] = 'yes';
$output_array['magnolia']['post_url'] = '{{image}}';
$output_array['segnalo']['header'] = 'segnalo';
$output_array['segnalo']['show'] = 'yes';
$output_array['segnalo']['post_url'] = '{{image}}';
// Edited by Wessley Roche w@vdoble.com
$output_array['gifttagging'] = array();
$output_array['gifttagging']['header'] = 'gifttagging';
$output_array['gifttagging']['show'] = 'yes';
$output_array['gifttagging']['post_url'] = '{{image}}';
return $output_array;
} // function notable_define_array
function notable_build_spacer_string_array() {
$output = array();
$output[0] = array(' ','Non-Breaking Space');
$output[1] = array(' ','Space');
$output[1] = array(' ','2 Non-Breaking Spaces');
$output[2] = array('-','Dash');
$output[3] = array('_','Underscore');
$output[4] = array('.','Dot');
$output[5] = array('/','Forward Slash');
$output[6] = array('','No Space');
return $output;
} // function notable_build_spacer_string_array()
function notable_fetch_options() {
$notable_settings = blogbling_fetch_options('notable');
$notable_settings['spacer_string_array']=notable_build_spacer_string_array();
return $notable_settings;
} // function notable_fetchoptions()
/*
* register our intentions with WordPress
*/
if (function_exists('add_action'))
{
add_action('admin_menu', 'notable_add_option_page');
} // if (function_exists('add_action'))
/*
* Add the option to the options menu.
*/
function notable_add_option_page()
{
add_options_page("Notable Configurator", 'Notable', 7, __FILE__, 'notable_options_page');
}
//register_activation_hook(__file__, 'notable_install');
add_action("activate_blogbling/wp-notable.php",'notable_install')
?>