From c6f7e0f155a4610116098a8872945207d0225f8f Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Wed, 14 Oct 2020 21:13:08 +0000 Subject: [PATCH] I18N: Use `wp.i18n` for translatable strings in `wp-admin/js/dashboard.js`. * Deprecate the `l10n` property on `communityEventsData`. * Introduce `version` parameter for `deprecateL10nObject` and backfill the version for deprecated objects in 5.5.0. * Add a noop version of `deprecateL10nObject` for QUnit testing. Fixes #51498. Built from https://develop.svn.wordpress.org/trunk@49151 git-svn-id: http://core.svn.wordpress.org/trunk@48913 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/common.js | 40 +++++++++-------- wp-admin/js/common.min.js | 2 +- wp-admin/js/dashboard.js | 60 +++++++++++++++++++++++--- wp-admin/js/dashboard.min.js | 2 +- wp-admin/js/theme-plugin-editor.js | 2 +- wp-admin/js/theme-plugin-editor.min.js | 2 +- wp-admin/js/updates.js | 2 +- wp-admin/js/updates.min.js | 2 +- wp-admin/js/widgets.js | 2 +- wp-admin/js/widgets.min.js | 2 +- wp-includes/script-loader.php | 28 ------------ wp-includes/version.php | 2 +- 12 files changed, 83 insertions(+), 63 deletions(-) diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index ef92097f66..3832bcac2c 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -55,13 +55,15 @@ function deprecatedProperty( propName, version, replacement ) { * Deprecate all properties on an object. * * @since 5.5.1 + * @since 5.6.0 Added the `version` parameter. * * @param {string} name The name of the object, i.e. commonL10n. * @param {object} l10nObject The object to deprecate the properties on. + * @param {string} version The version of WordPress that deprecated the property. * * @return {object} The object with all its properties deprecated. */ -function deprecateL10nObject( name, l10nObject ) { +function deprecateL10nObject( name, l10nObject, version ) { var deprecatedObject = {}; Object.keys( l10nObject ).forEach( function( key ) { @@ -70,12 +72,12 @@ function deprecateL10nObject( name, l10nObject ) { if ( 'object' === typeof prop ) { Object.defineProperty( deprecatedObject, key, { get: function() { - deprecatedProperty( propName, '5.5.0', prop.alternative ); + deprecatedProperty( propName, version, prop.alternative ); return prop.func(); } } ); } else { Object.defineProperty( deprecatedObject, key, { get: function() { - deprecatedProperty( propName, '5.5.0', 'wp.i18n' ); + deprecatedProperty( propName, version, 'wp.i18n' ); return prop; } } ); } @@ -99,7 +101,7 @@ window.commonL10n = window.commonL10n || { expandMenu: '' }; -window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n ); +window.commonL10n = deprecateL10nObject( 'commonL10n', window.commonL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -111,7 +113,7 @@ window.wpPointerL10n = window.wpPointerL10n || { dismiss: '' }; -window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n ); +window.wpPointerL10n = deprecateL10nObject( 'wpPointerL10n', window.wpPointerL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -129,7 +131,7 @@ window.userProfileL10n = window.userProfileL10n || { ariaHide: '' }; -window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n ); +window.userProfileL10n = deprecateL10nObject( 'userProfileL10n', window.userProfileL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -148,7 +150,7 @@ window.privacyToolsL10n = window.privacyToolsL10n || { exportError: '' }; -window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n ); +window.privacyToolsL10n = deprecateL10nObject( 'privacyToolsL10n', window.privacyToolsL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -160,7 +162,7 @@ window.authcheckL10n = { beforeunload: '' }; -window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n ); +window.authcheckL10n = window.authcheckL10n || deprecateL10nObject( 'authcheckL10n', window.authcheckL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -173,7 +175,7 @@ window.tagsl10n = { broken: '' }; -window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n ); +window.tagsl10n = window.tagsl10n || deprecateL10nObject( 'tagsl10n', window.tagsl10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -198,7 +200,7 @@ window.adminCommentsL10n = window.adminCommentsL10n || { docTitleCommentsCount: '' }; -window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n ); +window.adminCommentsL10n = deprecateL10nObject( 'adminCommentsL10n', window.adminCommentsL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -214,7 +216,7 @@ window.tagsSuggestL10n = window.tagsSuggestL10n || { termRemoved: '' }; -window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n ); +window.tagsSuggestL10n = deprecateL10nObject( 'tagsSuggestL10n', window.tagsSuggestL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -231,7 +233,7 @@ window.wpColorPickerL10n = window.wpColorPickerL10n || { defaultLabel: '' }; -window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n ); +window.wpColorPickerL10n = deprecateL10nObject( 'wpColorPickerL10n', window.wpColorPickerL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -243,7 +245,7 @@ window.attachMediaBoxL10n = window.attachMediaBoxL10n || { error: '' }; -window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n ); +window.attachMediaBoxL10n = deprecateL10nObject( 'attachMediaBoxL10n', window.attachMediaBoxL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -276,7 +278,7 @@ window.postL10n = window.postL10n || { permalinkSaved: '' }; -window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n ); +window.postL10n = deprecateL10nObject( 'postL10n', window.postL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -292,7 +294,7 @@ window.inlineEditL10n = window.inlineEditL10n || { saved: '' }; -window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n ); +window.inlineEditL10n = deprecateL10nObject( 'inlineEditL10n', window.inlineEditL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -306,7 +308,7 @@ window.plugininstallL10n = window.plugininstallL10n || { ays: '' }; -window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n ); +window.plugininstallL10n = deprecateL10nObject( 'plugininstallL10n', window.plugininstallL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -321,7 +323,7 @@ window.navMenuL10n = window.navMenuL10n || { untitled: '' }; -window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n ); +window.navMenuL10n = deprecateL10nObject( 'navMenuL10n', window.navMenuL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -334,7 +336,7 @@ window.commentL10n = window.commentL10n || { dateFormat: '' }; -window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n ); +window.commentL10n = deprecateL10nObject( 'commentL10n', window.commentL10n, '5.5.0' ); /** * Removed in 5.5.0, needed for back-compatibility. @@ -349,7 +351,7 @@ window.setPostThumbnailL10n = window.setPostThumbnailL10n || { done: '' }; -window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n ); +window.setPostThumbnailL10n = deprecateL10nObject( 'setPostThumbnailL10n', window.setPostThumbnailL10n, '5.5.0' ); /** * Removed in 3.3.0, needed for back-compatibility. diff --git a/wp-admin/js/common.min.js b/wp-admin/js/common.min.js index 89085dfb39..7b97a3ceb2 100644 --- a/wp-admin/js/common.min.js +++ b/wp-admin/js/common.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(W,$){var Q=W(document),H=W($),V=W(document.body),q=wp.i18n.__,o=wp.i18n.sprintf;function a(e,t,n){var i;i=void 0!==n?o(q("%1$s is deprecated since version %2$s! Use %3$s instead."),e,t,n):o(q("%1$s is deprecated since version %2$s with no alternative available."),e,t),$.console.warn(i)}function e(i,o){var s={};return Object.keys(o).forEach(function(e){var t=o[e],n=i+"."+e;"object"==typeof t?Object.defineProperty(s,e,{get:function(){return a(n,"5.5.0",t.alternative),t.func()}}):Object.defineProperty(s,e,{get:function(){return a(n,"5.5.0","wp.i18n"),t}})}),s}$.wp.deprecateL10nObject=e,$.commonL10n=$.commonL10n||{warnDelete:"",dismiss:"",collapseMenu:"",expandMenu:""},$.commonL10n=e("commonL10n",$.commonL10n),$.wpPointerL10n=$.wpPointerL10n||{dismiss:""},$.wpPointerL10n=e("wpPointerL10n",$.wpPointerL10n),$.userProfileL10n=$.userProfileL10n||{warn:"",warnWeak:"",show:"",hide:"",cancel:"",ariaShow:"",ariaHide:""},$.userProfileL10n=e("userProfileL10n",$.userProfileL10n),$.privacyToolsL10n=$.privacyToolsL10n||{noDataFound:"",foundAndRemoved:"",noneRemoved:"",someNotRemoved:"",removalError:"",emailSent:"",noExportFile:"",exportError:""},$.privacyToolsL10n=e("privacyToolsL10n",$.privacyToolsL10n),$.authcheckL10n={beforeunload:""},$.authcheckL10n=$.authcheckL10n||e("authcheckL10n",$.authcheckL10n),$.tagsl10n={noPerm:"",broken:""},$.tagsl10n=$.tagsl10n||e("tagsl10n",$.tagsl10n),$.adminCommentsL10n=$.adminCommentsL10n||{hotkeys_highlight_first:{alternative:"window.adminCommentsSettings.hotkeys_highlight_first",func:function(){return $.adminCommentsSettings.hotkeys_highlight_first}},hotkeys_highlight_last:{alternative:"window.adminCommentsSettings.hotkeys_highlight_last",func:function(){return $.adminCommentsSettings.hotkeys_highlight_last}},replyApprove:"",reply:"",warnQuickEdit:"",warnCommentChanges:"",docTitleComments:"",docTitleCommentsCount:""},$.adminCommentsL10n=e("adminCommentsL10n",$.adminCommentsL10n),$.tagsSuggestL10n=$.tagsSuggestL10n||{tagDelimiter:"",removeTerm:"",termSelected:"",termAdded:"",termRemoved:""},$.tagsSuggestL10n=e("tagsSuggestL10n",$.tagsSuggestL10n),$.wpColorPickerL10n=$.wpColorPickerL10n||{clear:"",clearAriaLabel:"",defaultString:"",defaultAriaLabel:"",pick:"",defaultLabel:""},$.wpColorPickerL10n=e("wpColorPickerL10n",$.wpColorPickerL10n),$.attachMediaBoxL10n=$.attachMediaBoxL10n||{error:""},$.attachMediaBoxL10n=e("attachMediaBoxL10n",$.attachMediaBoxL10n),$.postL10n=$.postL10n||{ok:"",cancel:"",publishOn:"",publishOnFuture:"",publishOnPast:"",dateFormat:"",showcomm:"",endcomm:"",publish:"",schedule:"",update:"",savePending:"",saveDraft:"",private:"",public:"",publicSticky:"",password:"",privatelyPublished:"",published:"",saveAlert:"",savingText:"",permalinkSaved:""},$.postL10n=e("postL10n",$.postL10n),$.inlineEditL10n=$.inlineEditL10n||{error:"",ntdeltitle:"",notitle:"",comma:"",saved:""},$.inlineEditL10n=e("inlineEditL10n",$.inlineEditL10n),$.plugininstallL10n=$.plugininstallL10n||{plugin_information:"",plugin_modal_label:"",ays:""},$.plugininstallL10n=e("plugininstallL10n",$.plugininstallL10n),$.navMenuL10n=$.navMenuL10n||{noResultsFound:"",warnDeleteMenu:"",saveAlert:"",untitled:""},$.navMenuL10n=e("navMenuL10n",$.navMenuL10n),$.commentL10n=$.commentL10n||{submittedOn:"",dateFormat:""},$.commentL10n=e("commentL10n",$.commentL10n),$.setPostThumbnailL10n=$.setPostThumbnailL10n||{setThumbnail:"",saving:"",error:"",done:""},$.setPostThumbnailL10n=e("setPostThumbnailL10n",$.setPostThumbnailL10n),$.adminMenu={init:function(){},fold:function(){},restoreMenuState:function(){},toggle:function(){},favorites:function(){}},$.columns={init:function(){var n=this;W(".hide-column-tog","#adv-settings").click(function(){var e=W(this),t=e.val();e.prop("checked")?n.checked(t):n.unchecked(t),columns.saveManageColumnsState()})},saveManageColumnsState:function(){var e=this.hidden();W.post(ajaxurl,{action:"hidden-columns",hidden:e,screenoptionnonce:W("#screenoptionnonce").val(),page:pagenow})},checked:function(e){W(".column-"+e).removeClass("hidden"),this.colSpanChange(1)},unchecked:function(e){W(".column-"+e).addClass("hidden"),this.colSpanChange(-1)},hidden:function(){return W(".manage-column[id]").filter(".hidden").map(function(){return this.id}).get().join(",")},useCheckboxesForHidden:function(){this.hidden=function(){return W(".hide-column-tog").not(":checked").map(function(){var e=this.id;return e.substring(e,e.length-5)}).get().join(",")}},colSpanChange:function(e){var t,n=W("table").find(".colspanchange");n.length&&(t=parseInt(n.attr("colspan"),10)+e,n.attr("colspan",t.toString()))}},Q.ready(function(){columns.init()}),$.validateForm=function(e){return!W(e).find(".form-required").filter(function(){return""===W(":input:visible",this).val()}).addClass("form-invalid").find(":input:visible").change(function(){W(this).closest(".form-invalid").removeClass("form-invalid")}).length},$.showNotice={warn:function(){return!!confirm(q("You are about to permanently delete these items from your site.\nThis action cannot be undone.\n'Cancel' to stop, 'OK' to delete."))},note:function(e){alert(e)}},$.screenMeta={element:null,toggles:null,page:null,init:function(){this.element=W("#screen-meta"),this.toggles=W("#screen-meta-links").find(".show-settings"),this.page=W("#wpcontent"),this.toggles.click(this.toggleEvent)},toggleEvent:function(){var e=W("#"+W(this).attr("aria-controls"));e.length&&(e.is(":visible")?screenMeta.close(e,W(this)):screenMeta.open(e,W(this)))},open:function(e,t){W("#screen-meta-links").find(".screen-meta-toggle").not(t.parent()).css("visibility","hidden"),e.parent().show(),e.slideDown("fast",function(){e.focus(),t.addClass("screen-meta-active").attr("aria-expanded",!0)}),Q.trigger("screen:options:open")},close:function(e,t){e.slideUp("fast",function(){t.removeClass("screen-meta-active").attr("aria-expanded",!1),W(".screen-meta-toggle").css("visibility",""),e.parent().hide()}),Q.trigger("screen:options:close")}},W(".contextual-help-tabs").delegate("a","click",function(e){var t,n=W(this);if(e.preventDefault(),n.is(".active a"))return!1;W(".contextual-help-tabs .active").removeClass("active"),n.parent("li").addClass("active"),t=W(n.attr("href")),W(".help-tab-content").not(t).removeClass("active").hide(),t.addClass("active").show()});var t,r=!1,l=W("#permalink_structure"),n=W(".permalink-structure input:radio"),c=W("#custom_selection"),i=W(".form-table.permalink-structure .available-structure-tags button");function d(e){-1!==l.val().indexOf(e.text().trim())?(e.attr("data-label",e.attr("aria-label")),e.attr("aria-label",e.attr("data-used")),e.attr("aria-pressed",!0),e.addClass("active")):e.attr("data-label")&&(e.attr("aria-label",e.attr("data-label")),e.attr("aria-pressed",!1),e.removeClass("active"))}function s(){Q.trigger("wp-window-resized")}n.on("change",function(){"custom"!==this.value&&(l.val(this.value),i.each(function(){d(W(this))}))}),l.on("click input",function(){c.prop("checked",!0)}),l.on("focus",function(e){r=!0,W(this).off(e)}),i.each(function(){d(W(this))}),l.on("change",function(){i.each(function(){d(W(this))})}),i.on("click",function(){var e,t=l.val(),n=l[0].selectionStart,i=l[0].selectionEnd,o=W(this).text().trim(),s=W(this).attr("data-added");if(-1!==t.indexOf(o))return t=t.replace(o+"/",""),l.val("/"===t?"":t),W("#custom_selection_updated").text(s),void d(W(this));r||0!==n||0!==i||(n=i=t.length),c.prop("checked",!0),"/"!==t.substr(0,n).substr(-1)&&(o="/"+o),"/"!==t.substr(i,1)&&(o+="/"),l.val(t.substr(0,n)+o+t.substr(i)),W("#custom_selection_updated").text(s),d(W(this)),r&&l[0].setSelectionRange&&(e=(t.substr(0,n)+o).length,l[0].setSelectionRange(e,e),l.focus())}),Q.ready(function(){var n,i,o,s,e,t,a,r,l,c,d,u=!1,p=W("input.current-page"),m=p.val(),h=/iPhone|iPad|iPod/.test(navigator.userAgent),f=-1!==navigator.userAgent.indexOf("Android"),v=W("#adminmenuwrap"),b=W("#wpwrap"),g=W("#adminmenu"),w=W("#wp-responsive-overlay"),k=W("#wp-toolbar"),C=k.find('a[aria-haspopup="true"]'),L=W(".meta-box-sortables"),y=!1,x=W("#wpadminbar"),S=0,P=!1,T=!1,M=0,_=!1,D={window:H.height(),wpwrap:b.height(),adminbar:x.height(),menu:v.height()},E=W(".wp-header-end");function A(){var e=W("a.wp-has-current-submenu");"folded"===r?e.attr("aria-haspopup","true"):e.attr("aria-haspopup","false")}function O(e){var t,n,i,o,s,a,r=e.find(".wp-submenu");a=(o=e.offset().top)-(s=H.scrollTop())-30,n=60+(t=o+r.height()+1)-b.height(),(i=H.height()+s-50)');e.find(".screen-reader-text").text(q("Dismiss this notice.")),e.on("click.wp-dismiss-notice",function(e){e.preventDefault(),t.fadeTo(100,0,function(){t.slideUp(100,function(){t.remove()})})}),t.append(e)})}function R(){l.prop("disabled",""===c.map(function(){return W(this).val()}).get().join(""))}function U(e){var t=H.scrollTop(),n=!e||"scroll"!==e.type;if(!h&&!g.data("wp-responsive"))if(D.menu+D.adminbarD.wpwrap)I();else{if(_=!0,D.menu+D.adminbar>D.window){if(t<0)return void(P||(T=!(P=!0),v.css({position:"fixed",top:"",bottom:""})));if(t+D.window>Q.height()-1)return void(T||(P=!(T=!0),v.css({position:"fixed",top:"",bottom:0})));St+D.window&&(M=t),v.css({position:"absolute",top:M,bottom:""})):!P&&v.offset().top>=t+D.adminbar&&(P=!0,v.css({position:"fixed",top:"",bottom:""})):n&&(P=T=!1,0<(M=t+D.window-D.menu-D.adminbar-1)?v.css({position:"absolute",top:M,bottom:""}):I())}S=t}}function F(){D={window:H.height(),wpwrap:b.height(),adminbar:x.height(),menu:v.height()}}function I(){!h&&_&&(P=T=_=!1,v.css({position:"",top:"",bottom:""}))}function K(){F(),g.data("wp-responsive")?(V.removeClass("sticky-menu"),I()):D.menu+D.adminbar>D.window?(U(),V.removeClass("sticky-menu")):(V.addClass("sticky-menu"),I())}function z(){W(".aria-button-if-js").attr("role","button")}function B(){var e=!1;return $.innerWidth&&(e=Math.max($.innerWidth,document.documentElement.clientWidth)),e}function N(){var e=B()||961;r=e<=782?"responsive":V.hasClass("folded")||V.hasClass("auto-fold")&&e<=960&&782 tr > .check-column :checkbox",function(e){if("undefined"==e.shiftKey)return!0;if(e.shiftKey){if(!u)return!0;n=W(u).closest("form").find(":checkbox").filter(":visible:enabled"),i=n.index(u),o=n.index(this),s=W(this).prop("checked"),0 a",function(e){g.data("wp-responsive")&&(W(this).parent("li").toggleClass("selected"),e.preventDefault())}),e.trigger(),Q.on("wp-window-resized.wp-responsive",W.proxy(this.trigger,this)),H.on("load.wp-responsive",this.maybeDisableSortables),Q.on("postbox-toggled",this.maybeDisableSortables),W("#screen-options-wrap input").on("click",this.maybeDisableSortables)},maybeDisableSortables:function(){(-1').insertAfter("#wpcontent").hide().on("click.wp-responsive",function(){k.find(".menupop.hover").removeClass("hover"),W(this).hide()})),C.on("click.wp-responsive",function(){w.show()})},disableOverlay:function(){C.off("click.wp-responsive"),w.hide()},disableSortables:function(){if(L.length)try{L.sortable("disable"),L.find(".ui-sortable-handle").addClass("is-non-sortable")}catch(e){}},enableSortables:function(){if(L.length)try{L.sortable("enable"),L.find(".ui-sortable-handle").removeClass("is-non-sortable")}catch(e){}}},W(document).ajaxComplete(function(){z()}),Q.on("wp-window-resized.set-menu-state",N),Q.on("wp-menu-state-set wp-collapse-menu",function(e,t){var n,i,o=W("#collapse-button");i="folded"===t.state?(n="false",q("Expand Main menu")):(n="true",q("Collapse Main menu")),o.attr({"aria-expanded":n,"aria-label":i})}),$.wpResponsive.init(),K(),N(),A(),j(),z(),Q.on("wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu",K),W(".wp-initial-focus").focus(),V.on("click",".js-update-details-toggle",function(){var e=W(this).closest(".js-update-details"),t=W("#"+e.data("update-details"));t.hasClass("update-details-moved")||t.insertAfter(e).addClass("update-details-moved"),t.toggle(),W(this).attr("aria-expanded",t.is(":visible"))})}),Q.ready(function(e){var t,n;V.hasClass("update-php")&&(t=e("a.update-from-upload-overwrite"),n=e(".update-from-upload-expired"),t.length&&n.length&&$.setTimeout(function(){t.hide(),n.removeClass("hidden"),$.wp&&$.wp.a11y&&$.wp.a11y.speak(n.text())},714e4))}),H.on("resize.wp-fire-once",function(){$.clearTimeout(t),t=$.setTimeout(s,200)}),function(){if("-ms-user-select"in document.documentElement.style&&navigator.userAgent.match(/IEMobile\/10\.0/)){var e=document.createElement("style");e.appendChild(document.createTextNode("@-ms-viewport{width:auto!important}")),document.getElementsByTagName("head")[0].appendChild(e)}}()}(jQuery,window); \ No newline at end of file +!function(W,$){var Q=W(document),H=W($),V=W(document.body),q=wp.i18n.__,o=wp.i18n.sprintf;function r(e,t,n){var i;i=void 0!==n?o(q("%1$s is deprecated since version %2$s! Use %3$s instead."),e,t,n):o(q("%1$s is deprecated since version %2$s with no alternative available."),e,t),$.console.warn(i)}function e(i,o,s){var a={};return Object.keys(o).forEach(function(e){var t=o[e],n=i+"."+e;"object"==typeof t?Object.defineProperty(a,e,{get:function(){return r(n,s,t.alternative),t.func()}}):Object.defineProperty(a,e,{get:function(){return r(n,s,"wp.i18n"),t}})}),a}$.wp.deprecateL10nObject=e,$.commonL10n=$.commonL10n||{warnDelete:"",dismiss:"",collapseMenu:"",expandMenu:""},$.commonL10n=e("commonL10n",$.commonL10n,"5.5.0"),$.wpPointerL10n=$.wpPointerL10n||{dismiss:""},$.wpPointerL10n=e("wpPointerL10n",$.wpPointerL10n,"5.5.0"),$.userProfileL10n=$.userProfileL10n||{warn:"",warnWeak:"",show:"",hide:"",cancel:"",ariaShow:"",ariaHide:""},$.userProfileL10n=e("userProfileL10n",$.userProfileL10n,"5.5.0"),$.privacyToolsL10n=$.privacyToolsL10n||{noDataFound:"",foundAndRemoved:"",noneRemoved:"",someNotRemoved:"",removalError:"",emailSent:"",noExportFile:"",exportError:""},$.privacyToolsL10n=e("privacyToolsL10n",$.privacyToolsL10n,"5.5.0"),$.authcheckL10n={beforeunload:""},$.authcheckL10n=$.authcheckL10n||e("authcheckL10n",$.authcheckL10n,"5.5.0"),$.tagsl10n={noPerm:"",broken:""},$.tagsl10n=$.tagsl10n||e("tagsl10n",$.tagsl10n,"5.5.0"),$.adminCommentsL10n=$.adminCommentsL10n||{hotkeys_highlight_first:{alternative:"window.adminCommentsSettings.hotkeys_highlight_first",func:function(){return $.adminCommentsSettings.hotkeys_highlight_first}},hotkeys_highlight_last:{alternative:"window.adminCommentsSettings.hotkeys_highlight_last",func:function(){return $.adminCommentsSettings.hotkeys_highlight_last}},replyApprove:"",reply:"",warnQuickEdit:"",warnCommentChanges:"",docTitleComments:"",docTitleCommentsCount:""},$.adminCommentsL10n=e("adminCommentsL10n",$.adminCommentsL10n,"5.5.0"),$.tagsSuggestL10n=$.tagsSuggestL10n||{tagDelimiter:"",removeTerm:"",termSelected:"",termAdded:"",termRemoved:""},$.tagsSuggestL10n=e("tagsSuggestL10n",$.tagsSuggestL10n,"5.5.0"),$.wpColorPickerL10n=$.wpColorPickerL10n||{clear:"",clearAriaLabel:"",defaultString:"",defaultAriaLabel:"",pick:"",defaultLabel:""},$.wpColorPickerL10n=e("wpColorPickerL10n",$.wpColorPickerL10n,"5.5.0"),$.attachMediaBoxL10n=$.attachMediaBoxL10n||{error:""},$.attachMediaBoxL10n=e("attachMediaBoxL10n",$.attachMediaBoxL10n,"5.5.0"),$.postL10n=$.postL10n||{ok:"",cancel:"",publishOn:"",publishOnFuture:"",publishOnPast:"",dateFormat:"",showcomm:"",endcomm:"",publish:"",schedule:"",update:"",savePending:"",saveDraft:"",private:"",public:"",publicSticky:"",password:"",privatelyPublished:"",published:"",saveAlert:"",savingText:"",permalinkSaved:""},$.postL10n=e("postL10n",$.postL10n,"5.5.0"),$.inlineEditL10n=$.inlineEditL10n||{error:"",ntdeltitle:"",notitle:"",comma:"",saved:""},$.inlineEditL10n=e("inlineEditL10n",$.inlineEditL10n,"5.5.0"),$.plugininstallL10n=$.plugininstallL10n||{plugin_information:"",plugin_modal_label:"",ays:""},$.plugininstallL10n=e("plugininstallL10n",$.plugininstallL10n,"5.5.0"),$.navMenuL10n=$.navMenuL10n||{noResultsFound:"",warnDeleteMenu:"",saveAlert:"",untitled:""},$.navMenuL10n=e("navMenuL10n",$.navMenuL10n,"5.5.0"),$.commentL10n=$.commentL10n||{submittedOn:"",dateFormat:""},$.commentL10n=e("commentL10n",$.commentL10n,"5.5.0"),$.setPostThumbnailL10n=$.setPostThumbnailL10n||{setThumbnail:"",saving:"",error:"",done:""},$.setPostThumbnailL10n=e("setPostThumbnailL10n",$.setPostThumbnailL10n,"5.5.0"),$.adminMenu={init:function(){},fold:function(){},restoreMenuState:function(){},toggle:function(){},favorites:function(){}},$.columns={init:function(){var n=this;W(".hide-column-tog","#adv-settings").click(function(){var e=W(this),t=e.val();e.prop("checked")?n.checked(t):n.unchecked(t),columns.saveManageColumnsState()})},saveManageColumnsState:function(){var e=this.hidden();W.post(ajaxurl,{action:"hidden-columns",hidden:e,screenoptionnonce:W("#screenoptionnonce").val(),page:pagenow})},checked:function(e){W(".column-"+e).removeClass("hidden"),this.colSpanChange(1)},unchecked:function(e){W(".column-"+e).addClass("hidden"),this.colSpanChange(-1)},hidden:function(){return W(".manage-column[id]").filter(".hidden").map(function(){return this.id}).get().join(",")},useCheckboxesForHidden:function(){this.hidden=function(){return W(".hide-column-tog").not(":checked").map(function(){var e=this.id;return e.substring(e,e.length-5)}).get().join(",")}},colSpanChange:function(e){var t,n=W("table").find(".colspanchange");n.length&&(t=parseInt(n.attr("colspan"),10)+e,n.attr("colspan",t.toString()))}},Q.ready(function(){columns.init()}),$.validateForm=function(e){return!W(e).find(".form-required").filter(function(){return""===W(":input:visible",this).val()}).addClass("form-invalid").find(":input:visible").change(function(){W(this).closest(".form-invalid").removeClass("form-invalid")}).length},$.showNotice={warn:function(){return!!confirm(q("You are about to permanently delete these items from your site.\nThis action cannot be undone.\n'Cancel' to stop, 'OK' to delete."))},note:function(e){alert(e)}},$.screenMeta={element:null,toggles:null,page:null,init:function(){this.element=W("#screen-meta"),this.toggles=W("#screen-meta-links").find(".show-settings"),this.page=W("#wpcontent"),this.toggles.click(this.toggleEvent)},toggleEvent:function(){var e=W("#"+W(this).attr("aria-controls"));e.length&&(e.is(":visible")?screenMeta.close(e,W(this)):screenMeta.open(e,W(this)))},open:function(e,t){W("#screen-meta-links").find(".screen-meta-toggle").not(t.parent()).css("visibility","hidden"),e.parent().show(),e.slideDown("fast",function(){e.focus(),t.addClass("screen-meta-active").attr("aria-expanded",!0)}),Q.trigger("screen:options:open")},close:function(e,t){e.slideUp("fast",function(){t.removeClass("screen-meta-active").attr("aria-expanded",!1),W(".screen-meta-toggle").css("visibility",""),e.parent().hide()}),Q.trigger("screen:options:close")}},W(".contextual-help-tabs").delegate("a","click",function(e){var t,n=W(this);if(e.preventDefault(),n.is(".active a"))return!1;W(".contextual-help-tabs .active").removeClass("active"),n.parent("li").addClass("active"),t=W(n.attr("href")),W(".help-tab-content").not(t).removeClass("active").hide(),t.addClass("active").show()});var t,a=!1,l=W("#permalink_structure"),n=W(".permalink-structure input:radio"),c=W("#custom_selection"),i=W(".form-table.permalink-structure .available-structure-tags button");function d(e){-1!==l.val().indexOf(e.text().trim())?(e.attr("data-label",e.attr("aria-label")),e.attr("aria-label",e.attr("data-used")),e.attr("aria-pressed",!0),e.addClass("active")):e.attr("data-label")&&(e.attr("aria-label",e.attr("data-label")),e.attr("aria-pressed",!1),e.removeClass("active"))}function s(){Q.trigger("wp-window-resized")}n.on("change",function(){"custom"!==this.value&&(l.val(this.value),i.each(function(){d(W(this))}))}),l.on("click input",function(){c.prop("checked",!0)}),l.on("focus",function(e){a=!0,W(this).off(e)}),i.each(function(){d(W(this))}),l.on("change",function(){i.each(function(){d(W(this))})}),i.on("click",function(){var e,t=l.val(),n=l[0].selectionStart,i=l[0].selectionEnd,o=W(this).text().trim(),s=W(this).attr("data-added");if(-1!==t.indexOf(o))return t=t.replace(o+"/",""),l.val("/"===t?"":t),W("#custom_selection_updated").text(s),void d(W(this));a||0!==n||0!==i||(n=i=t.length),c.prop("checked",!0),"/"!==t.substr(0,n).substr(-1)&&(o="/"+o),"/"!==t.substr(i,1)&&(o+="/"),l.val(t.substr(0,n)+o+t.substr(i)),W("#custom_selection_updated").text(s),d(W(this)),a&&l[0].setSelectionRange&&(e=(t.substr(0,n)+o).length,l[0].setSelectionRange(e,e),l.focus())}),Q.ready(function(){var n,i,o,s,e,t,a,r,l,c,d,u=!1,p=W("input.current-page"),m=p.val(),h=/iPhone|iPad|iPod/.test(navigator.userAgent),f=-1!==navigator.userAgent.indexOf("Android"),v=W("#adminmenuwrap"),b=W("#wpwrap"),g=W("#adminmenu"),w=W("#wp-responsive-overlay"),k=W("#wp-toolbar"),C=k.find('a[aria-haspopup="true"]'),L=W(".meta-box-sortables"),y=!1,x=W("#wpadminbar"),S=0,P=!1,T=!1,M=0,_=!1,D={window:H.height(),wpwrap:b.height(),adminbar:x.height(),menu:v.height()},E=W(".wp-header-end");function A(){var e=W("a.wp-has-current-submenu");"folded"===r?e.attr("aria-haspopup","true"):e.attr("aria-haspopup","false")}function O(e){var t,n,i,o,s,a,r=e.find(".wp-submenu");a=(o=e.offset().top)-(s=H.scrollTop())-30,n=60+(t=o+r.height()+1)-b.height(),(i=H.height()+s-50)');e.find(".screen-reader-text").text(q("Dismiss this notice.")),e.on("click.wp-dismiss-notice",function(e){e.preventDefault(),t.fadeTo(100,0,function(){t.slideUp(100,function(){t.remove()})})}),t.append(e)})}function R(){l.prop("disabled",""===c.map(function(){return W(this).val()}).get().join(""))}function U(e){var t=H.scrollTop(),n=!e||"scroll"!==e.type;if(!h&&!g.data("wp-responsive"))if(D.menu+D.adminbarD.wpwrap)I();else{if(_=!0,D.menu+D.adminbar>D.window){if(t<0)return void(P||(T=!(P=!0),v.css({position:"fixed",top:"",bottom:""})));if(t+D.window>Q.height()-1)return void(T||(P=!(T=!0),v.css({position:"fixed",top:"",bottom:0})));St+D.window&&(M=t),v.css({position:"absolute",top:M,bottom:""})):!P&&v.offset().top>=t+D.adminbar&&(P=!0,v.css({position:"fixed",top:"",bottom:""})):n&&(P=T=!1,0<(M=t+D.window-D.menu-D.adminbar-1)?v.css({position:"absolute",top:M,bottom:""}):I())}S=t}}function F(){D={window:H.height(),wpwrap:b.height(),adminbar:x.height(),menu:v.height()}}function I(){!h&&_&&(P=T=_=!1,v.css({position:"",top:"",bottom:""}))}function K(){F(),g.data("wp-responsive")?(V.removeClass("sticky-menu"),I()):D.menu+D.adminbar>D.window?(U(),V.removeClass("sticky-menu")):(V.addClass("sticky-menu"),I())}function z(){W(".aria-button-if-js").attr("role","button")}function B(){var e=!1;return $.innerWidth&&(e=Math.max($.innerWidth,document.documentElement.clientWidth)),e}function N(){var e=B()||961;r=e<=782?"responsive":V.hasClass("folded")||V.hasClass("auto-fold")&&e<=960&&782 tr > .check-column :checkbox",function(e){if("undefined"==e.shiftKey)return!0;if(e.shiftKey){if(!u)return!0;n=W(u).closest("form").find(":checkbox").filter(":visible:enabled"),i=n.index(u),o=n.index(this),s=W(this).prop("checked"),0 a",function(e){g.data("wp-responsive")&&(W(this).parent("li").toggleClass("selected"),e.preventDefault())}),e.trigger(),Q.on("wp-window-resized.wp-responsive",W.proxy(this.trigger,this)),H.on("load.wp-responsive",this.maybeDisableSortables),Q.on("postbox-toggled",this.maybeDisableSortables),W("#screen-options-wrap input").on("click",this.maybeDisableSortables)},maybeDisableSortables:function(){(-1').insertAfter("#wpcontent").hide().on("click.wp-responsive",function(){k.find(".menupop.hover").removeClass("hover"),W(this).hide()})),C.on("click.wp-responsive",function(){w.show()})},disableOverlay:function(){C.off("click.wp-responsive"),w.hide()},disableSortables:function(){if(L.length)try{L.sortable("disable"),L.find(".ui-sortable-handle").addClass("is-non-sortable")}catch(e){}},enableSortables:function(){if(L.length)try{L.sortable("enable"),L.find(".ui-sortable-handle").removeClass("is-non-sortable")}catch(e){}}},W(document).ajaxComplete(function(){z()}),Q.on("wp-window-resized.set-menu-state",N),Q.on("wp-menu-state-set wp-collapse-menu",function(e,t){var n,i,o=W("#collapse-button");i="folded"===t.state?(n="false",q("Expand Main menu")):(n="true",q("Collapse Main menu")),o.attr({"aria-expanded":n,"aria-label":i})}),$.wpResponsive.init(),K(),N(),A(),j(),z(),Q.on("wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu",K),W(".wp-initial-focus").focus(),V.on("click",".js-update-details-toggle",function(){var e=W(this).closest(".js-update-details"),t=W("#"+e.data("update-details"));t.hasClass("update-details-moved")||t.insertAfter(e).addClass("update-details-moved"),t.toggle(),W(this).attr("aria-expanded",t.is(":visible"))})}),Q.ready(function(e){var t,n;V.hasClass("update-php")&&(t=e("a.update-from-upload-overwrite"),n=e(".update-from-upload-expired"),t.length&&n.length&&$.setTimeout(function(){t.hide(),n.removeClass("hidden"),$.wp&&$.wp.a11y&&$.wp.a11y.speak(n.text())},714e4))}),H.on("resize.wp-fire-once",function(){$.clearTimeout(t),t=$.setTimeout(s,200)}),function(){if("-ms-user-select"in document.documentElement.style&&navigator.userAgent.match(/IEMobile\/10\.0/)){var e=document.createElement("style");e.appendChild(document.createTextNode("@-ms-viewport{width:auto!important}")),document.getElementsByTagName("head")[0].appendChild(e)}}()}(jQuery,window); \ No newline at end of file diff --git a/wp-admin/js/dashboard.js b/wp-admin/js/dashboard.js index 87a8493128..87a2191967 100644 --- a/wp-admin/js/dashboard.js +++ b/wp-admin/js/dashboard.js @@ -5,6 +5,7 @@ /* global pagenow, ajaxurl, postboxes, wpActiveEditor:true, ajaxWidgets */ /* global ajaxPopulateWidgets, quickPressLoad, */ window.wp = window.wp || {}; +window.communityEventsData = window.communityEventsData || {}; /** * Initializes the dashboard widget functionality. @@ -265,7 +266,7 @@ jQuery(document).ready( function($) { jQuery( function( $ ) { 'use strict'; - var communityEventsData = window.communityEventsData || {}, + var communityEventsData = window.communityEventsData, dateI18n = wp.date.dateI18n, format = wp.date.format, sprintf = wp.i18n.sprintf, @@ -466,7 +467,6 @@ jQuery( function( $ ) { renderEventsTemplate: function( templateParams, initiatedBy ) { var template, elementVisibility, - l10nPlaceholder = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc. $toggleButton = $( '.community-events-toggle-location' ), $locationMessage = $( '#community-events-location-message' ), $results = $( '.community-events-results' ); @@ -505,7 +505,7 @@ jQuery( function( $ ) { * If the API determined the location by geolocating an IP, it will * provide events, but not a specific location. */ - $locationMessage.text( communityEventsData.l10n.attend_event_near_generic ); + $locationMessage.text( __( 'Attend an upcoming event near you.' ) ); if ( templateParams.events.length ) { template = wp.template( 'community-events-event-list' ); @@ -532,7 +532,14 @@ jQuery( function( $ ) { } if ( 'user' === initiatedBy ) { - wp.a11y.speak( communityEventsData.l10n.city_updated.replace( l10nPlaceholder, templateParams.location.description ), 'assertive' ); + wp.a11y.speak( + sprintf( + /* translators: %s: The name of a city. */ + __( 'City updated. Listing events near %s.' ), + templateParams.location.description + ), + 'assertive' + ); } elementVisibility['#community-events-location-message'] = true; @@ -542,7 +549,28 @@ jQuery( function( $ ) { } else if ( templateParams.unknownCity ) { template = wp.template( 'community-events-could-not-locate' ); $( '.community-events-could-not-locate' ).html( template( templateParams ) ); - wp.a11y.speak( communityEventsData.l10n.could_not_locate_city.replace( l10nPlaceholder, templateParams.unknownCity ) ); + wp.a11y.speak( + sprintf( + /* + * These specific examples were chosen to highlight the fact that a + * state is not needed, even for cities whose name is not unique. + * It would be too cumbersome to include that in the instructions + * to the user, so it's left as an implication. + */ + /* + * translators: %s is the name of the city we couldn't locate. + * Replace the examples with cities related to your locale. Test that + * they match the expected location and have upcoming events before + * including them. If no cities related to your locale have events, + * then use cities related to your locale that would be recognizable + * to most users. Use only the city name itself, without any region + * or country. Use the endonym (native locale name) instead of the + * English name if possible. + */ + __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ), + templateParams.unknownCity + ) + ); elementVisibility['.community-events-errors'] = true; elementVisibility['.community-events-could-not-locate'] = true; @@ -554,12 +582,12 @@ jQuery( function( $ ) { * Showing error messages for an event that user isn't aware of * could be confusing or unnecessarily distracting. */ - wp.a11y.speak( communityEventsData.l10n.error_occurred_please_try_again ); + wp.a11y.speak( __( 'An error occurred. Please try again.' ) ); elementVisibility['.community-events-errors'] = true; elementVisibility['.community-events-error-occurred'] = true; } else { - $locationMessage.text( communityEventsData.l10n.enter_closest_city ); + $locationMessage.text( __( 'Enter your closest city to find nearby events.' ) ); elementVisibility['#community-events-location-message'] = true; elementVisibility['.community-events-toggle-location'] = true; @@ -791,3 +819,21 @@ jQuery( function( $ ) { }); } }); + +/** + * Removed in 5.6.0, needed for back-compatibility. + * + * @since 4.8.0 + * @deprecated 5.6.0 + * + * @type {object} +*/ +window.communityEventsData.l10n = window.communityEventsData.l10n || { + enter_closest_city: '', + error_occurred_please_try_again: '', + attend_event_near_generic: '', + could_not_locate_city: '', + city_updated: '' +}; + +window.communityEventsData.l10n = window.wp.deprecateL10nObject( 'communityEventsData.l10n', window.communityEventsData.l10n, '5.6.0' ); diff --git a/wp-admin/js/dashboard.min.js b/wp-admin/js/dashboard.min.js index a51b6218a5..4ef316f291 100644 --- a/wp-admin/js/dashboard.min.js +++ b/wp-admin/js/dashboard.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -window.wp=window.wp||{},jQuery(document).ready(function(c){var t,n=c("#welcome-panel"),e=c("#wp_welcome_panel-hide");t=function(e){c.post(ajaxurl,{action:"update-welcome-panel",visible:e,welcomepanelnonce:c("#welcomepanelnonce").val()})},n.hasClass("hidden")&&e.prop("checked")&&n.removeClass("hidden"),c(".welcome-panel-close, .welcome-panel-dismiss a",n).click(function(e){e.preventDefault(),n.addClass("hidden"),t(0),c("#wp_welcome_panel-hide").prop("checked",!1)}),e.click(function(){n.toggleClass("hidden",!this.checked),t(this.checked?1:0)}),window.ajaxWidgets=["dashboard_primary"],window.ajaxPopulateWidgets=function(e){function t(e,t){var n,i=c("#"+t+" div.inside:visible").find(".widget-loading");i.length&&(n=i.parent(),setTimeout(function(){n.load(ajaxurl+"?action=dashboard-widgets&widget="+t+"&pagenow="+pagenow,"",function(){n.hide().slideDown("normal",function(){c(this).css("display","")})})},500*e))}e?(e=e.toString(),-1!==c.inArray(e,ajaxWidgets)&&t(0,e)):c.each(ajaxWidgets,t)},ajaxPopulateWidgets(),postboxes.add_postbox_toggles(pagenow,{pbshow:ajaxPopulateWidgets}),window.quickPressLoad=function(){var t,e=c("#quickpost-action");c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",!1),t=c("#quick-press").submit(function(e){e.preventDefault(),c("#dashboard_quick_press #publishing-action .spinner").show(),c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",!0),c.post(t.attr("action"),t.serializeArray(),function(e){c("#dashboard_quick_press .inside").html(e),c("#quick-press").removeClass("initial-form"),quickPressLoad(),function(){var e=c(".drafts ul li").first();e.css("background","#fffbe5"),setTimeout(function(){e.css("background","none")},1e3)}(),c("#title").focus()})}),c("#publish").click(function(){e.val("post-quickpress-publish")}),c("#quick-press").on("click focusin",function(){wpActiveEditor="content"}),function(){if(document.documentMode&&document.documentMode<9)return;c("body").append('');var i=c(".quick-draft-textarea-clone"),o=c("#content"),a=o.height(),s=c(window).height()-100;i.css({"font-family":o.css("font-family"),"font-size":o.css("font-size"),"line-height":o.css("line-height"),"padding-bottom":o.css("paddingBottom"),"padding-left":o.css("paddingLeft"),"padding-right":o.css("paddingRight"),"padding-top":o.css("paddingTop"),"white-space":"pre-wrap","word-wrap":"break-word",display:"none"}),o.on("focus input propertychange",function(){var e=c(this),t=e.val()+" ",n=i.css("width",e.css("width")).text(t).outerHeight()+2;o.css("overflow-y","auto"),n===a||s<=n&&s<=a||(a=s