post_id = $post_id; } /** * Get post meta field. * * @param string $key * @param $default * @param bool $single * * @return mixed|null */ public function get( string $key, $default = null, bool $single = true ): mixed { $value = get_post_meta( $this->post_id, Constants::META_PREFIX . $key, $single ); return $value !== '' ? $value : $default; } /** * Set post meta field. Key is prefixed with Constants::META_PREFIX to match get(). * * @param string $key * @param $value * * @return void */ public function set( string $key, $value ): void { update_post_meta( $this->post_id, Constants::META_PREFIX . $key, $value ); } /** * Delete post meta field by key. Key is prefixed with Constants::META_PREFIX to match get(). * * @param string $key Meta key. * * @return void */ public function delete( string $key ): void { delete_post_meta( $this->post_id, Constants::META_PREFIX . $key ); } }