• Skip to primary navigation
  • Skip to main content
  • Skip to footer
  • Books
    • Content Strategy for WordPress (2015)
    • WordPress for Web Developers (2013)
    • Beginning WordPress 3 (2010)
  • Blog
    • Content Modeling for WordPress
    • WordPress Hidden Gems
    • Web Design
  • Work
    • Presentations and Interviews
    • on GitHub →
    • MLIS Class Projects (2019-2022)
    • Portfolio (2002-2019)
    • WordPress Plugins

Stephanie Leary

Writer, Front End Developer, former WordPress consultant

  • About
    • Press Kit
    • Presentations and Interviews
  • Contact Me

WordPress Hidden Gems: Options.php

September 15, 2010 Stephanie Leary 15 Comments

Type options.php into your address bar (example.com/wp-admin/options.php) and you’ll get this alphabetized listing of all the options stored in your wp_options database table. Some won’t be editable — if they’re stored as arrays, you’ll just see “Serialized data” — but the rest can be changed here.

If you’re familiar with PHP arrays, you can edit those serialized options by changing the database fields directly. Copy the serialized array (shown here in the row with the ID 10390) and paste it into the Online PHP Unserializer at blog.tanist.co.uk.

This tool will convert the serialized array to a more familiar array printout. You can then make changes and re-serialize the array to store it back in the database.

With great power comes great responsibility. Be very careful with this! And consider backing up your database before you tinker.

This Hidden Gem was cut from [link id=”2675″]Beginning WordPress 3[/link], but all the others are in the book!

WordPress

This is an excerpt from Content Strategy for WordPress.My latest books are Content Strategy for WordPress (2015) and WordPress for Web Developers (2013). Sign up to be notified when I have a new book for you.

Reader Interactions

