Created
May 22, 2015 02:34
-
-
Save qutek/19d58f2226525fa7c179 to your computer and use it in GitHub Desktop.
[Wordpress] Custom display setting section do_setting_section()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function custom_do_settings_sections($page) { | |
global $wp_settings_sections, $wp_settings_fields; | |
if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) | |
return; | |
foreach( (array) $wp_settings_sections[$page] as $section ) { | |
echo "<h3>{$section['title']}</h3>\n"; | |
call_user_func($section['callback'], $section); | |
if ( !isset($wp_settings_fields) || | |
!isset($wp_settings_fields[$page]) || | |
!isset($wp_settings_fields[$page][$section['id']]) ) | |
continue; | |
echo '<div class="settings-form-wrapper">'; | |
custom_do_settings_fields($page, $section['id']); | |
echo '</div>'; | |
} | |
} | |
function custom_do_settings_fields($page, $section) { | |
global $wp_settings_fields; | |
if ( !isset($wp_settings_fields) || | |
!isset($wp_settings_fields[$page]) || | |
!isset($wp_settings_fields[$page][$section]) ) | |
return; | |
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { | |
echo '<div class="settings-form-row">'; | |
if ( !empty($field['args']['label_for']) ) | |
echo '<p><label for="' . $field['args']['label_for'] . '">' . | |
$field['title'] . '</label><br />'; | |
else | |
echo '<p>' . $field['title'] . '<br />'; | |
call_user_func($field['callback'], $field['args']); | |
echo '</p></div>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment