• I have read in multiple places (unreliable sources? ?? that the settings api automatically handles serializing the options. Specifically when using the register_setting() and settings_fields() to allow WordPress to manage updating/saving the settings to the database.

    However, the settings are clearly not being serialized automatically. Am I missing something or does the settings API simply save the options as individual records only?

    I would love to continue using the settings_fields() method for the project(s) I am working on but would also much prefer to serialize all the settings for at least each option group. Thanks for any tips.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter beingzoe

    (@beingzoe)

    Thank you esmi. That is a fine tutorial but doesn’t really mention in what form (serialized or single entry) options in an option group will be saved.

    I’m just trying to figure out if there is way to serialize the options for an option group while still using the automated updating that WP handles via the Settings API.

    Not critical but I would prefer to store the options as serialized option groups to minimize table records and to simplify deactivation cleanup.

    You can serialize them. See how I have set up in this options framework plugin: https://github.com/devinsays/options-framework-plugin (not quite finished).

    Basically, just register one setting:

    register_setting('theme_options', 'theme_options', 'optionsframework_validate' );

    and then have the name of the field use that setting:

    <input id="yourid'"name="theme_options['uniquesetting']" type="input" value="'. $val .'" />'

    And if you didn’t know it already, a good place to check if the options are being saved correctly is in: /wp-admin/options.php

    Thread Starter beingzoe

    (@beingzoe)

    That is bloody brilliant! Sublime even.

    I am looking at your options-framework-plugin now. It’s been a long day so I’m not sure if I’ll be able to demo it right away but I will definitely have a look.

    I’ve done something similar (though perhaps a bit more broad) in something I’m calling Kitchen Sink HTML5 Base also on github. I would love your thoughts on the Options module. Check the wiki at github for an overview.

    As for options.php, it’s funny I never go there, it just seems like I always have a tab with phpmyadmin open ??

    But thank you so much Devin. You answered my question and gave me a genius option. Love it.

    Ah, very cool. I’ll look through it. Make sure to check out WP Framework beta too. Twitter @wpframework.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to serialize options using settings api?’ is closed to new replies.