How to save WordPress Options as an array?

Have you tried… <input type=”text” name=”my_options[option1]” value=”<?php echo $options[‘option1’]; ?>” /> <input type=”text” name=”my_options[option2]” value=”<?php echo $options[‘option2’]; ?>” /> <input type=”text” name=”my_options[option3]” value=”<?php echo $options[‘option3′]; ?>” />? I should say though (and maybe you have), that you should register your settings and perform necessary validation checks on the input – or if you really don’t … Read more

Can I use a space in an option name/key?

Other than general WordPress practice (http://make.wordpress.org/core/handbook/coding-standards/php/) which encourages spaces to always be replaced with – in file names and _ for other purposes, there isn’t a set reason that you can’t use spaces in an option name. From my tests, there is no technical reason to limit you from using a space. (edit) looking further, … Read more

how can I detect that option value has changed?

I just came across your question while trying to do a similar thing. I figured out what I needed so I thought I would post an answer here in case someone else finds it useful. In short I used this filter: https://codex.wordpress.org/Plugin_API/Filter_Reference/pre_update_option_(option_name) And it looks something like this: function set_admin_notice_options( $new_value, $old_value ) { // … Read more

How do I add a value to a wp_options option that is an array?

The option you’re showing in your question is a serialized array. Retrieving the option with get_option() gives you back the array, but unserialized. This is done by maybe_unserialize(), which get_option uses. Just add a new ‘key’ => ‘value’ pair to the array you retrieved and then update the option with update_option(), et voilà you have … Read more

Cannot unserialize WordPress serialized values in `wp_options` table?

Your problem is that serialized strings contains escape slashes that are not evaluated as such, because the wrapping quote is a single quote. You are using: $v = ‘a:2:{i:0;b:0;s:8:\”auto_add\”;a:0:{}}’; // wrong You have to use either $v = “a:2:{i:0;b:0;s:8:\”auto_add\”;a:0:{}}”; // ok or $v = ‘a:2:{i:0;b:0;s:8:”auto_add”;a:0:{}}’; // ok By the way, you should never manually unserialize … Read more

Theme options WP Editor

In theme options, I had to define wp_editor_settings. So, just in options.php, I used: //WP_editor settigs $wp_editor_settings = array( ‘wpautop’ => true, // Default ‘textarea_rows’ => 15, ‘tinymce’ => array( ‘plugins’ => ‘fullscreen,wordpress,wplink, textcolor’ )); Basically, I’m adding tinymce plugin.

Any way to partition wp_options?

No, and I strongly advise against changing the WordPress Options table schema, you’ll run into many problems such as: No longer having a reliable update process Non-portable code You won’t be able to use the get_options suite of functions and the object caching and optimisations that come with them If you managed to get it … Read more

How to update_site_option for specific site within network?

update_site_option() updates an option that’s set for the entire network. If you’re trying to update a specific site’s option, eg blogname, you’ll need to do update_option() instead. If you’re not sure of a site’s ID, you can get its details using the site’s slug with get_blog_details(). For example, if I wanted to change the admin_email … Read more

update_option method with support of utf8

Chances is are that the content-type/charset header is not being sent, and that you end up reading the utf8 chars as if they were latin-1. Also, note that serialize()/unserialize() are not multibyte character-safe. For a subset of characters, the string’s length as returned by serialize() will occasionally differ from the expected length as it would … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)