From d8f9f4b8e8ba4c049e823117fc17fcb353bd3a28 Mon Sep 17 00:00:00 2001 From: Anderson Grudtner Martins Date: Mon, 13 Mar 2017 18:29:46 -0300 Subject: [PATCH] EPRESS-103 Fixes PHP warning for Gists --- src/EmbedPress/Shortcode.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/EmbedPress/Shortcode.php b/src/EmbedPress/Shortcode.php index c79d18b6..173a7021 100644 --- a/src/EmbedPress/Shortcode.php +++ b/src/EmbedPress/Shortcode.php @@ -540,14 +540,25 @@ private static function extractContentFromHeaderAsArray($headerPattern, $headers */ private static function sanitizeUrlData($data) { - $attributes = get_object_vars($data); - - foreach ($attributes as $key => $value) { - if (substr_count($key, '-')) { - unset($data->$key); - - $key = str_replace('-', '_', $key); - $data->$key = $value; + if (is_object($data)) { + $attributes = get_object_vars($data); + + foreach ($attributes as $key => $value) { + if (substr_count($key, '-')) { + unset($data->$key); + + $key = str_replace('-', '_', $key); + $data->$key = $value; + } + } + } elseif (is_array($data)) { + foreach ($data as $key => $value) { + if (substr_count($key, '-')) { + unset($data[$key]); + + $key = str_replace('-', '_', $key); + $data[$key] = $value; + } } }