Categories::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/categories/widget.php

	public function update( $new_instance, $old_instance ) {
		$instance                = array();
		$instance['title']       = ( ! empty( $new_instance['title'] ) ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
		$instance['hide_empty']  = ( ! empty( $new_instance['hide_empty'] ) ) ? wp_strip_all_tags( $new_instance['hide_empty'] ) : false;
		$instance['parent']      = ( ! empty( $new_instance['parent'] ) ) ? wp_strip_all_tags( $new_instance['parent'] ) : '0';
		$instance['number']      = ( ! empty( $new_instance['number'] ) ) ? wp_strip_all_tags( $new_instance['number'] ) : '5';
		$instance['orderby']     = ( ! empty( $new_instance['orderby'] ) ) ? wp_strip_all_tags( $new_instance['orderby'] ) : 'count';
		$instance['order']       = ( ! empty( $new_instance['order'] ) ) ? wp_strip_all_tags( $new_instance['order'] ) : 'DESC';
		$instance['icon_width']  = ( ! empty( $new_instance['icon_width'] ) ) ? (int) $new_instance['icon_width'] : 32;
		$instance['icon_height'] = ( ! empty( $new_instance['icon_height'] ) ) ? (int) $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