Skip to content

Commit b46a486

Browse files
authored
Merge pull request #5 from PolyPlugins/releases/3.1.0
Added: Ability to define custom callbacks for tabs to include your own custom content outside of the framework.
2 parents ad01388 + 3471843 commit b46a486

File tree

3 files changed

+43
-16
lines changed

3 files changed

+43
-16
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ This library collects and stores certain data on your server to ensure proper fu
348348

349349
## Changelog
350350

351+
### 3.1.0
352+
Added: Ability to define custom [callbacks](https://www.polyplugins.com/docs/settings-class-for-wordpress/fields/sections/#callbacks) for tabs to include your own custom content outside of the framework.
353+
351354
### 3.0.0
352355
* Added: Subsections
353356
* Added: Templating

src/templates/default/index.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,16 @@
9090
<?php echo esc_html(ucfirst($section)) . ' Settings'; ?>
9191
</h2>
9292
<div class="fields">
93-
<?php foreach($fields as $field) : ?>
94-
<?php $field['section'] = $section; ?>
95-
<?php $this->add_field($field); ?>
96-
<?php endforeach; ?>
93+
<?php if (isset($section_data['callback']) && is_callable($section_data['callback'])) : ?>
94+
<div class="field-container">
95+
<?php call_user_func($section_data['callback'], $section, $section_data, $this->settings); ?>
96+
</div>
97+
<?php else :?>
98+
<?php foreach($fields as $field) : ?>
99+
<?php $field['section'] = $section; ?>
100+
<?php $this->add_field($field); ?>
101+
<?php endforeach; ?>
102+
<?php endif; ?>
97103
</div>
98104
</div>
99105
</div>
@@ -117,10 +123,16 @@
117123
<?php echo esc_html($subsection['label'] ?? ucfirst($sub_id)) . ' Settings'; ?>
118124
</h2>
119125
<div class="fields">
120-
<?php foreach($sub_fields as $field) : ?>
121-
<?php $field['section'] = $section . '-' . $sub_id; ?>
122-
<?php $this->add_field($field); ?>
123-
<?php endforeach; ?>
126+
<?php if (isset($section_data['callback']) && is_callable($section_data['callback'])) : ?>
127+
<div class="field-container">
128+
<?php call_user_func($section_data['callback'], $section, $section_data, $this->settings); ?>
129+
</div>
130+
<?php else :?>
131+
<?php foreach($sub_fields as $field) : ?>
132+
<?php $field['section'] = $section . '-' . $sub_id; ?>
133+
<?php $this->add_field($field); ?>
134+
<?php endforeach; ?>
135+
<?php endif; ?>
124136
</div>
125137
</div>
126138
</div>

src/templates/recharge/index.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,16 @@
8686
<?php endif; ?>
8787
<div class="options-padding">
8888
<div class="fields">
89-
<?php foreach($fields as $field) : ?>
90-
<?php $field['section'] = $section; ?>
91-
<?php $this->add_field($field); ?>
92-
<?php endforeach; ?>
89+
<?php if (isset($section_data['callback']) && is_callable($section_data['callback'])) : ?>
90+
<div class="field-container">
91+
<?php call_user_func($section_data['callback'], $section, $section_data, $this->settings); ?>
92+
</div>
93+
<?php else :?>
94+
<?php foreach($fields as $field) : ?>
95+
<?php $field['section'] = $section; ?>
96+
<?php $this->add_field($field); ?>
97+
<?php endforeach; ?>
98+
<?php endif; ?>
9399
</div>
94100
</div>
95101
</div>
@@ -107,10 +113,16 @@
107113
<?php endif; ?>
108114
<div class="options-padding">
109115
<div class="fields">
110-
<?php foreach($sub_fields as $field) : ?>
111-
<?php $field['section'] = $section . '-' . $sub_id; ?>
112-
<?php $this->add_field($field); ?>
113-
<?php endforeach; ?>
116+
<?php if (isset($section_data['callback']) && is_callable($section_data['callback'])) : ?>
117+
<div class="field-container">
118+
<?php call_user_func($section_data['callback'], $section, $section_data, $this->settings); ?>
119+
</div>
120+
<?php else :?>
121+
<?php foreach($sub_fields as $field) : ?>
122+
<?php $field['section'] = $section . '-' . $sub_id; ?>
123+
<?php $this->add_field($field); ?>
124+
<?php endforeach; ?>
125+
<?php endif; ?>
114126
</div>
115127
</div>
116128
</div>

0 commit comments

Comments
 (0)