';
}
//Run the setup fields after the section has been created
add_action( 'admin_init', 'apspider_setup_fields' );
// Create a 'section' for the settings page (Called by each post type)
function apspider_setup_sections($section_id, $section_title, $section_callback)
{
require_once( ABSPATH . 'wp-admin/includes/template.php' );
add_settings_section( $section_id, $section_title, $section_callback, 'apspider_fields' );
}
// Callback for a list of 'settings' for the sections
function apspider_setup_fields()
{
global $fields;
include_once('apspider-adminfieldsarray.php');
// Cycle through the settings, create the field and register the setting
foreach( $fields as $field ){
add_settings_field( $field['uid'], $field['label'], 'apspider_field_callback', 'apspider_fields', $field['section'], $field );
register_setting( 'apspider_fields', $field['uid'] );
$uid = $field['uid'];
$value = get_option($uid);
if ( $value === false){
update_option($field['uid'], $field['default']);
}
}
}
// Callback to handle each scenario of each settings field created and passed to it.
function apspider_field_callback( $arguments )
{
$value = get_option( $arguments['uid'] );
if( ! $value ) {
$value = $arguments['default'];
}
if ( ! empty ( $arguments['placeholder'] )){
$placeholder = $arguments['placeholder'];
} else {
$placeholder = false ;
}
printf('