classes/Pods.php
public function save( $data = null, $value = null, $id = null, $params = null ) {

		if ( null !== $data && ! is_array( $data ) ) {
			$data = array( $data => $value );
		}

		$fetch = false;

		// @codingStandardsIgnoreLine
		if ( null === $id || ( $this->row && $id == $this->id() ) ) {
			$fetch = true;

			if ( null === $id ) {
				$id = $this->id();
			}
		}

		$data = (array) $this->do_hook( 'save', $data, $id );

		if ( empty( $data ) && empty( $params['is_new_item'] ) ) {
			return $id;
		}

		$default = array();

		if ( ! empty( $params ) && is_array( $params ) ) {
			$default = $params;
		}

		$params = array(
			'pod'                 => $this->pod,
			'id'                  => $id,
			'data'                => $data,
			'allow_custom_fields' => true,
			'clear_slug_cache'    => false,
		);

		if ( ! empty( $default ) ) {
			$params = array_merge( $params, $default );
		}

		$id = $this->api->save_pod_item( $params );

		if ( 0 < $id && $fetch ) {
			// Clear local var cache of field values.
			$this->data->row = array();

			$this->fetch( $id, false );
		}

		if ( ! empty( $this->pod_data['field_slug'] ) ) {
			if ( 0 < $id && $fetch ) {
				$slug = $this->field( $this->pod_data['field_slug'] );
			} else {
				$slug = pods( $this->pod, $id )->field( $this->pod_data['field_slug'] );
			}

			if ( 0 < strlen( $slug ) ) {
				pods_cache_clear( $slug, 'pods_items_' . $this->pod );
			}
		}

		return $id;
	}
public function save( $data = null, $value = null, $id = null, $params = null ) {

		if ( null !== $data && ! is_array( $data ) ) {
			$data = array( $data => $value );
		}

		$fetch = false;

		// @codingStandardsIgnoreLine
		if ( null === $id || ( $this->row && $id == $this->id() ) ) {
			$fetch = true;

			if ( null === $id ) {
				$id = $this->id();
			}
		}

		$data = (array) $this->do_hook( 'save', $data, $id );

		if ( empty( $data ) && empty( $params['is_new_item'] ) ) {
			return $id;
		}

		$default = array();

		if ( ! empty( $params ) && is_array( $params ) ) {
			$default = $params;
		}

		$params = array(
			'pod'                 => $this->pod,
			'id'                  => $id,
			'data'                => $data,
			'allow_custom_fields' => true,
			'clear_slug_cache'    => false,
		);

		if ( ! empty( $default ) ) {
			$params = array_merge( $params, $default );
		}

		$id = $this->api->save_pod_item( $params );

		if ( 0 < $id && $fetch ) {
			// Clear local var cache of field values.
			$this->data->row = array();

			$this->fetch( $id, false );
		}

		if ( ! empty( $this->pod_data['field_slug'] ) ) {
			if ( 0 < $id && $fetch ) {
				$slug = $this->field( $this->pod_data['field_slug'] );
			} else {
				$slug = pods( $this->pod, $id )->field( $this->pod_data['field_slug'] );
			}

			if ( 0 < strlen( $slug ) ) {
				pods_cache_clear( $slug, 'pods_items_' . $this->pod );
			}
		}

		return $id;
	}
public function save ( $ data = null , $ value = null , $ id = null , $ params = null ) { if ( null !== $ data && ! is_array ( $ data ) ) { $ data = array ( $ data => $ value ) ; } $ fetch = false ; // @codingStandardsIgnoreLine if ( null === $ id || ( $ this -> row && $ id == $ this -> id ( ) ) ) { $ fetch = true ; if ( null === $ id ) { $ id = $ this -> id ( ) ; } } $ data = ( array ) $ this -> do_hook ( 'save' , $ data , $ id ) ; if ( empty ( $ data ) && empty ( $ params [ 'is_new_item' ] ) ) { return $ id ; } $ default = array ( ) ; if ( ! empty ( $ params ) && is_array ( $ params ) ) { $ default = $ params ; } $ params = array ( 'pod' => $ this -> pod , 'id' => $ id , 'data' => $ data , 'allow_custom_fields' => true , 'clear_slug_cache' => false , ) ; if ( ! empty ( $ default ) ) { $ params = array_merge ( $ params , $ default ) ; } $ id = $ this -> api -> save_pod_item ( $ params ) ; if ( 0 < $ id && $ fetch ) { // Clear local var cache of field values. $ this -> data -> row = array ( ) ; $ this -> fetch ( $ id , false ) ; } if ( ! empty ( $ this -> pod_data [ 'field_slug' ] ) ) { if ( 0 < $ id && $ fetch ) { $ slug = $ this -> field ( $ this -> pod_data [ 'field_slug' ] ) ; } else { $ slug = pods ( $ this -> pod , $ id ) -> field ( $ this -> pod_data [ 'field_slug' ] ) ; } if ( 0 < strlen ( $ slug ) ) { pods_cache_clear ( $ slug , 'pods_items_' . $ this -> pod ) ; } } return $ id ; }
Save an item by giving an array of field data or set a specific field to a specific value.

Though this function has the capacity to add new items, best practice should direct you
to use add() for that instead.

@see   PodsAPI::save_pod_item

@param array|string $data   Either an associative array of field information or a field name.
@param mixed        $value  (optional) Value of the field, if $data is a field name.
@param int          $id     (optional) ID of the pod item to update.
@param array        $params (optional) Additional params to send to save_pod_item.

@return int The item ID

@since 2.0.0
@link  https://pods.io/docs/save/
Save an item by giving an array of field data or set a specific field to a specific value .