From 0b1582dc2d3274866c19dfba92a5f875f0f255f8 Mon Sep 17 00:00:00 2001 From: champsupertramp Date: Thu, 21 Apr 2016 09:59:11 +0800 Subject: [PATCH] Remove notices --- core/um-shortcodes.php | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/core/um-shortcodes.php b/core/um-shortcodes.php index d5735e82..68943ee3 100644 --- a/core/um-shortcodes.php +++ b/core/um-shortcodes.php @@ -420,25 +420,29 @@ class UM_Shortcodes { foreach ($paths as $k => $files) { - foreach ($files as $file) { + if( isset( $files ) && ! empty( $files ) ){ + + 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; - } } }