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