# plugins_url()

URL: https://chugunov.pro/api-wordpress/functions/plugins_url/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.6.0.

## Сигнатура

```php
plugins_url( string $path = '', string $plugin = '' ): string
```

## Описание

По умолчанию возвращает URL каталога plugins, если аргументы не переданы.

## Параметры

- `$path` `string` — необязательный, по умолчанию `''`. Дополнительный путь, добавляемый в конец URL, включая относительный каталог, если передан $plugin.
- `$plugin` `string` — необязательный, по умолчанию `''`. Полный путь к файлу внутри плагина или mu-плагина.
  
  URL будет относительным по отношению к его каталогу.
  
  Обычно это делается передачей __FILE__ в качестве аргумента.

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-includes/link-template.php:3684`

```php
function plugins_url( $path = '', $plugin = '' ) {

	$path          = wp_normalize_path( $path );
	$plugin        = wp_normalize_path( $plugin );
	$mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );

	if ( ! empty( $plugin ) && str_starts_with( $plugin, $mu_plugin_dir ) ) {
		$url = WPMU_PLUGIN_URL;
	} else {
		$url = WP_PLUGIN_URL;
	}

	$url = set_url_scheme( $url );

	if ( ! empty( $plugin ) && is_string( $plugin ) ) {
		$folder = dirname( plugin_basename( $plugin ) );
		if ( '.' !== $folder ) {
			$url .= '/' . ltrim( $folder, '/' );
		}
	}

	if ( $path && is_string( $path ) ) {
		$url .= '/' . ltrim( $path, '/' );
	}

	/**
	 * Filters the URL to the plugins directory.
	 *
	 * @since 2.8.0
	 *
	 * @param string $url    The complete URL to the plugins directory including scheme and path.
	 * @param string $path   Path relative to the URL to the plugins directory. Blank string
	 *                       if no path is specified.
	 * @param string $plugin The plugin file path to be relative to. Blank string if no plugin
	 *                       is specified.
	 */
	return apply_filters( 'plugins_url', $url, $path, $plugin );
}
```

## История изменений

- 2.6.0 — Introduced.

## Связанные

Использует: [`wp_normalize_path`](https://chugunov.pro/api-wordpress/functions/wp_normalize_path/), [`set_url_scheme`](https://chugunov.pro/api-wordpress/functions/set_url_scheme/), [`plugin_basename`](https://chugunov.pro/api-wordpress/functions/plugin_basename/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`_load_script_textdomain_from_src`](https://chugunov.pro/api-wordpress/functions/_load_script_textdomain_from_src/), [`_wp_connectors_resolve_ai_provider_logo_url`](https://chugunov.pro/api-wordpress/functions/_wp_connectors_resolve_ai_provider_logo_url/), `WP_URL_Pattern_Prefixer::get_default_contexts`, [`get_block_asset_url`](https://chugunov.pro/api-wordpress/functions/get_block_asset_url/), [`get_theme_root_uri`](https://chugunov.pro/api-wordpress/functions/get_theme_root_uri/), [`plugin_dir_url`](https://chugunov.pro/api-wordpress/functions/plugin_dir_url/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/plugins_url/
