public function autoRegisterWidgets() { $widget_path = FileSystem::getDirectory('widgets_path'); $files_list = File::get_file_list($widget_path); foreach ($files_list as $file) { if ($file != '.' && $file != '..') { $class_file = $widget_path . DIRECTORY_SEPARATOR . $file; $classes = String::getClassNameFromFile($class_file); foreach ($classes as $class) { if (class_exists($class)) { \register_widget($class); } } } } }
/** * * filter $_POST meta data options and prepare to save in db * * @param array $options array with meta data to filter * @param string $prefix * * @return array */ public static function getPostOption(array $options, $prefix = null) { if (!\is_null($prefix)) { $prefix = '_' . $prefix . '_'; } $option = array(); foreach ($options as $key => $value) { $result = array(); if (\preg_match('/^' . THEME_OPTION_PREFIX . $prefix . '/', $key, $result)) { $index = \preg_replace('/^' . THEME_OPTION_PREFIX . '_/', '', $key); // Sanitize the user input. $option[$index] = String::sanitize_text_field($value); } } return $option; }