You need to add a ‘selected’ value to the option output, so that the html displays the value that’s saved in the psg_settings.
Something like this:
function psg_dyn_select_1_render ( ) {
$options = get_option( 'psg_settings' );
$files = glob( plugin_dir_path( __FILE__ ) . "assets/images/*" );
?>
<select name="psg_settings[psg_dyn_select_1]">
<?php foreach ($files as $filename){
$filename = basename($filename);
$selected = ($filename == $options['psg_dyn_select_1']) ? 'selected="selected"' : '';
echo "<option value="" . $filename . "" " .
$selected . ">".$filename." </option>";
}?>
</select>
}
If that’s not working, then you need to debug what the value of $options
and $options['psg_dyn_select_1']
are in comparison to what’s being output in your select dropdown (the values of $filename
).