From 77af346efddb2a61d5d887e3774e464b97bf373d Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Mon, 23 Sep 2024 12:02:16 +0200 Subject: [PATCH] optimize MC4WP_Form::get_subscriber_tags --- includes/forms/class-form.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/includes/forms/class-form.php b/includes/forms/class-form.php index e6bf8997..24b6b049 100755 --- a/includes/forms/class-form.php +++ b/includes/forms/class-form.php @@ -760,20 +760,14 @@ public function get_message($key) */ public function get_subscriber_tags() { - if (empty($this->settings['subscriber_tags'])) { - return array(); - } - - $tags = explode(',', $this->settings['subscriber_tags']); - $tags = array_map('trim', $tags); - - // remove empty tag values - foreach ($tags as $i => $tag) { - if ($tag === '') { - unset($tags[ $i ]); - } - } - - return array_values($tags); + $tags = array(); + foreach (explode(',', $this->settings['subscriber_tags']) as $v) { + $v = trim($v); + if ($v == '') { + continue; + } + $tags[] = $v; + } + return $tags; } }