The logic on the IF THEN ELSE does seem a bit wonky. If I’m reading it correctly…
The call to get_option( $option_name ) will return FALSE if the option does not exist or if it has no value.
So the IF would be executed:
- when the option doesn’t exist and $new_value != FALSE
- the option has no value and $new_value != FALSE
- the option exists and has a value that is != $new value
The update_option() call would then update the value or create the option with $new_value.
The ELSE would be called if:
- the option exists and has the same value as $new_value
- the option does not exist and the $new_value == FALSE
Related Posts:
- Is the codex no longer actively maintained?
- Why is the use of @uses tag in docblocks discouraged?
- What does the raw value for the get_bloginfo’s filter argument exactly do?
- *Just curious* I erroneously used hook add_action() instead of add_filter() and there was no error and the result was correct. Why is that?
- WordPress Codex has different number of arguments for get_previous_post and get_next_post functions. Why?
- WordPress Codex or equivlent for Kindle use?
- Set $options reference
- Difference between `is_serialized_string` and `is_serialized`
- Wp Super Cache – Function to reset cache of a specific page
- What is the significance of _e(“Some String”, ‘String’)?
- Using Json Schema with wordpress codex
- adding category and tags to admin plugins menu
- How to disable Wp-Page Navigation on Blank Search in WordPress
- Cleanup orphaned wp_terms and wp_term_taxonomy
- Where to find new class reference or function of deprecated one?
- how do i add customizer edit option without plugin in wp
- Next/Previous Url only
- What is the reason to use function strings for callbacks
- Is there a flowchart for WordPress loading sequence?
- Enable page templates. How?
- Modifying a JS file with data from plugin settings
- Difference between Option_Group and Option_Name in Register_Settings
- Efficient way of saving plugin options
- What is the advantage of the wp_options design pattern?
- Get category slug and display it on a query_post
- Get Content From Blog Page
- Add site options UI in Multisite Sites > Infos page
- Multiple Custom_Background, is it possible?
- Site Title and Tagline in Pagelines DMS Options Panel
- Why isn’t get_option array contents displaying?
- How to Save Different Settings Options Using Settings API and/or the Theme Optimizer
- Settings API erases itself?
- Proper use of option_page_capability_{$page_name}
- On Install, which code sets the ‘home’ option?
- How to save WordPress Options as an array?
- What to use , set_transient, set_option or file system? [closed]
- Extend plugin options page
- Settings API get_option best practices
- Cannot update WordPress General Settings Site Title and Tagline
- Remove obsolete plugins artifacts from database tables
- Redirecting to old domain, tried everything, nothing works
- Changing next and previous post link text
- Does codex.wordpress.org use a plugin of some sort? If so what plugin?
- Putting my site live
- How to get option values set from all sites within a Multisite setup?
- Can’t get plugin settings page to save data
- download_url() appears as grey icons
- Store and Work with huge array in WP [closed]
- Custom settings page TinyMce: no formatting when echoing value of editor
- Add an option to a Child theme of Twenty Eleven
- How can I add an options page for my class based plugin?
- problems with wordpress and php version 5.3.3-1
- The Settings API – What is the purpose of default value in register_setting?
- How to store a value on WP_option table
- Would it be dangerous to send all the wp_options to javascript file?
- loss of theme options while site deployment in production
- Custom blog settings
- wp_usermeta wp_usersettings
- WordPress slugs and 404 handling takes preference over folders in site root?
- get_option returns undesired blank instance of a widget
- How to get specific setting by settings_fields()?
- Display post option on frontend
- ERR_TOO_MANY_REDIRECTS when i config my subdomains
- Update problem with update_option() in combination with register_setting()
- Edit Custom Post Type on Custom Admin Page instead Post Admin
- API for wp menu hacks
- Breadcrumbs – get the author?
- Hide admin menu on update_option
- Change the style of h1, h2, only in post entry
- How do I define and register a shortcode function in a namespaced functions.php file?
- Which Hook can I use when creating unique post but not update/save/delete
- Settings API: Setting default option via ‘get_option’ fails
- How to show every second user different types of banners?
- Settings API and ‘type’ => ‘font’
- Every time I save my plugin options it erases another plugin options
- How to add a Reset to Defaults button with Settings API?
- How can I increase the post count for custom post types only?
- get_site_option / update_site_option – the main site and sub sites do not share the same storage
- display category name based on its equivalent id
- Native timestamp on wp_options option
- Post page overwrite the custom blog page
- How do I make mysite.com/comingsoon WordPress to become my main website’s WordPress?
- Update siteurl and home in multisite subsites to https
- Echo custom admin field into a is_single()
- add image in dropdown select
- Re-coding category-template.php to go to custom URL
- Plugin option for input box validation
- Custom Role accessing the wp-option table
- Dynamically Update Key in Associative Array When Saving Settings
- Possible to hide the search engine indexing disabled prompt/error message?
- Auto approve all comments (editor)
- Options page for widget
- update_option using variable name
- Hiding an added admin page menu using css
- Custom general settings (textarea field) don’t output HTML correctly
- Using get_option() for check box field
- Where to adjust presets for slider options “auto rotate” (3, 5, 10, 15 seconds)? [closed]
- WordPress shortcode select option not working [closed]
- Dynamic Email Handler with ‘header (“Location: …’
- change backend header options