PluginProbe
Jetpack Boost – Website Speed, Performance and Critical CSS / trunk
Jetpack Boost – Website Speed, Performance and Critical CSS vtrunk
4.7.0 4.7.0-beta 4.6.3 4.6.2 4.6.2-beta 3.12.0 3.12.1 3.13.0 3.13.1 3.2.0 3.2.1 3.2.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 All 124 releases
jetpack-boost / build / styles.php

styles.php in Jetpack Boost – Website Speed, Performance and Critical CSS trunk, 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 jetpack_boost_override_style()
7 * in lib/client-assets.php for complex cases (multiple files, conditional deps, etc.)
8 *
9 * @package jetpack_boost
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 jetpack_boost_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 jetpack_boost_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 = '.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 jetpack_boost_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', 'jetpack_boost_register_package_styles' );
74