WP_Sync_Post_Meta_Storage::add_update( string $room, mixed $update ): bool

In this article

Adds a sync update to a given room.

Parameters

$roomstringrequired
Room identifier.
$updatemixedrequired
Sync update.

Return

bool True on success, false on failure.

Source

public function add_update( string $room, $update ): bool {
	global $wpdb;

	$post_id = $this->get_storage_post_id( $room );
	if ( null === $post_id ) {
		return false;
	}

	// Use direct database operation to avoid cache invalidation performed by
	// post meta functions (`wp_cache_set_posts_last_changed()` and direct
	// `wp_cache_delete()` calls).
	return (bool) $wpdb->insert(
		$wpdb->postmeta,
		array(
			'post_id'    => $post_id,
			'meta_key'   => self::SYNC_UPDATE_META_KEY,
			'meta_value' => wp_json_encode( $update ),
		),
		array( '%d', '%s', '%s' )
	);
}

Changelog

VersionDescription
7.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.