Skip to content

Commit 25927c0

Browse files
committed
Allow to specify callback for section
Can be used to output dynamic content when needed and not set in desc in admin_init. Also when callback is not needed set to null instead of __return_false to avoid calling a function that does nothing. Signed-off-by: Roi Dayan <roi.dayan@gmail.com>
1 parent eaacd6a commit 25927c0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/class.settings-api.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ function admin_init() {
113113
if ( isset($section['desc']) && !empty($section['desc']) ) {
114114
$section['desc'] = '<div class="inside">'.$section['desc'].'</div>';
115115
$callback = create_function('', 'echo "'.str_replace('"', '\"', $section['desc']).'";');
116+
} else if ( isset( $section['callback'] ) ) {
117+
$callback = $section['callback'];
116118
} else {
117-
$callback = '__return_false';
119+
$callback = null;
118120
}
119121

120122
add_settings_section( $section['id'], $section['title'], $callback, $section['id'] );

0 commit comments

Comments
 (0)