Server : LiteSpeed System : Linux server321.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64 User : apotdzgr ( 7060) PHP Version : 8.0.30 Disable Function : NONE Directory : /home/apotdzgr/public_html/wp-content/plugins/nextend-facebook-connect/ |
Upload File : |
<?php class NextendSocialLoginSettings { protected $optionKey; protected $settings = array( 'default' => array(), 'stored' => array(), 'final' => array() ); /** * NextendSocialLoginSettings constructor. * * @param $optionKey string * @param $defaultSettings array */ public function __construct($optionKey, $defaultSettings) { $this->optionKey = $optionKey; $this->settings['default'] = $defaultSettings; $storedSettings = get_option($this->optionKey); if ($storedSettings !== false) { $storedSettings = (array)maybe_unserialize($storedSettings); } else { $storedSettings = array(); } $this->settings['stored'] = array_merge($this->settings['default'], $storedSettings); $this->settings['final'] = apply_filters('nsl_finalize_settings_' . $optionKey, $this->settings['stored']); } public function get($key, $storage = 'final') { if (!isset($this->settings[$storage][$key])) { return false; } return $this->settings[$storage][$key]; } public function set($key, $value) { $this->settings['stored'][$key] = $value; $this->storeSettings(); } public function getAll($storage = 'final') { return $this->settings[$storage]; } /** * @param array $postedData * * @return bool */ public function update($postedData) { if (is_array($postedData)) { $newData = array(); $newData = apply_filters('nsl_update_settings_validate_' . $this->optionKey, $newData, $postedData); if (count($newData)) { $isChanged = false; foreach ($newData AS $key => $value) { if ($this->settings['stored'][$key] != $value) { $this->settings['stored'][$key] = $value; $isChanged = true; } } if ($isChanged) { $allowedKeys = array_keys($this->settings['default']); $this->settings['stored'] = array_intersect_key($this->settings['stored'], array_flip($allowedKeys)); $this->storeSettings(); return true; } } } return false; } protected function storeSettings() { update_option($this->optionKey, maybe_serialize($this->settings['stored'])); $this->settings['final'] = apply_filters('nsl_finalize_settings_' . $this->optionKey, $this->settings['stored']); } }