Automattic\WooCommerce\Internal\Admin
WCAdminAssets::maybe_output_preload_link_tag()
Render a preload link tag for a dependency, optionally checked against a provided allowlist.
See: https://macarthur.me/posts/preloading-javascript-in-wordpress
Метод класса: WCAdminAssets{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->maybe_output_preload_link_tag( $dependency, $type, $allowlist );
- $dependency(WP_Dependency) (обязательный)
- The WP_Dependency being preloaded.
- $type(строка) (обязательный)
- Dependency type - 'script' or 'style'.
- $allowlist(массив)
- List of allowed dependency handles.
По умолчанию: array()
Код WCAdminAssets::maybe_output_preload_link_tag() WCAdminAssets::maybe output preload link tag WC 9.4.2
private function maybe_output_preload_link_tag( $dependency, $type, $allowlist = array() ) { if ( ( ! empty( $allowlist ) && ! in_array( $dependency->handle, $allowlist, true ) ) || ( ! empty( $this->preloaded_dependencies[ $type ] ) && in_array( $dependency->handle, $this->preloaded_dependencies[ $type ], true ) ) ) { return; } $this->preloaded_dependencies[ $type ][] = $dependency->handle; $source = $dependency->ver ? add_query_arg( 'ver', $dependency->ver, $dependency->src ) : $dependency->src; echo '<link rel="preload" href="', esc_url( $source ), '" as="', esc_attr( $type ), '" />', "\n"; }