All pastes #708903 Raw Edit

Something

public php v1 · immutable
#708903 ·published 2007-09-24 06:32 UTC
rendered paste body
<?php/*Plugin Name: wp-notablePlugin URI: http://www.calevans.com/view.php/page/notableVersion: 1.14Description: Add social bookmark links to each blog entry.Author: Cal EvansAuthor URI: http://blog.calevans.com*//* * Copyright 2006  Cal Evans * Thanks to Kirk Montgomery  (email : webmaster@maxpower.ca) for the graphics. *   *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *//* * History * 02/08/2006 - 1.0 - Cal * Initial Release. * * 02/09/2006 - 1.0 - Cal * Did not bump version. Added Options Saved banner for when the update button * is pressed. *  * 02/22/2006 - 1.1 - Cal * Fixed the default path. Thanks to CraigWD for finding that one. *  * 02/23/2006 - 1.2 - Cal * Added the ability to define the spacer between the images. Also found that * furl wasn't working. Fixed it so it will display. *  * 02/23/2006 - 1.4 - Cal * Fixed a nagging issue where the code generated wouldn't validate. * Thanks to HandySolo (http://www.solo-technology.com/blog/) for helping me * fix this one. * * 02/25/2006 - 1.5 - Cal * The tooltip wasn't displaying in IE. Thanks to Jason Barrow for point it out * to me. *  * 03/08/2006 - 1.6 - Faber <faber@smarking.com> * 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 .= '<br  />';				$icon_counter = 0;			} // if ($icon_counter>$notable_settings['icons_per_row'])						$post  = $wp_query->post;			$title =  $post->post_title;			$image = '<img src="'.$notable_settings['image_path'].$site.'.png" class="wp-notable_image" alt="'.$values_array['header'].':'.$title.'" />';			$output .= !empty($output)?$notable_settings['spacer_string_array'][$notable_settings['spacer_string']][0]:'';			$output .= '<span class="wp-notable" id="wp-notable-'.$site.'" >';			$output .= $values_array['post_url'];			$output .= '</span >';			$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 = '<span id="wp-notable-line" class="wp-notable-line">'.$before.$output.$after.'</span>';	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();?><?PHP if (isset($_POST['info_update'])) {?><div id="message" class="updated fade"><p><strong>Options Saved</strong></p></div><?PHP } ?><div class=wrap>  <form method="post">    <h2>Notable Configuration Options</h2>    <fieldset name="notable_icons_per_row">    	<legend>Icons Per Row</legend>    	<input type="text"                name="notable_settings[icons_per_row]"               size="5"               value="<?=$notable_settings['icons_per_row'];?>" >    </fieldset>    <fieldset name="notable_image_path">    	<legend>Image Path</legend>    	<input type="text"                name="notable_settings[image_path]"               size="45"               value="<?=$notable_settings['image_path'];?>" >    </fieldset>    <fieldset name="notable_spacer_string">    	<legend>Spacer String</legend>		<select name="notable_settings[spacer_string]"><?PHP	for($lcvA=0;$lcvA<count($notable_settings['spacer_string_array']);$lcvA++) {		echo '<option value="'.$lcvA.'" '. ($notable_settings['spacer_string']==$lcvA?'SELECTED':'') .' >'.$notable_settings['spacer_string_array'][$lcvA][1].'</option>';	} // for($lcvA=0;$lcvA<count($notable_settings['spacer_string_array']);$lcvA++)?>		</select>    </fieldset>	<fieldset name="version_check_interval">		<legend>Days Between Version Checks</legend>		<input type="text" name="notable_settings[version_check_interval]" value="<?=$notable_settings['version_check_interval'];?>" size="2" maxlength="2">	</fieldset>    <br />    <table name="i_hate_css_because_I_cant_do_horizontal_positioning">        <?php    foreach ($notable_settings['sites'] as $site=>$values_array) {    ?>    <tr>        <td><img src="<?=$notable_settings['image_path'];?><?=$site;?>.png"/></td>        <td><input type="hidden" name="notable_settings[sites][<?=$site;?>][show]" value="no">            <input type="checkbox" name="notable_settings[sites][<?=$site;?>][show]" value="yes" <?=$notable_settings['sites'][$site]['show']=='yes'?'CHECKED':'';?>></td>        <td><label name="show_delicious">Show <?=$site;?>?</label> </td>        <td><label name="prepend_<?=$site;?>">Prepend to tooltip:</label>    	<input type="text"                name="notable_settings[sites][<?=$site;?>][header]"                value="<?=$values_array['header'];?>"></td>    </tr>    <?PHP    } // foreach ($sites as $key=>$value)    ?>    </table>    <div class="submit">        <input type="submit" name="info_update" value="Update" />    </div>    </div>  </form> </div><?PHP	if ($notable_settings['version_check_interval']>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) {	?>				<div class="wrap" style="border:solid 1px red;">This is version <?=$version;?>. The current version of the plugin is <?=$current_version;?>. Click <a href="http://www.calevans.com/view.php/page/notable" target="_NEW" title="Opens a new window.">here</a> to go to the project page to find out more. </div> <?PHP			} else {?>				<div class="wrap" >This is version is up to date. </div><?PHP			} // if ($version!=$current_version)			$notable_settings['last_version_check']=mktime();			blogbling_post_options('notable',$notable_settings);		} // if ($current_version!=-1)	} // if ($notable_settings['version_check_interval']>0)?>	<div class="wrap" ><?PHP?>    Contact the <a href="mailto:cal@calevans.com">Author</a> if you are having problems or read his <a href="http://blog.calevans.com" target="_NEW" title="Postcards From My Life">blog</a>.<br /><br />	<a href="http://blog.calevans.com/blog-bling" target="_NEW" style="border:none;"><image src="/wp-content/plugins/blogbling/images/blogbling.gif" alt="Blog Bling"></a>	</div><?PHP	} /* * Undo the damage we may have done. if this plugin has alreayd been installed * then let's hit the database, grab the options, store them all in one array * then write the back out. */function notable_install() {   	$notable_settings = notable_fetch_options();	$work = notable_define_array();		/*	 * Merge the arrays	 */	foreach ($work as $site=>$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'] = '<a href="http://del.icio.us/post?url={{url}}&amp;title={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';    $output_array['digg'] = array();	$output_array['digg']['header']   = 'digg';	$output_array['digg']['show']     = 'yes';	$output_array['digg']['post_url'] = '<a href="http://digg.com/submit?phase=2&amp;url={{url}}&title={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['spurl']     = array();	$output_array['spurl']['header']='spurl';	$output_array['spurl']['show']='yes';	$output_array['spurl']['post_url']='<a href="http://www.spurl.net/spurl.php?title={{url_encoded_title}}&amp;url={{url}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['wists']     = array();	$output_array['wists']['header']='wists';	$output_array['wists']['show']='yes';	$output_array['wists']['post_url']='<a href="http://wists.com/r.php?c=&amp;r={{url}}&amp;title={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['simpy']     = array();	$output_array['simpy']['header']='simpy';	$output_array['simpy']['show']='yes';	$output_array['simpy']['post_url']='<a href="http://www.simpy.com/simpy/LinkAdd.do?href={{url}}&amp;title={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['newsvine']  = array();	$output_array['newsvine']['header']='newsvine';	$output_array['newsvine']['show']='yes';	$output_array['newsvine']['post_url']='<a href="http://www.newsvine.com/_tools/seed&amp;save?u={{url}}&amp;h={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['blinklist'] = array();	$output_array['blinklist']['header']='blinklist';	$output_array['blinklist']['show']='yes';	$output_array['blinklist']['post_url']='<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Description=&amp;Url={{url}}&amp;Title={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['furl']      = array();	$output_array['furl']['header']='furl';	$output_array['furl']['show']='yes';	$output_array['furl']['post_url']='<a href="http://www.furl.net/storeIt.jsp?u={{url}}&amp;t={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['reddit']    = array();	$output_array['reddit']['header']='reddit';	$output_array['reddit']['show']='yes';	$output_array['reddit']['post_url']='<a href="http://reddit.com/submit?url={{url}}&amp;title={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['fark']      = array();	$output_array['fark']['header']='fark';	$output_array['fark']['show']='yes';	$output_array['fark']['post_url']='<a href="http://cgi.fark.com/cgi/fark/edit.pl?new_url={{url}}&amp;new_comment={{url_encoded_title}}&amp;linktype={{category}}" title="{{prepend}}:{{title}}">{{image}}</a>';    $output_array['fark']['category']='';	$output_array['blogmarks'] = array();	$output_array['blogmarks']['header']='blogmarks';	$output_array['blogmarks']['show']='yes';	$output_array['blogmarks']['post_url']='<a href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url={{url}}&amp;title={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['yahoo']     = array();	$output_array['yahoo']['header']='Y!';	$output_array['yahoo']['show']='yes';	$output_array['yahoo']['post_url']='<a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u={{url}}&amp;t={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';    $output_array['smarking']  = array();	$output_array['smarking']['header']='smarking';	$output_array['smarking']['show']='yes';	$output_array['smarking']['post_url']='<a href="http://smarking.com/editbookmark/?url={{url}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['magnolia'] = array();	$output_array['magnolia']['header'] = 'magnolia';	$output_array['magnolia']['show'] = 'yes';	$output_array['magnolia']['post_url'] = '<a href="http://ma.gnolia.com/bookmarklet/add?url={{url}}&title={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';	$output_array['segnalo']['header'] = 'segnalo';	$output_array['segnalo']['show'] = 'yes';	$output_array['segnalo']['post_url'] = '<a href="http://segnalo.com/post.html.php?url={{url}}&title={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';		// 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'] = '<a href="http://www.gifttagging.com/gift/add?url={{url}}&title={{url_encoded_title}}" title="{{prepend}}:{{title}}">{{image}}</a>';		return $output_array;} // function notable_define_arrayfunction notable_build_spacer_string_array() {	$output    = array();	$output[0] = array('&nbsp;','Non-Breaking Space');	$output[1] = array(' ','Space');	$output[1] = array('&nbsp;&nbsp;','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')?>