protected function prepare_properties_data( array $data = [], $post_id = 0 ) {
		// Since we are storing witch property it is in the `$data` array
		// we need to remove that and set the property type to the property
		// and make a array of the property type and the value.
		foreach ( $data as $key => $value ) {
			if ( papi_is_property_type_key( $key ) ) {
				continue;
			}

			$property_type_key = papify( papi_get_property_type_key( $key ) );

			// Check if value exists.
			if ( ! isset( $data[$key] ) || ! isset( $data[$property_type_key] ) ) {
				continue;
			}

			// Pair property value with property type object.
			$data[$key] = [
				'type'  => $data[$property_type_key],
				'value' => $value
			];

			// Remove property type object since it's not needed anymore.
			unset( $data[$property_type_key] );
		}

		foreach ( $data as $key => $item ) {
			if ( papi_is_property_type_key( $key ) ) {
				if ( isset( $data[$key] ) ) {
						unset( $data[$key] );
				}
				continue;
			}

			if ( empty( $item['type'] ) ) {
				continue;
			}

			$property = papi_get_property_type( $item['type'] );

			unset( $data[ $key ] );

			if ( papi_is_property( $property ) ) {
				// Run `update_value` method on the property class.
				$data[$key] = $property->update_value(
					$item['value'],
					unpapify( $key ),
					$post_id
				);

				// Apply `update_value` filter so this can be changed from
				// the theme for specified property type.
				$data[$key] = papi_filter_update_value(
					$item['type']->type,
					$data[$key],
					unpapify( $key ),
					$post_id,
					papi_get_meta_type()
				);

				if ( $item['type']->overwrite ) {
					$slug = unpapify( $key );
					$this->overwrite[$slug] = $data[$key];
					unset( $data[$key] );
				}
			}
		}

		return $data;
	}
protected function prepare_properties_data( array $data = [], $post_id = 0 ) {
		// Since we are storing witch property it is in the `$data` array
		// we need to remove that and set the property type to the property
		// and make a array of the property type and the value.
		foreach ( $data as $key => $value ) {
			if ( papi_is_property_type_key( $key ) ) {
				continue;
			}

			$property_type_key = papify( papi_get_property_type_key( $key ) );

			// Check if value exists.
			if ( ! isset( $data[$key] ) || ! isset( $data[$property_type_key] ) ) {
				continue;
			}

			// Pair property value with property type object.
			$data[$key] = [
				'type'  => $data[$property_type_key],
				'value' => $value
			];

			// Remove property type object since it's not needed anymore.
			unset( $data[$property_type_key] );
		}

		foreach ( $data as $key => $item ) {
			if ( papi_is_property_type_key( $key ) ) {
				if ( isset( $data[$key] ) ) {
						unset( $data[$key] );
				}
				continue;
			}

			if ( empty( $item['type'] ) ) {
				continue;
			}

			$property = papi_get_property_type( $item['type'] );

			unset( $data[ $key ] );

			if ( papi_is_property( $property ) ) {
				// Run `update_value` method on the property class.
				$data[$key] = $property->update_value(
					$item['value'],
					unpapify( $key ),
					$post_id
				);

				// Apply `update_value` filter so this can be changed from
				// the theme for specified property type.
				$data[$key] = papi_filter_update_value(
					$item['type']->type,
					$data[$key],
					unpapify( $key ),
					$post_id,
					papi_get_meta_type()
				);

				if ( $item['type']->overwrite ) {
					$slug = unpapify( $key );
					$this->overwrite[$slug] = $data[$key];
					unset( $data[$key] );
				}
			}
		}

		return $data;
	}
protected function prepare_properties_data ( array $ data = [ ] , $ post_id = 0 ) { // Since we are storing witch property it is in the `$data` array // we need to remove that and set the property type to the property // and make a array of the property type and the value. foreach ( $ data as $ key => $ value ) { if ( papi_is_property_type_key ( $ key ) ) { continue ; } $ property_type_key = papify ( papi_get_property_type_key ( $ key ) ) ; // Check if value exists. if ( ! isset ( $ data [ $ key ] ) || ! isset ( $ data [ $ property_type_key ] ) ) { continue ; } // Pair property value with property type object. $ data [ $ key ] = [ 'type' => $ data [ $ property_type_key ] , 'value' => $ value ] ; // Remove property type object since it's not needed anymore. unset ( $ data [ $ property_type_key ] ) ; } foreach ( $ data as $ key => $ item ) { if ( papi_is_property_type_key ( $ key ) ) { if ( isset ( $ data [ $ key ] ) ) { unset ( $ data [ $ key ] ) ; } continue ; } if ( empty ( $ item [ 'type' ] ) ) { continue ; } $ property = papi_get_property_type ( $ item [ 'type' ] ) ; unset ( $ data [ $ key ] ) ; if ( papi_is_property ( $ property ) ) { // Run `update_value` method on the property class. $ data [ $ key ] = $ property -> update_value ( $ item [ 'value' ] , unpapify ( $ key ) , $ post_id ) ; // Apply `update_value` filter so this can be changed from // the theme for specified property type. $ data [ $ key ] = papi_filter_update_value ( $ item [ 'type' ] -> type , $ data [ $ key ] , unpapify ( $ key ) , $ post_id , papi_get_meta_type ( ) ) ; if ( $ item [ 'type' ] -> overwrite ) { $ slug = unpapify ( $ key ) ; $ this -> overwrite [ $ slug ] = $ data [ $ key ] ; unset ( $ data [ $ key ] ) ; } } } return $ data ; }
Prepare properties data for saving.

@param  array $data
@param  int   $post_id

@return array
Prepare properties data for saving .