C:\xampp\htdocs\landing\wp-content\plugins\amp\vendor\ampproject\common\src\Amp.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<?php

namespace AmpProject;

use 
DOMElement;
use 
DOMNode;

/**
 * Central helper functionality for all Amp-related PHP code.
 *
 * @package ampproject/common
 */
final class Amp
{

    
/**
     * List of AMP attribute tags that can be appended to the <html> element.
     *
     * The *_ALT version represent a Unicode variation of the lightning emoji.
     * @see https://github.com/ampproject/amphtml/issues/25990
     *
     * @var string[]
     */
    
const TAGS = [
        
Attribute::AMP,
        
Attribute::AMP_EMOJI,
        
Attribute::AMP_EMOJI_ALT,
        
Attribute::AMP4ADS,
        
Attribute::AMP4ADS_EMOJI,
        
Attribute::AMP4ADS_EMOJI_ALT,
        
Attribute::AMP4EMAIL,
        
Attribute::AMP4EMAIL_EMOJI,
        
Attribute::AMP4EMAIL_EMOJI_ALT,
    ];

    
/**
     * Host and scheme of the AMP cache.
     *
     * @var string
     */
    
const CACHE_HOST 'https://cdn.ampproject.org';

    
/**
     * URL of the AMP cache.
     *
     * @var string
     */
    
const CACHE_ROOT_URL self::CACHE_HOST '/';

    
/**
     * List of valid AMP formats.
     *
     * @var string[]
     */
    
const FORMATS = ['AMP''AMP4EMAIL''AMP4ADS'];

    
/**
     * List of dynamic components
     *
     * This list should be kept in sync with the list of dynamic components at:
     *
     * @see https://github.com/ampproject/amphtml/blob/292dc66b8c0bb078bbe3a1bca960e8f494f7fc8f/spec/amp-cache-guidelines.md#guidelines-adding-a-new-cache-to-the-amp-ecosystem
     *
     * @var array[]
     */
    
const DYNAMIC_COMPONENTS = [
        
Attribute::CUSTOM_ELEMENT  => [Extension::GEO],
        
Attribute::CUSTOM_TEMPLATE => [],
    ];

    
/**
     * Array of custom element names that delay rendering.
     *
     * @var string[]
     */
    
const RENDER_DELAYING_EXTENSIONS = [
        
Extension::DYNAMIC_CSS_CLASSES,
        
Extension::EXPERIMENT,
        
Extension::STORY,
    ];

    
/**
     * Standard boilerplate CSS stylesheet.
     *
     * @var string
     */
    
const BOILERPLATE_CSS 'body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}'// phpcs:ignore Generic.Files.LineLength.TooLong

    /**
     * Boilerplate CSS stylesheet for the <noscript> tag.
     *
     * @var string
     */
    
const BOILERPLATE_NOSCRIPT_CSS 'body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}'// phpcs:ignore Generic.Files.LineLength.TooLong

