/** * The default landing page for the plugin's admin pages. * * PHP + HTML = Messy :( */ public static function settings() { //fetch the options array $options_array = ThinkUpWordPressPlugin::getOptionsArray(); //check to see if the form was submitted if (isset($_POST['Submit'])) { //make sure the user submitting the form is an admin check_admin_referer('thinkup_settings_submit', ThinkUpWordPressPlugin::nonceName()); foreach ($options_array as $opt) { // read posted values $opt['value'] = $_POST[$opt['key']]; // save the posted value in the database if ($opt['key'] == 'thinkup_dbpw') { // scramble the password update_option($opt['key'], ThinkUpWordPressPlugin::scramblePassword($opt['value'])); } else { // store non-passwords normally update_option($opt['key'], $opt['value']); } } // print "updated!" message to screen ?> <div class="updated"> <p><strong> <?php _e('Options saved.', ThinkUpWordPressPlugin::uniqueIdentifier()); ?> </strong></p> </div> <?php //force an update to the options array for display purposes $options_array = ThinkUpWordPressPlugin::getOptionsArray('force-update'); } ?> <div id="poststuff" class="ui-sortable meta-box-sortable"> <div class="postbox" id="thinkup_settings"> <h3><?php _e('ThinkUp Plugin Settings', ThinkUpWordPressPlugin::uniqueIdentifier()); ?></h3> <div class="inside" style="line-height: 2;"> <form name="thinkup_settings_form" method="post" action=""><?php //Add the nonce field for added security. wp_nonce_field('thinkup_settings_submit', ThinkUpWordPressPlugin::nonceName()); ?> <table> <?php foreach ($options_array as $opt) { if ($opt['key'] == 'thinkup_dbpw') { $field_value = ThinkUpWordPressPlugin::unscramblePassword( get_option($opt['key'])); } else { $field_value = get_option($opt['key']); } ?> <tr> <td align="right" valign="top"><?php _e($opt['label'], ThinkUpWordPressPlugin::uniqueIdentifier()); ?></td> <td><input type="<?php echo $opt['type']; ?>" name="<?php echo $opt['key'] ?>" value="<?php echo $field_value ?>" size="20"> <br /> <small> <?php echo $opt['description']; ?> </small></td> </tr> <?php } ?> </table> <p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options', ThinkUpWordPressPlugin::uniqueIdentifier()); ?>" /> </p> </form> </div> </div> </div> <?php }