New answers tagged

0

I think it is always better to use the API, the functions of WP in this context. The function wp_load_alloptions() is under maintain and a custom select must always tested and maintain. Also the function use the Cache, if the installation support this. A good point for performance. The function supports also the Multisite installation, maybe this also a ...


4

Looking at the sources (core files, wp-includes/option.php) you can always find your target hook tags: add_action("added_option", "wpse230212_callback_add", 10, 2); add_action("updated_option", "wpse230212_callback_update", 10, 3); function wpse230212_callback_add( $option_name, $option_value ) { } function wpse230212_callback_update( $option_name, $...


0

I believe that the best approach to this issue is to create IF-ELSE logic like this one: if(get_option('some_option')){ update_option('some_option', 'value_we_want_to_add'); } else { add_option('some_option', 'value_we_want_to_add'); } Logic: get_option() will return TRUE if that option does exist. In this case we can simply ...



Top 50 recent answers are included