WooCommerce::api_request_url()
Return the WC API URL for a given request.
Method of the class: WooCommerce{}
Hooks from the method
Return
String
.
Usage
$WooCommerce = new WooCommerce(); $WooCommerce->api_request_url( $request, $ssl );
- $request(string) (required)
- Requested endpoint.
- $ssl(true|false|null)
- If should use SSL, null if should auto detect.
Default: null
WooCommerce::api_request_url() WooCommerce::api request url code WC 9.2.3
public function api_request_url( $request, $ssl = null ) { if ( is_null( $ssl ) ) { $scheme = wp_parse_url( home_url(), PHP_URL_SCHEME ); } elseif ( $ssl ) { $scheme = 'https'; } else { $scheme = 'http'; } if ( strstr( get_option( 'permalink_structure' ), '/index.php/' ) ) { $api_request_url = trailingslashit( home_url( '/index.php/wc-api/' . $request, $scheme ) ); } elseif ( get_option( 'permalink_structure' ) ) { $api_request_url = trailingslashit( home_url( '/wc-api/' . $request, $scheme ) ); } else { $api_request_url = add_query_arg( 'wc-api', $request, trailingslashit( home_url( '', $scheme ) ) ); } /** * Filter to adjust the url of an incoming API request. */ return esc_url_raw( apply_filters( 'woocommerce_api_request_url', $api_request_url, $request, $ssl ) ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingSinceComment }