{"_id":"543f96e4051bdc0e00dfbf09","user":"542ea80e6b0eb6080066c9d5","category":{"_id":"543264d3f2f806080098ad40","project":"5431c59ea55723080068e155","version":"5431c59ea55723080068e158","pages":["543249453ee609080061800c","543f96e4051bdc0e00dfbf09","54324b909afb2a080013cce0","54359c9e5e1b202000438229","54483f7bcfb4580800d5e2a8","546e2dfe0f33a80800f58518","56850afe65976e0d00001c9b"],"__v":8,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-06T09:45:55.706Z","from_sync":false,"order":2,"slug":"how-to","title":"How-to"},"__v":10,"is_link":false,"version":{"_id":"5431c59ea55723080068e158","project":"5431c59ea55723080068e155","__v":8,"createdAt":"2014-10-05T22:26:38.927Z","releaseDate":"2014-10-05T22:26:38.927Z","categories":["5431c59ea55723080068e159","54325f53f2f806080098ad37","543264b1f2f806080098ad3e","543264c8f2f806080098ad3f","543264d3f2f806080098ad40","543264f42aca39080046d81e","5435bbf15e1b20200043834d","54e9cfb4f152c50d009b49ed"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"parentDoc":null,"project":"5431c59ea55723080068e155","updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-16T09:59:00.542Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"basic_auth":false,"results":{"codes":[]},"try":true,"auth":"never","params":[],"url":""},"isReference":false,"order":1,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"The missing `set_option`\"\n}\n[/block]\nThere are two ways to set options in your DB:\n+ `update_option` or `add_option` Wordpress function which have different uses (read [the add_option](http://codex.wordpress.org/Function_Reference/add_option) and [the update_option](http://codex.wordpress.org/Function_Reference/update_option) references)\n+ the new `set_option` TeaThemeOptions function which uses the transient API if asked and store options in DB without autoload.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Set option from the theme\"\n}\n[/block]\nSimply, use the function as follow:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n$my_new_value = 'a new value';\\nTeaThemeOptions::set_option('my_value', $my_new_value);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nIn the same way, writing `TeaThemeOptions::set_option` is too long. So we suggest you to add these lines in your `functions.php`, after the Tea Theme Options declaration:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nfunction _set_option($option, $value, $transient = false)\\n{\\n    TeaThemeOptions::set_option($option, $value, $transient);\\n}\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nYou can now set your options:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n$my_new_value = 'a new value';\\n_set_option('my_value', $my_new_value);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]","excerpt":"Only if needed!","slug":"set-your-options","type":"basic","title":"Set your options"}

Set your options

Only if needed!

[block:api-header] { "type": "basic", "title": "The missing `set_option`" } [/block] There are two ways to set options in your DB: + `update_option` or `add_option` Wordpress function which have different uses (read [the add_option](http://codex.wordpress.org/Function_Reference/add_option) and [the update_option](http://codex.wordpress.org/Function_Reference/update_option) references) + the new `set_option` TeaThemeOptions function which uses the transient API if asked and store options in DB without autoload. [block:api-header] { "type": "basic", "title": "Set option from the theme" } [/block] Simply, use the function as follow: [block:code] { "codes": [ { "code": "<?php\n\n$my_new_value = 'a new value';\nTeaThemeOptions::set_option('my_value', $my_new_value);", "language": "php" } ] } [/block] In the same way, writing `TeaThemeOptions::set_option` is too long. So we suggest you to add these lines in your `functions.php`, after the Tea Theme Options declaration: [block:code] { "codes": [ { "code": "<?php\n\nfunction _set_option($option, $value, $transient = false)\n{\n TeaThemeOptions::set_option($option, $value, $transient);\n}", "language": "php" } ] } [/block] You can now set your options: [block:code] { "codes": [ { "code": "<?php\n\n$my_new_value = 'a new value';\n_set_option('my_value', $my_new_value);", "language": "php" } ] } [/block]