From 6eb0777e01a7e805b0693df9ec465d539b5afd4e Mon Sep 17 00:00:00 2001 From: champsupertramp Date: Wed, 30 Mar 2016 10:00:41 +0800 Subject: [PATCH] Remove notices --- core/um-shortcodes.php | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/core/um-shortcodes.php b/core/um-shortcodes.php index 2d16b30c..d5735e82 100644 --- a/core/um-shortcodes.php +++ b/core/um-shortcodes.php @@ -416,33 +416,37 @@ class UM_Shortcodes { $paths[] = glob(get_stylesheet_directory() . '/ultimate-member/templates/' . '*.php'); } - foreach ($paths as $k => $files) { + if( isset( $paths ) && ! empty( $paths ) ){ + + foreach ($paths as $k => $files) { - foreach ($files as $file) { + foreach ($files as $file) { - $clean_filename = $this->get_template_name($file); + $clean_filename = $this->get_template_name($file); - if (0 === strpos($clean_filename, $excluded)) { + if (0 === strpos($clean_filename, $excluded)) { - $source = file_get_contents($file); - $tokens = token_get_all($source); - $comment = array( - T_COMMENT, // All comments since PHP5 - T_DOC_COMMENT, // PHPDoc comments - ); - foreach ($tokens as $token) { - if (in_array($token[0], $comment) && strstr($token[1], '/* Template:') && $clean_filename != $excluded) { - $txt = $token[1]; - $txt = str_replace('/* Template: ', '', $txt); - $txt = str_replace(' */', '', $txt); - $array[$clean_filename] = $txt; + $source = file_get_contents($file); + $tokens = token_get_all($source); + $comment = array( + T_COMMENT, // All comments since PHP5 + T_DOC_COMMENT, // PHPDoc comments + ); + foreach ($tokens as $token) { + if (in_array($token[0], $comment) && strstr($token[1], '/* Template:') && $clean_filename != $excluded) { + $txt = $token[1]; + $txt = str_replace('/* Template: ', '', $txt); + $txt = str_replace(' */', '', $txt); + $array[$clean_filename] = $txt; + } } + } } } - + } return $array;