PluginProbe
AI / trunk
AI vtrunk
1.3.0 1.2.0 1.1.0 1.0.2 1.0.1 1.0.0 0.9.0 trunk 0.1.1 0.2.0 0.2.1 0.3.0 0.3.1 0.4.0 0.4.1 0.5.0 0.6.0 0.7.0 0.8.0
ai / build / styles.php

styles.php in AI trunk, at build/styles.php

74 lines 2.9 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 ai_override_style()
7 * in lib/client-assets.php for complex cases (multiple files, conditional deps, etc.)
8 *
9 * @package ai
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 ai_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 ai_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 ai_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', 'ai_register_package_styles' );
74