AnsPress_Category_Widget::update( array $new_instance, array $old_instance )

Description #

Sanitize widget form values as they are saved.

Parameters #

  • $new_instance
    array (Required) Values just sent to be saved.
  • $old_instance
    array (Required) Previously saved values from database.

Source #

File: addons/free/category/widget.php

	public function update( $new_instance, $old_instance ) {
		$instance = array();
		$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
		$instance['hide_empty'] = ( ! empty( $new_instance['hide_empty'] ) ) ? strip_tags( $new_instance['hide_empty'] ) : false;
		$instance['parent'] = ( ! empty( $new_instance['parent'] ) ) ? strip_tags( $new_instance['parent'] ) : '0';
		$instance['number'] = ( ! empty( $new_instance['number'] ) ) ? strip_tags( $new_instance['number'] ) : '5';
		$instance['orderby'] = ( ! empty( $new_instance['orderby'] ) ) ? strip_tags( $new_instance['orderby'] ) : 'count';
		$instance['order'] = ( ! empty( $new_instance['order'] ) ) ? strip_tags( $new_instance['order'] ) : 'DESC';
		$instance['icon_width'] = ( ! empty( $new_instance['icon_width'] ) ) ? (int)strip_tags( $new_instance['icon_width'] ) : 32;
		$instance['icon_height'] = ( ! empty( $new_instance['icon_height'] ) ) ? (int)strip_tags( $new_instance['icon_height'] ) : 32;

		return $instance;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment