classes/PodsRESTHandlers.php
public static function save_handler( $object, $request, $creating ) {

		if ( is_a( $object, 'WP_Post' ) ) {
			$pod_name = $object->post_type;

			if ( 'attachment' === $pod_name ) {
				$pod_name = 'media';
			}

			$id = $object->ID;
		} elseif ( is_a( $object, 'WP_Term' ) ) {
			$pod_name = $object->taxonomy;

			$id = $object->term_id;
		} elseif ( is_a( $object, 'WP_User' ) ) {
			$pod_name = 'user';

			$id = $object->ID;
		} elseif ( is_a( $object, 'WP_Comment' ) ) {
			$pod_name = 'comment';

			$id = $object->comment_ID;
		} else {
			// Not a supported object
			return;
		}//end if

		$pod = self::get_pod( $pod_name, $id );

		global $wp_rest_additional_fields;

		$rest_enable = (boolean) pods_v( 'rest_enable', $pod->pod_data['options'], false );

		if ( $pod && $rest_enable && ! empty( $wp_rest_additional_fields[ $pod_name ] ) ) {
			$fields = $pod->fields();

			$save_fields = array();

			$params = array(
				'is_new_item' => $creating,
			);

			foreach ( $fields as $field_name => $field ) {
				if ( empty( $wp_rest_additional_fields[ $pod_name ][ $field_name ]['pods_update'] ) ) {
					continue;
				} elseif ( ! isset( $request[ $field_name ] ) ) {
					continue;
				} elseif ( ! PodsRESTFields::field_allowed_to_extend( $field_name, $pod, 'write' ) ) {
					continue;
				}

				$save_fields[ $field_name ] = $request[ $field_name ];
			}

			if ( ! empty( $save_fields ) || $creating ) {
				$pod->save( $save_fields, null, null, $params );
			}
		}//end if

	}
public static function save_handler( $object, $request, $creating ) {

		if ( is_a( $object, 'WP_Post' ) ) {
			$pod_name = $object->post_type;

			if ( 'attachment' === $pod_name ) {
				$pod_name = 'media';
			}

			$id = $object->ID;
		} elseif ( is_a( $object, 'WP_Term' ) ) {
			$pod_name = $object->taxonomy;

			$id = $object->term_id;
		} elseif ( is_a( $object, 'WP_User' ) ) {
			$pod_name = 'user';

			$id = $object->ID;
		} elseif ( is_a( $object, 'WP_Comment' ) ) {
			$pod_name = 'comment';

			$id = $object->comment_ID;
		} else {
			// Not a supported object
			return;
		}//end if

		$pod = self::get_pod( $pod_name, $id );

		global $wp_rest_additional_fields;

		$rest_enable = (boolean) pods_v( 'rest_enable', $pod->pod_data['options'], false );

		if ( $pod && $rest_enable && ! empty( $wp_rest_additional_fields[ $pod_name ] ) ) {
			$fields = $pod->fields();

			$save_fields = array();

			$params = array(
				'is_new_item' => $creating,
			);

			foreach ( $fields as $field_name => $field ) {
				if ( empty( $wp_rest_additional_fields[ $pod_name ][ $field_name ]['pods_update'] ) ) {
					continue;
				} elseif ( ! isset( $request[ $field_name ] ) ) {
					continue;
				} elseif ( ! PodsRESTFields::field_allowed_to_extend( $field_name, $pod, 'write' ) ) {
					continue;
				}

				$save_fields[ $field_name ] = $request[ $field_name ];
			}

			if ( ! empty( $save_fields ) || $creating ) {
				$pod->save( $save_fields, null, null, $params );
			}
		}//end if

	}
public static function save_handler ( $ object , $ request , $ creating ) { if ( is_a ( $ object , 'WP_Post' ) ) { $ pod_name = $ object -> post_type ; if ( 'attachment' === $ pod_name ) { $ pod_name = 'media' ; } $ id = $ object -> ID ; } elseif ( is_a ( $ object , 'WP_Term' ) ) { $ pod_name = $ object -> taxonomy ; $ id = $ object -> term_id ; } elseif ( is_a ( $ object , 'WP_User' ) ) { $ pod_name = 'user' ; $ id = $ object -> ID ; } elseif ( is_a ( $ object , 'WP_Comment' ) ) { $ pod_name = 'comment' ; $ id = $ object -> comment_ID ; } else { // Not a supported object return ; } //end if $ pod = self :: get_pod ( $ pod_name , $ id ) ; global $ wp_rest_additional_fields ; $ rest_enable = ( boolean ) pods_v ( 'rest_enable' , $ pod -> pod_data [ 'options' ] , false ) ; if ( $ pod && $ rest_enable && ! empty ( $ wp_rest_additional_fields [ $ pod_name ] ) ) { $ fields = $ pod -> fields ( ) ; $ save_fields = array ( ) ; $ params = array ( 'is_new_item' => $ creating , ) ; foreach ( $ fields as $ field_name => $ field ) { if ( empty ( $ wp_rest_additional_fields [ $ pod_name ] [ $ field_name ] [ 'pods_update' ] ) ) { continue ; } elseif ( ! isset ( $ request [ $ field_name ] ) ) { continue ; } elseif ( ! PodsRESTFields :: field_allowed_to_extend ( $ field_name , $ pod , 'write' ) ) { continue ; } $ save_fields [ $ field_name ] = $ request [ $ field_name ] ; } if ( ! empty ( $ save_fields ) || $ creating ) { $ pod -> save ( $ save_fields , null , null , $ params ) ; } } //end if }
Handle saving of Pod fields from REST API write requests.

@param WP_Post|WP_Term|WP_User|WP_Comment $object   Inserted or updated object.
@param WP_REST_Request                    $request  Request object.
@param bool                               $creating True when creating an item, false when updating.
Handle saving of Pod fields from REST API write requests .