WC_Frontend_Scripts::localize_script()private staticWC 2.3.0

Localize a WC script once.

Метод класса: WC_Frontend_Scripts{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

$result = WC_Frontend_Scripts::localize_script( $handle );
$handle(строка) (обязательный)
Script handle the data will be attached to.

Список изменений

С версии 2.3.0 Введена.
С версии 2.3.0 this needs less wp_script_is() calls due to https://core.trac.wordpress.org/ticket/28404 being added in WP 4.0.

Код WC_Frontend_Scripts::localize_script() WC 8.7.0

private static function localize_script( $handle ) {
	if ( ! in_array( $handle, self::$wp_localize_scripts, true ) && wp_script_is( $handle ) ) {
		$data = self::get_script_data( $handle );

		if ( ! $data ) {
			return;
		}

		$name                        = str_replace( '-', '_', $handle ) . '_params';
		self::$wp_localize_scripts[] = $handle;
		wp_localize_script( $handle, $name, apply_filters( $name, $data ) );
	}
}