Hooks::update_option ( $meta_key, $newvalue )
Update (add if doesn’t exist) an option to options_meta
Source file: app/src/Hooks.php
Used by
Uses
- app/src/Hooks.php: Hooks::get_option()
- app/src/Hooks.php: Hooks::add_option()
- app/src/Hooks.php: Hooks::maybe_serialize()
- app/src/Hooks.php: Hooks::do_action()
- app/functions/global-function.php: _etsis_flash()
- app/functions/cache-function.php: etsis_cache_delete() Show 6 more uses
Source
public function update_option($meta_key, $newvalue) { $oldvalue = $this->get_option($meta_key); // If the new and old values are the same, no need to update. if ($newvalue === $oldvalue) { return false; } if (null === $oldvalue) { $this->add_option($meta_key, $newvalue); return true; } $_newvalue = $this->maybe_serialize($newvalue); etsis_cache_delete($meta_key, 'option'); $this->do_action('update_option', $meta_key, $oldvalue, $newvalue); try { $key = $this->app->db->options_meta(); $key->meta_value = $_newvalue; $key->where('meta_key = ?', $meta_key)->update(); if (count($key) > 0) { $this->app->db->option[$meta_key] = $newvalue; } } catch (NotFoundException $e) { Cascade::getLogger('error')->error(sprintf('SQLSTATE[%s]: Error: %s', $e->getCode(), $e->getMessage())); _etsis_flash()->error(_etsis_flash()->notice(409)); } catch (ORMException $e) { Cascade::getLogger('error')->error(sprintf('SQLSTATE[%s]: Error: %s', $e->getCode(), $e->getMessage())); _etsis_flash()->error(_etsis_flash()->notice(409)); } catch (Exception $e) { Cascade::getLogger('error')->error(sprintf('SQLSTATE[%s]: Error: %s', $e->getCode(), $e->getMessage())); _etsis_flash()->error(_etsis_flash()->notice(409)); } }
Expand full source code Collapse full source code View on Github