public function Get_Template_Files() { $arr_template = Array_Unique(Array_Merge((array) Glob(DirName(__FILE__) . '/templates/*.php'), (array) Glob(DirName(__FILE__) . '/templates/*/*.php'), (array) Glob(Get_StyleSheet_Directory() . '/*.php'), (array) Glob(Get_StyleSheet_Directory() . '/*/*.php'), Is_Child_Theme() ? (array) Glob(Get_Template_Directory() . '/*.php') : array(), Is_Child_Theme() ? (array) Glob(Get_Template_Directory() . '/*/*.php') : array(), (array) Glob($this->template_dir . '/*.php'), (array) Glob($this->template_dir . '/*/*.php'))); # Filter to add template files - you can use this filter to add template files to the user interface $arr_template = Apply_Filters('fancy_gallery_template_files', $arr_template); # Check if there template files if (empty($arr_template)) { return False; } $arr_result = array(); $arr_sort = array(); foreach ($arr_template as $index => $template_file) { # Read meta data from the template if ($arr_properties = $this->Get_Template_Properties($template_file)) { $stylesheet_file = SubStr($template_file, 0, -4) . '.css'; $stylesheet_url = Is_File($stylesheet_file); if ($stylesheet_url) { if (StrPos($stylesheet_file, DirName(__FILE__)) === 0) { # the template is inside the plugin folder $stylesheet_url = $this->base_url . SubStr($stylesheet_file, StrLen(DirName(__FILE__))); } elseif (StrPos($stylesheet_file, ABSPATH) === 0) { # the template is inside the wordpress folder $stylesheet_url = Get_Bloginfo('wpurl') . '/' . SubStr($stylesheet_file, Strlen(ABSPATH)); } else { $stylesheet_url = $stylesheet_file = False; } } $arr_result[$arr_properties['name']] = Array_Merge($arr_properties, array('file' => $template_file, 'stylesheet_file' => Is_File($stylesheet_file) ? $stylesheet_file : False, 'stylesheet_uri' => $stylesheet_url)); $arr_sort[$arr_properties['name']] = StrToLower($arr_properties['name']); } else { continue; } } Array_MultiSort($arr_sort, SORT_STRING, SORT_ASC, $arr_result); return $arr_result; }
function Get_Template_Files() { $arr_template = Array_Unique(Array_Merge((array) Glob(DirName(__FILE__) . '/templates/*.php'), (array) Glob(DirName(__FILE__) . '/templates/*/*.php'), (array) Glob(Get_StyleSheet_Directory() . '/*.php'), (array) Glob(Get_StyleSheet_Directory() . '/*/*.php'), Is_Child_Theme() ? (array) Glob(Get_Template_Directory() . '/*.php') : array(), Is_Child_Theme() ? (array) Glob(Get_Template_Directory() . '/*/*.php') : array(), (array) Glob($this->template_dir . '/*.php'), (array) Glob($this->template_dir . '/*/*.php'))); // Filter to add template files - you can use this filter to add template files to the user interface $arr_template = (array) Apply_Filters('fancy_gallery_template_files', $arr_template); // Check if there template files if (empty($arr_template)) { return False; } $arr_result = array(); $arr_sort = array(); foreach ($arr_template as $index => $template_file) { // Read meta data from the template if (!($arr_properties = $this->Get_Template_Properties($template_file))) { continue; } else { $arr_result[$arr_properties['name']] = Array_Merge($arr_properties, array('file' => $template_file)); $arr_sort[$arr_properties['name']] = StrToLower($arr_properties['name']); } } Array_MultiSort($arr_sort, SORT_STRING, SORT_ASC, $arr_result); return $arr_result; }