Skip to main content
deleted 204 characters in body
Source Link
s_ha_dum
  • 65.5k
  • 13
  • 84
  • 174

Your primary issue isn't with saving the data but displaying in the form if it has been saved. I rewrote the offending function:

  function form($instance) {
    $title = strip_tags( $instance['title'] );
    $info = esc_textarea( $instance['info'] );
    // var_dump($instance); // debug
    ?>
    <p>
      <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
      <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
    </p>
    <p>
    <label for="<?php echo $this->get_field_id('info'); ?>"><?php _e('Text Goes here:'); ?></label>
      <textarea class="widefat" rows="8" cols="10" id="<?php echo $this->get_field_id('info'); ?>" name="<?php echo $this->get_field_name('info'); ?>">
        <>"><?php // This will add the previously saved data to the form
        if (!empty($info)) echo $info; ?>
      <></textarea>
    <?php
  }

Your form appears to be adding some odd characters to the form text, though. I will update when I sort that out.

You should make the change suggest by @br3nt, though.

I don't see any other issues except for some minor notices that you would see if you had debugging enabled

Your primary issue isn't with saving the data but displaying in the form if it has been saved. I rewrote the offending function:

  function form($instance) {
    $title = strip_tags( $instance['title'] );
    $info = esc_textarea( $instance['info'] );
    // var_dump($instance); // debug
    ?>
    <p>
      <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
      <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
    </p>
    <p>
    <label for="<?php echo $this->get_field_id('info'); ?>"><?php _e('Text Goes here:'); ?></label>
      <textarea class="widefat" rows="8" cols="10" id="<?php echo $this->get_field_id('info'); ?>" name="<?php echo $this->get_field_name('info'); ?>">
        <?php // This will add the previously saved data to the form
        if (!empty($info)) echo $info; ?>
      </textarea>
    <?php
  }

Your form appears to be adding some odd characters to the form text, though. I will update when I sort that out.

You should make the change suggest by @br3nt, though.

Your primary issue isn't with saving the data but displaying in the form if it has been saved. I rewrote the offending function:

  function form($instance) {
    $title = strip_tags( $instance['title'] );
    $info = esc_textarea( $instance['info'] );
    // var_dump($instance); // debug
    ?>
    <p>
      <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
      <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
    </p>
    <p>
    <label for="<?php echo $this->get_field_id('info'); ?>"><?php _e('Text Goes here:'); ?></label>
      <textarea class="widefat" rows="8" cols="10" id="<?php echo $this->get_field_id('info'); ?>" name="<?php echo $this->get_field_name('info'); ?>"><?php if (!empty($info)) echo $info; ?></textarea>
    <?php
  }

You should make the change suggest by @br3nt, though.

I don't see any other issues except for some minor notices that you would see if you had debugging enabled

Source Link
s_ha_dum
  • 65.5k
  • 13
  • 84
  • 174

Your primary issue isn't with saving the data but displaying in the form if it has been saved. I rewrote the offending function:

  function form($instance) {
    $title = strip_tags( $instance['title'] );
    $info = esc_textarea( $instance['info'] );
    // var_dump($instance); // debug
    ?>
    <p>
      <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
      <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
    </p>
    <p>
    <label for="<?php echo $this->get_field_id('info'); ?>"><?php _e('Text Goes here:'); ?></label>
      <textarea class="widefat" rows="8" cols="10" id="<?php echo $this->get_field_id('info'); ?>" name="<?php echo $this->get_field_name('info'); ?>">
        <?php // This will add the previously saved data to the form
        if (!empty($info)) echo $info; ?>
      </textarea>
    <?php
  }

Your form appears to be adding some odd characters to the form text, though. I will update when I sort that out.

You should make the change suggest by @br3nt, though.