__('Allows a registered user to add to the Acronym Manager collection from a sidebar widget.', 'Acronym Manager') ); parent::WP_Widget( 'Acronym_Manager_Widget', __('Acronym Manager Widget','Acronym_Manager'), $widget_ops); } /* Widget Admin form */ function form($instance) { /* Set up default values for widget settings. */ $instance = wp_parse_args((array) $instance, array('title'=>'Add Acronym')); echo '
'; } function update($new_instance, $old_instance) { /* If the user tries to type any HTML tags, like
, or into the title field, this line will strip it out. */ $instance['title'] = strip_tags($new_instance['title']); return $instance; } /* What widget displays when called */ function widget( $args, $instance ) { echo $args['before_widget']; /* If the user has set a title for the widget, display it. */ if ( $instance['title'] ) echo $args['before_title'] . $instance['title'] . $args['after_title']; if ( isset($_GET['acronym']) ) { $acronym = $_GET['acronym']; $fulltext = $_GET['fulltext']; get_currentuserinfo() ; global $user_level; if ( empty($acronym) || empty($fulltext) ) { $message = __('Acronym not added: incomplete.'); } elseif ($user_level <= 0) { $message = __('You do not have permission to add an acronym.'); } elseif ($user_level > 0) { $acronyms = get_option('acronym_acronyms'); $acronyms[$acronym] = $fulltext; update_option('acronym_acronyms', $acronyms); $message = __('Acronym successfully added.'); } } ?>