PluginProbe
Gutenberg / 22.9.0
Gutenberg v22.9.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / styles.php

styles.php in Gutenberg 22.9.0, at build/styles.php

74 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Style registration - Auto-generated by build process.
4 * Do not edit this file manually.
5 *
6 * Note: These styles can be overridden by calling gutenberg_override_style()
7 * in lib/client-assets.php for complex cases (multiple files, conditional deps, etc.)
8 *
9 * @package gutenberg
10 */
11
12 /**
13 * Registers a style according to `wp_register_style`. Honors this request by
14 * deregistering any style by the same handler before registration.
15 *
16 * @param WP_Styles $styles WP_Styles instance.
17 * @param string $handle Name of the stylesheet. Should be unique.
18 * @param string $src Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory.
19 * @param array $deps Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array.
20 * @param string|bool|null $ver Optional. String specifying stylesheet version number, if it has one, which is added to the URL
21 * as a query string for cache busting purposes. If version is set to false, a version
22 * number is automatically added equal to current installed WordPress version.
23 * If set to null, no version is added.
24 * @param string $media Optional. The media for which this stylesheet has been defined.
25 * Default 'all'. Accepts media types like 'all', 'print' and 'screen', or media queries like
26 * '(orientation: portrait)' and '(max-width: 640px)'.
27 */
28 function gutenberg_override_style( $styles, $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
29 $style = $styles->query( $handle, 'registered' );
30 if ( $style ) {
31 $styles->remove( $handle );
32 }
33 $styles->add( $handle, $src, $deps, $ver, $media );
34 }
35
36 /**
37 * Register all package styles (simple cases only).
38 * Complex cases should be manually registered in lib/client-assets.php.
39 *
40 * @param WP_Styles $styles WP_Styles instance.
41 */
42 function gutenberg_register_package_styles( $styles ) {
43 // Load build constants
44 $build_constants = require __DIR__ . '/constants.php';
45 $default_version = ! SCRIPT_DEBUG ? $build_constants['version'] : time();
46 $suffix = SCRIPT_DEBUG ? '' : '.min';
47
48 $styles_dir = __DIR__ . '/styles';
49 $styles_file = $styles_dir . '/registry.php';
50
51 if ( ! file_exists( $styles_file ) ) {
52 return;
53 }
54
55 $styles_data = require $styles_file;
56 $plugin_dir = dirname( __FILE__ );
57
58 foreach ( $styles_data as $style_data ) {
59 gutenberg_override_style(
60 $styles,
61 $style_data['handle'],
62 $build_constants['build_url'] . 'styles/' . $style_data['path'] . $suffix . '.css',
63 $style_data['dependencies'],
64 $default_version
65 );
66
67 // Enable RTL support (WordPress automatically loads -rtl.css variant)
68 $styles->add_data( $style_data['handle'], 'rtl', 'replace' );
69 $styles->add_data( $style_data['handle'], 'suffix', $suffix );
70 }
71 }
72
73 add_action( 'wp_default_styles', 'gutenberg_register_package_styles' );
74