contains($rule[1], $value); } if (is_callable($rule)) { return $rule($value, $raw, $validate); } switch ($rule) { case 'field_id': return $validate->fieldId($value); case 'number': return $validate->number($value); case 'text': return $validate->textField($value); case 'email': return $validate->email($value); case 'url': return $validate->url($value); // Prefixed (unlike the other rule names above): a plain 'date' or 'time' rule name is, unlike any // other name here, itself a callable PHP function (date(), time()) -- is_callable($rule) above // would catch it before this switch is ever reached and call the wrong thing. case 'aop_date': return $validate->date($value); case 'aop_time': return $validate->time($value); case 'aop_date_time': return $validate->dateTime($value); case 'textarea': return $validate->textArea($value); case 'toggle': return $validate->toggle($value); case 'toggle_onoff': return $validate->toggleOnOff($value); case 'class_attribute': return $validate->classAttribute($value); case 'field_name': // The name is checked together with all the other names of the page. return $validate->already($value, $validate->pages()); case 'toggle_autoload': return $validate->toggleAutoload($raw); case 'toggle_frontend': return $validate->toggleFrontend($value); case 'toggle_text_format': return $validate->toggleTextFormat($raw); case 'text_field_style': return $validate->textFieldStyle($value); case 'textarea_style': return $validate->textareaStyle($value); case 'choices': return $validate->tableList($value); case 'color_hex': return $validate->colorHex($value); case 'extensions': return $validate->imageExtensions($value); case 'file_extensions': return $validate->fileExtensions($value); } // A developer error, never printed to visitors. throw new \InvalidArgumentException('Unknown sanitizer: ' . (is_string($rule) ? $rule : gettype($rule))); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped } }