public function get(string $key, $default = null)
    {
        if ($this->has($key)) {
            if ($this->get_raw($key) === null) {
                return null;
            }

            if (\is_array($this->get_raw($key))) {
                return \array_map([$this, 'sanitise_array'], $this->get_raw($key));
            }

            if ($this->get_raw($key) instanceof File) {
                return $this->get_raw($key);
            }

            return \sanitize_textarea_field($this->get_raw($key));
        }

        return $default;
    }
public function get(string $key, $default = null)
    {
        if ($this->has($key)) {
            if ($this->get_raw($key) === null) {
                return null;
            }

            if (\is_array($this->get_raw($key))) {
                return \array_map([$this, 'sanitise_array'], $this->get_raw($key));
            }

            if ($this->get_raw($key) instanceof File) {
                return $this->get_raw($key);
            }

            return \sanitize_textarea_field($this->get_raw($key));
        }

        return $default;
    }
public function get ( string $ key , $ default = null ) { if ( $ this -> has ( $ key ) ) { if ( $ this -> get_raw ( $ key ) === null ) { return null ; } if ( \ is_array ( $ this -> get_raw ( $ key ) ) ) { return \ array_map ( [ $ this , 'sanitise_array' ] , $ this -> get_raw ( $ key ) ) ; } if ( $ this -> get_raw ( $ key ) instanceof File ) { return $ this -> get_raw ( $ key ) ; } return \ sanitize_textarea_field ( $ this -> get_raw ( $ key ) ) ; } return $ default ; }
Gets a sanitized value from the bag, or a supplied default if not present.

Use get_raw to get an un-sanitized version (should you need to).

@param  string $key     Item key to fetch.
@param  mixed  $default Default value if the key is not present.
@return mixed
Gets a sanitized value from the bag or a supplied default if not present .