| 19 | | __ = wp.i18n.__; |
| | 19 | __ = wp.i18n.__, |
| | 20 | _x = wp.i18n._x, |
| | 21 | sprintf = wp.i18n.sprintf; |
| | 22 | |
| | 23 | /** |
| | 24 | * Throws a warning for a deprecated property. |
| | 25 | * |
| | 26 | * @since 5.5.1 |
| | 27 | * |
| | 28 | * @param {string} propName The property that was used. |
| | 29 | * @param {string} version The version of WordPress that deprecated the property. |
| | 30 | * @param {string} replacement The property that should have been used. |
| | 31 | */ |
| | 32 | function deprecatedProperty( propName, version, replacement ) { |
| | 33 | var message; |
| | 34 | |
| | 35 | if ( 'undefined' !== typeof replacement ) { |
| | 36 | message = sprintf( |
| | 37 | /* translators: 1: Deprecated property name, 2: Version number, 3: Alternative property name. */ |
| | 38 | __( '%1$s is deprecated since version %2$s! Use %3$s instead.' ), |
| | 39 | propName, |
| | 40 | version, |
| | 41 | replacement |
| | 42 | ); |
| | 43 | } else { |
| | 44 | message = sprintf( |
| | 45 | /* translators: 1: Deprecated property name, 2: Version number. */ |
| | 46 | __( '%1$s is deprecated since version %2$s with no alternative available.' ), |
| | 47 | propName, |
| | 48 | version |
| | 49 | ); |
| | 50 | } |
| | 51 | |
| | 52 | window.console.warn( message ); |
| | 53 | } |
| | 54 | |
| | 55 | /** |
| | 56 | * Deprecate all properties on an object. |
| | 57 | * |
| | 58 | * @since 5.5.1 |
| | 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 | * |
| | 63 | * @return {object} The object with all its properties deprecated. |
| | 64 | */ |
| | 65 | function deprecateL10nObject( name, l10nObject ) { |
| | 66 | var deprecatedObject = {}; |
| | 67 | |
| | 68 | Object.keys( l10nObject ).forEach( function( key ) { |
| | 69 | var prop = l10nObject[ key ]; |
| | 70 | var propName = name + '.' + key; |
| | 71 | |
| | 72 | if ( 'object' === typeof prop ) { |
| | 73 | Object.defineProperty( deprecatedObject, key, { get: function() { |
| | 74 | deprecatedProperty( propName, '5.5.0', prop.alternative ); |
| | 75 | return prop.func(); |
| | 76 | } } ); |
| | 77 | } else { |
| | 78 | Object.defineProperty( deprecatedObject, key, { get: function() { |
| | 79 | deprecatedProperty( propName, '5.5.0', 'wp.i18n' ); |
| | 80 | return prop; |
| | 81 | } } ); |
| | 82 | } |
| | 83 | } ); |
| | 84 | |
| | 85 | return deprecatedObject; |
| | 86 | } |
| | 87 | |
| | 88 | window.wp.deprecateL10nObject = deprecateL10nObject; |
| | 89 | |
| | 90 | /** |
| | 91 | * Removed in 5.5.0, needed for back-compatibility. |
| | 92 | * |
| | 93 | * @since 2.6.0 |
| | 94 | * @deprecated 5.5.0 |
| | 95 | */ |
| | 96 | window.commonL10n = window.commonL10n || { |
| | 97 | warnDelete: __( 'You are about to permanently delete these items from your site.\nThis action cannot be undone.\n\'Cancel\' to stop, \'OK\' to delete.' ), |
| | 98 | dismiss: __( 'Dismiss this notice.' ), |
| | 99 | collapseMenu: __( 'Collapse Main menu' ), |
| | 100 | expandMenu: __( 'Expand Main menu' ) |
| | 101 | }; |
| | 102 | |
| | 103 | window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n ); |
| | 104 | |
| | 105 | /** |
| | 106 | * Removed in 5.5.0, needed for back-compatibility. |
| | 107 | * |
| | 108 | * @since 3.3.0 |
| | 109 | * @deprecated 5.5.0 |
| | 110 | */ |
| | 111 | window.wpPointerL10n = window.wpPointerL10n || { |
| | 112 | dismiss: __( 'Dismiss' ) |
| | 113 | }; |
| | 114 | |
| | 115 | window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n ); |
| | 116 | |
| | 117 | /** |
| | 118 | * Removed in 5.5.0, needed for back-compatibility. |
| | 119 | * |
| | 120 | * @deprecated 5.5.0 |
| | 121 | */ |
| | 122 | window.userProfileL10n = window.userProfileL10n || { |
| | 123 | warn: __( 'Your new password has not been saved.' ), |
| | 124 | warnWeak: __( 'Confirm use of weak password' ), |
| | 125 | show: __( 'Show' ), |
| | 126 | hide: __( 'Hide' ), |
| | 127 | cancel: __( 'Cancel' ), |
| | 128 | ariaShow: __( 'Show password' ), |
| | 129 | ariaHide: __( 'Hide password' ) |
| | 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: __( 'No personal data was found for this user.' ), |
| | 142 | foundAndRemoved: __( 'All of the personal data found for this user was erased.' ), |
| | 143 | noneRemoved: __( 'Personal data was found for this user but was not erased.' ), |
| | 144 | someNotRemoved: __( 'Personal data was found for this user but some of the personal data found was not erased.' ), |
| | 145 | removalError: __( 'An error occurred while attempting to find and erase personal data.' ), |
| | 146 | emailSent: __( 'The personal data export link for this user was sent.' ), |
| | 147 | noExportFile: __( 'No personal data export file was generated.' ), |
| | 148 | exportError: __( 'An error occurred while attempting to export personal data.' ) |
| | 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: __( 'Your session has expired. You can log in again from this page or go to the login page.' ) |
| | 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: __( 'Sorry, you are not allowed to do that.' ), |
| | 173 | broken: __( 'Something went wrong.' ) |
| | 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: __( 'Approve and Reply' ), |
| | 194 | reply: __( 'Reply' ), |
| | 195 | warnQuickEdit: __( 'Are you sure you want to edit this comment?\nThe changes you made will be lost.' ), |
| | 196 | warnCommentChanges: __( 'Are you sure you want to do this?\nThe comment changes you made will be lost.' ), |
| | 197 | docTitleComments: __( 'Comments' ), |
| | 198 | /* translators: %s: Comments count. */ |
| | 199 | docTitleCommentsCount: __( 'Comments (%s)' ) |
| | 200 | }; |
| | 201 | |
| | 202 | window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n ); |
| | 203 | |
| | 204 | /** |
| | 205 | * Removed in 5.5.0, needed for back-compatibility. |
| | 206 | * |
| | 207 | * @since 2.5.0 |
| | 208 | * @deprecated 5.5.0 |
| | 209 | */ |
| | 210 | window.tagsl10n = window.tagsl10n || { |
| | 211 | tagDelimiter: _x( ',', 'tag delimiter' ), |
| | 212 | removeTerm: __( 'Remove term:' ), |
| | 213 | termSelected: __( 'Term selected.' ), |
| | 214 | termAdded: __( 'Term added.' ), |
| | 215 | termRemoved: __( 'Term removed.' ) |
| | 216 | }; |
| | 217 | |
| | 218 | window.tagsL10n = deprecateL10nObject( 'tagsl10n', window.tagsl10n ); |
| | 219 | |
| | 220 | /** |
| | 221 | * Removed in 5.5.0, needed for back-compatibility. |
| | 222 | * |
| | 223 | * @since 3.5.0 |
| | 224 | * @deprecated 5.5.0 |
| | 225 | */ |
| | 226 | window.wpColorPickerL10n = window.wpColorPickerL10n || { |
| | 227 | clear: __( 'Clear' ), |
| | 228 | clearAriaLabel: __( 'Clear color' ), |
| | 229 | defaultString: __( 'Default' ), |
| | 230 | defaultAriaLabel: __( 'Select default color' ), |
| | 231 | pick: __( 'Select Color' ), |
| | 232 | defaultLabel: __( 'Color value' ) |
| | 233 | }; |
| | 234 | |
| | 235 | window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n ); |
| | 236 | |
| | 237 | /** |
| | 238 | * Removed in 5.5.0, needed for back-compatibility. |
| | 239 | * |
| | 240 | * @since 2.7.0 |
| | 241 | * @deprecated 5.5.0 |
| | 242 | */ |
| | 243 | window.attachMediaBoxL10n = window.attachMediaBoxL10n || { |
| | 244 | error: __( 'An error has occurred. Please reload the page and try again.' ) |
| | 245 | }; |
| | 246 | |
| | 247 | window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n ); |
| | 248 | |
| | 249 | /** |
| | 250 | * Removed in 5.5.0, needed for back-compatibility. |
| | 251 | * |
| | 252 | * @deprecated 5.5.0 |
| | 253 | */ |
| | 254 | window.postL10n = window.postL10n || { |
| | 255 | ok: __( 'OK' ), |
| | 256 | cancel: __( 'Cancel' ), |
| | 257 | publishOn: __( 'Publish on:' ), |
| | 258 | publishOnFuture: __( 'Schedule for:' ), |
| | 259 | publishOnPast: __( 'Published on:' ), |
| | 260 | /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */ |
| | 261 | dateFormat: __( '%1$s %2$s, %3$s at %4$s:%5$s' ), |
| | 262 | showcomm: __( 'Show more comments' ), |
| | 263 | endcomm: __( 'No more comments found.' ), |
| | 264 | publish: __( 'Publish' ), |
| | 265 | schedule: _x( 'Schedule', 'post action/button label' ), |
| | 266 | update: __( 'Update' ), |
| | 267 | savePending: __( 'Save as Pending' ), |
| | 268 | saveDraft: __( 'Save Draft' ), |
| | 269 | 'private': __( 'Private' ), |
| | 270 | 'public': __( 'Public' ), |
| | 271 | publicSticky: __( 'Public, Sticky' ), |
| | 272 | password: __( 'Password Protected' ), |
| | 273 | privatelyPublished: __( 'Privately Published' ), |
| | 274 | published: __( 'Published' ), |
| | 275 | saveAlert: __( 'The changes you made will be lost if you navigate away from this page.' ), |
| | 276 | savingText: __( 'Saving Draft…' ), |
| | 277 | permalinkSaved: __( 'Permalink saved' ) |
| | 278 | }; |
| | 279 | |
| | 280 | window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n ); |
| | 281 | |
| | 282 | /** |
| | 283 | * Removed in 5.5.0, needed for back-compatibility. |
| | 284 | * |
| | 285 | * @since 2.7.0 |
| | 286 | * @deprecated 5.5.0 |
| | 287 | */ |
| | 288 | window.inlineEditL10n = window.inlineEditL10n || { |
| | 289 | error: __( 'Error while saving the changes.' ), |
| | 290 | ntdeltitle: __( 'Remove From Bulk Edit' ), |
| | 291 | notitle: __( '(no title)' ), |
| | 292 | comma: _x( ',', 'tag delimiter' ).trim(), |
| | 293 | saved: __( 'Changes saved.' ) |
| | 294 | }; |
| | 295 | |
| | 296 | window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n ); |
| | 297 | |
| | 298 | /** |
| | 299 | * Removed in 5.5.0, needed for back-compatibility. |
| | 300 | * |
| | 301 | * @deprecated 5.5.0 |
| | 302 | */ |
| | 303 | window.plugininstallL10n = window.plugininstallL10n || { |
| | 304 | plugin_information: __( 'Plugin:' ), |
| | 305 | plugin_modal_label: __( 'Plugin details' ), |
| | 306 | ays: __( 'Are you sure you want to install this plugin?' ) |
| | 307 | }; |
| | 308 | |
| | 309 | window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n ); |
| | 310 | |
| | 311 | /** |
| | 312 | * Removed in 5.5.0, needed for back-compatibility. |
| | 313 | * |
| | 314 | * @deprecated 5.5.0 |
| | 315 | */ |
| | 316 | window.navMenuL10n = window.navMenuL10n || { |
| | 317 | noResultsFound: __( 'No results found.' ), |
| | 318 | warnDeleteMenu: __( 'You are about to permanently delete this menu.\n\'Cancel\' to stop, \'OK\' to delete.' ), |
| | 319 | saveAlert: __( 'The changes you made will be lost if you navigate away from this page.' ), |
| | 320 | untitled: _x( '(no label)', 'missing menu item navigation label' ) |
| | 321 | }; |
| | 322 | |
| | 323 | window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n ); |
| | 324 | |
| | 325 | /** |
| | 326 | * Removed in 5.5.0, needed for back-compatibility. |
| | 327 | * |
| | 328 | * @since 2.5.0 |
| | 329 | * @deprecated 5.5.0 |
| | 330 | */ |
| | 331 | window.commentL10n = window.commentL10n || { |
| | 332 | submittedOn: __( 'Submitted on:' ), |
| | 333 | /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */ |
| | 334 | dateFormat: __( '%1$s %2$s, %3$s at %4$s:%5$s' ) |
| | 335 | }; |
| | 336 | |
| | 337 | window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n ); |
| | 338 | |
| | 339 | /** |
| | 340 | * Removed in 5.5.0, needed for back-compatibility. |
| | 341 | * |
| | 342 | * @deprecated 5.5.0 |
| | 343 | */ |
| | 344 | window.setPostThumbnailL10n = window.setPostThumbnailL10n || { |
| | 345 | setThumbnail: __( 'Use as featured image' ), |
| | 346 | saving: __( 'Saving…' ), |
| | 347 | error: __( 'Could not set that as the thumbnail image. Try a different attachment.' ), |
| | 348 | done: __( 'Done' ) |
| | 349 | }; |
| | 350 | |
| | 351 | window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n ); |
| | 352 | |