Comments

  1. Stephen Cronin says

    September 15, 2010 at 8:59 pm

    Hi Stephanie,

    This is one of those tips I loved from your appearance on the WP Weekly podcast.

    I can’t tell you how often I go into the DB to check what a particular options is set to – this will be so much quicker. I only wish they exposed the serialized data (even if it was readonly), because I use that for all my plugins.

    Reply
    • steph says

      September 15, 2010 at 9:01 pm

      Thanks, Stephen! I wish I could see the serialized ones, too.

      Hmm, maybe it’s possible to filter that…..

      Reply
      • steph says

        September 15, 2010 at 9:06 pm

        … or not. Sigh.

        Reply
  2. Stephen Cronin says

    September 15, 2010 at 9:13 pm

    or maybe it a patch to core? to either add a filter action or just show it in a non editable form? I can’t see why anyone would have a problem with that…

    Reply
    • steph says

      September 15, 2010 at 9:22 pm

      Or, for now, a quick clone of the core code minus the part that obfuscates the serialized options, dressed up as a plugin complete with a menu option:

      <?php
      /*
      Plugin Name: Edit All Options
      Plugin URI: http://stephanieleary.com/
      Description: A quick options editor. 
      Version: 0.1
      Author: Stephanie Leary
      Author URI: http://stephanieleary.com/
      */
      
      add_action('admin_menu', 'scl_options_add_pages');
      
      function scl_options_add_pages() {
          // Add a new submenu under Options:
      	$css = add_options_page('All Options', 'All Options', 'manage_options', 'my-options', 'scl_all_options');
      	add_action("admin_head-$css", 'scl_all_options_css');
      }
      
      function scl_all_options_css() { ?>
      <style type="text/css">
      textarea.all-options { width: 40em; }
      </style>
      <?php 
      }
      
      
      // displays the options page content
      function scl_all_options() {
      	global $wpdb; ?>	
          <div class="wrap">
      		  <h2><?php esc_html_e('All Settings'); ?></h2>
      		  <form name="form" action="options.php" method="post" id="all-options">
      		  <?php wp_nonce_field('options-options') ?>
      		  <input type="hidden" name="action" value="update" />
      		  <input type='hidden' name='option_page' value='options' />
      		  <table class="form-table">
      		<?php
      		$options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );
      
      		foreach ( (array) $options as $option ) :
      			$disabled = false;
      			if ( $option->option_name == '' )
      				continue;
      			if ( is_serialized( $option->option_value ) ) {
      				if ( is_serialized_string( $option->option_value ) ) {
      					// this is a serialized string, so we should display it
      					$value = maybe_unserialize( $option->option_value );
      					$options_to_update[] = $option->option_name;
      					$class = 'all-options';
      				} else {
      					$value = $option->option_value;
      					$class = 'all-options serialized';
      				}
      			} else {
      				$value = $option->option_value;
      				$options_to_update[] = $option->option_name;
      				$class = 'all-options';
      			}
      			$name = esc_attr( $option->option_name );
      			echo "
      		<tr>
      			<th scope='row'><label for='$name'>" . esc_html( $option->option_name ) . "</label></th>
      		<td>";
      			if ( strpos( $value, "n" ) !== false || strpos ($class, 'serialized') !== false )
      				echo "<textarea class='$class' name='$name' id='$name' cols='30' rows='5'>" . wp_htmledit_pre( $value ) . "</textarea>";
      			else
      				echo "<input class='regular-text $class' type='text' name='$name' id='$name' value='" . esc_attr( $value ) . "'" . disabled( $disabled, true, false ) . " />";
      			echo "</td>
      		</tr>";
      		endforeach;
      		?>
      		  </table>
      		<p class="submit"><input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" /><input type="submit" name="Update" value="<?php esc_attr_e( 'Save Changes' ); ?>" class="button-primary" /></p>
      		  </form>
      		</div>
      	</div>
      <?php 
      } 
      ?>
      

      … but I’m not going to publicize that very widely, because HOLY SMOKES you could nuke an entire blog pretty quick using that.

      Reply
      • steph says

        September 15, 2010 at 9:41 pm

        … well, I deliberately left out the line that would update the serialized options, so it’s not too bad. Copying line 47 to line 50/51 would really turn it into a loaded gun.

        Reply
  3. Stephen Cronin says

    September 15, 2010 at 10:10 pm

    Wow, you just made me swear, as in “[something stronger than damn] she’s good”. I’m using this plugin!

    If you wanted to publicise it more widely, just change line 64 to:

    echo "<textarea class='$class' name='$name' id='$name' cols='30' rows='5' readonly='readonly'>" . wp_htmledit_pre( $value ) . "</textarea>";
    

    The readonly=”readonly” will stops people from actually changing the value of the text areas, which should make it safer.

    Reply
    • steph says

      September 15, 2010 at 11:02 pm

      I fixed the markup. Glad you like it! People can’t actually change the values anyway because the serialized options aren’t added to the $options_to_update[] array — compare lines 50-51 to lines 54-56. But adding the readonly attribute makes it obvious, which is definitely better than just silently ignoring the input.

      Reply
  4. Stephen Cronin says

    September 15, 2010 at 10:13 pm

    Whoops, I wrapped the code in my last comment with the code tags, but it’s been messed up. No worries, just add readonly=”readonly” to line 64..

    Reply
  5. Richard Cairns says

    March 21, 2011 at 11:52 pm

    I found this a few months ago and then again today, this is absolute gold, I love it. I store the address and phone numbers in the options table.

    Reply
  6. Stephanie says

    July 25, 2011 at 2:22 pm

    In case anyone’s subscribed to comments… I’ve posted an updated version of this mini-plugin on its own page.

    Reply
  7. jamie says

    April 29, 2015 at 5:28 pm

    hi! this question may not fit this post but since it was one of the few posts i found about the options.php file i am looking here for help. i have been receiving a ‘fatal memory error’ and i went through all the changes i could find, including going to my host to make the changes needed, and i am still getting the error randomly. the error went away after i edited my wp-config.php for a while but now it is back but primarily in my dashboard. now when the error happens i get the error and it always ends with referencing the same line of my options.php; line 320.

    i am pretty noobish when it comes to the tech side but i believe i have built this site with consideration to best practices, recommended/researched plugins/themes, limiting plugins and crunching everything i put up down to as small as possible. all unused plugins and themes are deleted and every bit of ‘dust’ swept up. is this something with my options.php or is it just coincidence that the error is at the same line of this file every time?

    Reply
    • Stephanie Leary says

      April 30, 2015 at 9:27 am

      Jamie, options.php is used as a form handler for all other plugins’ and themes’ options/settings. The error you’re seeing is probably caused when a plugin’s code reaches that point in the options.php logic. The best way to locate your error is to do the standard WordPress troubleshooting routine: switch to one of the default themes, deactivate all your plugins, and re-activate them one by one until you see the error again.

      Reply
      • jamie says

        April 30, 2015 at 9:56 am

        Stephanie, thank you for your response! i found out after i made this post that the issue i was having was due to transients being left in my wp_options by woocommerce. so it looks like i littered your blog comments with irrelevant info but i did want to say thank you! now to learn how to clear transients! o_O

        Reply
  8. Jorge says

    December 2, 2016 at 7:03 am

    Hello and thank you for this information.

    I have tried to edit the values for the Tablepress plugin I have installed but when I save, the changes are not applied. Weird…

    I am not an advanced user. I suppose this is obvious. :-)

    Reply

Leave a Reply to Stephanie Leary Cancel reply

Your email address will not be published. Required fields are marked *

Footer

My Books

I’m a front end developer at Equinox OLI, working on open source library software. I was previously a freelance WordPress developer in higher education. You can get in touch here or on LinkedIn.

Copyright © 2025 Stephanie Leary · Contact