Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class signup_Widget extends WP_Widget {
- function signup_Widget() {
- $widget_ops = array(
- 'classname' => 'widget',
- 'description' => 'Email signup form.'
- );
- $this->WP_Widget( 'email-signup', 'Email Signup', $widget_ops );
- }
- function widget($args, $instance) {
- extract( $args );
- $title = apply_filters( 'widget_title', $instance['title'] );
- $script = $instance['script'];
- echo $before_widget;
- echo $before_title . $title . $after_title ;
- htmlspecialchars( $script );
- echo $after_widget;
- }
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['title'] = $new_instance['title'];
- $instance['script'] = $new_instance['script'];
- /* Exists to test output, unfortunately they show up with no data */
- file_put_contents( '/wp_results.txt', print_r( $old_instance, true ) );
- file_put_contents( '/wp_results.txt', print_r( $new_instance, true ), FILE_APPEND );
- return $instance;
- }
- function form( $instance ) {
- /* Defaults */
- $defaults = array(
- 'title' => 'Email Signup',
- 'script' => 'Default Email Signup Script goes here'
- );
- $instance = wp_parse_args( (array) $instance, $defaults );
- ?>
- <p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label>
- <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_id( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:95%" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'script' ); ?>">Script:</label>
- <input id="<?php $this->get_field_id( 'script' ); ?>" name="<?php $this->get_field_id( 'script' ); ?>" value="<?php echo $instance['script']; ?>" style="width:95%" />
- </p>
- <?php
- }
- }
- register_widget( 'signup_Widget' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement