Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\Transformers
PrepareUrl::transform()
Prepares the site URL by removing the protocol and trailing slash.
Method of the class: PrepareUrl{}
No Hooks.
Return
Mixed|null
.
Usage
$PrepareUrl = new PrepareUrl(); $PrepareUrl->transform( $value, ?stdClass $arguments, $default_value );
- $value(string) (required)
- a value to transform.
- ?stdClass $arguments **
- -
Default: null - $default_value(string|null)
- default value.
Default: null
PrepareUrl::transform() PrepareUrl::transform code WC 9.7.1
public function transform( $value, ?stdClass $arguments = null, $default_value = null ) { if ( ! is_string( $value ) ) { return $default_value; } $url_parts = wp_parse_url( rtrim( $value, '/' ) ); if ( ! $url_parts ) { return $default_value; } if ( ! isset( $url_parts['host'] ) ) { return $default_value; } if ( isset( $url_parts['path'] ) ) { return $url_parts['host'] . $url_parts['path']; } return $url_parts['host']; }