Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/google-site-kit/includes/Core/Assets/Stylesheet.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * Class Google\Site_Kit\Core\Assets\Stylesheet
4 + *
5 + * @package Google\Site_Kit
6 + * @copyright 2021 Google LLC
7 + * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
8 + * @link https://sitekit.withgoogle.com
9 + */
10 +
11 + namespace Google\Site_Kit\Core\Assets;
12 +
13 + use Google\Site_Kit\Context;
14 +
15 + /**
16 + * Class representing a single stylesheet.
17 + *
18 + * @since 1.0.0
19 + * @access private
20 + * @ignore
21 + */
22 + final class Stylesheet extends Asset {
23 +
24 + /**
25 + * Constructor.
26 + *
27 + * @since 1.0.0
28 + *
29 + * @param string $handle Unique stylesheet handle.
30 + * @param array $args {
31 + * Associative array of stylesheet arguments.
32 + *
33 + * @type string $src Required stylesheet source URL.
34 + * @type array $dependencies List of stylesheet dependencies. Default empty array.
35 + * @type string $version Stylesheet version. Default is the version of Site Kit.
36 + * @type bool $fallback Whether to only register as a fallback. Default false.
37 + * @type callable $before_print Optional callback to execute before printing. Default none.
38 + * @type string $media Media for which the stylesheet is defined. Default 'all'.
39 + * }
40 + */
41 + public function __construct( $handle, array $args ) {
42 + parent::__construct( $handle, $args );
43 +
44 + $this->args = wp_parse_args(
45 + $this->args,
46 + array(
47 + 'media' => 'all',
48 + )
49 + );
50 + }
51 +
52 + /**
53 + * Registers the stylesheet.
54 + *
55 + * @since 1.0.0
56 + * @since 1.15.0 Adds $context parameter.
57 + *
58 + * @param Context $context Plugin context.
59 + */
60 + public function register( Context $context ) {
61 + if ( $this->args['fallback'] && wp_style_is( $this->handle, 'registered' ) ) {
62 + return;
63 + }
64 + $src = $this->args['src'];
65 + $version = $this->args['version'];
66 +
67 + list( $filename, $hash ) = Manifest::get( $this->handle );
68 +
69 + if ( $filename ) {
70 + $src = $context->url( 'dist/assets/css/' . $filename );
71 + $version = $hash;
72 + }
73 +
74 + wp_register_style(
75 + $this->handle,
76 + $src,
77 + (array) $this->args['dependencies'],
78 + $version,
79 + $this->args['media']
80 + );
81 + }
82 +
83 + /**
84 + * Enqueues the stylesheet.
85 + *
86 + * @since 1.0.0
87 + */
88 + public function enqueue() {
89 + wp_enqueue_style( $this->handle );
90 + }
91 + }
92 +