WP_Script_Modules::get_src
Gets the versioned URL for a script module src.
If $version is set to false, the version number is the currently installed WordPress version. If $version is set to null, no version is added. Otherwise, the string passed in $version is used.
Метод класса: WP_Script_Modules{}
Хуки из метода
Возвращает
string. The script module src with a version if relevant.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_src( $id ): string;
- $id(строка) (обязательный)
- The script module identifier.
Список изменений
| С версии 6.5.0 | Введена. |
Код WP_Script_Modules::get_src() WP Script Modules::get src WP 7.1
private function get_src( string $id ): string {
if ( ! isset( $this->registered[ $id ] ) ) {
return '';
}
$script_module = $this->registered[ $id ];
$src = $script_module['src'];
if ( '' !== $src ) {
if ( false === $script_module['version'] ) {
$src = add_query_arg( 'ver', get_bloginfo( 'version' ), $src );
} elseif ( null !== $script_module['version'] ) {
$src = add_query_arg( 'ver', $script_module['version'], $src );
}
}
/**
* Filters the script module source.
*
* @since 6.5.0
*
* @param string $src Module source URL.
* @param string $id Module identifier.
*/
$src = apply_filters( 'script_module_loader_src', $src, $id );
if ( ! is_string( $src ) ) {
$src = '';
}
return $src;
}