(string) get_post_meta( $post_id, $this->title_key(), true ), 'description' => (string) get_post_meta( $post_id, $this->description_key(), true ), ); } public function set( int $post_id, ?string $title, ?string $description ): void { if ( null !== $title ) { self::write( $post_id, $this->title_key(), $title ); } if ( null !== $description ) { self::write( $post_id, $this->description_key(), $description ); } } private static function write( int $post_id, string $key, string $value ): void { if ( '' === $value ) { delete_post_meta( $post_id, $key ); return; } // update_post_meta() unslashes; slash first so backslashes survive. update_post_meta( $post_id, $key, wp_slash( $value ) ); } }