I wrote this Widget (Plugin) for WordPress to be able to properly display the subscription form for The Tech Doctor Newsletter. It builds on the PHPlist Plugin by Jesse Heap which connects to PHPlist. It is based on a sample plugin by Kaf Oseo
<::?php
/*
Plugin Name: PHPlist Widget
Plugin URI: http://www.geekzone.com.au/
Description: PHPlist Widget that makes a widget out of <::a href="::http://www.jesseheap.com/projects/wordpress-phplist-plugin.php"::>::Jesse Heap\’s PHPlist<::/a>:: plugin
Author: Mark Snell
Version: 0.65
Author URI: http://www.geekzone.com.au/
based on: http://guff.szub.net/2006/04/06/my-widget-example-wordpress-widget/
*/
function widget_PHPlist_init(){
function widget_PHPlist($args) {
extract($args)::
$options = get_option(\’widget_PHPlist\’)::
$title = empty($options[\’title\’]) ? \’<::b>::\’.\’Join our Mailing List:\’.\’<::/b>::\’ : \’<::b>::\’.$options[\’title\’].\’<::/b>::\’::
echo $before_widget::
echo $before_title . $title . $after_title::
$content = apply_filters(\’the_content\’, \’<::!–phplist form–>::\’)::
echo $content::
echo $after_widget::
}
// This is the function that outputs the form to let users edit
// the widget\’s title and so on. It\’s an optional feature, but
// we\’ll use it because we can!
function widget_PHPlist_control() {
// Collect our widget\’s options.
$options = get_option(\’widget_PHPlist\’)::
// This is for handing the control form submission.
if ( $_POST[\’PHPlist-submit\’] ) {
// Clean up control form submission options
$options[\’title\’] = strip_tags(stripslashes($_POST[\’PHPlist-title\’]))::
update_option(\’widget_PHPlist\’, $options)::
}
// Format options as valid HTML. Hey, why not.
$title = htmlspecialchars($options[\’title\’], ENT_QUOTES)::
// The HTML below is the control form for editing options.
?>::
<::div>::
<::label for="::PHPlist-title":: style="::line-height:35px::display:block::"::>::Widget title: <::input type="::text":: id="::PHPlist-title":: name="::PHPlist-title":: value="::<::?php echo $title:: ?>::":: />::<::/label>::
<::input type="::hidden":: name="::PHPlist-submit":: id="::PHPlist-submit":: value="::1":: />::
<::/div>::
<::?php
// end of widget_PHPlist_control()
}
register_sidebar_widget(\’PHPlist\’, \’widget_PHPlist\’)::
// This registers the (optional!) widget control form.
register_widget_control(\’PHPlist\’, \’widget_PHPlist_control\’)::
}
add_action(\’plugins_loaded\’, \’widget_PHPlist_init\’)::
?>::
You can download the file here.