diff --git a/src/helpers.php b/src/helpers.php index 3917363..3bb248f 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -12,16 +12,24 @@ if (!function_exists('dd')) { function dd(): never { echo '
';
- array_map(function($arg) {var_dump($arg);}, func_get_args());
+ array_map(function ($arg) {
+ var_dump($arg);
+ }, func_get_args());
die;
}
}
+function setup_configs(): void
+{
+ $configs = [];
+ $configs_dir = plugin_dir_path(__FILE__).'configs';
+ foreach (glob($configs_dir.'/*.php') as $configs_file) {
+ $configs[basename($configs_file, '.php')] = include $configs_file;
+ }
-define("DA_CASHED_CONFIG", [
- 'da' => require plugin_dir_path(__FILE__) . 'configs/da.php',
-]);
-
+ define("DA_CASHED_CONFIG", $configs);
+}
+setup_configs();
if (!function_exists('config')) {
function config(string $key, ?string $default = null): null|string|array
@@ -33,3 +41,11 @@ if (!function_exists('config')) {
return $value;
}
}
+
+
+if (!function_exists('get_configured_option')) {
+ function get_configured_option(string $key, ?string $default = null): null|string|array
+ {
+ return get_option(config($key), $default);
+ }
+}