this worked for me, though I still didnt brush up my code
<?php
add_action( 'admin_menu', 'cmby_add_admin_menu' );
add_action( 'admin_init', 'cmby_settings_init' );
$settingfields = array('NA','HTML Banner','GIF Banner','Booking Form','Udemy Course', 'Test Missile');
function cmby_add_admin_menu( ) {
add_options_page( 'Cambrickyard Settings', 'Cambrickyard', 'manage_options', 'cambrickyard', 'cmby_options_page' );
};
function cmby_settings_init( ) {
global $settingfields;
register_setting( 'pluginPage', 'cmby_settings' );
add_settings_section(
"cmby_pluginPage_section",
__( "Cambrick Yard Plugin Settings Page", "wordpress" ),
"cmby_settings_section_callback",
'pluginPage'
);
foreach ($settingfields as $id => $item) {
$i=0;
add_settings_field(
'cmby_textarea_field_'.$id,
__( "Enter widget code", "wordpress" ),
'cmby_textarea_render_field',
"pluginPage",
"cmby_pluginPage_section",
array (
'indicator' => $id
)
);
$i++;
}
}
function cmby_textarea_render_field($args) {
$options = get_option( 'cmby_settings' );
echo $args['indicator'];
echo '<textarea cols="60" rows="5" name="cmby_settings[cmby_textarea_field_'.$args['indicator'].']">';
echo $options['cmby_textarea_field_'.$args['indicator']];
//echo "test";
echo '</textarea>';
};
function cmby_settings_section_callback( ) {
echo __( 'Use fields below to enter the code to be displayed when shortcode called out', 'wordpress' );
}
function cmby_options_page( ) {
?>
<form action='options.php' method='post'>
<?php
settings_fields( 'pluginPage' );
do_settings_sections( 'pluginPage' );
submit_button();
?>
</form>
<?php
}
?>
[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]