Repository navigation
Expand file tree
/
Copy pathLoadingError.php
More file actions
146 lines (129 loc) · 3.23 KB
/
Copy pathLoadingError.php
File metadata and controls
146 lines (129 loc) · 3.23 KB
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
<?php
/**
* Class LoadingError.
*
* @package AmpProject\AmpWP
*/
namespace AmpProject\AmpWP;
use AmpProject\AmpWP\Infrastructure\Service;
/**
* Client-side app loading error markup and styles.
*
* @package AmpProject\AmpWP
* @since 2.1.3
* @internal
*/
final class LoadingError implements Service {
/**
* Render error message along with necessary styles.
*/
public function render() {
?>
<div id="amp-pre-loading-spinner" class="amp-spinner-container">
<span class="amp-loading-spinner">
<span class="screen-reader-text">
<?php esc_html_e( 'Loading', 'amp' ); ?>
</span>
</span>
</div>
<div id="amp-loading-failure" class="error-screen-container">
<div class="error-screen components-panel">
<h1>
<?php esc_html_e( 'Something went wrong.', 'amp' ); ?>
</h1>
<?php
printf(
'<p class="amp-loading-failure-script">%s</p>',
wp_kses(
sprintf(
/* translators: %s is the AMP support forum URL. */
__( 'Check your connection and open your browser console to see if there are any error messages. You may share them on the <a href="%s" target="_blank" rel="noreferrer noopener">support forum</a>.', 'amp' ),
esc_url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fampproject%2Famp-wp%2Fblob%2Fdevelop%2Fsrc%2F__%28%2520%26%23039%3Bhttps%3A%2F%2Fwordpress.org%2Fsupport%2Fplugin%2Famp%2F%26%23039%3B%2C%2520%26%23039%3Bamp%26%23039%3B) )
),
[
'a' => [
'href' => true,
'target' => true,
'rel' => true,
],
]
)
);
?>
<noscript>
<p class="amp-loading-failure-noscript"><?php esc_html_e( 'You must have JavaScript enabled to use this page.', 'amp' ); ?></p>
</noscript>
</div>
</div>
<style>
#amp-loading-failure {
visibility: hidden;
animation: amp-wp-show-element 30s steps(1, end) 0s 1 normal both;
}
#amp-pre-loading-spinner {
visibility: visible;
animation: amp-wp-hide-element 30s steps(1, end) 0s 1 normal both; /* This could probably reuse amp-wp-show-element if reversed. */
}
.amp-loading-failure-noscript {
display: none;
}
@keyframes amp-wp-show-element {
from {
visibility: hidden;
}
to {
visibility: visible;
}
}
@keyframes amp-wp-hide-element {
from {
visibility: visible;
}
to {
visibility: hidden;
}
}
@keyframes amp-loading-spinner {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
body.no-js #amp-loading-failure {
animation: none;
visibility: visible;
}
body.no-js .amp-loading-failure-noscript {
display: block;
}
body.no-js #amp-pre-loading-spinner,
body.no-js .amp-loading-failure-script {
display: none;
}
.amp-spinner-container .amp-loading-spinner {
display: inline-block;
background-color: #949494;
width: 18px;
height: 18px;
opacity: 0.7;
border-radius: 100%;
position: relative;
}
.amp-spinner-container .amp-loading-spinner::before {
content: '';
position: absolute;
background-color: #fff;
width: calc(18px / 4.5);
height: calc(18px / 4.5);
border-radius: 100%;
transform-origin: calc(18px / 3) calc(18px / 3);
top: calc((18px - 18px * (2 / 3)) / 2);
left: calc((18px - 18px * (2 / 3)) / 2);
animation: amp-loading-spinner 1s infinite linear;
}
</style>
<?php
}
}