WC_Widget::get_widget_id_for_cache()protectedWC 3.4.0

Get widget id plus scheme/protocol to prevent serving mixed content from (persistently) cached widgets.

Method of the class: WC_Widget{}

Hooks from the method

Return

String. Widget id including scheme/protocol.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_widget_id_for_cache( $widget_id, $scheme );
$widget_id(string) (required)
Id of the cached widget.
$scheme(string)
Scheme for the widget id.
Default: ''

Changelog

Since 3.4.0 Introduced.

WC_Widget::get_widget_id_for_cache() code WC 8.7.0

protected function get_widget_id_for_cache( $widget_id, $scheme = '' ) {
	if ( $scheme ) {
		$widget_id_for_cache = $widget_id . '-' . $scheme;
	} else {
		$widget_id_for_cache = $widget_id . '-' . ( is_ssl() ? 'https' : 'http' );
	}

	return apply_filters( 'woocommerce_cached_widget_id', $widget_id_for_cache );
}