-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.php
More file actions
59 lines (50 loc) · 1.67 KB
/
settings.php
File metadata and controls
59 lines (50 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace tangible\framework;
use tangible\framework;
function render_features_settings_page($plugin) {
$settings_key = framework\get_plugin_settings_key($plugin);
$settings = framework\get_plugin_settings($plugin);
$features = $plugin->features ?? [];
$features_title = 'Features';
?>
<div class="tangible-plugin-features-settings tangible-plugin-<?php echo $plugin->name; ?>-features-settings">
<h2><?php echo $features_title; ?></h2>
<div class="tangible-plugin-features-cards">
<?php
foreach ($features as $feature) {
$name = $feature['name'];
$title = $feature['title'];
$feature_key = framework\get_plugin_feature_key($plugin, $feature);
$is_enabled = framework\is_plugin_feature_enabled($plugin, $feature, $settings);
$settings = framework\get_plugin_settings($plugin, $feature);
if (is_callable($feature['description'] ?? '')) {
$feature['description'] = function() use($feature, $settings, $feature_key, $is_enabled) {
$feature['description'](
$settings,
$feature_key,
$is_enabled
);
};
}
?>
<div class="setting-row feature-<?php echo $name; ?>">
<?php
framework\render_setting_field_checkbox([
'type' => 'switch',
'name' => "{$settings_key}[$feature_key]",
'value' => $is_enabled ? 'true' : '',
'label' => $title,
'description' => $feature['description'] ?? '',
]);
?>
</div>
<?php
}
?>
</div>
<?php
submit_button();
?>
</div>
<?php
};