Version Description
- Introduced a queueing system for font-styles search, preload and remove for easier management. The 'Apply' buttons now process all your changes at once.
- The 'Apply' buttons are sticky, so they're visible for long lists.
Download this release
Release Info
Developer | DaanvandenBergh |
Plugin | OMGF | GDPR/DSVGO Compliant, Faster Google Fonts. Easy. |
Version | 3.3.0 |
Comparing to | |
See all releases |
Code changes from version 3.1.3 to 3.3.0
- css/omgf-admin.css +95 -50
- css/omgf-admin.css.map +1 -0
- css/omgf-admin.less +215 -0
- css/omgf-admin.min.css +0 -1
- host-webfonts-local.php +2 -2
- includes/admin/class-auto-detect.php +7 -3
- includes/admin/class-notice.php +6 -4
- includes/admin/class-settings.php +4 -2
- includes/ajax/class-download.php +1 -13
- includes/ajax/class-generate.php +4 -4
- includes/class-admin.php +236 -6
- includes/class-omgf.php +8 -3
- js/omgf-admin.js +170 -72
- readme.txt +14 -1
- templates/admin/block-advanced-settings.phtml +6 -6
- templates/admin/block-generate-stylesheet.phtml +22 -23
- templates/admin/block-welcome.phtml +61 -65
css/omgf-admin.css
CHANGED
@@ -12,7 +12,6 @@
|
|
12 |
* @copyright: (c) 2020 Daan van den Bergh
|
13 |
* @url : https://daan.dev
|
14 |
* * * * * * * * * * * * * * * * * * * */
|
15 |
-
|
16 |
/**
|
17 |
* Navigation
|
18 |
*/
|
@@ -20,10 +19,6 @@
|
|
20 |
padding: 1em 0 1.5em;
|
21 |
}
|
22 |
|
23 |
-
.omgf-nav .dashicons-before:before {
|
24 |
-
margin-right: .25em;
|
25 |
-
}
|
26 |
-
|
27 |
.omgf-nav span {
|
28 |
color: #23282d;
|
29 |
font-size: 1.3em;
|
@@ -35,18 +30,20 @@
|
|
35 |
cursor: pointer;
|
36 |
}
|
37 |
|
|
|
|
|
|
|
|
|
38 |
.omgf-nav .selected,
|
39 |
.omgf-nav span:hover {
|
40 |
border-bottom: 1px dashed #23282d;
|
41 |
padding: 3px 0;
|
42 |
}
|
43 |
|
44 |
-
.omgf-nav
|
45 |
-
|
46 |
}
|
47 |
|
48 |
-
|
49 |
-
|
50 |
/**
|
51 |
* Sections
|
52 |
*/
|
@@ -56,84 +53,82 @@
|
|
56 |
|
57 |
.settings-column.left {
|
58 |
float: left;
|
59 |
-
min-width: 655px;
|
60 |
width: 66%;
|
61 |
}
|
62 |
|
63 |
.settings-column.right {
|
64 |
float: right;
|
65 |
-
width:
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
-
*
|
70 |
*/
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
float: none;
|
75 |
-
}
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
width: 100%;
|
80 |
-
}
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
* Generate Stylesheet-form
|
85 |
*/
|
86 |
.omgf-generate-stylesheet table {
|
87 |
-
margin-top: .66em;
|
88 |
}
|
89 |
|
90 |
-
.omgf-search-section {
|
|
|
91 |
margin-top: 1em;
|
92 |
}
|
93 |
|
94 |
-
|
95 |
-
line-height:
|
96 |
-
width:
|
97 |
-
padding: 3px 10px;
|
98 |
}
|
99 |
|
100 |
-
.omgf-search-section caption {
|
101 |
text-align: left;
|
102 |
font-size: 1.2em;
|
103 |
font-weight: 600;
|
104 |
margin: 0.66em 0 0.33em;
|
105 |
}
|
106 |
|
107 |
-
.omgf-
|
108 |
-
|
109 |
-
width: 100%;
|
110 |
-
height: 100%;
|
111 |
-
left: 0;
|
112 |
-
right: 0;
|
113 |
-
top: 0;
|
114 |
-
text-align: center;
|
115 |
}
|
116 |
|
117 |
-
.omgf-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
-ms-transform: translate(0, -70%);
|
122 |
-
transform: translate(0, -70%);
|
123 |
}
|
124 |
|
125 |
-
.omgf-font-remove {
|
|
|
126 |
padding: 0 0 0 20px;
|
127 |
position: relative;
|
128 |
display: inline-block;
|
129 |
}
|
130 |
|
131 |
-
.omgf-font-remove:before {
|
132 |
position: absolute;
|
133 |
left: 0;
|
134 |
}
|
135 |
|
136 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
color: #a00;
|
138 |
text-decoration: none;
|
139 |
border-color: transparent;
|
@@ -141,17 +136,67 @@
|
|
141 |
background: 0 0;
|
142 |
border-radius: 3px;
|
143 |
white-space: nowrap;
|
144 |
-
padding:
|
145 |
}
|
146 |
|
147 |
-
.button-cancel:hover {
|
148 |
cursor: pointer;
|
149 |
background: #d54e21;
|
150 |
color: #fff;
|
151 |
border-color: #d54e21;
|
152 |
}
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
* @copyright: (c) 2020 Daan van den Bergh
|
13 |
* @url : https://daan.dev
|
14 |
* * * * * * * * * * * * * * * * * * * */
|
|
|
15 |
/**
|
16 |
* Navigation
|
17 |
*/
|
19 |
padding: 1em 0 1.5em;
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
22 |
.omgf-nav span {
|
23 |
color: #23282d;
|
24 |
font-size: 1.3em;
|
30 |
cursor: pointer;
|
31 |
}
|
32 |
|
33 |
+
.omgf-nav span:not(.selected) {
|
34 |
+
opacity: 0.85;
|
35 |
+
}
|
36 |
+
|
37 |
.omgf-nav .selected,
|
38 |
.omgf-nav span:hover {
|
39 |
border-bottom: 1px dashed #23282d;
|
40 |
padding: 3px 0;
|
41 |
}
|
42 |
|
43 |
+
.omgf-nav .dashicons-before:before {
|
44 |
+
margin-right: 0.25em;
|
45 |
}
|
46 |
|
|
|
|
|
47 |
/**
|
48 |
* Sections
|
49 |
*/
|
53 |
|
54 |
.settings-column.left {
|
55 |
float: left;
|
|
|
56 |
width: 66%;
|
57 |
}
|
58 |
|
59 |
.settings-column.right {
|
60 |
float: right;
|
61 |
+
width: 21.75%;
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
+
* Welcome block
|
66 |
*/
|
67 |
+
#omgf-welcome-panel {
|
68 |
+
padding: 20px 10px 5px;
|
69 |
+
}
|
|
|
|
|
70 |
|
71 |
+
#omgf-welcome-panel h3 > .dashicons {
|
72 |
+
line-height: 1.4;
|
|
|
|
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
* Generate Stylesheet-form
|
77 |
*/
|
78 |
.omgf-generate-stylesheet table {
|
79 |
+
margin-top: 0.66em;
|
80 |
}
|
81 |
|
82 |
+
.omgf-generate-stylesheet .omgf-search-section {
|
83 |
+
max-width: 640px;
|
84 |
margin-top: 1em;
|
85 |
}
|
86 |
|
87 |
+
.omgf-generate-stylesheet .omgf-search-section a.omgf-apply span:before {
|
88 |
+
line-height: 1.4;
|
89 |
+
width: 16px;
|
|
|
90 |
}
|
91 |
|
92 |
+
.omgf-generate-stylesheet .omgf-search-section caption {
|
93 |
text-align: left;
|
94 |
font-size: 1.2em;
|
95 |
font-weight: 600;
|
96 |
margin: 0.66em 0 0.33em;
|
97 |
}
|
98 |
|
99 |
+
.omgf-generate-stylesheet .omgf-search-section span.omgf-apply.font-styles-search {
|
100 |
+
width: 75%;
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
|
103 |
+
.omgf-generate-stylesheet .omgf-search-section #omgf-search {
|
104 |
+
line-height: 38px;
|
105 |
+
width: 360px;
|
106 |
+
padding: 3px 10px;
|
|
|
|
|
107 |
}
|
108 |
|
109 |
+
.omgf-generate-stylesheet .omgf-search-section #omgf-font-styles .omgf-font-remove {
|
110 |
+
cursor: pointer;
|
111 |
padding: 0 0 0 20px;
|
112 |
position: relative;
|
113 |
display: inline-block;
|
114 |
}
|
115 |
|
116 |
+
.omgf-generate-stylesheet .omgf-search-section #omgf-font-styles .omgf-font-remove:before {
|
117 |
position: absolute;
|
118 |
left: 0;
|
119 |
}
|
120 |
|
121 |
+
.omgf-generate-stylesheet .omgf-search-section #omgf-font-styles #font-styles-nav.sticky {
|
122 |
+
background: #f1f1f1;
|
123 |
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
|
124 |
+
width: 565px;
|
125 |
+
}
|
126 |
+
|
127 |
+
.omgf-generate-stylesheet #omgf-control-panel {
|
128 |
+
margin-top: 1em;
|
129 |
+
}
|
130 |
+
|
131 |
+
.omgf-generate-stylesheet #omgf-control-panel .button-cancel {
|
132 |
color: #a00;
|
133 |
text-decoration: none;
|
134 |
border-color: transparent;
|
136 |
background: 0 0;
|
137 |
border-radius: 3px;
|
138 |
white-space: nowrap;
|
139 |
+
padding: 1px 10px !important;
|
140 |
}
|
141 |
|
142 |
+
.omgf-generate-stylesheet #omgf-control-panel .button-cancel:hover {
|
143 |
cursor: pointer;
|
144 |
background: #d54e21;
|
145 |
color: #fff;
|
146 |
border-color: #d54e21;
|
147 |
}
|
148 |
|
149 |
+
/**
|
150 |
+
* Loader
|
151 |
+
*/
|
152 |
+
.omgf-loading {
|
153 |
+
position: absolute;
|
154 |
+
width: 100%;
|
155 |
+
height: 100%;
|
156 |
+
left: 0;
|
157 |
+
right: 0;
|
158 |
+
top: 0;
|
159 |
+
text-align: center;
|
160 |
+
}
|
161 |
+
|
162 |
+
.omgf-loading .spinner {
|
163 |
+
top: 50%;
|
164 |
+
left: 50%;
|
165 |
+
position: absolute;
|
166 |
+
-ms-transform: translate(0, -70%);
|
167 |
+
transform: translate(0, -70%);
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Sticky elements.
|
172 |
+
*/
|
173 |
+
.sticky {
|
174 |
+
position: -webkit-sticky;
|
175 |
+
position: sticky;
|
176 |
+
overflow: visible;
|
177 |
+
}
|
178 |
+
|
179 |
+
.sticky.top {
|
180 |
+
top: 25px;
|
181 |
+
}
|
182 |
+
|
183 |
+
.sticky.bottom {
|
184 |
+
bottom: 0;
|
185 |
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Responsiveness
|
189 |
+
*/
|
190 |
+
@media only screen and (max-width: 1024px) {
|
191 |
+
.settings-column {
|
192 |
+
display: block;
|
193 |
+
float: none;
|
194 |
+
}
|
195 |
+
|
196 |
+
.settings-column.left,
|
197 |
+
.settings-column.right {
|
198 |
+
width: 100%;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
/*# sourceMappingURL=omgf-admin.css.map */
|
css/omgf-admin.css.map
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
{"version":3,"sources":["omgf-admin.less"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAkBA;EACE,oBAAA;;AADF,SAGE;EACE,cAAA;EACA,gBAAA;EACA,mBAAA;EACA,gBAAA;;AAEA,SANF,KAMG;EACC,eAAA;;AAGF,SAVF,KAUG,IAAI;EACH,aAAA;;AAdN,SAkBE;AAlBF,SAmBE,KAAI;EACF,iCAAA;EACA,cAAA;;AArBJ,SAwBE,kBAAiB;EACf,oBAAA;;;;;AAOJ;EACE,qBAAA;;AAEA,gBAAC;EACC,WAAA;EACA,UAAA;;AAGF,gBAAC;EACC,YAAA;EACA,aAAA;;;;;AAOJ;EACE,sBAAA;;AADF,mBAGE,GAAG;EACD,gBAAA;;;;;AAOJ,yBACE;EACE,kBAAA;;AAFJ,yBAKE;EACE,gBAAA;EACA,eAAA;;AAGE,yBALJ,qBAIE,EACG,WACC,KAAI;EACF,gBAAA;EACA,WAAA;;AAbV,yBAKE,qBAaE;EACE,gBAAA;EACA,gBAAA;EACA,gBAAA;EACA,uBAAA;;AAKE,yBAtBN,qBAoBE,KACG,WACE;EACC,UAAA;;AA5BV,yBAKE,qBA4BE;EACE,iBAAA;EACA,YAAA;EACA,iBAAA;;AApCN,yBAKE,qBAkCE,kBACE;EACE,eAAA;EACA,mBAAA;EACA,kBAAA;EACA,qBAAA;;AAEA,yBAzCN,qBAkCE,kBACE,kBAMG;EACC,kBAAA;EACA,OAAA;;AAKF,yBAhDN,qBAkCE,kBAaE,iBACG;EACC,mBAAA;EACA,yCAAA;EACA,YAAA;;AAxDV,yBA8DE;EACE,eAAA;;AA/DJ,yBA8DE,oBAGE;EACE,WAAA;EACA,qBAAA;EACA,yBAAA;EACA,gBAAA;EACA,eAAA;EACA,kBAAA;EACA,mBAAA;EACA,4BAAA;;AAEA,yBAbJ,oBAGE,eAUG;EACC,eAAA;EACA,mBAAA;EACA,WAAA;EACA,qBAAA;;;;;AASR;EACE,kBAAA;EACA,WAAA;EACA,YAAA;EACA,OAAA;EACA,QAAA;EACA,MAAA;EACA,kBAAA;;AAPF,aASE;EACE,QAAA;EACA,SAAA;EACA,kBAAA;EACA,eAAe,kBAAf;EACA,WAAW,kBAAX;;;;;AAOJ;EACE,wBAAA;EACA,gBAAA;EACA,iBAAA;;AAEA,OAAC;EACC,SAAA;;AAGF,OAAC;EACC,SAAA;;;;;AAOJ,wBAA2C;EACzC;IACE,cAAA;IACA,WAAA;;EAEA,gBAAC;EACD,gBAAC;IACC,WAAA","file":"omgf-admin.css"}
|
css/omgf-admin.less
ADDED
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* * * * * * * * * * * * * * * * * * * * *
|
2 |
+
*
|
3 |
+
* ██████╗ ███╗ ███╗ ██████╗ ███████╗
|
4 |
+
* ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
|
5 |
+
* ██║ ██║██╔████╔██║██║ ███╗█████╗
|
6 |
+
* ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
|
7 |
+
* ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
|
8 |
+
* ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
|
9 |
+
*
|
10 |
+
* @package : OMGF
|
11 |
+
* @author : Daan van den Bergh
|
12 |
+
* @copyright: (c) 2020 Daan van den Bergh
|
13 |
+
* @url : https://daan.dev
|
14 |
+
* * * * * * * * * * * * * * * * * * * */
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Navigation
|
18 |
+
*/
|
19 |
+
.omgf-nav {
|
20 |
+
padding: 1em 0 1.5em;
|
21 |
+
|
22 |
+
span {
|
23 |
+
color: #23282d;
|
24 |
+
font-size: 1.3em;
|
25 |
+
margin-right: 1.5em;
|
26 |
+
font-weight: 600;
|
27 |
+
|
28 |
+
&:hover {
|
29 |
+
cursor: pointer;
|
30 |
+
}
|
31 |
+
|
32 |
+
&:not(.selected) {
|
33 |
+
opacity: 0.85;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
.selected,
|
38 |
+
span:hover {
|
39 |
+
border-bottom: 1px dashed #23282d;
|
40 |
+
padding: 3px 0;
|
41 |
+
}
|
42 |
+
|
43 |
+
.dashicons-before:before {
|
44 |
+
margin-right: .25em;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Sections
|
50 |
+
*/
|
51 |
+
.settings-column {
|
52 |
+
display: inline-block;
|
53 |
+
|
54 |
+
&.left {
|
55 |
+
float: left;
|
56 |
+
width: 66%;
|
57 |
+
}
|
58 |
+
|
59 |
+
&.right {
|
60 |
+
float: right;
|
61 |
+
width: 21.75%;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Welcome block
|
67 |
+
*/
|
68 |
+
#omgf-welcome-panel {
|
69 |
+
padding: 20px 10px 5px;
|
70 |
+
|
71 |
+
h3 > .dashicons {
|
72 |
+
line-height: 1.4;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Generate Stylesheet-form
|
78 |
+
*/
|
79 |
+
.omgf-generate-stylesheet {
|
80 |
+
table {
|
81 |
+
margin-top: .66em;
|
82 |
+
}
|
83 |
+
|
84 |
+
.omgf-search-section {
|
85 |
+
max-width: 640px;
|
86 |
+
margin-top: 1em;
|
87 |
+
|
88 |
+
a {
|
89 |
+
&.omgf-apply {
|
90 |
+
span:before {
|
91 |
+
line-height: 1.4;
|
92 |
+
width: 16px;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
caption {
|
98 |
+
text-align: left;
|
99 |
+
font-size: 1.2em;
|
100 |
+
font-weight: 600;
|
101 |
+
margin: 0.66em 0 0.33em;
|
102 |
+
}
|
103 |
+
|
104 |
+
span {
|
105 |
+
&.omgf-apply {
|
106 |
+
&.font-styles-search {
|
107 |
+
width: 75%;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
#omgf-search {
|
113 |
+
line-height: 38px;
|
114 |
+
width: 360px;
|
115 |
+
padding: 3px 10px;
|
116 |
+
}
|
117 |
+
|
118 |
+
#omgf-font-styles {
|
119 |
+
.omgf-font-remove {
|
120 |
+
cursor: pointer;
|
121 |
+
padding: 0 0 0 20px;
|
122 |
+
position: relative;
|
123 |
+
display: inline-block;
|
124 |
+
|
125 |
+
&:before {
|
126 |
+
position: absolute;
|
127 |
+
left: 0;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
#font-styles-nav {
|
132 |
+
&.sticky {
|
133 |
+
background: #f1f1f1;
|
134 |
+
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
135 |
+
width: 565px;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
#omgf-control-panel {
|
142 |
+
margin-top: 1em;
|
143 |
+
|
144 |
+
.button-cancel {
|
145 |
+
color: #a00;
|
146 |
+
text-decoration: none;
|
147 |
+
border-color: transparent;
|
148 |
+
box-shadow: none;
|
149 |
+
background: 0 0;
|
150 |
+
border-radius: 3px;
|
151 |
+
white-space: nowrap;
|
152 |
+
padding: 1px 10px !important;
|
153 |
+
|
154 |
+
&:hover {
|
155 |
+
cursor: pointer;
|
156 |
+
background: #d54e21;
|
157 |
+
color: #fff;
|
158 |
+
border-color: #d54e21;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Loader
|
166 |
+
*/
|
167 |
+
.omgf-loading {
|
168 |
+
position: absolute;
|
169 |
+
width: 100%;
|
170 |
+
height: 100%;
|
171 |
+
left: 0;
|
172 |
+
right: 0;
|
173 |
+
top: 0;
|
174 |
+
text-align: center;
|
175 |
+
|
176 |
+
.spinner {
|
177 |
+
top: 50%;
|
178 |
+
left: 50%;
|
179 |
+
position: absolute;
|
180 |
+
-ms-transform: translate(0, -70%);
|
181 |
+
transform: translate(0, -70%);
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Sticky elements.
|
187 |
+
*/
|
188 |
+
.sticky {
|
189 |
+
position: -webkit-sticky;
|
190 |
+
position: sticky;
|
191 |
+
overflow: visible;
|
192 |
+
|
193 |
+
&.top {
|
194 |
+
top: 25px;
|
195 |
+
}
|
196 |
+
|
197 |
+
&.bottom {
|
198 |
+
bottom: 0;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Responsiveness
|
204 |
+
*/
|
205 |
+
@media only screen and (max-width: 1024px) {
|
206 |
+
.settings-column {
|
207 |
+
display: block;
|
208 |
+
float: none;
|
209 |
+
|
210 |
+
&.left,
|
211 |
+
&.right {
|
212 |
+
width: 100%;
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
css/omgf-admin.min.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
.settings-column{display:inline-block}.settings-column.left{float:left;min-width:655px;width:37%}.settings-column.center{width:35%}.settings-column.right{float:right;width:25%}@media only screen and (max-width:940px){.settings-column{display:block;float:none}.settings-column.left,.settings-column.center,.settings-column.right{width:100%}}@media only screen and (min-width:941px) and (max-width:1024px){.settings-column.center{width:66%}.settings-column.right{width:33%}}#omgf-search{line-height:38px;width:360px;font-size:20px;padding:3px 10px}.omgf-loading{position:absolute;width:100%;height:100%;left:0;right:0;top:0;text-align:center}.omgf-loading .spinner{top:50%;left:50%;position:absolute;-ms-transform:translate(0,-70%);transform:translate(0,-70%)}.omgf-font-remove{padding:0 0 0 20px;position:relative;display:inline-block}.omgf-font-remove:before{position:absolute;left:0}.button-cancel{color:#a00;text-decoration:none;border-color:transparent;box-shadow:none;background:0;border-radius:3px;white-space:nowrap;padding:6px 10px !important}.button-cancel:hover{cursor:pointer;background:#d54e21;color:#fff;border-color:#d54e21}#omgf-control-panel{min-width:654px;width:66%}
|
|
host-webfonts-local.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: OMGF
|
5 |
* Plugin URI: https://daan.dev/wordpress-plugins/host-google-fonts-locally
|
6 |
* Description: Minimize DNS requests and leverage browser cache by easily saving Google Fonts to your server and removing the external Google Fonts.
|
7 |
-
* Version: 3.
|
8 |
* Author: Daan van den Bergh
|
9 |
* Author URI: https://daan.dev
|
10 |
* License: GPL2v2 or later
|
@@ -20,7 +20,7 @@ defined('ABSPATH') || exit;
|
|
20 |
define('OMGF_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
21 |
define('OMGF_PLUGIN_FILE', __FILE__);
|
22 |
define('OMGF_DB_VERSION', '3.0.0');
|
23 |
-
define('OMGF_STATIC_VERSION', '3.
|
24 |
define('OMGF_WEB_FONT_LOADER_VERSION', '1.6.26');
|
25 |
|
26 |
/**
|
4 |
* Plugin Name: OMGF
|
5 |
* Plugin URI: https://daan.dev/wordpress-plugins/host-google-fonts-locally
|
6 |
* Description: Minimize DNS requests and leverage browser cache by easily saving Google Fonts to your server and removing the external Google Fonts.
|
7 |
+
* Version: 3.3.0
|
8 |
* Author: Daan van den Bergh
|
9 |
* Author URI: https://daan.dev
|
10 |
* License: GPL2v2 or later
|
20 |
define('OMGF_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
21 |
define('OMGF_PLUGIN_FILE', __FILE__);
|
22 |
define('OMGF_DB_VERSION', '3.0.0');
|
23 |
+
define('OMGF_STATIC_VERSION', '3.3.0');
|
24 |
define('OMGF_WEB_FONT_LOADER_VERSION', '1.6.26');
|
25 |
|
26 |
/**
|
includes/admin/class-auto-detect.php
CHANGED
@@ -80,10 +80,14 @@ class OMGF_Admin_AutoDetect
|
|
80 |
|
81 |
OMGF_Admin_Notice::set_notice(sprintf(__('Your theme (or plugin) might be using unconventional methods (or Web Font Loader) to load Google Fonts. For a custom integration to load your Google Fonts locally, <a href="%s" target="_blank">hire me</a> or <a href="%s" target="_blank">contact me</a> when in doubt.', 'host-webfonts-local'), 'https://woosh.dev/wordpress-services/omgf-expert-configuration/', OMGF_SITE_URL . '/contact'), false, 'info');
|
82 |
} else {
|
83 |
-
$
|
84 |
-
$
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
OMGF_Admin_Notice::set_notice(__("Auto Detect found $count_subsets subsets and $
|
87 |
}
|
88 |
}
|
89 |
|
80 |
|
81 |
OMGF_Admin_Notice::set_notice(sprintf(__('Your theme (or plugin) might be using unconventional methods (or Web Font Loader) to load Google Fonts. For a custom integration to load your Google Fonts locally, <a href="%s" target="_blank">hire me</a> or <a href="%s" target="_blank">contact me</a> when in doubt.', 'host-webfonts-local'), 'https://woosh.dev/wordpress-services/omgf-expert-configuration/', OMGF_SITE_URL . '/contact'), false, 'info');
|
82 |
} else {
|
83 |
+
$count_fonts = count($subsets);
|
84 |
+
$count_subsets = 0;
|
85 |
+
foreach ($subsets as $subset) {
|
86 |
+
$count_subsets += count($subset['available_subsets']);
|
87 |
+
}
|
88 |
+
$count_font_styles = count($detected_font_styles);
|
89 |
|
90 |
+
OMGF_Admin_Notice::set_notice(__("Auto Detect found $count_fonts fonts in $count_subsets different subsets and $count_font_styles font styles. Please check the results and proceed to download the fonts and generate the stylesheet.", 'host-webfonts-local'), false);
|
91 |
}
|
92 |
}
|
93 |
|
includes/admin/class-notice.php
CHANGED
@@ -33,8 +33,8 @@ class OMGF_Admin_Notice
|
|
33 |
*/
|
34 |
public static function set_notice($message, $die = true, $type = 'success', $code = 200, $screen_id = 'all')
|
35 |
{
|
36 |
-
self::$notices
|
37 |
-
self::$notices[$screen_id][$type] = $message;
|
38 |
|
39 |
set_transient(self::OMGF_ADMIN_NOTICE_TRANSIENT, self::$notices, self::OMGF_ADMIN_NOTICE_EXPIRATION);
|
40 |
|
@@ -50,7 +50,7 @@ class OMGF_Admin_Notice
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
* Prints notice (if any)
|
54 |
*/
|
55 |
public static function print_notice()
|
56 |
{
|
@@ -67,7 +67,9 @@ class OMGF_Admin_Notice
|
|
67 |
foreach ($notice as $type => $message) {
|
68 |
?>
|
69 |
<div id="message" class="notice notice-<?php echo $type; ?> is-dismissible">
|
70 |
-
|
|
|
|
|
71 |
</div>
|
72 |
<?php
|
73 |
}
|
33 |
*/
|
34 |
public static function set_notice($message, $die = true, $type = 'success', $code = 200, $screen_id = 'all')
|
35 |
{
|
36 |
+
self::$notices = get_transient(self::OMGF_ADMIN_NOTICE_TRANSIENT);
|
37 |
+
self::$notices[$screen_id][$type][] = $message;
|
38 |
|
39 |
set_transient(self::OMGF_ADMIN_NOTICE_TRANSIENT, self::$notices, self::OMGF_ADMIN_NOTICE_EXPIRATION);
|
40 |
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* Prints notice (if any) grouped by type.
|
54 |
*/
|
55 |
public static function print_notice()
|
56 |
{
|
67 |
foreach ($notice as $type => $message) {
|
68 |
?>
|
69 |
<div id="message" class="notice notice-<?php echo $type; ?> is-dismissible">
|
70 |
+
<?php foreach ($message as $line): ?>
|
71 |
+
<p><?= $line; ?></p>
|
72 |
+
<?php endforeach; ?>
|
73 |
</div>
|
74 |
<?php
|
75 |
}
|
includes/admin/class-settings.php
CHANGED
@@ -92,7 +92,7 @@ class OMGF_Admin_Settings extends OMGF_Admin
|
|
92 |
<div class="wrap">
|
93 |
<h1><?php _e('OMGF | Optimize My Google Fonts', 'host-webfonts-local'); ?></h1>
|
94 |
|
95 |
-
<p
|
96 |
<?= get_plugin_data(OMGF_PLUGIN_FILE)['Description']; ?>
|
97 |
</p>
|
98 |
|
@@ -123,7 +123,9 @@ class OMGF_Admin_Settings extends OMGF_Admin
|
|
123 |
</div>
|
124 |
|
125 |
<div class="settings-column right">
|
126 |
-
|
|
|
|
|
127 |
</div>
|
128 |
</div>
|
129 |
<?php
|
92 |
<div class="wrap">
|
93 |
<h1><?php _e('OMGF | Optimize My Google Fonts', 'host-webfonts-local'); ?></h1>
|
94 |
|
95 |
+
<p>
|
96 |
<?= get_plugin_data(OMGF_PLUGIN_FILE)['Description']; ?>
|
97 |
</p>
|
98 |
|
123 |
</div>
|
124 |
|
125 |
<div class="settings-column right">
|
126 |
+
<div id="omgf-welcome-panel" class="welcome-panel">
|
127 |
+
<?php $this->get_template('welcome'); ?>
|
128 |
+
</div>
|
129 |
</div>
|
130 |
</div>
|
131 |
<?php
|
includes/ajax/class-download.php
CHANGED
@@ -71,11 +71,6 @@ class OMGF_AJAX_Download extends OMGF_AJAX
|
|
71 |
}
|
72 |
|
73 |
foreach ($selectedFonts as $id => &$font) {
|
74 |
-
// If font is marked as downloaded. Skip it.
|
75 |
-
if ($font['downloaded']) {
|
76 |
-
continue;
|
77 |
-
}
|
78 |
-
|
79 |
$urls['url_ttf'] = $font['url_ttf'];
|
80 |
$urls['url_woff'] = $font['url_woff'];
|
81 |
$urls['url_woff2'] = $font['url_woff2'];
|
@@ -88,13 +83,6 @@ class OMGF_AJAX_Download extends OMGF_AJAX
|
|
88 |
|
89 |
$remoteFile = esc_url_raw($url);
|
90 |
|
91 |
-
/**
|
92 |
-
* We've already downloaded this one before.
|
93 |
-
*/
|
94 |
-
if (strpos($remoteFile, get_site_url()) !== false) {
|
95 |
-
continue;
|
96 |
-
}
|
97 |
-
|
98 |
/**
|
99 |
* We rewrite the local filename for easier debugging in the waterfall.
|
100 |
*/
|
@@ -110,7 +98,7 @@ class OMGF_AJAX_Download extends OMGF_AJAX
|
|
110 |
|
111 |
clearstatcache();
|
112 |
|
113 |
-
$font[$type] = OMGF_FONTS_URL . '/' . $filename;
|
114 |
}
|
115 |
}
|
116 |
|
71 |
}
|
72 |
|
73 |
foreach ($selectedFonts as $id => &$font) {
|
|
|
|
|
|
|
|
|
|
|
74 |
$urls['url_ttf'] = $font['url_ttf'];
|
75 |
$urls['url_woff'] = $font['url_woff'];
|
76 |
$urls['url_woff2'] = $font['url_woff2'];
|
83 |
|
84 |
$remoteFile = esc_url_raw($url);
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
/**
|
87 |
* We rewrite the local filename for easier debugging in the waterfall.
|
88 |
*/
|
98 |
|
99 |
clearstatcache();
|
100 |
|
101 |
+
$font[$type . '_local'] = OMGF_FONTS_URL . '/' . $filename;
|
102 |
}
|
103 |
}
|
104 |
|
includes/ajax/class-generate.php
CHANGED
@@ -97,10 +97,10 @@ class OMGF_AJAX_Generate extends OMGF_AJAX
|
|
97 |
$i = 1;
|
98 |
|
99 |
foreach ($fonts as $font) {
|
100 |
-
$fontUrlEot = isset($font['
|
101 |
-
$fontSources = isset($font['
|
102 |
-
$fontSources = $fontSources + (isset($font['
|
103 |
-
$fontSources = $fontSources + (isset($font['
|
104 |
$locals = explode(',', sanitize_text_field($font['local']));
|
105 |
|
106 |
$this->fonts[$i] = "@font-face { \n";
|
97 |
$i = 1;
|
98 |
|
99 |
foreach ($fonts as $font) {
|
100 |
+
$fontUrlEot = isset($font['url_eot_local']) ? array(0 => esc_url_raw($font['url_eot_local'])) : array();
|
101 |
+
$fontSources = isset($font['url_woff2_local']) ? array('woff2' => esc_url_raw($font['url_woff2_local'])) : array();
|
102 |
+
$fontSources = $fontSources + (isset($font['url_woff_local']) ? array('woff' => esc_url_raw($font['url_woff_local'])) : array());
|
103 |
+
$fontSources = $fontSources + (isset($font['url_ttf_local']) ? array('truetype' => esc_url_raw($font['url_ttf_local'])) : array());
|
104 |
$locals = explode(',', sanitize_text_field($font['local']));
|
105 |
|
106 |
$this->fonts[$i] = "@font-face { \n";
|
includes/class-admin.php
CHANGED
@@ -21,17 +21,23 @@ class OMGF_Admin
|
|
21 |
const OMGF_ADMIN_JS_HANDLE = 'omgf-admin-js';
|
22 |
const OMGF_ADMIN_CSS_HANDLE = 'omgf-admin-css';
|
23 |
|
24 |
-
/** @var
|
25 |
-
private $
|
26 |
|
|
|
|
|
|
|
27 |
public function __construct()
|
28 |
{
|
29 |
-
|
30 |
|
31 |
-
$this->wpdb = $wpdb;
|
32 |
// @formatter:off
|
33 |
-
add_action('admin_enqueue_scripts',
|
34 |
-
add_action('admin_notices',
|
|
|
|
|
|
|
|
|
35 |
// @formatter:on
|
36 |
}
|
37 |
|
@@ -72,4 +78,228 @@ class OMGF_Admin
|
|
72 |
{
|
73 |
OMGF_Admin_Notice::print_notice();
|
74 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
21 |
const OMGF_ADMIN_JS_HANDLE = 'omgf-admin-js';
|
22 |
const OMGF_ADMIN_CSS_HANDLE = 'omgf-admin-css';
|
23 |
|
24 |
+
/** @var OMGF_DB */
|
25 |
+
private $db;
|
26 |
|
27 |
+
/**
|
28 |
+
* OMGF_Admin constructor.
|
29 |
+
*/
|
30 |
public function __construct()
|
31 |
{
|
32 |
+
$this->db = new OMGF_DB();
|
33 |
|
|
|
34 |
// @formatter:off
|
35 |
+
add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts']);
|
36 |
+
add_action('admin_notices', [$this, 'add_notice']);
|
37 |
+
add_filter('pre_update_option_omgf_cache_dir', [$this, 'cache_dir_changed'], 10, 2);
|
38 |
+
add_filter('pre_update_option_omgf_cache_uri', [$this, 'serve_uri_changed'], 10, 2);
|
39 |
+
add_filter('pre_update_option_omgf_relative_url', [$this, 'relative_url_changed'], 10, 2);
|
40 |
+
add_filter('pre_update_option_omgf_cdn_url', [$this, 'cdn_url_changed'], 10, 2);
|
41 |
// @formatter:on
|
42 |
}
|
43 |
|
78 |
{
|
79 |
OMGF_Admin_Notice::print_notice();
|
80 |
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* When the cache path is changed, OMGF moves the entire fonts folder to its new destination and throws a notice to
|
84 |
+
* regenerate the stylesheet.
|
85 |
+
*
|
86 |
+
* @param $new_cache_dir
|
87 |
+
* @param $old_cache_dir
|
88 |
+
*
|
89 |
+
* @return mixed
|
90 |
+
*/
|
91 |
+
public function cache_dir_changed($new_cache_dir, $old_cache_dir)
|
92 |
+
{
|
93 |
+
if ($new_cache_dir !== $old_cache_dir && !empty($new_cache_dir)) {
|
94 |
+
$font_styles = $this->db->get_downloaded_fonts();
|
95 |
+
|
96 |
+
if (empty($font_styles)) {
|
97 |
+
return $new_cache_dir;
|
98 |
+
}
|
99 |
+
|
100 |
+
$files = array_diff(scandir(OMGF_FONTS_DIR), ['.', '..']);
|
101 |
+
|
102 |
+
$this->move_files($files, $new_cache_dir);
|
103 |
+
|
104 |
+
if (!OMGF_CACHE_URI) {
|
105 |
+
$font_styles = $this->rewrite_urls($font_styles, $old_cache_dir, $new_cache_dir);
|
106 |
+
|
107 |
+
OMGF_Admin_Notice::set_notice(__("You've changed OMGF's storage folder to <strong>$new_cache_dir</strong>. Regenerate the stylesheet to implement this change.", 'host-webfonts-local'), false, 'info');
|
108 |
+
} else {
|
109 |
+
OMGF_Admin_Notice::set_notice(__("You've changed OMGF's storage folder to <strong>$new_cache_dir</strong>. Make sure the setting <em>Serve font files from...</em> reflects your changes and regenerate the stylesheet.", 'host-webfonts-local'), false);
|
110 |
+
}
|
111 |
+
|
112 |
+
update_option(OMGF_Admin_Settings::OMGF_SETTING_FONTS, $font_styles);
|
113 |
+
}
|
114 |
+
|
115 |
+
return $new_cache_dir;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* @param $new_uri
|
120 |
+
* @param $old_uri
|
121 |
+
*
|
122 |
+
* @return mixed
|
123 |
+
*/
|
124 |
+
public function serve_uri_changed($new_uri, $old_uri)
|
125 |
+
{
|
126 |
+
if ($new_uri !== $old_uri && !empty($new_uri)) {
|
127 |
+
$font_styles = $this->db->get_downloaded_fonts();
|
128 |
+
|
129 |
+
if (empty($font_styles)) {
|
130 |
+
return $new_uri;
|
131 |
+
}
|
132 |
+
|
133 |
+
preg_match('/[^\/]+$/u', WP_CONTENT_DIR, $match);
|
134 |
+
|
135 |
+
$font_styles = $this->rewrite_urls($font_styles, $old_uri, $new_uri);
|
136 |
+
|
137 |
+
update_option(OMGF_Admin_Settings::OMGF_SETTING_FONTS, $font_styles);
|
138 |
+
|
139 |
+
OMGF_Admin_Notice::set_notice(__("Fonts updated successfully. Regenerate the stylesheet to <em>serve font files from</em> $new_uri.", 'host-webfonts-local'), false, 'info');
|
140 |
+
}
|
141 |
+
|
142 |
+
return $new_uri;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* @param $new_value
|
147 |
+
* @param $old_value
|
148 |
+
*
|
149 |
+
* @return mixed
|
150 |
+
*/
|
151 |
+
public function relative_url_changed($new_value, $old_value)
|
152 |
+
{
|
153 |
+
if ($new_value != $old_value) {
|
154 |
+
$font_styles = $this->db->get_downloaded_fonts();
|
155 |
+
|
156 |
+
if (empty($font_styles)) {
|
157 |
+
return $new_value;
|
158 |
+
}
|
159 |
+
|
160 |
+
$result = $this->unset_downloaded_value($font_styles);
|
161 |
+
|
162 |
+
if ($new_value == 'on') {
|
163 |
+
$status = 'enabled';
|
164 |
+
} elseif (!$new_value) {
|
165 |
+
$status = 'disabled';
|
166 |
+
}
|
167 |
+
|
168 |
+
if ($result) {
|
169 |
+
OMGF_Admin_Notice::set_notice(sprintf(__('You\'ve %s using <em>relative URLs</em>. <strong>Download</strong> the <strong>fonts</strong> again and (re-)<strong>generate</strong> the <strong>stylesheet</strong> to implement this change.', 'host-webfonts-local'), $status), false, 'info');
|
170 |
+
|
171 |
+
return $new_value;
|
172 |
+
}
|
173 |
+
|
174 |
+
OMGF_Admin_Notice::set_notice(__('You\'ve %s using <em>relative URLs</em>. Something went wrong while updating the fonts. <strong>Empty</strong> the <strong>cache directory</strong>, <strong>download</strong> the <strong>fonts</strong> and <strong>generate</strong> the <strong>stylesheet</strong> to implement this change.', 'host-webfonts-local'), false, 'error');
|
175 |
+
}
|
176 |
+
|
177 |
+
return $new_value;
|
178 |
+
}
|
179 |
+
|
180 |
+
public function cdn_url_changed($new_url, $old_url)
|
181 |
+
{
|
182 |
+
if ($new_url != $old_url) {
|
183 |
+
$font_styles = $this->db->get_downloaded_fonts();
|
184 |
+
|
185 |
+
if (empty($font_styles)) {
|
186 |
+
return $new_url;
|
187 |
+
}
|
188 |
+
|
189 |
+
$result = $this->unset_downloaded_value($font_styles);
|
190 |
+
|
191 |
+
if ($result) {
|
192 |
+
OMGF_Admin_Notice::set_notice(__('Fonts updated successfully. <strong>Download</strong> the <strong>fonts</strong> and (re-)<strong>generate</strong> the <strong>stylesheet</strong> to <em>serve fonts from CDN</em>.', 'host-webfonts-local'), false, 'info');
|
193 |
+
} else {
|
194 |
+
OMGF_Admin_Notice::set_notice(__('Something went wrong while updating your settings. <strong>Empty</strong> the <strong>Cache Directory</strong>, <strong>download</strong> the <strong>fonts</strong> and <strong>generate</strong> the <strong>stylesheet</strong> to <em>serve fonts from CDN</em>.', 'host-webfonts-local'), false, 'error');
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
return $new_url;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* @param $files
|
203 |
+
* @param $destination
|
204 |
+
*
|
205 |
+
* @return bool
|
206 |
+
*/
|
207 |
+
private function move_files($files, $destination)
|
208 |
+
{
|
209 |
+
$this->create_dir_recursive($destination);
|
210 |
+
|
211 |
+
foreach($files as $filename) {
|
212 |
+
$old_path = OMGF_FONTS_DIR . "/$filename";
|
213 |
+
$new_path = WP_CONTENT_DIR . $destination . "/$filename";
|
214 |
+
$move = rename($old_path, $new_path);
|
215 |
+
|
216 |
+
if ($move == false) {
|
217 |
+
$errors[] = $filename;
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
if (!empty($errors)) {
|
222 |
+
$errored_files = ucfirst(implode(', ', $errors));
|
223 |
+
|
224 |
+
OMGF_Admin_Notice::set_notice($errored_files . __('could not be moved. Do it manually and then regenerate the stylesheet.', 'host-webfonts-local'), false, 'error');
|
225 |
+
|
226 |
+
return false;
|
227 |
+
}
|
228 |
+
|
229 |
+
$message = sprintf(__('Moved %s files', 'host-webfonts-local'), count($files));
|
230 |
+
$remove_dir = rmdir(OMGF_FONTS_DIR);
|
231 |
+
|
232 |
+
if ($remove_dir) {
|
233 |
+
$message .= ' ' . __('and succesfully removed the previously set storage folder.', 'host-webfonts-local');
|
234 |
+
} else {
|
235 |
+
$message .= '.';
|
236 |
+
}
|
237 |
+
|
238 |
+
OMGF_Admin_Notice::set_notice($message, false);
|
239 |
+
|
240 |
+
return true;
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* @param $font_styles
|
245 |
+
* @param $old_path
|
246 |
+
* @param $new_path
|
247 |
+
*
|
248 |
+
* @return mixed
|
249 |
+
*/
|
250 |
+
private function rewrite_urls($font_styles, $old_path, $new_path)
|
251 |
+
{
|
252 |
+
foreach ($font_styles as &$font) {
|
253 |
+
$urls = array_filter($font, function($key) {
|
254 |
+
return strpos($key, 'url') !== false;
|
255 |
+
}, ARRAY_FILTER_USE_KEY);
|
256 |
+
|
257 |
+
foreach ($urls as &$url) {
|
258 |
+
$url = str_replace($old_path, $new_path, $url);
|
259 |
+
}
|
260 |
+
|
261 |
+
$font = array_replace($font, $urls);
|
262 |
+
}
|
263 |
+
|
264 |
+
return $font_styles;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* @param $fonts
|
269 |
+
*
|
270 |
+
* @return bool
|
271 |
+
*/
|
272 |
+
private function unset_downloaded_value($fonts)
|
273 |
+
{
|
274 |
+
foreach ($fonts as &$font_style) {
|
275 |
+
$font_style['downloaded'] = 0;
|
276 |
+
}
|
277 |
+
|
278 |
+
$updated = update_option(OMGF_Admin_Settings::OMGF_SETTING_FONTS, $fonts);
|
279 |
+
|
280 |
+
if ($updated) {
|
281 |
+
return true;
|
282 |
+
}
|
283 |
+
|
284 |
+
return false;
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* @param $dir
|
289 |
+
*/
|
290 |
+
private function create_dir_recursive($dir)
|
291 |
+
{
|
292 |
+
$uploadDir = WP_CONTENT_DIR . $dir;
|
293 |
+
if (!file_exists($uploadDir)) {
|
294 |
+
wp_mkdir_p($uploadDir);
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* @param $path
|
300 |
+
*/
|
301 |
+
private function remove_dir_recursive($path)
|
302 |
+
{
|
303 |
+
$dirs = explode('/', $path);
|
304 |
+
}
|
305 |
}
|
includes/class-omgf.php
CHANGED
@@ -133,9 +133,14 @@ class OMGF
|
|
133 |
*
|
134 |
* @return mixed
|
135 |
*/
|
136 |
-
|
137 |
{
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
return $match[0];
|
141 |
}
|
@@ -152,7 +157,7 @@ class OMGF
|
|
152 |
if (OMGF_CDN_URL) {
|
153 |
$uploadUrl = '//' . OMGF_CDN_URL . '/' . $this->get_content_dir() . OMGF_CACHE_PATH;
|
154 |
} elseif (OMGF_CACHE_URI) {
|
155 |
-
$uploadUrl = OMGF_CACHE_URI;
|
156 |
} else {
|
157 |
$uploadUrl = get_site_url(OMGF_CURRENT_BLOG_ID, $this->get_content_dir() . OMGF_CACHE_PATH);
|
158 |
}
|
133 |
*
|
134 |
* @return mixed
|
135 |
*/
|
136 |
+
private function get_content_dir()
|
137 |
{
|
138 |
+
if (OMGF_CACHE_URI) {
|
139 |
+
$match = array_filter(explode('/', OMGF_CACHE_URI));
|
140 |
+
$match = array_values($match);
|
141 |
+
} else {
|
142 |
+
preg_match('/[^\/]+$/u', WP_CONTENT_DIR, $match);
|
143 |
+
}
|
144 |
|
145 |
return $match[0];
|
146 |
}
|
157 |
if (OMGF_CDN_URL) {
|
158 |
$uploadUrl = '//' . OMGF_CDN_URL . '/' . $this->get_content_dir() . OMGF_CACHE_PATH;
|
159 |
} elseif (OMGF_CACHE_URI) {
|
160 |
+
$uploadUrl = get_site_url(OMGF_CURRENT_BLOG_ID, OMGF_CACHE_URI);
|
161 |
} else {
|
162 |
$uploadUrl = get_site_url(OMGF_CURRENT_BLOG_ID, $this->get_content_dir() . OMGF_CACHE_PATH);
|
163 |
}
|
js/omgf-admin.js
CHANGED
@@ -42,9 +42,6 @@ jQuery(document).ready(function ($) {
|
|
42 |
$preload_font_styles: $('.omgf-font-preload'),
|
43 |
$removed_font_style: $('.omgf-font-remove'),
|
44 |
|
45 |
-
// Timeout for User Interaction
|
46 |
-
timeout: 2000,
|
47 |
-
|
48 |
/**
|
49 |
* Initialize all on click events.
|
50 |
*/
|
@@ -52,19 +49,25 @@ jQuery(document).ready(function ($) {
|
|
52 |
// Nav
|
53 |
this.$nav.on('click', this.toggle_section);
|
54 |
|
55 |
-
//
|
56 |
-
this.$subsets.on('click',
|
57 |
-
this.$preload_font_styles.on('click',
|
58 |
-
this.$removed_font_style.on('click', this.
|
59 |
|
60 |
// Buttons
|
61 |
$('#omgf-search-subsets').on('click', this.click_search);
|
62 |
-
$('#omgf-auto-detect').on('click', this.enable_auto_detect);
|
63 |
-
$('
|
64 |
-
$('
|
|
|
|
|
|
|
65 |
$('#omgf-empty').on('click', this.empty_cache_directory);
|
66 |
},
|
67 |
|
|
|
|
|
|
|
68 |
toggle_section: function () {
|
69 |
omgf_admin.$nav.removeClass('selected');
|
70 |
$(this).addClass('selected');
|
@@ -78,6 +81,95 @@ jQuery(document).ready(function ($) {
|
|
78 |
}
|
79 |
},
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
/**
|
82 |
* Triggered when Search is clicked.
|
83 |
*/
|
@@ -87,64 +179,48 @@ jQuery(document).ready(function ($) {
|
|
87 |
},
|
88 |
|
89 |
/**
|
90 |
-
*
|
|
|
|
|
91 |
*/
|
92 |
-
|
93 |
-
|
94 |
type: 'POST',
|
95 |
url: ajaxurl,
|
96 |
data: {
|
97 |
-
action: '
|
|
|
98 |
},
|
99 |
dataType: 'json',
|
100 |
beforeSend: function () {
|
101 |
omgf_admin.show_loader('.omgf-search-box');
|
102 |
},
|
103 |
-
complete: function
|
104 |
location.reload();
|
105 |
}
|
106 |
-
})
|
107 |
},
|
108 |
|
109 |
/**
|
110 |
-
*
|
111 |
-
*
|
112 |
-
* @param query
|
113 |
*/
|
114 |
-
|
115 |
-
|
116 |
type: 'POST',
|
117 |
url: ajaxurl,
|
118 |
data: {
|
119 |
-
action: '
|
120 |
-
search_query: query
|
121 |
},
|
122 |
dataType: 'json',
|
123 |
beforeSend: function () {
|
124 |
-
omgf_admin.show_loader('.omgf-search-box')
|
125 |
},
|
126 |
-
complete: function() {
|
127 |
location.reload();
|
128 |
}
|
129 |
});
|
130 |
},
|
131 |
|
132 |
-
/**
|
133 |
-
* Show loader on element
|
134 |
-
*
|
135 |
-
* @param element
|
136 |
-
*/
|
137 |
-
show_loader: function (element) {
|
138 |
-
let clone = omgf_admin.$loader.clone();
|
139 |
-
|
140 |
-
$(element).append(clone).css({
|
141 |
-
'position': 'relative',
|
142 |
-
'opacity': '0.5'
|
143 |
-
});
|
144 |
-
|
145 |
-
clone.show();
|
146 |
-
},
|
147 |
-
|
148 |
/**
|
149 |
* Triggered on Search
|
150 |
*/
|
@@ -179,41 +255,15 @@ jQuery(document).ready(function ($) {
|
|
179 |
omgf_admin.show_loader('#omgf-font-styles-list');
|
180 |
},
|
181 |
complete: function () {
|
182 |
-
location.reload()
|
183 |
-
}
|
184 |
-
});
|
185 |
-
},
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Triggered when preload is checked. If multiple are checked, all are processed at once.
|
189 |
-
*/
|
190 |
-
preload_font_style: function() {
|
191 |
-
if (omgf_admin.preload_font_style_xhr) {
|
192 |
-
omgf_admin.preload_font_style_xhr.abort();
|
193 |
-
}
|
194 |
-
|
195 |
-
omgf_admin.preload_font_styles = $('.omgf-font-preload:checked').map(function () {
|
196 |
-
return $(this).data('preload');
|
197 |
-
}).get();
|
198 |
-
|
199 |
-
omgf_admin.preload_font_style_xhr = $.ajax({
|
200 |
-
type: 'POST',
|
201 |
-
url: ajaxurl,
|
202 |
-
data: {
|
203 |
-
action: 'omgf_ajax_preload_font_style',
|
204 |
-
preload_font_styles: omgf_admin.preload_font_styles
|
205 |
-
},
|
206 |
-
dataType: 'json',
|
207 |
-
success: function () {
|
208 |
location.reload();
|
209 |
}
|
210 |
});
|
211 |
},
|
212 |
|
213 |
/**
|
214 |
-
*
|
215 |
*/
|
216 |
-
|
217 |
row = '#' + $(this).data('row');
|
218 |
|
219 |
omgf_admin.show_loader(row);
|
@@ -242,12 +292,44 @@ jQuery(document).ready(function ($) {
|
|
242 |
font_styles: omgf_admin.font_style_list
|
243 |
},
|
244 |
dataType: 'json',
|
|
|
|
|
|
|
245 |
success: function() {
|
246 |
location.reload();
|
247 |
}
|
248 |
});
|
249 |
},
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
/**
|
252 |
* Download fonts and refresh window.
|
253 |
*/
|
@@ -269,7 +351,7 @@ jQuery(document).ready(function ($) {
|
|
269 |
complete: function() {
|
270 |
location.reload();
|
271 |
}
|
272 |
-
})
|
273 |
},
|
274 |
|
275 |
/**
|
@@ -289,7 +371,7 @@ jQuery(document).ready(function ($) {
|
|
289 |
complete: function() {
|
290 |
location.reload();
|
291 |
}
|
292 |
-
})
|
293 |
},
|
294 |
|
295 |
/**
|
@@ -314,6 +396,22 @@ jQuery(document).ready(function ($) {
|
|
314 |
}
|
315 |
});
|
316 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
};
|
318 |
|
319 |
omgf_admin.init();
|
@@ -337,5 +435,5 @@ jQuery(document).ready(function ($) {
|
|
337 |
} else {
|
338 |
$('#omgf_cdn_url').prop('disabled', false);
|
339 |
}
|
340 |
-
})
|
341 |
});
|
42 |
$preload_font_styles: $('.omgf-font-preload'),
|
43 |
$removed_font_style: $('.omgf-font-remove'),
|
44 |
|
|
|
|
|
|
|
45 |
/**
|
46 |
* Initialize all on click events.
|
47 |
*/
|
49 |
// Nav
|
50 |
this.$nav.on('click', this.toggle_section);
|
51 |
|
52 |
+
// Manage queues
|
53 |
+
this.$subsets.on('click', this.manage_subset_queue);
|
54 |
+
this.$preload_font_styles.on('click', this.manage_preload_queue);
|
55 |
+
this.$removed_font_style.on('click', this.manage_removal_queue);
|
56 |
|
57 |
// Buttons
|
58 |
$('#omgf-search-subsets').on('click', this.click_search);
|
59 |
+
$('#omgf-auto-detect, .help.auto-detect').on('click', this.enable_auto_detect);
|
60 |
+
$('.omgf-apply.font-styles-search').on('click', this.search_google_fonts);
|
61 |
+
$('.omgf-apply.remove').on('click', this.process_removal_queue);
|
62 |
+
$('.omgf-apply.preload').on('click', this.preload_font_style);
|
63 |
+
$('#omgf-download, .help.download-fonts').on('click', this.download_fonts);
|
64 |
+
$('#omgf-generate, .help.generate-stylesheet').on('click', this.generate_stylesheet);
|
65 |
$('#omgf-empty').on('click', this.empty_cache_directory);
|
66 |
},
|
67 |
|
68 |
+
/**
|
69 |
+
* Toggle settings sections.
|
70 |
+
*/
|
71 |
toggle_section: function () {
|
72 |
omgf_admin.$nav.removeClass('selected');
|
73 |
$(this).addClass('selected');
|
81 |
}
|
82 |
},
|
83 |
|
84 |
+
/**
|
85 |
+
* If any subsets are checked for search.
|
86 |
+
*/
|
87 |
+
manage_subset_queue: function () {
|
88 |
+
section = $('#omgf-subsets');
|
89 |
+
colspan = section.find("tr:first td").length - 1;
|
90 |
+
$('.omgf-subsets-search').attr('colspan', colspan);
|
91 |
+
|
92 |
+
omgf_admin.toggle_button($('.omgf-subset:checked'), $('.omgf-apply.font-styles-search'), section);
|
93 |
+
},
|
94 |
+
|
95 |
+
/**
|
96 |
+
* If any fonts are checked for preload, display Preload apply button.
|
97 |
+
*/
|
98 |
+
manage_preload_queue: function () {
|
99 |
+
omgf_admin.toggle_button($('.omgf-font-preload:checked'), $('.omgf-apply.preload'), $('#omgf-font-styles-list'));
|
100 |
+
},
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Enqueue for removal or undo removal of current item.
|
104 |
+
*/
|
105 |
+
manage_removal_queue: function () {
|
106 |
+
if (this.classList.contains('notice-dismiss')) {
|
107 |
+
omgf_admin.enqueue_for_removal(this);
|
108 |
+
} else {
|
109 |
+
omgf_admin.undo_removal(this);
|
110 |
+
}
|
111 |
+
},
|
112 |
+
|
113 |
+
/**
|
114 |
+
* @param conditional
|
115 |
+
* @param button
|
116 |
+
* @param section
|
117 |
+
*/
|
118 |
+
toggle_button: function(conditional, button, section) {
|
119 |
+
help_text = section.find('.omgf-apply.help');
|
120 |
+
buttons = section.find('.omgf-apply.button');
|
121 |
+
|
122 |
+
if (conditional.length > 0) {
|
123 |
+
button.show();
|
124 |
+
} else {
|
125 |
+
button.hide();
|
126 |
+
}
|
127 |
+
|
128 |
+
if (buttons.is(':visible')) {
|
129 |
+
help_text.show();
|
130 |
+
} else {
|
131 |
+
help_text.hide();
|
132 |
+
}
|
133 |
+
},
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Add current item to removal queue.
|
137 |
+
*
|
138 |
+
* @param item
|
139 |
+
*/
|
140 |
+
enqueue_for_removal: function (item) {
|
141 |
+
row = '#' + $(item).data('row');
|
142 |
+
|
143 |
+
$(row).css({
|
144 |
+
'opacity': '0.5'
|
145 |
+
});
|
146 |
+
|
147 |
+
$(item).addClass('dashicons-before dashicons-undo');
|
148 |
+
$(item).removeClass('notice-dismiss');
|
149 |
+
$(row).removeClass('omgf-font-style');
|
150 |
+
|
151 |
+
omgf_admin.toggle_button($('.dashicons-undo'), $('.omgf-apply.remove'), $('#omgf-font-styles-list'));
|
152 |
+
},
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Remove current item from removal queue.
|
156 |
+
*
|
157 |
+
* @param item
|
158 |
+
*/
|
159 |
+
undo_removal: function (item) {
|
160 |
+
row = '#' + $(item).data('row');
|
161 |
+
|
162 |
+
$(row).css({
|
163 |
+
'opacity': '1'
|
164 |
+
});
|
165 |
+
|
166 |
+
$(item).removeClass('dashicons-before dashicons-undo');
|
167 |
+
$(item).addClass('notice-dismiss');
|
168 |
+
$(row).addClass('omgf-font-style');
|
169 |
+
|
170 |
+
omgf_admin.toggle_button($('.dashicons-undo'), $('.omgf-apply.remove'), $('#omgf-font-styles-list'));
|
171 |
+
},
|
172 |
+
|
173 |
/**
|
174 |
* Triggered when Search is clicked.
|
175 |
*/
|
179 |
},
|
180 |
|
181 |
/**
|
182 |
+
* Triggered by Click Search
|
183 |
+
*
|
184 |
+
* @param query
|
185 |
*/
|
186 |
+
search_subsets: function (query) {
|
187 |
+
jQuery.ajax({
|
188 |
type: 'POST',
|
189 |
url: ajaxurl,
|
190 |
data: {
|
191 |
+
action: 'omgf_ajax_search_font_subsets',
|
192 |
+
search_query: query
|
193 |
},
|
194 |
dataType: 'json',
|
195 |
beforeSend: function () {
|
196 |
omgf_admin.show_loader('.omgf-search-box');
|
197 |
},
|
198 |
+
complete: function() {
|
199 |
location.reload();
|
200 |
}
|
201 |
+
});
|
202 |
},
|
203 |
|
204 |
/**
|
205 |
+
* Enable Auto Detect.
|
|
|
|
|
206 |
*/
|
207 |
+
enable_auto_detect: function () {
|
208 |
+
$.ajax({
|
209 |
type: 'POST',
|
210 |
url: ajaxurl,
|
211 |
data: {
|
212 |
+
action: 'omgf_ajax_enable_auto_detect'
|
|
|
213 |
},
|
214 |
dataType: 'json',
|
215 |
beforeSend: function () {
|
216 |
+
omgf_admin.show_loader('.omgf-search-box');
|
217 |
},
|
218 |
+
complete: function () {
|
219 |
location.reload();
|
220 |
}
|
221 |
});
|
222 |
},
|
223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
/**
|
225 |
* Triggered on Search
|
226 |
*/
|
255 |
omgf_admin.show_loader('#omgf-font-styles-list');
|
256 |
},
|
257 |
complete: function () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
location.reload();
|
259 |
}
|
260 |
});
|
261 |
},
|
262 |
|
263 |
/**
|
264 |
+
* Processes the removal queue.
|
265 |
*/
|
266 |
+
process_removal_queue: function() {
|
267 |
row = '#' + $(this).data('row');
|
268 |
|
269 |
omgf_admin.show_loader(row);
|
292 |
font_styles: omgf_admin.font_style_list
|
293 |
},
|
294 |
dataType: 'json',
|
295 |
+
beforeSend: function() {
|
296 |
+
omgf_admin.show_loader('#omgf-font-styles-list');
|
297 |
+
},
|
298 |
success: function() {
|
299 |
location.reload();
|
300 |
}
|
301 |
});
|
302 |
},
|
303 |
|
304 |
+
/**
|
305 |
+
* Triggered when preload is checked. If multiple are checked, all are processed at once.
|
306 |
+
*/
|
307 |
+
preload_font_style: function() {
|
308 |
+
if (omgf_admin.preload_font_style_xhr) {
|
309 |
+
omgf_admin.preload_font_style_xhr.abort();
|
310 |
+
}
|
311 |
+
|
312 |
+
omgf_admin.preload_font_styles = $('.omgf-font-preload:checked').map(function () {
|
313 |
+
return $(this).data('preload');
|
314 |
+
}).get();
|
315 |
+
|
316 |
+
omgf_admin.preload_font_style_xhr = $.ajax({
|
317 |
+
type: 'POST',
|
318 |
+
url: ajaxurl,
|
319 |
+
data: {
|
320 |
+
action: 'omgf_ajax_preload_font_style',
|
321 |
+
preload_font_styles: omgf_admin.preload_font_styles
|
322 |
+
},
|
323 |
+
dataType: 'json',
|
324 |
+
beforeSend: function() {
|
325 |
+
omgf_admin.show_loader('#omgf-font-styles-list');
|
326 |
+
},
|
327 |
+
success: function () {
|
328 |
+
location.reload();
|
329 |
+
}
|
330 |
+
});
|
331 |
+
},
|
332 |
+
|
333 |
/**
|
334 |
* Download fonts and refresh window.
|
335 |
*/
|
351 |
complete: function() {
|
352 |
location.reload();
|
353 |
}
|
354 |
+
});
|
355 |
},
|
356 |
|
357 |
/**
|
371 |
complete: function() {
|
372 |
location.reload();
|
373 |
}
|
374 |
+
});
|
375 |
},
|
376 |
|
377 |
/**
|
396 |
}
|
397 |
});
|
398 |
},
|
399 |
+
|
400 |
+
/**
|
401 |
+
* Show loader on element
|
402 |
+
*
|
403 |
+
* @param element
|
404 |
+
*/
|
405 |
+
show_loader: function (element) {
|
406 |
+
var clone = omgf_admin.$loader.clone();
|
407 |
+
|
408 |
+
$(element).append(clone).css({
|
409 |
+
'position': 'relative',
|
410 |
+
'opacity': '0.5'
|
411 |
+
});
|
412 |
+
|
413 |
+
clone.show();
|
414 |
+
},
|
415 |
};
|
416 |
|
417 |
omgf_admin.init();
|
435 |
} else {
|
436 |
$('#omgf_cdn_url').prop('disabled', false);
|
437 |
}
|
438 |
+
});
|
439 |
});
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: DaanvandenBergh
|
|
3 |
Tags: google, fonts, preload, font-display, webfonts, subsets, remove, minimize, external, requests, leverage, browser, cache
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 5.4
|
6 |
-
Stable tag: 3.
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -105,6 +105,19 @@ N/A
|
|
105 |
|
106 |
== Changelog ==
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
= 3.1.3 =
|
109 |
* Added toggleable navigation menu. Made it a bit more UX friendly.
|
110 |
* Enhanced search and auto-detect: search results of one, are now appended to the result of the other. Also, duplicate search queries are now filtered, so they will not return duplicate subset results.
|
3 |
Tags: google, fonts, preload, font-display, webfonts, subsets, remove, minimize, external, requests, leverage, browser, cache
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 5.4
|
6 |
+
Stable tag: 3.3.0
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
105 |
|
106 |
== Changelog ==
|
107 |
|
108 |
+
= 3.3.0 =
|
109 |
+
* Introduced a queueing system for font-styles search, preload and remove for easier management. The 'Apply' buttons now process all your changes at once.
|
110 |
+
* The 'Apply' buttons are sticky, so they're visible for long lists.
|
111 |
+
|
112 |
+
= 3.2.1 =
|
113 |
+
* Fixes in responsiveness of admin screen.
|
114 |
+
* Fixed links in Quick Start and Support block.
|
115 |
+
|
116 |
+
= 3.2.0 =
|
117 |
+
* Fonts are now automatically updated and font files and stylesheet are automatically moved after the 'Serve fonts from...' or 'Save fonts to...' options are changed.
|
118 |
+
* Added several reminder notices to improve UX and reduce the level of complexity.
|
119 |
+
* Notices/warnings/errors are now grouped.
|
120 |
+
|
121 |
= 3.1.3 =
|
122 |
* Added toggleable navigation menu. Made it a bit more UX friendly.
|
123 |
* Enhanced search and auto-detect: search results of one, are now appended to the result of the other. Also, duplicate search queries are now filtered, so they will not return duplicate subset results.
|
templates/admin/block-advanced-settings.phtml
CHANGED
@@ -23,10 +23,10 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
|
23 |
<strong><?= __('Make sure you\'ve saved your settings, before generating the stylesheet!', 'host-webfonts-local'); ?></strong>
|
24 |
</p>
|
25 |
<p class="description">
|
26 |
-
<?php _e('*
|
27 |
</p>
|
28 |
<p class="description">
|
29 |
-
<?php _e('**
|
30 |
</p>
|
31 |
<table class="form-table">
|
32 |
<tr valign="top">
|
@@ -64,26 +64,26 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
|
64 |
<tr valign="top">
|
65 |
<th scope="row">
|
66 |
<label for="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_PATH; ?>">
|
67 |
-
<?php _e('Save
|
68 |
</label>
|
69 |
</th>
|
70 |
<td>
|
71 |
<input id="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_PATH; ?>" class="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_PATH; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_PATH; ?>" placeholder="<?= __('e.g. /cache/omgf-webfonts', 'host-webfonts-local'); ?>" value="<?= OMGF_CACHE_PATH; ?>"/>
|
72 |
<p class="description">
|
73 |
-
<?php _e("The
|
74 |
</p>
|
75 |
</td>
|
76 |
</tr>
|
77 |
<tr valign="top">
|
78 |
<th scope="row">
|
79 |
<label for="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_URI; ?>">
|
80 |
-
<?php _e('Serve
|
81 |
</label>
|
82 |
</th>
|
83 |
<td>
|
84 |
<input id="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_URI; ?>" class="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_URI; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_URI; ?>" placeholder="<?= __('e.g. /app/cache/omgf-webfonts', 'host-webfonts-local'); ?>" value="<?= OMGF_CACHE_URI; ?>" />
|
85 |
<p class="description">
|
86 |
-
<?php _e('The relative path to serve
|
87 |
</p>
|
88 |
</td>
|
89 |
</tr>
|
23 |
<strong><?= __('Make sure you\'ve saved your settings, before generating the stylesheet!', 'host-webfonts-local'); ?></strong>
|
24 |
</p>
|
25 |
<p class="description">
|
26 |
+
<?php _e('* <strong>Generate stylesheet</strong> after changing this setting.', 'host-webfonts-local'); ?>
|
27 |
</p>
|
28 |
<p class="description">
|
29 |
+
<?php _e('** <strong>Download Fonts</strong> and <strong>Generate Stylesheet</strong> after changing this setting.', 'host-webfonts-local'); ?>
|
30 |
</p>
|
31 |
<table class="form-table">
|
32 |
<tr valign="top">
|
64 |
<tr valign="top">
|
65 |
<th scope="row">
|
66 |
<label for="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_PATH; ?>">
|
67 |
+
<?php _e('Save font files to...', 'host-webfonts-local'); ?> *
|
68 |
</label>
|
69 |
</th>
|
70 |
<td>
|
71 |
<input id="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_PATH; ?>" class="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_PATH; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_PATH; ?>" placeholder="<?= __('e.g. /cache/omgf-webfonts', 'host-webfonts-local'); ?>" value="<?= OMGF_CACHE_PATH; ?>"/>
|
72 |
<p class="description">
|
73 |
+
<?php _e("The folder (inside <code>wp-content</code>) where font files should be stored. Give each site a unique value if you're using Multisite. Defaults to <code>/cache/omgf-webfonts</code>. Folder will be created if it doesn't exist and existing files will be moved automatically.", 'host-webfonts-local'); ?>
|
74 |
</p>
|
75 |
</td>
|
76 |
</tr>
|
77 |
<tr valign="top">
|
78 |
<th scope="row">
|
79 |
<label for="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_URI; ?>">
|
80 |
+
<?php _e('Serve font files from...', 'host-webfonts-local'); ?> *
|
81 |
</label>
|
82 |
</th>
|
83 |
<td>
|
84 |
<input id="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_URI; ?>" class="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_URI; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_URI; ?>" placeholder="<?= __('e.g. /app/cache/omgf-webfonts', 'host-webfonts-local'); ?>" value="<?= OMGF_CACHE_URI; ?>" />
|
85 |
<p class="description">
|
86 |
+
<?php _e('The relative path to serve font files from. Useful for when you\'re using security through obscurity plugins, such as WP Hide. If left empty, the cache directory specified above will be used.', 'host-webfonts-local'); ?>
|
87 |
</p>
|
88 |
</td>
|
89 |
</tr>
|
templates/admin/block-generate-stylesheet.phtml
CHANGED
@@ -57,6 +57,10 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
|
57 |
<?php endforeach; ?>
|
58 |
</tr>
|
59 |
<?php endforeach; ?>
|
|
|
|
|
|
|
|
|
60 |
<?php else: ?>
|
61 |
<tr colspan="3">
|
62 |
<td>
|
@@ -101,10 +105,10 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
|
101 |
<td style="width: 100px;">
|
102 |
<input style="width: 100px;" readonly type="text" value="<?= $font['font_weight']; ?>" />
|
103 |
</td>
|
104 |
-
<td align="center" style="width:
|
105 |
<input type="checkbox" class="omgf-font-preload" data-preload="<?= $fontId; ?>" value="1" <?= $font['preload'] == 1 ? 'checked' : ''; ?> />
|
106 |
</td>
|
107 |
-
<td style="width:
|
108 |
<input type="hidden" value="<?= $fontId; ?>" />
|
109 |
<input type="hidden" value="<?= $font['local']; ?>" />
|
110 |
<input type="hidden" value="<?= $font['url_ttf']; ?>" />
|
@@ -115,11 +119,17 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
|
115 |
</td>
|
116 |
</tr>
|
117 |
<?php endforeach; ?>
|
118 |
-
|
119 |
-
<
|
120 |
-
<span class="
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
</tbody>
|
124 |
<?php else: ?>
|
125 |
<tr>
|
@@ -131,22 +141,11 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
|
131 |
</table>
|
132 |
</div>
|
133 |
|
134 |
-
<
|
135 |
-
<
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
</td>
|
140 |
-
<td>
|
141 |
-
<input type="button" id="omgf-generate" class="button-secondary" value="<?php _e('Generate Stylesheet', 'host-webfonts-local'); ?>" />
|
142 |
-
</td>
|
143 |
-
<td>
|
144 |
-
<a id="omgf-empty" class="button-cancel"><?php _e('Empty Cache Directory', 'host-webfonts-local'); ?></a>
|
145 |
-
</td>
|
146 |
-
<td style="width: 33%;"></td>
|
147 |
-
</tr>
|
148 |
-
</tbody>
|
149 |
-
</table>
|
150 |
</div>
|
151 |
<div class="omgf-loading" style="display: none;">
|
152 |
<span class="spinner is-active"> </span>
|
57 |
<?php endforeach; ?>
|
58 |
</tr>
|
59 |
<?php endforeach; ?>
|
60 |
+
<tr align="center">
|
61 |
+
<td class="omgf-subsets-search" align="right"><span class="omgf-apply help" style="display: none;"><strong><?= __('Search Font Styles', 'host-webfonts-local'); ?></strong></span></td>
|
62 |
+
<td><a class="button-primary omgf-apply button font-styles-search" href="#" style="display: none;"><span class="dashicons-before dashicons-search"> </span></a></td>
|
63 |
+
</tr>
|
64 |
<?php else: ?>
|
65 |
<tr colspan="3">
|
66 |
<td>
|
105 |
<td style="width: 100px;">
|
106 |
<input style="width: 100px;" readonly type="text" value="<?= $font['font_weight']; ?>" />
|
107 |
</td>
|
108 |
+
<td align="center" style="width: 45px;">
|
109 |
<input type="checkbox" class="omgf-font-preload" data-preload="<?= $fontId; ?>" value="1" <?= $font['preload'] == 1 ? 'checked' : ''; ?> />
|
110 |
</td>
|
111 |
+
<td style="width: 45px;">
|
112 |
<input type="hidden" value="<?= $fontId; ?>" />
|
113 |
<input type="hidden" value="<?= $font['local']; ?>" />
|
114 |
<input type="hidden" value="<?= $font['url_ttf']; ?>" />
|
119 |
</td>
|
120 |
</tr>
|
121 |
<?php endforeach; ?>
|
122 |
+
<!-- The navbar at the bottom of the table. -->
|
123 |
+
<tr id="font-styles-nav" class="sticky bottom" align="right">
|
124 |
+
<td align="right" colspan="3"><span class="omgf-apply help font-styles" style="display: none;"><strong><?= __('Apply Changes', 'host-webfonts-local'); ?></strong></span></td>
|
125 |
+
<td align="center" style="width: 45px"><a class="button-primary omgf-apply button preload" href="#" style="display: none;"><span class="dashicons-before dashicons-yes"> </span></a></td>
|
126 |
+
<td align="left" style="width: 45px;"><a class="button-primary omgf-apply button remove" href="#" style="display: none;'"><span class="dashicons-before dashicons-yes"> </span></a></td>
|
127 |
+
</tr>
|
128 |
+
<tr>
|
129 |
+
<td colspan="5">
|
130 |
+
<span class="description">* <?= __('Only the <strong>woff2</strong> format is preloaded, since this format is widely supported by Modern Browsers which support preload.', 'host-webfonts-local'); ?></span>
|
131 |
+
</td>
|
132 |
+
</tr>
|
133 |
</tbody>
|
134 |
<?php else: ?>
|
135 |
<tr>
|
141 |
</table>
|
142 |
</div>
|
143 |
|
144 |
+
<div id="omgf-control-panel">
|
145 |
+
<input type="button" id="omgf-download" class="button-primary" value="<?php _e('Download Fonts', 'host-webfonts-local'); ?>" />
|
146 |
+
<input type="button" id="omgf-generate" class="button-secondary" value="<?php _e('Generate Stylesheet', 'host-webfonts-local'); ?>" />
|
147 |
+
<a id="omgf-empty" class="button-cancel"><?php _e('Empty Cache Directory', 'host-webfonts-local'); ?></a>
|
148 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
</div>
|
150 |
<div class="omgf-loading" style="display: none;">
|
151 |
<span class="spinner is-active"> </span>
|
templates/admin/block-welcome.phtml
CHANGED
@@ -16,73 +16,69 @@
|
|
16 |
|
17 |
defined('ABSPATH') || exit;
|
18 |
|
19 |
-
$utmTags
|
20 |
$tweetUrl = 'https://twitter.com/intent/tweet?text=I+just+optimized+my+Google+Fonts+with+OMGF+for+@WordPress!+Try+it+for+yourself:&via=Dan0sz&hashtags=GoogleFonts,WordPress,Pagespeed,Insights&url=https://wordpress.org/plugins/host-webfonts-local/';
|
21 |
?>
|
22 |
-
<div
|
23 |
-
<div class="welcome-panel-
|
24 |
-
<div class="welcome-panel-column-
|
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 |
</div>
|
82 |
</div>
|
83 |
</div>
|
84 |
-
<style>
|
85 |
-
h3 > .dashicons {
|
86 |
-
line-height: 1.4;
|
87 |
-
}
|
88 |
-
</style>
|
16 |
|
17 |
defined('ABSPATH') || exit;
|
18 |
|
19 |
+
$utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=support_tab';
|
20 |
$tweetUrl = 'https://twitter.com/intent/tweet?text=I+just+optimized+my+Google+Fonts+with+OMGF+for+@WordPress!+Try+it+for+yourself:&via=Dan0sz&hashtags=GoogleFonts,WordPress,Pagespeed,Insights&url=https://wordpress.org/plugins/host-webfonts-local/';
|
21 |
?>
|
22 |
+
<div class="welcome-panel-content">
|
23 |
+
<div class="welcome-panel-column-container">
|
24 |
+
<div class="welcome-panel-column" style="width: 100%; margin-right: 15px;">
|
25 |
+
<h2><?php _e('Quickstart', 'host-webfonts-local'); ?></h2>
|
26 |
+
<ul>
|
27 |
+
<li class="welcome-icon dashicons-before dashicons-admin-settings">
|
28 |
+
<?= sprintf(__('Click %sAuto-detect%s and wait for the on-screen instructions', 'host-webfonts-local'), '<a class="help auto-detect" href="#">', '</a>'); ?>
|
29 |
+
</li>
|
30 |
+
<li class="welcome-icon dashicons-before dashicons-update">
|
31 |
+
<?= sprintf(__('Click %sDownload Fonts%s and wait for the download to complete', 'host-webfonts-local'), '<a class="help download-fonts" href="#">', '</a>'); ?>
|
32 |
+
</li>
|
33 |
+
<li class="welcome-icon dashicons-before dashicons-art">
|
34 |
+
<?= sprintf(__('Click %sGenerate Stylesheet%s and wait for the process to complete', 'host-webfonts-local'), '<a class="help generate-stylesheet" href="#">', '</a>'); ?>
|
35 |
+
</li>
|
36 |
+
<li class="welcome-icon dashicons-before dashicons-editor-removeformatting"><?php _e('Check \'Remove Google Fonts\' and save your changes', 'host-webfonts-local'); ?></li>
|
37 |
+
<li class="welcome-icon dashicons-before dashicons-smiley"><?php _e('Done!', 'host-webfonts-local'); ?></li>
|
38 |
+
</ul>
|
39 |
+
<p>
|
40 |
+
<?= sprintf(__('%sClick here%s for a more comprehensive guide.', 'host-webfonts-local'), '<a target="_blank" href="' . OMGF_SITE_URL . '/wordpress/host-google-fonts-locally/' . $utmTags . '">', '</a>'); ?>
|
41 |
+
</p>
|
42 |
+
<hr/>
|
43 |
+
</div>
|
44 |
+
<div class="welcome-panel-column" style="width: 100%; margin-right: 15px;">
|
45 |
+
<h3>
|
46 |
+
<span class="dashicons dashicons-dashboard"></span> <?php _e('Make WordPress <em>Faster</em> Than Superman', 'host-webfonts-local'); ?>
|
47 |
+
</h3>
|
48 |
+
<p>
|
49 |
+
<?= __('Superman can reach the other side of the world in <strong>3 seconds</strong>. Google wants your website to do it <strong>faster</strong>. Let\'s give Google a run for its money.', 'host-webfonts-local'); ?>
|
50 |
+
</p>
|
51 |
+
<p>
|
52 |
+
<a target="_blank" class="button button-primary button-hero" href="https://woosh.dev/wordpress-services/<?= $utmTags; ?>"><span class="dashicons dashicons-thumbs-up"></span> <?= __('Hire me', 'host-webfonts-local'); ?>
|
53 |
+
</a>
|
54 |
+
<span><em>(<?= __('Starting at € 99,-', 'host-analyticsjs-local'); ?>)</em></span>
|
55 |
+
</p>
|
56 |
+
<hr/>
|
57 |
+
</div>
|
58 |
+
<div class="welcome-panel-column welcome-panel-last" style="width: 100%;">
|
59 |
+
<h3>
|
60 |
+
<?php _e('Support OMGF by Spreading the Word!', 'host-webfonts-local'); ?>
|
61 |
+
</h3>
|
62 |
+
<p>
|
63 |
+
<?= sprintf(__('Knowledge should be free. That\'s why I will never charge you for the plugins I create and I will help you to succeed in your projects through the %stutorials%s on my blog.', 'host-webfonts-local'), '<a href="' . OMGF_SITE_URL . '/how-to/' . $utmTags . '" target="_blank">', '</a>'); ?>
|
64 |
+
</p>
|
65 |
+
<p>
|
66 |
+
<?= __('But that doesn\'t mean there\'s nothing you can do to support me! :)', 'host-webfonts-local'); ?>
|
67 |
+
</p>
|
68 |
+
<p>
|
69 |
+
<?= sprintf(__('Please help me spread the word by leaving a %s5-star review%s on Wordpress.org or sending a %sTweet%s about OMGF.', 'host-webfonts-local'), '<a target="_blank" href="https://wordpress.org/support/plugin/host-webfonts-local/reviews/?rate=5#new-post">', '</a>', "<a href='$tweetUrl'>", '</a>'); ?>
|
70 |
+
</p>
|
71 |
+
<p>
|
72 |
+
<a target="_blank" class="button button-secondary button-hero" href="https://wordpress.org/support/plugin/host-webfonts-local/reviews/?rate=5#new-post"><span class="dashicons-before dashicons-star-filled"> <?php _e('Review', 'host-webfonts-local'); ?></span></a>
|
73 |
+
<a target="_blank" class="button button-secondary button-hero" href="<?= $tweetUrl; ?>"><span class="dashicons-before dashicons-twitter"> <?php _e('Tweet', 'host-webfonts-local'); ?></span></a>
|
74 |
+
</p>
|
75 |
+
<hr/>
|
76 |
+
<h3>
|
77 |
+
<?php _e('Need Help?', 'host-webfonts-local'); ?>
|
78 |
+
</h3>
|
79 |
+
<p>
|
80 |
+
<?= sprintf(__('Visit the %sFAQ%s and %sSupport Forum%s to see if your question has already been answered. If not, ask a question on the Support Forum.', 'host-webfonts-local'), '<a href="https://wordpress.org/plugins/host-webfonts-local/#description" target="_blank">', '</a>', '<a href="https://wordpress.org/support/plugin/host-webfonts-local">', '</a>'); ?>
|
81 |
+
</p>
|
82 |
</div>
|
83 |
</div>
|
84 |
</div>
|
|
|
|
|
|
|
|
|
|