| | 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 | * @deprecated 5.5.0 |
| | 120 | */ |
| | 121 | window.userProfileL10n = window.userProfileL10n || { |
| | 122 | warn: '', |
| | 123 | warnWeak: '', |
| | 124 | show: '', |
| | 125 | hide: '', |
| | 126 | cancel: '', |
| | 127 | ariaShow: '', |
| | 128 | ariaHide: '' |
| | 129 | }; |
| | 130 | |
| | 131 | window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n ); |
| | 132 | |
| | 133 | /** |
| | 134 | * Removed in 5.5.0, needed for back-compatibility. |
| | 135 | * |
| | 136 | * @since 4.9.6 |
| | 137 | * @deprecated 5.5.0 |
| | 138 | */ |
| | 139 | window.privacyToolsL10n = window.privacyToolsL10n || { |
| | 140 | noDataFound: '', |
| | 141 | foundAndRemoved: '', |
| | 142 | noneRemoved: '', |
| | 143 | someNotRemoved: '', |
| | 144 | removalError: '', |
| | 145 | emailSent: '', |
| | 146 | noExportFile: '', |
| | 147 | exportError: '' |
| | 148 | }; |
| | 149 | |
| | 150 | window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n ); |
| | 151 | |
| | 152 | /** |
| | 153 | * Removed in 5.5.0, needed for back-compatibility. |
| | 154 | * |
| | 155 | * @since 3.6.0 |
| | 156 | * @deprecated 5.5.0 |
| | 157 | */ |
| | 158 | window.authcheckL10n = { |
| | 159 | beforeunload: '' |
| | 160 | }; |
| | 161 | |
| | 162 | window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n ); |
| | 163 | |
| | 164 | /** |
| | 165 | * Removed in 5.5.0, needed for back-compatibility. |
| | 166 | * |
| | 167 | * @since 2.8.0 |
| | 168 | * @deprecated 5.5.0 |
| | 169 | */ |
| | 170 | window.tagsl10n = { |
| | 171 | noPerm: '', |
| | 172 | broken: '' |
| | 173 | }; |
| | 174 | |
| | 175 | window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n ); |
| | 176 | |
| | 177 | /** |
| | 178 | * Removed in 5.5.0, needed for back-compatibility. |
| | 179 | * |
| | 180 | * @since 2.5.0 |
| | 181 | * @deprecated 5.5.0 |
| | 182 | */ |
| | 183 | window.adminCommentsL10n = window.adminCommentsL10n || { |
| | 184 | hotkeys_highlight_first: { |
| | 185 | alternative: 'window.adminCommentsSettings.hotkeys_highlight_first', |
| | 186 | func: function() { return window.adminCommentsSettings.hotkeys_highlight_first; } |
| | 187 | }, |
| | 188 | hotkeys_highlight_last: { |
| | 189 | alternative: 'window.adminCommentsSettings.hotkeys_highlight_last', |
| | 190 | func: function() { return window.adminCommentsSettings.hotkeys_highlight_last; } |
| | 191 | }, |
| | 192 | replyApprove: '', |
| | 193 | reply: '', |
| | 194 | warnQuickEdit: '', |
| | 195 | warnCommentChanges: '', |
| | 196 | docTitleComments: '', |
| | 197 | docTitleCommentsCount: '' |
| | 198 | }; |
| | 199 | |
| | 200 | window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n ); |
| | 201 | |
| | 202 | /** |
| | 203 | * Removed in 5.5.0, needed for back-compatibility. |
| | 204 | * |
| | 205 | * @since 2.5.0 |
| | 206 | * @deprecated 5.5.0 |
| | 207 | */ |
| | 208 | window.tagsSuggestL10n = window.tagsSuggestL10n || { |
| | 209 | tagDelimiter: '', |
| | 210 | removeTerm: '', |
| | 211 | termSelected: '', |
| | 212 | termAdded: '', |
| | 213 | termRemoved: '' |
| | 214 | }; |
| | 215 | |
| | 216 | window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n ); |
| | 217 | |
| | 218 | /** |
| | 219 | * Removed in 5.5.0, needed for back-compatibility. |
| | 220 | * |
| | 221 | * @since 3.5.0 |
| | 222 | * @deprecated 5.5.0 |
| | 223 | */ |
| | 224 | window.wpColorPickerL10n = window.wpColorPickerL10n || { |
| | 225 | clear: '', |
| | 226 | clearAriaLabel: '', |
| | 227 | defaultString: '', |
| | 228 | defaultAriaLabel: '', |
| | 229 | pick: '', |
| | 230 | defaultLabel: '' |
| | 231 | }; |
| | 232 | |
| | 233 | window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n ); |
| | 234 | |
| | 235 | /** |
| | 236 | * Removed in 5.5.0, needed for back-compatibility. |
| | 237 | * |
| | 238 | * @since 2.7.0 |
| | 239 | * @deprecated 5.5.0 |
| | 240 | */ |
| | 241 | window.attachMediaBoxL10n = window.attachMediaBoxL10n || { |
| | 242 | error: '' |
| | 243 | }; |
| | 244 | |
| | 245 | window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n ); |
| | 246 | |
| | 247 | /** |
| | 248 | * Removed in 5.5.0, needed for back-compatibility. |
| | 249 | * |
| | 250 | * @deprecated 5.5.0 |
| | 251 | */ |
| | 252 | window.postL10n = window.postL10n || { |
| | 253 | ok: '', |
| | 254 | cancel: '', |
| | 255 | publishOn: '', |
| | 256 | publishOnFuture: '', |
| | 257 | publishOnPast: '', |
| | 258 | dateFormat: '', |
| | 259 | showcomm: '', |
| | 260 | endcomm: '', |
| | 261 | publish: '', |
| | 262 | schedule: '', |
| | 263 | update: '', |
| | 264 | savePending: '', |
| | 265 | saveDraft: '', |
| | 266 | 'private': '', |
| | 267 | 'public': '', |
| | 268 | publicSticky: '', |
| | 269 | password: '', |
| | 270 | privatelyPublished: '', |
| | 271 | published: '', |
| | 272 | saveAlert: '', |
| | 273 | savingText: '', |
| | 274 | permalinkSaved: '' |
| | 275 | }; |
| | 276 | |
| | 277 | window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n ); |
| | 278 | |
| | 279 | /** |
| | 280 | * Removed in 5.5.0, needed for back-compatibility. |
| | 281 | * |
| | 282 | * @since 2.7.0 |
| | 283 | * @deprecated 5.5.0 |
| | 284 | */ |
| | 285 | window.inlineEditL10n = window.inlineEditL10n || { |
| | 286 | error: '', |
| | 287 | ntdeltitle: '', |
| | 288 | notitle: '', |
| | 289 | comma: '', |
| | 290 | saved: '' |
| | 291 | }; |
| | 292 | |
| | 293 | window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n ); |
| | 294 | |
| | 295 | /** |
| | 296 | * Removed in 5.5.0, needed for back-compatibility. |
| | 297 | * |
| | 298 | * @deprecated 5.5.0 |
| | 299 | */ |
| | 300 | window.plugininstallL10n = window.plugininstallL10n || { |
| | 301 | plugin_information: '', |
| | 302 | plugin_modal_label: '', |
| | 303 | ays: '' |
| | 304 | }; |
| | 305 | |
| | 306 | window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n ); |
| | 307 | |
| | 308 | /** |
| | 309 | * Removed in 5.5.0, needed for back-compatibility. |
| | 310 | * |
| | 311 | * @deprecated 5.5.0 |
| | 312 | */ |
| | 313 | window.navMenuL10n = window.navMenuL10n || { |
| | 314 | noResultsFound: '', |
| | 315 | warnDeleteMenu: '', |
| | 316 | saveAlert: '', |
| | 317 | untitled: '' |
| | 318 | }; |
| | 319 | |
| | 320 | window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n ); |
| | 321 | |
| | 322 | /** |
| | 323 | * Removed in 5.5.0, needed for back-compatibility. |
| | 324 | * |
| | 325 | * @since 2.5.0 |
| | 326 | * @deprecated 5.5.0 |
| | 327 | */ |
| | 328 | window.commentL10n = window.commentL10n || { |
| | 329 | submittedOn: '', |
| | 330 | dateFormat: '' |
| | 331 | }; |
| | 332 | |
| | 333 | window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n ); |
| | 334 | |
| | 335 | /** |
| | 336 | * Removed in 5.5.0, needed for back-compatibility. |
| | 337 | * |
| | 338 | * @deprecated 5.5.0 |
| | 339 | */ |
| | 340 | window.setPostThumbnailL10n = window.setPostThumbnailL10n || { |
| | 341 | setThumbnail: '', |
| | 342 | saving: '', |
| | 343 | error: '', |
| | 344 | done: '' |
| | 345 | }; |
| | 346 | |
| | 347 | window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n ); |
| | 348 | |
| | 349 | /** |