| | 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 | * |
| | 59 | * @param {string} name The name of the object, i.e. commonL10n. |
| | 60 | * @param {object} l10nObject The object to deprecate the properties on. |
| | 61 | * |
| | 62 | * @return {object} The object with all its properties deprecated. |
| | 63 | */ |
| | 64 | function deprecateL10nObject( name, l10nObject ) { |
| | 65 | var deprecatedObject = {}; |
| | 66 | |
| | 67 | Object.keys( l10nObject ).forEach( function( key ) { |
| | 68 | var prop = l10nObject[ key ]; |
| | 69 | var propName = name + '.' + key; |
| | 70 | |
| | 71 | if ( 'object' === typeof prop ) { |
| | 72 | Object.defineProperty( deprecatedObject, key, { get: function() { |
| | 73 | deprecatedProperty( propName, '5.5.0', prop.alternative ); |
| | 74 | return prop.func(); |
| | 75 | } } ); |
| | 76 | } else { |
| | 77 | Object.defineProperty( deprecatedObject, key, { get: function() { |
| | 78 | deprecatedProperty( propName, '5.5.0', 'wp.i18n' ); |
| | 79 | return prop; |
| | 80 | } } ); |
| | 81 | } |
| | 82 | } ); |
| | 83 | |
| | 84 | return deprecatedObject; |
| | 85 | } |
| | 86 | |
| | 87 | window.wp.deprecateL10nObject = deprecateL10nObject; |
| | 88 | |
| | 89 | /** |
| | 90 | * Removed in 5.5.0, needed for back-compatibility. |
| | 91 | * |
| | 92 | * @since 2.6.0 |
| | 93 | * @deprecated 5.5.0 |
| | 94 | */ |
| | 95 | window.commonL10n = window.commonL10n || { |
| | 96 | warnDelete: '', |
| | 97 | dismiss: '', |
| | 98 | collapseMenu: '', |
| | 99 | expandMenu: '' |
| | 100 | }; |
| | 101 | |
| | 102 | window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n ); |
| | 103 | |
| | 104 | /** |
| | 105 | * Removed in 5.5.0, needed for back-compatibility. |
| | 106 | * |
| | 107 | * @since 3.3.0 |
| | 108 | * @deprecated 5.5.0 |
| | 109 | */ |
| | 110 | window.wpPointerL10n = window.wpPointerL10n || { |
| | 111 | dismiss: '' |
| | 112 | }; |
| | 113 | |
| | 114 | window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n ); |
| | 115 | |
| | 116 | /** |
| | 117 | * Removed in 5.5.0, needed for back-compatibility. |
| | 118 | * |
| | 119 | * @since 4.3.0 |
| | 120 | * @deprecated 5.5.0 |
| | 121 | */ |
| | 122 | window.userProfileL10n = window.userProfileL10n || { |
| | 123 | warn: '', |
| | 124 | warnWeak: '', |
| | 125 | show: '', |
| | 126 | hide: '', |
| | 127 | cancel: '', |
| | 128 | ariaShow: '', |
| | 129 | ariaHide: '' |
| | 130 | }; |
| | 131 | |
| | 132 | window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n ); |
| | 133 | |
| | 134 | /** |
| | 135 | * Removed in 5.5.0, needed for back-compatibility. |
| | 136 | * |
| | 137 | * @since 4.9.6 |
| | 138 | * @deprecated 5.5.0 |
| | 139 | */ |
| | 140 | window.privacyToolsL10n = window.privacyToolsL10n || { |
| | 141 | noDataFound: '', |
| | 142 | foundAndRemoved: '', |
| | 143 | noneRemoved: '', |
| | 144 | someNotRemoved: '', |
| | 145 | removalError: '', |
| | 146 | emailSent: '', |
| | 147 | noExportFile: '', |
| | 148 | exportError: '' |
| | 149 | }; |
| | 150 | |
| | 151 | window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n ); |
| | 152 | |
| | 153 | /** |
| | 154 | * Removed in 5.5.0, needed for back-compatibility. |
| | 155 | * |
| | 156 | * @since 3.6.0 |
| | 157 | * @deprecated 5.5.0 |
| | 158 | */ |
| | 159 | window.authcheckL10n = { |
| | 160 | beforeunload: '' |
| | 161 | }; |
| | 162 | |
| | 163 | window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n ); |
| | 164 | |
| | 165 | /** |
| | 166 | * Removed in 5.5.0, needed for back-compatibility. |
| | 167 | * |
| | 168 | * @since 2.8.0 |
| | 169 | * @deprecated 5.5.0 |
| | 170 | */ |
| | 171 | window.tagsl10n = { |
| | 172 | noPerm: '', |
| | 173 | broken: '' |
| | 174 | }; |
| | 175 | |
| | 176 | window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n ); |
| | 177 | |
| | 178 | /** |
| | 179 | * Removed in 5.5.0, needed for back-compatibility. |
| | 180 | * |
| | 181 | * @since 2.5.0 |
| | 182 | * @deprecated 5.5.0 |
| | 183 | */ |
| | 184 | window.adminCommentsL10n = window.adminCommentsL10n || { |
| | 185 | hotkeys_highlight_first: { |
| | 186 | alternative: 'window.adminCommentsSettings.hotkeys_highlight_first', |
| | 187 | func: function() { return window.adminCommentsSettings.hotkeys_highlight_first; } |
| | 188 | }, |
| | 189 | hotkeys_highlight_last: { |
| | 190 | alternative: 'window.adminCommentsSettings.hotkeys_highlight_last', |
| | 191 | func: function() { return window.adminCommentsSettings.hotkeys_highlight_last; } |
| | 192 | }, |
| | 193 | replyApprove: '', |
| | 194 | reply: '', |
| | 195 | warnQuickEdit: '', |
| | 196 | warnCommentChanges: '', |
| | 197 | docTitleComments: '', |
| | 198 | docTitleCommentsCount: '' |
| | 199 | }; |
| | 200 | |
| | 201 | window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n ); |
| | 202 | |
| | 203 | /** |
| | 204 | * Removed in 5.5.0, needed for back-compatibility. |
| | 205 | * |
| | 206 | * @since 2.5.0 |
| | 207 | * @deprecated 5.5.0 |
| | 208 | */ |
| | 209 | window.tagsSuggestL10n = window.tagsSuggestL10n || { |
| | 210 | tagDelimiter: '', |
| | 211 | removeTerm: '', |
| | 212 | termSelected: '', |
| | 213 | termAdded: '', |
| | 214 | termRemoved: '' |
| | 215 | }; |
| | 216 | |
| | 217 | window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n ); |
| | 218 | |
| | 219 | /** |
| | 220 | * Removed in 5.5.0, needed for back-compatibility. |
| | 221 | * |
| | 222 | * @since 3.5.0 |
| | 223 | * @deprecated 5.5.0 |
| | 224 | */ |
| | 225 | window.wpColorPickerL10n = window.wpColorPickerL10n || { |
| | 226 | clear: '', |
| | 227 | clearAriaLabel: '', |
| | 228 | defaultString: '', |
| | 229 | defaultAriaLabel: '', |
| | 230 | pick: '', |
| | 231 | defaultLabel: '' |
| | 232 | }; |
| | 233 | |
| | 234 | window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n ); |
| | 235 | |
| | 236 | /** |
| | 237 | * Removed in 5.5.0, needed for back-compatibility. |
| | 238 | * |
| | 239 | * @since 2.7.0 |
| | 240 | * @deprecated 5.5.0 |
| | 241 | */ |
| | 242 | window.attachMediaBoxL10n = window.attachMediaBoxL10n || { |
| | 243 | error: '' |
| | 244 | }; |
| | 245 | |
| | 246 | window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n ); |
| | 247 | |
| | 248 | /** |
| | 249 | * Removed in 5.5.0, needed for back-compatibility. |
| | 250 | * |
| | 251 | * @since 2.5.0 |
| | 252 | * @deprecated 5.5.0 |
| | 253 | */ |
| | 254 | window.postL10n = window.postL10n || { |
| | 255 | ok: '', |
| | 256 | cancel: '', |
| | 257 | publishOn: '', |
| | 258 | publishOnFuture: '', |
| | 259 | publishOnPast: '', |
| | 260 | dateFormat: '', |
| | 261 | showcomm: '', |
| | 262 | endcomm: '', |
| | 263 | publish: '', |
| | 264 | schedule: '', |
| | 265 | update: '', |
| | 266 | savePending: '', |
| | 267 | saveDraft: '', |
| | 268 | 'private': '', |
| | 269 | 'public': '', |
| | 270 | publicSticky: '', |
| | 271 | password: '', |
| | 272 | privatelyPublished: '', |
| | 273 | published: '', |
| | 274 | saveAlert: '', |
| | 275 | savingText: '', |
| | 276 | permalinkSaved: '' |
| | 277 | }; |
| | 278 | |
| | 279 | window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n ); |
| | 280 | |
| | 281 | /** |
| | 282 | * Removed in 5.5.0, needed for back-compatibility. |
| | 283 | * |
| | 284 | * @since 2.7.0 |
| | 285 | * @deprecated 5.5.0 |
| | 286 | */ |
| | 287 | window.inlineEditL10n = window.inlineEditL10n || { |
| | 288 | error: '', |
| | 289 | ntdeltitle: '', |
| | 290 | notitle: '', |
| | 291 | comma: '', |
| | 292 | saved: '' |
| | 293 | }; |
| | 294 | |
| | 295 | window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n ); |
| | 296 | |
| | 297 | /** |
| | 298 | * Removed in 5.5.0, needed for back-compatibility. |
| | 299 | * |
| | 300 | * @since 2.7.0 |
| | 301 | * @deprecated 5.5.0 |
| | 302 | */ |
| | 303 | window.plugininstallL10n = window.plugininstallL10n || { |
| | 304 | plugin_information: '', |
| | 305 | plugin_modal_label: '', |
| | 306 | ays: '' |
| | 307 | }; |
| | 308 | |
| | 309 | window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n ); |
| | 310 | |
| | 311 | /** |
| | 312 | * Removed in 5.5.0, needed for back-compatibility. |
| | 313 | * |
| | 314 | * @since 3.0.0 |
| | 315 | * @deprecated 5.5.0 |
| | 316 | */ |
| | 317 | window.navMenuL10n = window.navMenuL10n || { |
| | 318 | noResultsFound: '', |
| | 319 | warnDeleteMenu: '', |
| | 320 | saveAlert: '', |
| | 321 | untitled: '' |
| | 322 | }; |
| | 323 | |
| | 324 | window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n ); |
| | 325 | |
| | 326 | /** |
| | 327 | * Removed in 5.5.0, needed for back-compatibility. |
| | 328 | * |
| | 329 | * @since 2.5.0 |
| | 330 | * @deprecated 5.5.0 |
| | 331 | */ |
| | 332 | window.commentL10n = window.commentL10n || { |
| | 333 | submittedOn: '', |
| | 334 | dateFormat: '' |
| | 335 | }; |
| | 336 | |
| | 337 | window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n ); |
| | 338 | |
| | 339 | /** |
| | 340 | * Removed in 5.5.0, needed for back-compatibility. |
| | 341 | * |
| | 342 | * @since 2.9.0 |
| | 343 | * @deprecated 5.5.0 |
| | 344 | */ |
| | 345 | window.setPostThumbnailL10n = window.setPostThumbnailL10n || { |
| | 346 | setThumbnail: '', |
| | 347 | saving: '', |
| | 348 | error: '', |
| | 349 | done: '' |
| | 350 | }; |
| | 351 | |
| | 352 | window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n ); |
| | 353 | |
| | 354 | /** |