示例#1
0
 protected function _get_unique_key($key)
 {
     $key = sanitize_key($key);
     $keys = (array) GlobalStorage::get('option_box', 'keys');
     if (in_array($key, $keys)) {
         throw new WpException("Option box \"{$this->_title}\" has non unique key");
     }
     array_push($keys, $key);
     GlobalStorage::set('option_box', $keys, 'keys');
     return $key;
 }
示例#2
0
 /**
  * @param $key
  * @param $name
  * @return string
  * @throws \WPKit\Exception\WpException
  */
 protected function _get_unique_key($key, $name)
 {
     $key = sanitize_key($key);
     $keys = (array) GlobalStorage::get('widget', 'keys');
     if (in_array($key, $keys)) {
         throw new WpException("Widget \"{$name}\" has non unique key");
     }
     array_push($keys, $key);
     GlobalStorage::set('widget', $keys, 'keys');
     return $key;
 }