    /**
     * Boilerplate CSS stylesheet for Amp4Ads & Amp4Email.
     *
     * @var string
     */
    
const AMP4ADS_AND_AMP4EMAIL_BOILERPLATE_CSS 'body{visibility:hidden}';

    
/**
     * AMP runtime tag name.
     *
     * @var string
     */
    
const RUNTIME 'amp-runtime';

    
// AMP classes reserved for internal use.
    
const LAYOUT_ATTRIBUTE          'i-amphtml-layout';
    const 
NO_BOILERPLATE_ATTRIBUTE  'i-amphtml-no-boilerplate';
    const 
LAYOUT_CLASS_PREFIX       'i-amphtml-layout-';
    const 
LAYOUT_SIZE_DEFINED_CLASS 'i-amphtml-layout-size-defined';
    const 
SIZER_ELEMENT             'i-amphtml-sizer';
    const 
INTRINSIC_SIZER_ELEMENT   'i-amphtml-intrinsic-sizer';

    
/**
     * Check if a given node is the AMP runtime script.
     *
     * The AMP runtime script node is of the form '<script async src="https://cdn.ampproject.org...v0.js"></script>'.
     *
     * @param DOMNode $node Node to check.
     * @return bool Whether the given node is the AMP runtime script.
     */
    
public static function isRuntimeScript(DOMNode $node)
    {
        if (
            ! 
$node instanceof DOMElement
            
|| ! self::isAsyncScript($node)
            || 
self::isExtension($node)
        ) {
            return 
false;
        }

        
$src $node->getAttribute(Attribute::SRC);

        if (
strpos($srcself::CACHE_ROOT_URL) !== 0) {
            return 
false;
        }

        if (
            
substr($src, -6) !== '/v0.js'
            
&& substr($src, -14) !== '/amp4ads-v0.js'
        
) {
            return 
false;
        }

        return 
true;
    }

    
/**
     * Check if a given node is the AMP viewer script.
     *
     * The AMP viewer script node is of the form '<script async
     * src="https://cdn.ampproject.org/v0/amp-viewer-integration-...js>"</script>'.
     *
     * @param DOMNode $node Node to check.
     * @return bool Whether the given node is the AMP runtime script.
     */
    
public static function isViewerScript(DOMNode $node)
    {
        if (
            ! 
$node instanceof DOMElement
            
|| ! self::isAsyncScript($node)
            || 
self::isExtension($node)
        ) {
            return 
false;
        }

        
$src $node->getAttribute(Attribute::SRC);

        if (
strpos($srcself::CACHE_HOST '/v0/amp-viewer-integration-') !== 0) {
            return 
false;
        }

        if (
substr($src, -3) !== '.js') {
            return 
false;
        }

        return 
true;
    }

    
/**
     * Check if a given node is an AMP extension.
     *
     * @param DOMNode $node Node to check.
     * @return bool Whether the given node is the AMP runtime script.
     */
    
public static function isExtension(DOMNode $node)
    {
        return ! empty(
self::getExtensionName($node));
    }

    
/**
     * Get the name of the extension.
     *
     * Returns an empty string if the name of the extension could not be retrieved.
     *
     * @param DOMNode $node Node to get the name of.
     * @return string Name of the custom node or template. Empty string if none found.
     */
    
public static function getExtensionName(DOMNode $node)
    {
        if (! 
$node instanceof DOMElement || $node->tagName !== Tag::SCRIPT) {
            return 
'';
        }

        if (
$node->hasAttribute(Attribute::CUSTOM_ELEMENT)) {
            return 
$node->getAttribute(Attribute::CUSTOM_ELEMENT);
        }

        if (
$node->hasAttribute(Attribute::CUSTOM_TEMPLATE)) {
            return 
$node->getAttribute(Attribute::CUSTOM_TEMPLATE);
        }

        if (
$node->hasAttribute(Attribute::HOST_SERVICE)) {
            return 
$node->getAttribute(Attribute::HOST_SERVICE);
        }

        return 
'';
    }

    
/**
     * Check whether a given node is a script for a render-delaying extension.
     *
     * @param DOMNode $node Node to check.
     * @return bool Whether the node is a script for a render-delaying extension.
     */
    
public static function isRenderDelayingExtension(DOMNode $node)
    {
        
$extensionName self::getExtensionName($node);

        if (empty(
$extensionName)) {
            return 
false;
        }

        return 
in_array($extensionNameself::RENDER_DELAYING_EXTENSIONStrue);
    }

    
/**
     * Check whether a given DOM node is an AMP custom element.
     *
     * @param DOMNode $node DOM node to check.
     * @return bool Whether the checked DOM node is an AMP custom element.
     */
    
public static function isCustomElement(DOMNode $node)
    {
        return 
$node instanceof DOMElement && strpos($node->tagNameExtension::PREFIX) === 0;
    }

    
/**
     * Check whether a given node is an async <script> element.
     *
     * @param DOMNode $node Node to check.
     * @return bool Whether the given node is an async <script> element.
     */
    
private static function isAsyncScript(DOMNode $node)
    {
        if (
            ! 
$node instanceof DOMElement
            
|| $node->tagName !== Tag::SCRIPT
        
) {
            return 
false;
        }

        if (
            ! 
$node->hasAttribute(Attribute::SRC)
            || ! 
$node->hasAttribute(Attribute::ASYNC)
        ) {
            return 
false;
        }

        return 
true;
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586