Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions includes/fields/class-directorist-url-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ class Url_Field extends Base_Field {
public $type = 'url';

public function validate( $posted_data ) {
$value = $this->sanitize( $posted_data );

if ( ! wp_http_validate_url( $value ) ) {
$value = $this->sanitize( $posted_data );
$parsed_url = wp_parse_url( $value );

if (
! filter_var( $value, FILTER_VALIDATE_URL ) ||
false === $parsed_url ||
isset( $parsed_url['user'] ) ||
isset( $parsed_url['pass'] )
) {
$this->add_error( __( 'Invalid URL.', 'directorist' ) );

return false;
Expand All @@ -30,7 +36,7 @@ public function sanitize( $posted_data ) {
return $value;
}

return esc_url_raw( $value );
return esc_url_raw( $value, [ 'http', 'https' ] );
}
}

Expand Down
Loading