check if is a valid key, remove old code

This commit is contained in:
Jacson Passold 2018-05-29 20:32:02 -03:00
parent a9698cb3f6
commit 63e23420bb
1 changed files with 8 additions and 8 deletions

View File

@ -85,12 +85,14 @@ class Exposers {
* @return string * @return string
*/ */
public function check_class_name($class_name, $root = false, $prefix = 'Tainacan\Exposers\Types\\') { public function check_class_name($class_name, $root = false, $prefix = 'Tainacan\Exposers\Types\\') {
if(array_key_exists($class_name, $this->types)) { if(is_string($class_name)) {
$class_name = $this->types[$class_name]; if(array_key_exists($class_name, $this->types)) {
$prefix = ''; $class_name = $this->types[$class_name];
} elseif( array_key_exists($class_name, $this->mappers)) { $prefix = '';
$class_name = $this->mappers[$class_name]; } elseif( array_key_exists($class_name, $this->mappers)) {
$prefix = ''; $class_name = $this->mappers[$class_name];
$prefix = '';
}
} }
$class = $prefix.sanitize_text_field($class_name); $class = $prefix.sanitize_text_field($class_name);
$class = str_replace(['-', ' '], ['_', '_'], $class); $class = str_replace(['-', ' '], ['_', '_'], $class);
@ -231,8 +233,6 @@ class Exposers {
* @return boolean * @return boolean
*/ */
public function has_mapper($mapper) { public function has_mapper($mapper) {
if(array_key_exists($mapper, $this->mappers)) return true;
return in_array($this->check_class_name($mapper, false, self::MAPPER_CLASS_PREFIX), $this->mappers); return in_array($this->check_class_name($mapper, false, self::MAPPER_CLASS_PREFIX), $this->mappers);
} }