Skip to content

Commit b0911f8

Browse files
Plugin features: Description callback - Set parameter inside render_features_settings_page instead of inside render_setting_field_checkbox
1 parent 03fc17b commit b0911f8

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

plugin/features/settings.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ function render_features_settings_page($plugin) {
2222

2323
$feature_key = framework\get_plugin_feature_key($plugin, $feature);
2424
$is_enabled = framework\is_plugin_feature_enabled($plugin, $feature, $settings);
25+
$settings = framework\get_plugin_settings($plugin, $feature);
26+
27+
if (is_callable($feature['description'] ?? '')) {
28+
$feature['description'] = function() use($feature, $settings, $feature_key, $is_enabled) {
29+
$feature['description'](
30+
$settings,
31+
$feature_key,
32+
$is_enabled
33+
);
34+
};
35+
}
2536

2637
?>
2738
<div class="setting-row feature-<?php echo $name; ?>">

plugin/settings/checkbox.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,8 @@ function render_setting_field_checkbox($config) {
6868
<?php if (!empty($description)): ?>
6969
<div class="feature-description">
7070
<?php
71-
if (is_callable($description)) {
72-
$description(
73-
tangible\framework\get_plugin_feature_settings($plugin, $feature),
74-
tangible\framework\get_plugin_feature_settings_key($plugin, $feature),
75-
$is_enabled
76-
);
77-
} else {
71+
if (is_callable($description)) $description();
72+
else {
7873
echo $description;
7974
}
8075
?>

0 commit comments

Comments
 (0)