Automattic\WooCommerce\Blocks\Assets
Api::register_style()
Registers a style according to wp_register_style.
Метод класса: Api{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$Api = new Api(); $Api->register_style( $handle, $relative_src, $deps, $media, $rtl );
- $handle(строка) (обязательный)
- Name of the stylesheet. Should be unique.
- $relative_src(строка) (обязательный)
- Relative source of the stylesheet to the plugin path.
- $deps(массив)
- An array of registered stylesheet handles this stylesheet depends on.
По умолчанию: empty array - $media(строка)
- The media for which this stylesheet has been defined. Accepts media types like 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'.
По умолчанию: 'all' - $rtl(true|false)
- Whether or not to register RTL styles.
По умолчанию: false
Список изменений
С версии 2.5.0 | Введена. |
С версии 2.6.0 | Change src to be relative source. |
Код Api::register_style() Api::register style WC 9.8.1
public function register_style( $handle, $relative_src, $deps = [], $media = 'all', $rtl = false ) { $filename = str_replace( plugins_url( '/', dirname( __DIR__ ) ), '', $relative_src ); $src = $this->get_asset_url( $relative_src ); $ver = $this->get_file_version( $filename ); wp_register_style( $handle, $src, $deps, $ver, $media ); if ( $rtl ) { wp_style_add_data( $handle, 'rtl', 'replace' ); } }