Created
August 14, 2010 03:27
-
-
Save slambert/523912 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Relevant Taxonomies Widget | |
Plugin URI: http://github.com/slambert | |
Description: Displays a list of taxonomies related to the content of the post. And doesn't work. | |
Version: 0.1 | |
Author: Steve Lambert | |
Author URI: http://visitsteve.com | |
*/ | |
// error_reporting(E_ALL); | |
add_action("widgets_init", array('RelevantTaxonomies', 'register')); | |
register_activation_hook( __FILE__, array('RelevantTaxonomies', 'activate')); | |
register_deactivation_hook( __FILE__, array('RelevantTaxonomies', 'deactivate')); | |
class RelevantTaxonomies { | |
function activate(){ | |
$data = array( 'title' => 'Relevant Taxonomies' ,'option2' => 55); | |
if ( ! get_option('RelevantTaxonomies')){ | |
add_option('RelevantTaxonomies' , $data); | |
} else { | |
update_option('RelevantTaxonomies' , $data); | |
} | |
} | |
function deactivate(){ | |
delete_option('RelevantTaxonomies'); | |
} | |
function control(){ | |
$data = get_option('RelevantTaxonomies'); | |
?> | |
<p><label>Title: <input name="RelevantTaxonomies_title" | |
type="text" value="<?php echo $data['title']; ?>" /></label></p> | |
<p><label>Option 2<input name="RelevantTaxonomies_option2" | |
type="text" value="<?php echo $data['option2']; ?>" /></label></p> | |
<?php | |
if (isset($_POST['RelevantTaxonomies_title'])){ | |
$data['title'] = attribute_escape($_POST['RelevantTaxonomies_title']); | |
$data['option2'] = attribute_escape($_POST['RelevantTaxonomies_option2']); | |
update_option('RelevantTaxonomies', $data); | |
} | |
} | |
function widget($args){ | |
echo $args['before_widget']; | |
echo $args['before_title'] . $data['title'] . $args['after_title']; | |
echo the_taxonomies(); | |
echo $args['after_widget']; | |
} | |
function register(){ | |
register_sidebar_widget('RelevantTaxonomies', array('RelevantTaxonomies', 'widget')); | |
register_widget_control('Relevant Taxonomies', array('RelevantTaxonomies', 'control')); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment