AnsPress_Leaderboard_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: widgets/leaderboard.php

	public function update( $new_instance, $old_instance ) {
		$instance = array();

		$instance['title']         = ( ! empty( $new_instance['title'] ) ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
		$instance['avatar_size']   = ( ! empty( $new_instance['avatar_size'] ) ) ? absint( $new_instance['avatar_size'] ) : 40;
		$instance['show_users']    = ( ! empty( $new_instance['show_users'] ) ) ? absint( $new_instance['show_users'] ) : 12;
		$instance['users_per_row'] = ( ! empty( $new_instance['users_per_row'] ) ) ? absint( $new_instance['users_per_row'] ) : 4;
		$instance['interval']      = ( ! empty( $new_instance['interval'] ) ) ? absint( $new_instance['interval'] ) : 30;

		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