/** * Retrieve all widgets that are in the theme, both within 'core' folder, then 'inc' folder * * @since 1.0 * * @return array An array with all widgets name */ function yiw_get_widgets() { $widgets = array(); $file_widgets = yiw_list_files_into(YIW_WIDGETS_FOLDER); foreach ($file_widgets as $file) { if (!preg_match('/(.*).php/', $file)) { continue; } $name = preg_replace('/(.*).php/', '$1', $file); $widgets['theme'][] = $name; } $file_widgets = yiw_list_files_into(YIW_DEFAULT_WIDGETS_FOLDER); foreach ($file_widgets as $file) { if (!preg_match('/(.*).php/', $file)) { continue; } $name = preg_replace('/(.*).php/', '$1', $file); if (!in_array($name, $widgets['theme'])) { $widgets['default'][] = $name; } } return $widgets; }
/** * Generate a list of options of all icons, retrieved from a folder. * * @param string $selected The icon name to select * @param bool $echo If print the html output or only return it. * @return string The html output with all <option> * * @since 1.0 */ function yiw_list_icons($selected = '', $echo = TRUE) { $icons_name = yiw_list_files_into(YIW_THEME_PATH . 'images/icons/set_icons/'); $html = ''; foreach ($icons_name as $name_icon) { list($icon, $ext) = explode('.', $name_icon); $html .= '<option value="' . $icon . '"' . selected($selected, $icon, false) . '>' . $icon . '</option>' . "\n"; } if ($echo) { echo $html; } return $html; }
function yiw_list_cufon_fonts() { global $yiw_list_cufon_fonts; if (isset($yiw_list_cufon_fonts)) { return $yiw_list_cufon_fonts; } $folder = dirname(__FILE__) . '/../fonts/'; $files = $fonts = array(); $files = yiw_list_files_into($folder); foreach ($files as $file) { $file = preg_replace('/(.*).font.(.*)/', '$1', $file); $fonts[$file] = ucfirst(str_replace('_', ' ', $file)); } $yiw_list_cufon_fonts = $fonts; return $fonts; }