From 508170e9f4e4a921f6e7c61c4f5f3b78c3d725b0 Mon Sep 17 00:00:00 2001
From: Kyle Phillips <kyle@object9.com>
Date: Wed, 21 Nov 2018 13:40:45 -0500
Subject: [PATCH] Fixes issue where only one custom field was being output when
 multiple were specified in the custom list html. Closes #95

---
 app/Entities/FavoriteList/FavoriteListingPresenter.php | 6 ++++--
 readme.txt                                             | 3 +++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/app/Entities/FavoriteList/FavoriteListingPresenter.php b/app/Entities/FavoriteList/FavoriteListingPresenter.php
index c9c6346..0b1ccbb 100644
--- a/app/Entities/FavoriteList/FavoriteListingPresenter.php
+++ b/app/Entities/FavoriteList/FavoriteListingPresenter.php
@@ -131,10 +131,12 @@ private function getThumbnail($size)
 	*/
 	private function replaceCustomFields()
 	{
-		preg_match("/\[[^\]]*\]/", $this->html, $out);
-		foreach($out as $field){
+		preg_match_all("/\[[^\]]*\]/", $this->html, $out);
+		if ( empty($out) ) return;
+		foreach($out[0] as $field){
 			$field_bracketed = $field;
 			$key = str_replace('[', '', $field);
+			$key = str_replace('custom_field:', '', $key);
 			$key = str_replace(']', '', $key);
 			$meta = get_post_meta($this->favorite, $key, true);
 			if ( !$meta ) $meta = '';
diff --git a/readme.txt b/readme.txt
index abdc6e5..16e5316 100644
--- a/readme.txt
+++ b/readme.txt
@@ -81,6 +81,9 @@ As of version 1.1.0, Favorites is compatible with multisite installations. By de
 
 == Changelog ==
 
+= 2.3.1 =
+* Bug Fix: Fixes issue where only one custom field was being output when multiple were specified in the custom list html.
+
 = 2.3.0 =
 * Security Update: Removes ability for users to manipulate favorites belonging to other users. Thanks to Arne van Hoorn for uncovering this issue.