*/ function abj404_get_settings_options() { if (function_exists('abj_service_optional')) { $optionsRepository = abj_service_optional('options_repository'); if (is_object($optionsRepository) && method_exists($optionsRepository, 'getOptions')) { try { $options = $optionsRepository->getOptions(true); if (is_array($options)) { $normalizedOptions = array(); foreach ($options as $key => $value) { if (is_string($key)) { $normalizedOptions[$key] = $value; } } return $normalizedOptions; } if (function_exists('abj404_logRuntimeWarning')) { abj404_logRuntimeWarning('options_repository->getOptions(true) returned ' . gettype($options) . '; falling back to raw bootstrap option read'); } } catch (\Throwable $e) { if (function_exists('abj404_logRuntimeWarning')) { abj404_logRuntimeWarning('options_repository->getOptions(true) failed while reading settings options; falling back to raw bootstrap option read', $e); } else { abj404_logPhpFallback( 'early-boot', 'options_repository->getOptions(true) failed while reading settings options; falling back to raw bootstrap option read (' . $e->getMessage() . ')' ); } } } } // The shape-checked read, so a persistent object cache that answers with // a non-array cannot read as no settings. $options = abj404_option_shape_read_available() && function_exists('get_option') ? ABJ_404_Solution_OptionShapeRead::arrayValue('abj404_settings') : false; if (!is_array($options)) { return array(); } $normalizedOptions = array(); foreach ($options as $key => $value) { if (is_string($key)) { $normalizedOptions[$key] = $value; } } return $normalizedOptions; } } if (!function_exists('abj404_get_raw_setting_value')) { /** * Read one setting without resolving or normalizing the options repository. * * This is the degraded/cold-boot companion to the repository's * getRawSettingValue() accessor. It stays in this bootstrap module so * OptionShapeRead remains the only raw reader before the service container * is ready. * * @param string $key * @param mixed $default * @return mixed */ function abj404_get_raw_setting_value($key, $default = null) { if (!is_string($key) || $key === '' || !abj404_option_shape_read_available() || !function_exists('get_option')) { return $default; } $options = ABJ_404_Solution_OptionShapeRead::arrayValue('abj404_settings'); if (!is_array($options) || !array_key_exists($key, $options)) { return $default; } return $options[$key]; } }