/** * @author Vova Feldman (@svovaf) * @since 1.0.7 * * @param string $key * @param mixed $value * @param bool $flush */ function store($key, $value, $flush = true) { if ($this->_logger->is_on()) { $this->_logger->entrance($key . ' = ' . var_export($value, true)); } if (array_key_exists($key, $this->_data) && $value === $this->_data[$key]) { // No need to store data if the value wasn't changed. return; } $all_data = $this->get_all_data(); $this->_data[$key] = $value; $all_data[$this->_slug] = $this->_data; $options_manager = $this->get_option_manager(); $options_manager->set_option($this->_id, $all_data, $flush); }
/** * Dump options to database. * * @author Vova Feldman (@svovaf) * @since 1.0.3 */ function store() { $this->_logger->entrance(); $option_name = $this->_get_option_manager_name(); if ($this->_logger->is_on()) { $this->_logger->info($option_name . ' = ' . var_export($this->_options, true)); } // Update DB. update_option($option_name, $this->_options); if (!WP_FS__DEBUG_SDK) { wp_cache_set($option_name, $this->_options, WP_FS__SLUG); } }
private function _load_account() { $this->_logger->entrance(); $this->do_action('before_account_load'); $sites = self::get_all_sites(); $users = self::get_all_users(); $plans = self::get_all_plans(); $licenses = self::get_all_licenses(); if ($this->_logger->is_on() && is_admin()) { $this->_logger->log('sites = ' . var_export($sites, true)); $this->_logger->log('users = ' . var_export($users, true)); $this->_logger->log('plans = ' . var_export($plans, true)); $this->_logger->log('licenses = ' . var_export($licenses, true)); } $site = isset($sites[$this->_slug]) ? $sites[$this->_slug] : false; if (is_object($site) && is_numeric($site->id) && is_numeric($site->user_id) && is_object($site->plan)) { // Load site. $this->_site = clone $site; $this->_site->plan = $this->_decrypt_entity($this->_site->plan); // Load relevant user. $this->_user = clone $users[$this->_site->user_id]; // Load plans. $this->_plans = $plans[$this->_slug]; if (!is_array($this->_plans) || empty($this->_plans)) { $this->_sync_plans(true); } else { for ($i = 0, $len = count($this->_plans); $i < $len; $i++) { if ($this->_plans[$i] instanceof FS_Plugin_Plan) { $this->_plans[$i] = $this->_decrypt_entity($this->_plans[$i]); } else { unset($this->_plans[$i]); } } } // Load licenses. $this->_licenses = array(); if (is_array($licenses) && isset($licenses[$this->_slug]) && isset($licenses[$this->_slug][$this->_user->id])) { $this->_licenses = $licenses[$this->_slug][$this->_user->id]; } $this->_license = $this->_get_license_by_id($this->_site->license_id); if ($this->_site->version != $this->get_plugin_version()) { // If stored install version is different than current installed plugin version, // then update plugin version event. $this->update_plugin_version_event(); } } $this->_register_account_hooks(); }