|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Adds a custom loading icon when the previewer refreshes. |
|
4
|
|
|
* |
|
5
|
|
|
* @package Kirki |
|
6
|
|
|
* @subpackage Modules |
|
7
|
|
|
* @copyright Copyright (c) 2016, Aristeides Stathopoulos |
|
8
|
|
|
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT |
|
9
|
|
|
* @since 2.4.0 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Modifies the loading overlay. |
|
14
|
|
|
*/ |
|
15
|
|
|
class Kirki_Modules_Loading { |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Constructor. |
|
19
|
|
|
* |
|
20
|
|
|
* @access public |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct() { |
|
23
|
|
|
|
|
24
|
|
|
add_action( 'init', array( $this, 'init' ) ); |
|
25
|
|
|
|
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Runs on init. |
|
30
|
|
|
* |
|
31
|
|
|
* @access public |
|
32
|
|
|
* @since 2.4.0 |
|
33
|
|
|
*/ |
|
34
|
|
|
public function init() { |
|
35
|
|
|
|
|
36
|
|
|
global $wp_customize; |
|
37
|
|
|
if ( ! $wp_customize ) { |
|
38
|
|
|
return; |
|
39
|
|
|
} |
|
40
|
|
|
// Allow disabling the custom loader using the kirki/config filter. |
|
41
|
|
|
$config = apply_filters( 'kirki/config', array() ); |
|
42
|
|
|
if ( isset( $config['disable_loader'] ) && true === $config['disable_loader'] ) { |
|
43
|
|
|
return; |
|
44
|
|
|
} |
|
45
|
|
|
// Add the "loading" icon. |
|
46
|
|
|
add_action( 'wp_footer', array( $this, 'add_loader_to_footer' ) ); |
|
47
|
|
|
add_action( 'wp_head', array( $this, 'add_loader_styles_to_header' ), 99 ); |
|
48
|
|
|
$this->remove_default_loading_styles(); |
|
49
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Adds a custom "loading" div $ its styles when changes are made to the customizer. |
|
54
|
|
|
* |
|
55
|
|
|
* @access public |
|
56
|
|
|
*/ |
|
57
|
|
|
public function add_loader_to_footer() { |
|
58
|
|
|
?> |
|
59
|
|
|
<div class="kirki-customizer-loading-wrapper"> |
|
60
|
|
|
<span class="kirki-customizer-loading"></span> |
|
61
|
|
|
</div> |
|
62
|
|
|
<?php |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Adds the loader CSS to our `<head>`. |
|
67
|
|
|
* |
|
68
|
|
|
* @access public |
|
69
|
|
|
*/ |
|
70
|
|
|
public function add_loader_styles_to_header() { |
|
71
|
|
|
?> |
|
72
|
|
|
<style> |
|
73
|
|
|
body.wp-customizer-unloading { |
|
74
|
|
|
opacity: 1; |
|
75
|
|
|
cursor: progress !important; |
|
76
|
|
|
-webkit-transition: none; |
|
77
|
|
|
transition: none; |
|
78
|
|
|
} |
|
79
|
|
|
body.wp-customizer-unloading * { |
|
80
|
|
|
pointer-events: none !important; |
|
81
|
|
|
} |
|
82
|
|
|
.kirki-customizer-loading-wrapper { |
|
83
|
|
|
width: 100%; |
|
84
|
|
|
height: 100%; |
|
85
|
|
|
position: fixed; |
|
86
|
|
|
top: 0; |
|
87
|
|
|
left: 0; |
|
88
|
|
|
background: rgba(255,255,255,0.83); |
|
89
|
|
|
z-index: 999999; |
|
90
|
|
|
display: none; |
|
91
|
|
|
opacity: 0; |
|
92
|
|
|
-webkit-transition: opacity 0.5s; |
|
93
|
|
|
transition: opacity 0.5s; |
|
94
|
|
|
background-image: url("<?php echo esc_url_raw( Kirki::$url ); ?>/assets/images/kirki-logo.svg"); |
|
95
|
|
|
background-repeat: no-repeat; |
|
96
|
|
|
background-position: center center; |
|
97
|
|
|
} |
|
98
|
|
|
body.wp-customizer-unloading .kirki-customizer-loading-wrapper { |
|
99
|
|
|
display: block; |
|
100
|
|
|
opacity: 1; |
|
101
|
|
|
} |
|
102
|
|
|
.kirki-customizer-loading-wrapper .kirki-customizer-loading { |
|
103
|
|
|
position: absolute; |
|
104
|
|
|
width: 60px; |
|
105
|
|
|
height: 60px; |
|
106
|
|
|
top: 50%; |
|
107
|
|
|
left: 50%; |
|
108
|
|
|
margin: -30px; |
|
109
|
|
|
background-color: rgba(0,0,0,.83); |
|
110
|
|
|
border-radius: 100%; |
|
111
|
|
|
-webkit-animation: sk-scaleout 1.0s infinite ease-in-out; |
|
112
|
|
|
animation: sk-scaleout 1.0s infinite ease-in-out; |
|
113
|
|
|
} |
|
114
|
|
|
@-webkit-keyframes sk-scaleout { |
|
115
|
|
|
0% { -webkit-transform: scale(0) } |
|
116
|
|
|
100% { |
|
117
|
|
|
-webkit-transform: scale(1.0); |
|
118
|
|
|
opacity: 0; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
@keyframes sk-scaleout { |
|
122
|
|
|
0% { |
|
123
|
|
|
-webkit-transform: scale(0); |
|
124
|
|
|
transform: scale(0); |
|
125
|
|
|
} |
|
126
|
|
|
100% { |
|
127
|
|
|
-webkit-transform: scale(1.0); |
|
128
|
|
|
transform: scale(1.0); |
|
129
|
|
|
opacity: 0; |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
</style> |
|
133
|
|
|
<?php |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Removes the default loader styles from WP Core. |
|
138
|
|
|
* |
|
139
|
|
|
* @access public |
|
140
|
|
|
*/ |
|
141
|
|
|
public function remove_default_loading_styles() { |
|
142
|
|
|
global $wp_customize; |
|
143
|
|
|
remove_action( 'wp_head', array( $wp_customize, 'customize_preview_loading_style' ) ); |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|