'; echo $after_widget; } // This is the function that outputs the form to let the users edit // the widget's title and other options. function widget_ldtv_control() { // Get our options and see if we're handling a form submission. $options = get_option('widget_ldtv'); if ( !is_array($options) ) $options = array('title'=>'','width'=>'200','text'=>'on'); if ( $_POST['ldtv-submit'] ) { // Sanitize and format use input appropriately. $options['title'] = strip_tags(stripslashes($_POST['ldtv-title'])); $options['width'] = strip_tags(stripslashes($_POST['ldtv-width'])); $options['text'] = strip_tags(stripslashes($_POST['ldtv-text'])); update_option('widget_ldtv', $options); } // Format options to be valid HTML attributes. $title = htmlspecialchars($options['title'], ENT_QUOTES); $width = htmlspecialchars($options['width'], ENT_QUOTES); $text = htmlspecialchars($options['text'], ENT_QUOTES); // Form segment. This will be embedded into the existing form. echo '


Leave this blank if you do not want a header.
'; echo '


'; echo '

'; echo ''; } // Register the widget so it appears with the other available // widgets and can be dragged and dropped into any active sidebars. register_sidebar_widget('Lib Dem latest film widget', 'widget_ldtv'); // Register optional widget control form. Because of this // the widget will have a button that reveals a 300x350 pixel form. register_widget_control('Lib Dem latest film widget', 'widget_ldtv_control', 300, 350); } // Run code later in case this loads prior to any required plugins. add_action('plugins_loaded', 'widget_ldtv_init'); ?>