|
16 | 16 | var $document = $( document ), |
17 | 17 | $window = $( window ), |
18 | 18 | $body = $( document.body ), |
19 | | - __ = wp.i18n.__, |
20 | | - sprintf = wp.i18n.sprintf; |
21 | | - |
22 | | -/** |
23 | | - * Throws an error for a deprecated property. |
24 | | - * |
25 | | - * @since 5.5.1 |
26 | | - * |
27 | | - * @param {string} propName The property that was used. |
28 | | - * @param {string} version The version of WordPress that deprecated the property. |
29 | | - * @param {string} replacement The property that should have been used. |
30 | | - */ |
31 | | -function deprecatedProperty( propName, version, replacement ) { |
32 | | - var message; |
33 | | - |
34 | | - if ( 'undefined' !== typeof replacement ) { |
35 | | - message = sprintf( |
36 | | - /* translators: 1: Deprecated property name, 2: Version number, 3: Alternative property name. */ |
37 | | - __( '%1$s is deprecated since version %2$s! Use %3$s instead.' ), |
38 | | - propName, |
39 | | - version, |
40 | | - replacement |
41 | | - ); |
42 | | - } else { |
43 | | - message = sprintf( |
44 | | - /* translators: 1: Deprecated property name, 2: Version number. */ |
45 | | - __( '%1$s is deprecated since version %2$s with no alternative available.' ), |
46 | | - propName, |
47 | | - version |
48 | | - ); |
49 | | - } |
50 | | - |
51 | | - window.console.warn( message ); |
52 | | -} |
53 | | - |
54 | | -/** |
55 | | - * Deprecate all properties on an object. |
56 | | - * |
57 | | - * @since 5.5.1 |
58 | | - * @since 5.6.0 Added the `version` parameter. |
59 | | - * |
60 | | - * @param {string} name The name of the object, i.e. commonL10n. |
61 | | - * @param {object} l10nObject The object to deprecate the properties on. |
62 | | - * @param {string} version The version of WordPress that deprecated the property. |
63 | | - * |
64 | | - * @return {object} The object with all its properties deprecated. |
65 | | - */ |
66 | | -function deprecateL10nObject( name, l10nObject, version ) { |
67 | | - var deprecatedObject = {}; |
68 | | - |
69 | | - Object.keys( l10nObject ).forEach( function( key ) { |
70 | | - var prop = l10nObject[ key ]; |
71 | | - var propName = name + '.' + key; |
72 | | - |
73 | | - if ( 'object' === typeof prop ) { |
74 | | - Object.defineProperty( deprecatedObject, key, { get: function() { |
75 | | - deprecatedProperty( propName, version, prop.alternative ); |
76 | | - return prop.func(); |
77 | | - } } ); |
78 | | - } else { |
79 | | - Object.defineProperty( deprecatedObject, key, { get: function() { |
80 | | - deprecatedProperty( propName, version, 'wp.i18n' ); |
81 | | - return prop; |
82 | | - } } ); |
83 | | - } |
84 | | - } ); |
85 | | - |
86 | | - return deprecatedObject; |
87 | | -} |
88 | | - |
89 | | -window.wp.deprecateL10nObject = deprecateL10nObject; |
90 | | - |
91 | | -/** |
92 | | - * Removed in 5.5.0, needed for back-compatibility. |
93 | | - * |
94 | | - * @since 2.6.0 |
95 | | - * @deprecated 5.5.0 |
96 | | - */ |
97 | | -window.commonL10n = window.commonL10n || { |
98 | | - warnDelete: '', |
99 | | - dismiss: '', |
100 | | - collapseMenu: '', |
101 | | - expandMenu: '' |
102 | | -}; |
103 | | - |
104 | | -window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n, '5.5.0' ); |
105 | | - |
106 | | -/** |
107 | | - * Removed in 5.5.0, needed for back-compatibility. |
108 | | - * |
109 | | - * @since 3.3.0 |
110 | | - * @deprecated 5.5.0 |
111 | | - */ |
112 | | -window.wpPointerL10n = window.wpPointerL10n || { |
113 | | - dismiss: '' |
114 | | -}; |
115 | | - |
116 | | -window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n, '5.5.0' ); |
117 | | - |
118 | | -/** |
119 | | - * Removed in 5.5.0, needed for back-compatibility. |
120 | | - * |
121 | | - * @since 4.3.0 |
122 | | - * @deprecated 5.5.0 |
123 | | - */ |
124 | | -window.userProfileL10n = window.userProfileL10n || { |
125 | | - warn: '', |
126 | | - warnWeak: '', |
127 | | - show: '', |
128 | | - hide: '', |
129 | | - cancel: '', |
130 | | - ariaShow: '', |
131 | | - ariaHide: '' |
132 | | -}; |
133 | | - |
134 | | -window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n, '5.5.0' ); |
135 | | - |
136 | | -/** |
137 | | - * Removed in 5.5.0, needed for back-compatibility. |
138 | | - * |
139 | | - * @since 4.9.6 |
140 | | - * @deprecated 5.5.0 |
141 | | - */ |
142 | | -window.privacyToolsL10n = window.privacyToolsL10n || { |
143 | | - noDataFound: '', |
144 | | - foundAndRemoved: '', |
145 | | - noneRemoved: '', |
146 | | - someNotRemoved: '', |
147 | | - removalError: '', |
148 | | - emailSent: '', |
149 | | - noExportFile: '', |
150 | | - exportError: '' |
151 | | -}; |
152 | | - |
153 | | -window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n, '5.5.0' ); |
154 | | - |
155 | | -/** |
156 | | - * Removed in 5.5.0, needed for back-compatibility. |
157 | | - * |
158 | | - * @since 3.6.0 |
159 | | - * @deprecated 5.5.0 |
160 | | - */ |
161 | | -window.authcheckL10n = { |
162 | | - beforeunload: '' |
163 | | -}; |
164 | | - |
165 | | -window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n, '5.5.0' ); |
166 | | - |
167 | | -/** |
168 | | - * Removed in 5.5.0, needed for back-compatibility. |
169 | | - * |
170 | | - * @since 2.8.0 |
171 | | - * @deprecated 5.5.0 |
172 | | - */ |
173 | | -window.tagsl10n = { |
174 | | - noPerm: '', |
175 | | - broken: '' |
176 | | -}; |
177 | | - |
178 | | -window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n, '5.5.0' ); |
179 | | - |
180 | | -/** |
181 | | - * Removed in 5.5.0, needed for back-compatibility. |
182 | | - * |
183 | | - * @since 2.5.0 |
184 | | - * @deprecated 5.5.0 |
185 | | - */ |
186 | | -window.adminCommentsL10n = window.adminCommentsL10n || { |
187 | | - hotkeys_highlight_first: { |
188 | | - alternative: 'window.adminCommentsSettings.hotkeys_highlight_first', |
189 | | - func: function() { return window.adminCommentsSettings.hotkeys_highlight_first; } |
190 | | - }, |
191 | | - hotkeys_highlight_last: { |
192 | | - alternative: 'window.adminCommentsSettings.hotkeys_highlight_last', |
193 | | - func: function() { return window.adminCommentsSettings.hotkeys_highlight_last; } |
194 | | - }, |
195 | | - replyApprove: '', |
196 | | - reply: '', |
197 | | - warnQuickEdit: '', |
198 | | - warnCommentChanges: '', |
199 | | - docTitleComments: '', |
200 | | - docTitleCommentsCount: '' |
201 | | -}; |
202 | | - |
203 | | -window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n, '5.5.0' ); |
204 | | - |
205 | | -/** |
206 | | - * Removed in 5.5.0, needed for back-compatibility. |
207 | | - * |
208 | | - * @since 2.5.0 |
209 | | - * @deprecated 5.5.0 |
210 | | - */ |
211 | | -window.tagsSuggestL10n = window.tagsSuggestL10n || { |
212 | | - tagDelimiter: '', |
213 | | - removeTerm: '', |
214 | | - termSelected: '', |
215 | | - termAdded: '', |
216 | | - termRemoved: '' |
217 | | -}; |
218 | | - |
219 | | -window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n, '5.5.0' ); |
220 | | - |
221 | | -/** |
222 | | - * Removed in 5.5.0, needed for back-compatibility. |
223 | | - * |
224 | | - * @since 3.5.0 |
225 | | - * @deprecated 5.5.0 |
226 | | - */ |
227 | | -window.wpColorPickerL10n = window.wpColorPickerL10n || { |
228 | | - clear: '', |
229 | | - clearAriaLabel: '', |
230 | | - defaultString: '', |
231 | | - defaultAriaLabel: '', |
232 | | - pick: '', |
233 | | - defaultLabel: '' |
234 | | -}; |
235 | | - |
236 | | -window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n, '5.5.0' ); |
237 | | - |
238 | | -/** |
239 | | - * Removed in 5.5.0, needed for back-compatibility. |
240 | | - * |
241 | | - * @since 2.7.0 |
242 | | - * @deprecated 5.5.0 |
243 | | - */ |
244 | | -window.attachMediaBoxL10n = window.attachMediaBoxL10n || { |
245 | | - error: '' |
246 | | -}; |
247 | | - |
248 | | -window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n, '5.5.0' ); |
249 | | - |
250 | | -/** |
251 | | - * Removed in 5.5.0, needed for back-compatibility. |
252 | | - * |
253 | | - * @since 2.5.0 |
254 | | - * @deprecated 5.5.0 |
255 | | - */ |
256 | | -window.postL10n = window.postL10n || { |
257 | | - ok: '', |
258 | | - cancel: '', |
259 | | - publishOn: '', |
260 | | - publishOnFuture: '', |
261 | | - publishOnPast: '', |
262 | | - dateFormat: '', |
263 | | - showcomm: '', |
264 | | - endcomm: '', |
265 | | - publish: '', |
266 | | - schedule: '', |
267 | | - update: '', |
268 | | - savePending: '', |
269 | | - saveDraft: '', |
270 | | - 'private': '', |
271 | | - 'public': '', |
272 | | - publicSticky: '', |
273 | | - password: '', |
274 | | - privatelyPublished: '', |
275 | | - published: '', |
276 | | - saveAlert: '', |
277 | | - savingText: '', |
278 | | - permalinkSaved: '' |
279 | | -}; |
280 | | - |
281 | | -window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n, '5.5.0' ); |
282 | | - |
283 | | -/** |
284 | | - * Removed in 5.5.0, needed for back-compatibility. |
285 | | - * |
286 | | - * @since 2.7.0 |
287 | | - * @deprecated 5.5.0 |
288 | | - */ |
289 | | -window.inlineEditL10n = window.inlineEditL10n || { |
290 | | - error: '', |
291 | | - ntdeltitle: '', |
292 | | - notitle: '', |
293 | | - comma: '', |
294 | | - saved: '' |
295 | | -}; |
296 | | - |
297 | | -window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n, '5.5.0' ); |
298 | | - |
299 | | -/** |
300 | | - * Removed in 5.5.0, needed for back-compatibility. |
301 | | - * |
302 | | - * @since 2.7.0 |
303 | | - * @deprecated 5.5.0 |
304 | | - */ |
305 | | -window.plugininstallL10n = window.plugininstallL10n || { |
306 | | - plugin_information: '', |
307 | | - plugin_modal_label: '', |
308 | | - ays: '' |
309 | | -}; |
310 | | - |
311 | | -window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n, '5.5.0' ); |
312 | | - |
313 | | -/** |
314 | | - * Removed in 5.5.0, needed for back-compatibility. |
315 | | - * |
316 | | - * @since 3.0.0 |
317 | | - * @deprecated 5.5.0 |
318 | | - */ |
319 | | -window.navMenuL10n = window.navMenuL10n || { |
320 | | - noResultsFound: '', |
321 | | - warnDeleteMenu: '', |
322 | | - saveAlert: '', |
323 | | - untitled: '' |
324 | | -}; |
325 | | - |
326 | | -window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n, '5.5.0' ); |
327 | | - |
328 | | -/** |
329 | | - * Removed in 5.5.0, needed for back-compatibility. |
330 | | - * |
331 | | - * @since 2.5.0 |
332 | | - * @deprecated 5.5.0 |
333 | | - */ |
334 | | -window.commentL10n = window.commentL10n || { |
335 | | - submittedOn: '', |
336 | | - dateFormat: '' |
337 | | -}; |
338 | | - |
339 | | -window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n, '5.5.0' ); |
340 | | - |
341 | | -/** |
342 | | - * Removed in 5.5.0, needed for back-compatibility. |
343 | | - * |
344 | | - * @since 2.9.0 |
345 | | - * @deprecated 5.5.0 |
346 | | - */ |
347 | | -window.setPostThumbnailL10n = window.setPostThumbnailL10n || { |
348 | | - setThumbnail: '', |
349 | | - saving: '', |
350 | | - error: '', |
351 | | - done: '' |
352 | | -}; |
353 | | - |
354 | | -window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n, '5.5.0' ); |
355 | | - |
356 | | -/** |
357 | | - * Removed in 6.5.0, needed for back-compatibility. |
358 | | - * |
359 | | - * @since 4.5.0 |
360 | | - * @deprecated 6.5.0 |
361 | | - */ |
362 | | -window.uiAutocompleteL10n = window.uiAutocompleteL10n || { |
363 | | - noResults: '', |
364 | | - oneResult: '', |
365 | | - manyResults: '', |
366 | | - itemSelected: '' |
367 | | -}; |
368 | | - |
369 | | -window.uiAutocompleteL10n = deprecateL10nObject( 'uiAutocompleteL10n', window.uiAutocompleteL10n, '6.5.0' ); |
| 19 | + __ = wp.i18n.__; |
370 | 20 |
|
371 | 21 | /** |
372 | 22 | * Removed in 3.3.0, needed for back-compatibility. |
|
0 commit comments