$field) {
if (! empty($fields) && ! in_array($key, $fields, true)) {
continue;
}
if (! self::meets_requirements($field)) {
continue; // Field is only relevant when its dependency is present.
}
$name = sprintf('%s[%s][%s]', $settings_field, $section, $key);
$value = Fastless_Cache_Options::get($section . '.' . $key);
self::render($name, $field, $value, $section);
}
}
/**
* Whether a field's dependency is satisfied and it should be rendered.
*
* A field may declare a `requires` key naming a dependency (currently only
* 'elementor'); a missing or unknown dependency is treated as satisfied so
* a typo never hides a field.
*
* @param array $field Field definition from the schema.
* @return bool True when the field should be rendered.
*/
public static function meets_requirements($field)
{
if (empty($field['requires'])) {
return true;
}
switch ($field['requires']) {
case 'elementor':
return (class_exists('Fastless_Cache_Elementor') && Fastless_Cache_Elementor::is_active());
default:
return true;
}
}
/**
* Render a single field, dispatching on its type.
*
* @param string $name Field name (e.g. "fastless_cache[general][cache_expires]").
* @param array $field Field definition from the schema.
* @param mixed $value Current value.
* @param string $section Section key.
* @return void
*/
public static function render($name, $field, $value, $section)
{
$key = self::key_from_name($name);
$type = isset($field['type']) ? $field['type'] : 'text';
$id = 'fastless-cache-' . $section . '-' . str_replace('_', '-', $key);
?>
';
}
/**
* An informational notice.
*
* @param array $field Field definition.
* @return void
*/
private static function render_info($field)
{
?>