I was dealing with network DB option filtering few weeks back and I was unable to find a proper way to use update_option, update_site_option or any relevant function to update the main site's option value. I just found update_blog_option which is pretty cool and it does the following inside: [php] ... switch_to_blog( $id ); $return = update_option( $option, $value ); restore_current_blog(); ... [/php] Since the option filtering is triggered per update option, I had to hack it with recursively switching the blog and resetting it after the second callback: [php] public function get_network_trzapi_key( $option ) { $site_id = get_current_blog_id(); if… Continue Reading

Settings API in 9 Steps

I'm going to update my DX Plugin Base script soon with sample code, but Settings API are something that needs a few lines of text too. There are several good resources for that, such as: http://codex.wordpress.org/Settings_API http://ottodestruct.com/blog/2009/wordpress-settings-api-tutorial/ http://wp.tutsplus.com/tutorials/the-complete-guide-to-the-wordpress-settings-api-part-2-sections-fields-and-settings/ (awesome btw) But for the very quick overview of what to be done, that's needed: hook to admin_init with a function registering settings call register_setting to reserve a slot in the DB where the setting is to be stored (setting name for DB, how is it stored in DB) call add_setting_section to create a section for settings (setting name, setting title, callback func,… Continue Reading