read($option_name, $default, ABJ_404_Solution_OptionShapeRead::SHAPE_SCALAR); } /** * Read an array option (a state record or site list) with the same * scoping and cache recovery as {@see getOption()}. * * @param string $option_name * @param mixed $default * @return mixed Null means absent when the default is null. */ public function getArrayOption($option_name, $default = null) { return $this->read($option_name, $default, ABJ_404_Solution_OptionShapeRead::SHAPE_ARRAY); } /** * @param string $option_name * @param mixed $default * @param string $shape * @return mixed */ private function read($option_name, $default, string $shape) { $value = ABJ_404_Solution_OptionShapeRead::read(array( 'name' => (string)$option_name, 'shape' => $shape, 'default' => $default, 'scope' => $this->isNetworkActivated() ? ABJ_404_Solution_OptionShapeRead::SCOPE_NETWORK : ABJ_404_Solution_OptionShapeRead::SCOPE_SITE, )); // WordPress serializes update_option($name, null) as an empty string. // Within this adapter, a nullable read represents absence, including // the empty-string clear marker written by older releases. return $default === null && $value === '' ? null : $value; } /** * Write an option to the network-wide store when network-activated, * otherwise to the site-local store. * * @param string $option_name * @param mixed $value * @return bool Null values delete the correctly scoped option. */ public function updateOption($option_name, $value) { if ($this->isNetworkActivated()) { if ($value === null) { return delete_site_option($option_name); } return update_site_option($option_name, $value); } if ($value === null) { return delete_option($option_name); } return update_option($option_name, $value); } }