Skip to content

Instantly share code, notes, and snippets.

@mymizan
Created June 1, 2019 01:21
Show Gist options
  • Save mymizan/ef34d7f3574f8aaf6e19835d5b60bc86 to your computer and use it in GitHub Desktop.
Save mymizan/ef34d7f3574f8aaf6e19835d5b60bc86 to your computer and use it in GitHub Desktop.
<?php
public function menu_markup()
{
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
?>
<div class="wrap">
<h1>YM Options</h1>
<form method="post" action="options.php">
<?php settings_fields( 'ymoptions-group' ); ?>
<?php do_settings_sections( 'ymoptions-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Enter Your Name</th>
<td><input type="text" name="ymoptions_name" value="<?php echo esc_attr( get_option('ymoptions_name') ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Age</th>
<td><input type="text" name="ymoptions_age" value="<?php echo esc_attr( get_option('ymoptions_age') ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Gender</th>
<td>
<select name='ymoptions_gender'>
<option value=''> Select </option>
<option value='male' <?php echo get_option('ymoptions_gender') == 'male' ? "selected=selected" : ' '?>> Male </option>
<option value='female' <?php echo get_option('ymoptions_gender') == 'female' ? "selected=selected" : ' '?>> Female </option>
<option value='other' <?php echo get_option('ymoptions_gender') == 'other' ? "selected=selected" : ' '?>> Other </option>
</select>
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment