isStagingSite()) { return $default; } $settings = get_option(self::WPSTG_CLONE_SETTINGS_KEY, null); // Return settings if no options given if ($option === null) { return $settings; } // Early Bail: if settings is null or if settings isn't object if ($settings === null || !is_object($settings)) { return $default; } // Early bail if given option not exists if (!property_exists($settings, $option)) { return $default; } return $settings->{$option}; } /** * Set the value of given option * * @param string $option * @param mixed $value * * @return bool */ public function set(string $option, $value): bool { // Early bail if not a staging site if (!WPStaging::make(SiteInfo::class)->isStagingSite()) { return false; } $settings = get_option(self::WPSTG_CLONE_SETTINGS_KEY, null); // If settings is null or if settings isn't object make settings a object if ($settings === null || !is_object($settings)) { $settings = new stdClass(); } $settings->{$option} = $value; return update_option(self::WPSTG_CLONE_SETTINGS_KEY, $settings); } /** * Delete the given option * * @param string $option * * @return bool */ public function delete(string $option): bool { // Early bail if not a staging site if (!WPStaging::make(SiteInfo::class)->isStagingSite()) { return false; } $settings = get_option(self::WPSTG_CLONE_SETTINGS_KEY, null); // Early Bail: if settings is null or if settings isn't object if ($settings === null || !is_object($settings)) { return false; } // Early bail if given option not exists if (!property_exists($settings, $option)) { return true; } unset($settings->{$option}); return update_option(self::WPSTG_CLONE_SETTINGS_KEY, $settings); } }