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

update


Description Description

Saves the widget settings when a dashboard user clicks the Save button.


Top ↑

Parameters Parameters

$new_instance

(array) (Required)

$old_instance

(array) (Required)


Top ↑

Return Return

(array) The updated array full of settings


Top ↑

Source Source

File: includes/widget/class-widget-order-by.php

	public function update( $new_instance, $old_instance ) {
		$instance          = array();
		$instance['title'] = strip_tags( $new_instance['title'] );
		$keys              = array();
		foreach ( INVP::keys() as $key ) {
			$key = apply_filters( 'invp_prefix_meta_key', $key );
			if ( isset( $_REQUEST[ 'obpm-key-' . $key ] ) ) {
				array_push( $keys, $key );
				if ( isset( $_REQUEST[ 'obpm-label-' . $key ] ) ) {
					$instance[ 'label-' . $key ] = strip_tags( $_REQUEST[ 'obpm-label-' . $key ] );
				}
			} else {
				unset( $instance[ 'label-' . $key ] );
			}
		}
		$instance['post-meta-keys'] = implode( '|', $keys );
		return $instance;
	}