Best practice differences in DB options and wp-config between live, staging and local WordPress environments?

Seems like a good list you have going… Just a few that come to mind: SCRIPT_DEBUG to false on live and true on staging. WP_CACHE to true on live and false on staging. ping_sites to empty on staging to disable ping services. default_pingback_flag to 0 on staging to not send outgoing pingbacks. Maybe install a … Read more

How to verify this checkbox is checked?

<?php echo “<input type=”checkbox” name=”automatic” value=”1″ “.checked(1, get_option(‘automatic’)).” />”; if (get_option(‘automatic’) === ‘1’) { require_once ‘myfile.php’; } ?>

update_option not working in stand-alone PHP script

I’m not sure why it does’t work for you, but the following works in the file wp-content/test.php: <?php // doesn’t make difference to have this or not, for the rest to work define( ‘WP_USE_THEMES’, false ); require( $_SERVER[‘DOCUMENT_ROOT’] .’/wp-load.php’ ); function my_function() { return ‘hello world’; } $value = my_function(); update_option( ‘my_option’, $value ); var_dump( … Read more

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

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

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)