Last active
May 31, 2016 16:24
-
-
Save ChrisFlannagan/26264438230bad687680c8cf61a8f5fa to your computer and use it in GitHub Desktop.
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 | |
if( ! current_user_can( 'manage_options' ) ) { | |
exit(); | |
} | |
$settings_color = "#fff"; | |
if( isset( $_POST['settings_color'] ) && wp_verify_nonce( $_POST['_wpnonce'] ) ) { | |
update_option( "myplugin_settings_color", $_POST['settings_color'] ); | |
if( isset( $_POST['feature_on'] ) ) { | |
update_option( "my_plugin_featureon", true ); | |
} else { | |
update_option( "my_plugin_featureon", false ); | |
} | |
echo "<p><strong>Settings Saved!</strong></p>"; | |
} | |
if( get_option( "myplugin_settings_color" ) !== false ) { | |
$settings_color = get_option( "myplugin_settings_color" ); | |
} | |
?> | |
<div class="wrap"> | |
<h2>Plugin Settings</h2> | |
<form action="" method="post"> | |
<?php wp_nonce_field(); ?> | |
<p><input name="feature_on" type="checkbox" <?php | |
if ( get_option( "myplugin_feature_on" ) !== false && get_option( "myplugin_feature_on" ) ) { | |
echo 'checked="checked" '; | |
} | |
?> /> Turn Feature On</p> | |
<p>Color: <input type="text" name="settings_color" value="<?php echo $settings_color; ?>" /></p> | |
<p><button type="submit">Save Settings</button></p> | |
</form> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment