From 4377e9a44e2c10ac66cb9cc49a4a3c8dff6a433f Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 7 Jul 2020 18:55:04 +0000 Subject: [PATCH] I18N: Use `wp.i18n` for translatable strings in `wp-admin/js/set-post-thumbnail.js`. This removes the usage of `wp_localize_script()` for passing translations to the script and instead adds the translatable strings in the script directly through the use of `wp.i18n` and its utilities. Props swissspidy, ocean90. See #20491. Fixes #50605. Built from https://develop.svn.wordpress.org/trunk@48396 git-svn-id: http://core.svn.wordpress.org/trunk@48165 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/post.js | 4 ++-- wp-admin/js/post.min.js | 2 +- wp-admin/js/set-post-thumbnail.js | 10 +++++----- wp-admin/js/set-post-thumbnail.min.js | 2 +- wp-includes/js/media-editor.js | 2 +- wp-includes/js/media-editor.min.js | 2 +- wp-includes/script-loader.php | 12 ++---------- wp-includes/version.php | 2 +- 8 files changed, 14 insertions(+), 22 deletions(-) diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 2ca60e7c4b..0fc9a17d21 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -4,7 +4,7 @@ * @output wp-admin/js/post.js */ - /* global ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting, ClipboardJS */ + /* global ajaxurl, wpAjax, postboxes, pagenow, tinymce, alert, deleteUserSetting, ClipboardJS */ /* global theList:true, theExtraList:true, getUserSetting, setUserSetting, commentReply, commentsBox */ /* global WPSetThumbnailHTML, wptitlehint */ @@ -145,7 +145,7 @@ window.wp = window.wp || {}; */ function(str){ if ( str == '0' ) { - alert( setPostThumbnailL10n.error ); + alert( __( 'Could not set that as the thumbnail image. Try a different attachment.' ) ); } else { WPSetThumbnailHTML(str); } diff --git a/wp-admin/js/post.min.js b/wp-admin/js/post.min.js index 80bc324b9b..36b83be35c 100644 --- a/wp-admin/js/post.min.js +++ b/wp-admin/js/post.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -window.makeSlugeditClickable=window.editPermalink=function(){},window.wp=window.wp||{},function(n){var t=!1,s=wp.i18n.__;window.commentsBox={st:0,get:function(t,e){var i,a=this.st;return e=e||20,this.st+=e,this.total=t,n("#commentsdiv .spinner").addClass("is-active"),i={action:"get-comments",mode:"single",_ajax_nonce:n("#add_comment_nonce").val(),p:n("#post_ID").val(),start:a,number:e},n.post(ajaxurl,i,function(t){if(t=wpAjax.parseAjaxResponse(t),n("#commentsdiv .widefat").show(),n("#commentsdiv .spinner").removeClass("is-active"),"object"==typeof t&&t.responses[0])return n("#the-comment-list").append(t.responses[0].data),theList=theExtraList=null,n("a[className*=':']").unbind(),void(commentsBox.st>commentsBox.total?n("#show-comments").hide():n("#show-comments").show().children("a").text(s("Show more comments")));1!=t?n("#the-comment-list").append(''+wpAjax.broken+""):n("#show-comments").text(s("No more comments found."))}),!1},load:function(t){this.st=jQuery("#the-comment-list tr.comment:visible").length,this.get(t)}},window.WPSetThumbnailHTML=function(t){n(".inside","#postimagediv").html(t)},window.WPSetThumbnailID=function(t){var e=n('input[value="_thumbnail_id"]',"#list-table");0",{class:"avatar avatar-64 photo",width:64,height:64,alt:"",src:i.lock_error.avatar_src,srcset:i.lock_error.avatar_src_2x?i.lock_error.avatar_src_2x+" 2x":void 0}),a.find("div.post-locked-avatar").empty().append(s)),a.show().find(".currently-editing").text(i.lock_error.text),a.find(".wp-tab-first").focus()):i.new_lock&&n("#active_post_lock").val(i.new_lock))}).on("before-autosave.update-post-slug",function(){t=document.activeElement&&"title"===document.activeElement.id}).on("after-autosave.update-post-slug",function(){n("#edit-slug-box > *").length||t||n.post(ajaxurl,{action:"sample-permalink",post_id:n("#post_ID").val(),new_title:n("#title").val(),samplepermalinknonce:n("#samplepermalinknonce").val()},function(t){"-1"!=t&&n("#edit-slug-box").html(t)})})}(jQuery),function(s){var n,t;function a(){n=!1,window.clearTimeout(t),t=window.setTimeout(function(){n=!0},3e5)}s(document).on("heartbeat-send.wp-refresh-nonces",function(t,e){var i,a=s("#wp-auth-check-wrap");(n||a.length&&!a.hasClass("hidden"))&&(i=s("#post_ID").val())&&s("#_wpnonce").val()&&(e["wp-refresh-post-nonces"]={post_id:i})}).on("heartbeat-tick.wp-refresh-nonces",function(t,e){var i=e["wp-refresh-post-nonces"];i&&(a(),i.replace&&s.each(i.replace,function(t,e){s("#"+t).val(e)}),i.heartbeatNonce&&(window.heartbeatSettings.nonce=i.heartbeatNonce))}).ready(function(){a()})}(jQuery),jQuery(document).ready(function(h){var p,e,i,a,s,n,o,l,c,t,r,d,u=h("#content"),f=h(document),v=h("#post_ID").val()||0,m=h("#submitpost"),w=!0,b=h("#post-visibility-select"),g=h("#timestampdiv"),k=h("#post-status-select"),_=!!window.navigator.platform&&-1!==window.navigator.platform.indexOf("Mac"),y=new ClipboardJS(".copy-attachment-url.edit-media"),x=wp.i18n.__,C=wp.i18n._x;function D(t){r.hasClass("wp-editor-expand")||(c?o.theme.resizeTo(null,l+t.pageY):u.height(Math.max(50,l+t.pageY)),t.preventDefault())}function j(){var t,e;r.hasClass("wp-editor-expand")||(t=c?(o.focus(),((e=parseInt(h("#wp-content-editor-container .mce-toolbar-grp").height(),10))<10||200 *").length&&(h("form#post").one("submit",function(){t=!0}),window.setTimeout(function(){!t&&wp.autosave&&wp.autosave.server.triggerSave()},200))}),f.on("autosave-disable-buttons.edit-post",function(){i.addClass("disabled")}).on("autosave-enable-buttons.edit-post",function(){wp.heartbeat&&wp.heartbeat.hasConnectionError()||i.removeClass("disabled")}).on("before-autosave.edit-post",function(){h(".autosave-message").text(x("Saving Draft\u2026"))}).on("after-autosave.edit-post",function(t,e){h(".autosave-message").text(e.message),h(document.body).hasClass("post-new-php")&&h(".submitbox .submitdelete").show()}),h(window).on("beforeunload.edit-post",function(){var t="undefined"!=typeof tinymce&&tinymce.get("content");if(t&&!t.isHidden()&&t.isDirty()||wp.autosave&&wp.autosave.server.postChanged())return x("The changes you made will be lost if you navigate away from this page.")}).on("unload.edit-post",function(t){if(w&&(!t.target||"#document"==t.target.nodeName)){var e=h("#post_ID").val(),i=h("#active_post_lock").val();if(e&&i){var a={action:"wp-remove-post-lock",_wpnonce:h("#_wpnonce").val(),post_ID:e,active_post_lock:i};if(window.FormData&&window.navigator.sendBeacon){var s=new window.FormData;if(h.each(a,function(t,e){s.append(t,e)}),window.navigator.sendBeacon(ajaxurl,s))return}h.post({async:!1,data:a,url:ajaxurl})}}}),h("#tagsdiv-post_tag").length?window.tagBox&&window.tagBox.init():h(".meta-box-sortables").children("div.postbox").each(function(){if(0===this.id.indexOf("tagsdiv-"))return window.tagBox&&window.tagBox.init(),!1}),h(".categorydiv").each(function(){var t,e,i,s,a;(i=h(this).attr("id").split("-")).shift(),s=i.join("-"),a=s+"_tab","category"==s&&(a="cats"),h("a","#"+s+"-tabs").click(function(t){t.preventDefault();var e=h(this).attr("href");h(this).parent().addClass("tabs").siblings("li").removeClass("tabs"),h("#"+s+"-tabs").siblings(".tabs-panel").hide(),h(e).show(),"#"+s+"-all"==e?deleteUserSetting(a):setUserSetting(a,"pop")}),getUserSetting(a)&&h('a[href="#'+s+'-pop"]',"#"+s+"-tabs").click(),h("#new"+s).one("focus",function(){h(this).val("").removeClass("form-input-tip")}),h("#new"+s).keypress(function(t){13===t.keyCode&&(t.preventDefault(),h("#"+s+"-add-submit").click())}),h("#"+s+"-add-submit").click(function(){h("#new"+s).focus()}),t=function(t){return!!h("#new"+s).val()&&(t.data+="&"+h(":checked","#"+s+"checklist").serialize(),h("#"+s+"-add-submit").prop("disabled",!0),t)},e=function(t,e){var i,a=h("#new"+s+"_parent");h("#"+s+"-add-submit").prop("disabled",!1),"undefined"!=e.parsed.responses[0]&&(i=e.parsed.responses[0].supplemental.newcat_parent)&&(a.before(i),a.remove())},h("#"+s+"checklist").wpList({alt:"",response:s+"-ajax-response",addBefore:t,addAfter:e}),h("#"+s+"-add-toggle").click(function(t){t.preventDefault(),h("#"+s+"-adder").toggleClass("wp-hidden-children"),h('a[href="#'+s+'-all"]',"#"+s+"-tabs").click(),h("#new"+s).focus()}),h("#"+s+"checklist, #"+s+"checklist-pop").on("click",'li.popular-category > label input[type="checkbox"]',function(){var t=h(this),e=t.is(":checked"),i=t.val();i&&t.parents("#taxonomy-"+s).length&&h("#in-"+s+"-"+i+", #in-popular-"+s+"-"+i).prop("checked",e)})}),h("#postcustom").length&&h("#the-list").wpList({addBefore:function(t){return t.data+="&post_id="+h("#post_ID").val(),t},addAfter:function(){h("table#list-table").show()}}),h("#submitdiv").length&&(p=h("#timestamp").html(),e=h("#post-visibility-display").html(),a=function(){"public"!=b.find("input:radio:checked").val()?(h("#sticky").prop("checked",!1),h("#sticky-span").hide()):h("#sticky-span").show(),"password"!=b.find("input:radio:checked").val()?h("#password-span").hide():h("#password-span").show()},s=function(){if(!g.length)return!0;var t,e,i,a,s=h("#post_status"),n=h('option[value="publish"]',s),o=h("#aa").val(),l=h("#mm").val(),c=h("#jj").val(),r=h("#hh").val(),d=h("#mn").val();return t=new Date(o,l-1,c,r,d),e=new Date(h("#hidden_aa").val(),h("#hidden_mm").val()-1,h("#hidden_jj").val(),h("#hidden_hh").val(),h("#hidden_mn").val()),i=new Date(h("#cur_aa").val(),h("#cur_mm").val()-1,h("#cur_jj").val(),h("#cur_hh").val(),h("#cur_mn").val()),t.getFullYear()!=o||1+t.getMonth()!=l||t.getDate()!=c||t.getMinutes()!=d?(g.find(".timestamp-wrap").addClass("form-invalid"),!1):(g.find(".timestamp-wrap").removeClass("form-invalid"),i"+x("%1$s %2$s, %3$s at %4$s:%5$s").replace("%1$s",h('option[value="'+l+'"]',"#mm").attr("data-text")).replace("%2$s",parseInt(c,10)).replace("%3$s",o).replace("%4$s",("00"+r).slice(-2)).replace("%5$s",("00"+d).slice(-2))+" "),"private"==b.find("input:radio:checked").val()?(h("#publish").val(x("Update")),0===n.length?s.append('"):n.html(x("Privately Published")),h('option[value="publish"]',s).prop("selected",!0),h("#misc-publishing-actions .edit-post-status").hide()):("future"==h("#original_post_status").val()||"draft"==h("#original_post_status").val()?n.length&&(n.remove(),s.val(h("#hidden_post_status").val())):n.html(x("Published")),s.is(":hidden")&&h("#misc-publishing-actions .edit-post-status").show()),h("#post-status-display").text(wp.sanitize.stripTagsAndEncodeText(h("option:selected",s).text())),"private"==h("option:selected",s).val()||"publish"==h("option:selected",s).val()?h("#save-post").hide():(h("#save-post").show(),"pending"==h("option:selected",s).val()?h("#save-post").show().val(x("Save as Pending")):h("#save-post").show().val(x("Save Draft"))),!0)},h("#visibility .edit-visibility").click(function(t){t.preventDefault(),b.is(":hidden")&&(a(),b.slideDown("fast",function(){b.find('input[type="radio"]').first().focus()}),h(this).hide())}),b.find(".cancel-post-visibility").click(function(t){b.slideUp("fast"),h("#visibility-radio-"+h("#hidden-post-visibility").val()).prop("checked",!0),h("#post_password").val(h("#hidden-post-password").val()),h("#sticky").prop("checked",h("#hidden-post-sticky").prop("checked")),h("#post-visibility-display").html(e),h("#visibility .edit-visibility").show().focus(),s(),t.preventDefault()}),b.find(".save-post-visibility").click(function(t){var e="",i=b.find("input:radio:checked").val();switch(b.slideUp("fast"),h("#visibility .edit-visibility").show().focus(),s(),"public"!==i&&h("#sticky").prop("checked",!1),i){case"public":e=h("#sticky").prop("checked")?x("Public, Sticky"):x("Public");break;case"private":e=x("Private");break;case"password":e=x("Password Protected")}h("#post-visibility-display").text(e),t.preventDefault()}),b.find("input:radio").change(function(){a()}),g.siblings("a.edit-timestamp").click(function(t){g.is(":hidden")&&(g.slideDown("fast",function(){h("input, select",g.find(".timestamp-wrap")).first().focus()}),h(this).hide()),t.preventDefault()}),g.find(".cancel-timestamp").click(function(t){g.slideUp("fast").siblings("a.edit-timestamp").show().focus(),h("#mm").val(h("#hidden_mm").val()),h("#jj").val(h("#hidden_jj").val()),h("#aa").val(h("#hidden_aa").val()),h("#hh").val(h("#hidden_hh").val()),h("#mn").val(h("#hidden_mn").val()),s(),t.preventDefault()}),g.find(".save-timestamp").click(function(t){s()&&(g.slideUp("fast"),g.siblings("a.edit-timestamp").show().focus()),t.preventDefault()}),h("#post").on("submit",function(t){s()||(t.preventDefault(),g.show(),wp.autosave&&wp.autosave.enableButtons(),h("#publishing-action .spinner").removeClass("is-active"))}),k.siblings("a.edit-post-status").click(function(t){k.is(":hidden")&&(k.slideDown("fast",function(){k.find("select").focus()}),h(this).hide()),t.preventDefault()}),k.find(".save-post-status").click(function(t){k.slideUp("fast").siblings("a.edit-post-status").show().focus(),s(),t.preventDefault()}),k.find(".cancel-post-status").click(function(t){k.slideUp("fast").siblings("a.edit-post-status").show().focus(),h("#post_status").val(h("#hidden_post_status").val()),s(),t.preventDefault()})),h("#titlediv").on("click",".edit-slug",function(){!function(){var t,e,a,i,s=0,n=h("#post_name"),o=n.val(),l=h("#sample-permalink"),c=l.html(),r=h("#sample-permalink a").html(),d=h("#edit-slug-buttons"),p=d.html(),u=h("#editable-post-name-full");for(u.find("img").replaceWith(function(){return this.alt}),u=u.html(),l.html(r),a=h("#editable-post-name"),i=a.html(),d.html(' "),d.children(".save").click(function(){var i=a.children("input").val();i!=h("#editable-post-name-full").text()?h.post(ajaxurl,{action:"sample-permalink",post_id:v,new_slug:i,new_title:h("#title").val(),samplepermalinknonce:h("#samplepermalinknonce").val()},function(t){var e=h("#edit-slug-box");e.html(t),e.hasClass("hidden")&&e.fadeIn("fast",function(){e.removeClass("hidden")}),d.html(p),l.html(c),n.val(i),h(".edit-slug").focus(),wp.a11y.speak(x("Permalink saved"))}):d.children(".cancel").click()}),d.children(".cancel").click(function(){h("#view-post-btn").show(),a.html(i),d.html(p),l.html(c),n.val(o),h(".edit-slug").focus()}),t=0;tu.length/4?"":u,a.html('').children("input").keydown(function(t){var e=t.which;13===e&&(t.preventDefault(),d.children(".save").click()),27===e&&d.children(".cancel").click()}).keyup(function(){n.val(this.value)}).focus()}()}),window.wptitlehint=function(t){var e=h("#"+(t=t||"title")),i=h("#"+t+"-prompt-text");""===e.val()&&i.removeClass("screen-reader-text"),e.on("input",function(){""!==this.value?i.addClass("screen-reader-text"):i.removeClass("screen-reader-text")})},wptitlehint(),t=h("#post-status-info"),r=h("#postdivrich"),!u.length||"ontouchstart"in window?h("#content-resize-handle").hide():t.on("mousedown.wp-editor-resize",function(t){"undefined"!=typeof tinymce&&(o=tinymce.get("content")),o&&!o.isHidden()?(c=!0,l=h("#content_ifr").height()-t.pageY):(c=!1,l=u.height()-t.pageY,u.blur()),f.on("mousemove.wp-editor-resize",D).on("mouseup.wp-editor-resize mouseleave.wp-editor-resize",j),t.preventDefault()}).on("mouseup.wp-editor-resize",j),"undefined"!=typeof tinymce&&(h("#post-formats-select input.post-format").on("change.set-editor-class",function(){var t,e,i=this.id;i&&h(this).prop("checked")&&(t=tinymce.get("content"))&&((e=t.getBody()).className=e.className.replace(/\bpost-format-[^ ]+/,""),t.dom.addClass(e,"post-format-0"==i?"post-format-standard":i),h(document).trigger("editor-classchange"))}),h("#page_template").on("change.set-editor-class",function(){var t,e,i=h(this).val()||"";(i=i.substr(i.lastIndexOf("/")+1,i.length).replace(/\.php$/,"").replace(/\./g,"-"))&&(t=tinymce.get("content"))&&((e=t.getBody()).className=e.className.replace(/\bpage-template-[^ ]+/,""),t.dom.addClass(e,"page-template-"+i),h(document).trigger("editor-classchange"))})),u.on("keydown.wp-autosave",function(t){if(83===t.which){if(t.shiftKey||t.altKey||_&&(!t.metaKey||t.ctrlKey)||!_&&!t.ctrlKey)return;wp.autosave&&wp.autosave.server.triggerSave(),t.preventDefault()}}),"auto-draft"===h("#original_post_status").val()&&window.history.replaceState&&h("#publish").on("click",function(){d=window.location.href,d+=-1!==d.indexOf("?")?"&":"?",d+="wp-post-new-reload=true",window.history.replaceState(null,null,d)});y.on("success",function(t){var e=h(t.trigger),i=h(".success",e.closest(".copy-to-clipboard-container"));t.clearSelection(),e.focus(),clearTimeout(n),i.removeClass("hidden"),n=setTimeout(function(){i.addClass("hidden")},3e3),wp.a11y.speak(x("The file URL has been copied to your clipboard"))})}),function(t,l){t(function(){var i,a=t("#content"),s=t("#wp-word-count").find(".word-count"),n=0;function o(){var t,e;t=!i||i.isHidden()?a.val():i.getContent({format:"raw"}),(e=l.count(t))!==n&&s.text(e),n=e}t(document).on("tinymce-editor-init",function(t,e){"content"===e.id&&(i=e).on("nodechange keyup",_.debounce(o,1e3))}),a.on("input keyup",_.debounce(o,1e3)),o()})}(jQuery,new wp.utils.WordCounter); \ No newline at end of file +window.makeSlugeditClickable=window.editPermalink=function(){},window.wp=window.wp||{},function(n){var t=!1,s=wp.i18n.__;window.commentsBox={st:0,get:function(t,e){var i,a=this.st;return e=e||20,this.st+=e,this.total=t,n("#commentsdiv .spinner").addClass("is-active"),i={action:"get-comments",mode:"single",_ajax_nonce:n("#add_comment_nonce").val(),p:n("#post_ID").val(),start:a,number:e},n.post(ajaxurl,i,function(t){if(t=wpAjax.parseAjaxResponse(t),n("#commentsdiv .widefat").show(),n("#commentsdiv .spinner").removeClass("is-active"),"object"==typeof t&&t.responses[0])return n("#the-comment-list").append(t.responses[0].data),theList=theExtraList=null,n("a[className*=':']").unbind(),void(commentsBox.st>commentsBox.total?n("#show-comments").hide():n("#show-comments").show().children("a").text(s("Show more comments")));1!=t?n("#the-comment-list").append(''+wpAjax.broken+""):n("#show-comments").text(s("No more comments found."))}),!1},load:function(t){this.st=jQuery("#the-comment-list tr.comment:visible").length,this.get(t)}},window.WPSetThumbnailHTML=function(t){n(".inside","#postimagediv").html(t)},window.WPSetThumbnailID=function(t){var e=n('input[value="_thumbnail_id"]',"#list-table");0",{class:"avatar avatar-64 photo",width:64,height:64,alt:"",src:i.lock_error.avatar_src,srcset:i.lock_error.avatar_src_2x?i.lock_error.avatar_src_2x+" 2x":void 0}),a.find("div.post-locked-avatar").empty().append(s)),a.show().find(".currently-editing").text(i.lock_error.text),a.find(".wp-tab-first").focus()):i.new_lock&&n("#active_post_lock").val(i.new_lock))}).on("before-autosave.update-post-slug",function(){t=document.activeElement&&"title"===document.activeElement.id}).on("after-autosave.update-post-slug",function(){n("#edit-slug-box > *").length||t||n.post(ajaxurl,{action:"sample-permalink",post_id:n("#post_ID").val(),new_title:n("#title").val(),samplepermalinknonce:n("#samplepermalinknonce").val()},function(t){"-1"!=t&&n("#edit-slug-box").html(t)})})}(jQuery),function(s){var n,t;function a(){n=!1,window.clearTimeout(t),t=window.setTimeout(function(){n=!0},3e5)}s(document).on("heartbeat-send.wp-refresh-nonces",function(t,e){var i,a=s("#wp-auth-check-wrap");(n||a.length&&!a.hasClass("hidden"))&&(i=s("#post_ID").val())&&s("#_wpnonce").val()&&(e["wp-refresh-post-nonces"]={post_id:i})}).on("heartbeat-tick.wp-refresh-nonces",function(t,e){var i=e["wp-refresh-post-nonces"];i&&(a(),i.replace&&s.each(i.replace,function(t,e){s("#"+t).val(e)}),i.heartbeatNonce&&(window.heartbeatSettings.nonce=i.heartbeatNonce))}).ready(function(){a()})}(jQuery),jQuery(document).ready(function(h){var p,e,i,a,s,n,o,l,c,t,r,d,u=h("#content"),f=h(document),v=h("#post_ID").val()||0,m=h("#submitpost"),w=!0,b=h("#post-visibility-select"),g=h("#timestampdiv"),k=h("#post-status-select"),_=!!window.navigator.platform&&-1!==window.navigator.platform.indexOf("Mac"),y=new ClipboardJS(".copy-attachment-url.edit-media"),x=wp.i18n.__,C=wp.i18n._x;function D(t){r.hasClass("wp-editor-expand")||(c?o.theme.resizeTo(null,l+t.pageY):u.height(Math.max(50,l+t.pageY)),t.preventDefault())}function j(){var t,e;r.hasClass("wp-editor-expand")||(t=c?(o.focus(),((e=parseInt(h("#wp-content-editor-container .mce-toolbar-grp").height(),10))<10||200 *").length&&(h("form#post").one("submit",function(){t=!0}),window.setTimeout(function(){!t&&wp.autosave&&wp.autosave.server.triggerSave()},200))}),f.on("autosave-disable-buttons.edit-post",function(){i.addClass("disabled")}).on("autosave-enable-buttons.edit-post",function(){wp.heartbeat&&wp.heartbeat.hasConnectionError()||i.removeClass("disabled")}).on("before-autosave.edit-post",function(){h(".autosave-message").text(x("Saving Draft\u2026"))}).on("after-autosave.edit-post",function(t,e){h(".autosave-message").text(e.message),h(document.body).hasClass("post-new-php")&&h(".submitbox .submitdelete").show()}),h(window).on("beforeunload.edit-post",function(){var t="undefined"!=typeof tinymce&&tinymce.get("content");if(t&&!t.isHidden()&&t.isDirty()||wp.autosave&&wp.autosave.server.postChanged())return x("The changes you made will be lost if you navigate away from this page.")}).on("unload.edit-post",function(t){if(w&&(!t.target||"#document"==t.target.nodeName)){var e=h("#post_ID").val(),i=h("#active_post_lock").val();if(e&&i){var a={action:"wp-remove-post-lock",_wpnonce:h("#_wpnonce").val(),post_ID:e,active_post_lock:i};if(window.FormData&&window.navigator.sendBeacon){var s=new window.FormData;if(h.each(a,function(t,e){s.append(t,e)}),window.navigator.sendBeacon(ajaxurl,s))return}h.post({async:!1,data:a,url:ajaxurl})}}}),h("#tagsdiv-post_tag").length?window.tagBox&&window.tagBox.init():h(".meta-box-sortables").children("div.postbox").each(function(){if(0===this.id.indexOf("tagsdiv-"))return window.tagBox&&window.tagBox.init(),!1}),h(".categorydiv").each(function(){var t,e,i,s,a;(i=h(this).attr("id").split("-")).shift(),s=i.join("-"),a=s+"_tab","category"==s&&(a="cats"),h("a","#"+s+"-tabs").click(function(t){t.preventDefault();var e=h(this).attr("href");h(this).parent().addClass("tabs").siblings("li").removeClass("tabs"),h("#"+s+"-tabs").siblings(".tabs-panel").hide(),h(e).show(),"#"+s+"-all"==e?deleteUserSetting(a):setUserSetting(a,"pop")}),getUserSetting(a)&&h('a[href="#'+s+'-pop"]',"#"+s+"-tabs").click(),h("#new"+s).one("focus",function(){h(this).val("").removeClass("form-input-tip")}),h("#new"+s).keypress(function(t){13===t.keyCode&&(t.preventDefault(),h("#"+s+"-add-submit").click())}),h("#"+s+"-add-submit").click(function(){h("#new"+s).focus()}),t=function(t){return!!h("#new"+s).val()&&(t.data+="&"+h(":checked","#"+s+"checklist").serialize(),h("#"+s+"-add-submit").prop("disabled",!0),t)},e=function(t,e){var i,a=h("#new"+s+"_parent");h("#"+s+"-add-submit").prop("disabled",!1),"undefined"!=e.parsed.responses[0]&&(i=e.parsed.responses[0].supplemental.newcat_parent)&&(a.before(i),a.remove())},h("#"+s+"checklist").wpList({alt:"",response:s+"-ajax-response",addBefore:t,addAfter:e}),h("#"+s+"-add-toggle").click(function(t){t.preventDefault(),h("#"+s+"-adder").toggleClass("wp-hidden-children"),h('a[href="#'+s+'-all"]',"#"+s+"-tabs").click(),h("#new"+s).focus()}),h("#"+s+"checklist, #"+s+"checklist-pop").on("click",'li.popular-category > label input[type="checkbox"]',function(){var t=h(this),e=t.is(":checked"),i=t.val();i&&t.parents("#taxonomy-"+s).length&&h("#in-"+s+"-"+i+", #in-popular-"+s+"-"+i).prop("checked",e)})}),h("#postcustom").length&&h("#the-list").wpList({addBefore:function(t){return t.data+="&post_id="+h("#post_ID").val(),t},addAfter:function(){h("table#list-table").show()}}),h("#submitdiv").length&&(p=h("#timestamp").html(),e=h("#post-visibility-display").html(),a=function(){"public"!=b.find("input:radio:checked").val()?(h("#sticky").prop("checked",!1),h("#sticky-span").hide()):h("#sticky-span").show(),"password"!=b.find("input:radio:checked").val()?h("#password-span").hide():h("#password-span").show()},s=function(){if(!g.length)return!0;var t,e,i,a,s=h("#post_status"),n=h('option[value="publish"]',s),o=h("#aa").val(),l=h("#mm").val(),c=h("#jj").val(),r=h("#hh").val(),d=h("#mn").val();return t=new Date(o,l-1,c,r,d),e=new Date(h("#hidden_aa").val(),h("#hidden_mm").val()-1,h("#hidden_jj").val(),h("#hidden_hh").val(),h("#hidden_mn").val()),i=new Date(h("#cur_aa").val(),h("#cur_mm").val()-1,h("#cur_jj").val(),h("#cur_hh").val(),h("#cur_mn").val()),t.getFullYear()!=o||1+t.getMonth()!=l||t.getDate()!=c||t.getMinutes()!=d?(g.find(".timestamp-wrap").addClass("form-invalid"),!1):(g.find(".timestamp-wrap").removeClass("form-invalid"),i"+x("%1$s %2$s, %3$s at %4$s:%5$s").replace("%1$s",h('option[value="'+l+'"]',"#mm").attr("data-text")).replace("%2$s",parseInt(c,10)).replace("%3$s",o).replace("%4$s",("00"+r).slice(-2)).replace("%5$s",("00"+d).slice(-2))+" "),"private"==b.find("input:radio:checked").val()?(h("#publish").val(x("Update")),0===n.length?s.append('"):n.html(x("Privately Published")),h('option[value="publish"]',s).prop("selected",!0),h("#misc-publishing-actions .edit-post-status").hide()):("future"==h("#original_post_status").val()||"draft"==h("#original_post_status").val()?n.length&&(n.remove(),s.val(h("#hidden_post_status").val())):n.html(x("Published")),s.is(":hidden")&&h("#misc-publishing-actions .edit-post-status").show()),h("#post-status-display").text(wp.sanitize.stripTagsAndEncodeText(h("option:selected",s).text())),"private"==h("option:selected",s).val()||"publish"==h("option:selected",s).val()?h("#save-post").hide():(h("#save-post").show(),"pending"==h("option:selected",s).val()?h("#save-post").show().val(x("Save as Pending")):h("#save-post").show().val(x("Save Draft"))),!0)},h("#visibility .edit-visibility").click(function(t){t.preventDefault(),b.is(":hidden")&&(a(),b.slideDown("fast",function(){b.find('input[type="radio"]').first().focus()}),h(this).hide())}),b.find(".cancel-post-visibility").click(function(t){b.slideUp("fast"),h("#visibility-radio-"+h("#hidden-post-visibility").val()).prop("checked",!0),h("#post_password").val(h("#hidden-post-password").val()),h("#sticky").prop("checked",h("#hidden-post-sticky").prop("checked")),h("#post-visibility-display").html(e),h("#visibility .edit-visibility").show().focus(),s(),t.preventDefault()}),b.find(".save-post-visibility").click(function(t){var e="",i=b.find("input:radio:checked").val();switch(b.slideUp("fast"),h("#visibility .edit-visibility").show().focus(),s(),"public"!==i&&h("#sticky").prop("checked",!1),i){case"public":e=h("#sticky").prop("checked")?x("Public, Sticky"):x("Public");break;case"private":e=x("Private");break;case"password":e=x("Password Protected")}h("#post-visibility-display").text(e),t.preventDefault()}),b.find("input:radio").change(function(){a()}),g.siblings("a.edit-timestamp").click(function(t){g.is(":hidden")&&(g.slideDown("fast",function(){h("input, select",g.find(".timestamp-wrap")).first().focus()}),h(this).hide()),t.preventDefault()}),g.find(".cancel-timestamp").click(function(t){g.slideUp("fast").siblings("a.edit-timestamp").show().focus(),h("#mm").val(h("#hidden_mm").val()),h("#jj").val(h("#hidden_jj").val()),h("#aa").val(h("#hidden_aa").val()),h("#hh").val(h("#hidden_hh").val()),h("#mn").val(h("#hidden_mn").val()),s(),t.preventDefault()}),g.find(".save-timestamp").click(function(t){s()&&(g.slideUp("fast"),g.siblings("a.edit-timestamp").show().focus()),t.preventDefault()}),h("#post").on("submit",function(t){s()||(t.preventDefault(),g.show(),wp.autosave&&wp.autosave.enableButtons(),h("#publishing-action .spinner").removeClass("is-active"))}),k.siblings("a.edit-post-status").click(function(t){k.is(":hidden")&&(k.slideDown("fast",function(){k.find("select").focus()}),h(this).hide()),t.preventDefault()}),k.find(".save-post-status").click(function(t){k.slideUp("fast").siblings("a.edit-post-status").show().focus(),s(),t.preventDefault()}),k.find(".cancel-post-status").click(function(t){k.slideUp("fast").siblings("a.edit-post-status").show().focus(),h("#post_status").val(h("#hidden_post_status").val()),s(),t.preventDefault()})),h("#titlediv").on("click",".edit-slug",function(){!function(){var t,e,a,i,s=0,n=h("#post_name"),o=n.val(),l=h("#sample-permalink"),c=l.html(),r=h("#sample-permalink a").html(),d=h("#edit-slug-buttons"),p=d.html(),u=h("#editable-post-name-full");for(u.find("img").replaceWith(function(){return this.alt}),u=u.html(),l.html(r),a=h("#editable-post-name"),i=a.html(),d.html(' "),d.children(".save").click(function(){var i=a.children("input").val();i!=h("#editable-post-name-full").text()?h.post(ajaxurl,{action:"sample-permalink",post_id:v,new_slug:i,new_title:h("#title").val(),samplepermalinknonce:h("#samplepermalinknonce").val()},function(t){var e=h("#edit-slug-box");e.html(t),e.hasClass("hidden")&&e.fadeIn("fast",function(){e.removeClass("hidden")}),d.html(p),l.html(c),n.val(i),h(".edit-slug").focus(),wp.a11y.speak(x("Permalink saved"))}):d.children(".cancel").click()}),d.children(".cancel").click(function(){h("#view-post-btn").show(),a.html(i),d.html(p),l.html(c),n.val(o),h(".edit-slug").focus()}),t=0;tu.length/4?"":u,a.html('').children("input").keydown(function(t){var e=t.which;13===e&&(t.preventDefault(),d.children(".save").click()),27===e&&d.children(".cancel").click()}).keyup(function(){n.val(this.value)}).focus()}()}),window.wptitlehint=function(t){var e=h("#"+(t=t||"title")),i=h("#"+t+"-prompt-text");""===e.val()&&i.removeClass("screen-reader-text"),e.on("input",function(){""!==this.value?i.addClass("screen-reader-text"):i.removeClass("screen-reader-text")})},wptitlehint(),t=h("#post-status-info"),r=h("#postdivrich"),!u.length||"ontouchstart"in window?h("#content-resize-handle").hide():t.on("mousedown.wp-editor-resize",function(t){"undefined"!=typeof tinymce&&(o=tinymce.get("content")),o&&!o.isHidden()?(c=!0,l=h("#content_ifr").height()-t.pageY):(c=!1,l=u.height()-t.pageY,u.blur()),f.on("mousemove.wp-editor-resize",D).on("mouseup.wp-editor-resize mouseleave.wp-editor-resize",j),t.preventDefault()}).on("mouseup.wp-editor-resize",j),"undefined"!=typeof tinymce&&(h("#post-formats-select input.post-format").on("change.set-editor-class",function(){var t,e,i=this.id;i&&h(this).prop("checked")&&(t=tinymce.get("content"))&&((e=t.getBody()).className=e.className.replace(/\bpost-format-[^ ]+/,""),t.dom.addClass(e,"post-format-0"==i?"post-format-standard":i),h(document).trigger("editor-classchange"))}),h("#page_template").on("change.set-editor-class",function(){var t,e,i=h(this).val()||"";(i=i.substr(i.lastIndexOf("/")+1,i.length).replace(/\.php$/,"").replace(/\./g,"-"))&&(t=tinymce.get("content"))&&((e=t.getBody()).className=e.className.replace(/\bpage-template-[^ ]+/,""),t.dom.addClass(e,"page-template-"+i),h(document).trigger("editor-classchange"))})),u.on("keydown.wp-autosave",function(t){if(83===t.which){if(t.shiftKey||t.altKey||_&&(!t.metaKey||t.ctrlKey)||!_&&!t.ctrlKey)return;wp.autosave&&wp.autosave.server.triggerSave(),t.preventDefault()}}),"auto-draft"===h("#original_post_status").val()&&window.history.replaceState&&h("#publish").on("click",function(){d=window.location.href,d+=-1!==d.indexOf("?")?"&":"?",d+="wp-post-new-reload=true",window.history.replaceState(null,null,d)});y.on("success",function(t){var e=h(t.trigger),i=h(".success",e.closest(".copy-to-clipboard-container"));t.clearSelection(),e.focus(),clearTimeout(n),i.removeClass("hidden"),n=setTimeout(function(){i.addClass("hidden")},3e3),wp.a11y.speak(x("The file URL has been copied to your clipboard"))})}),function(t,l){t(function(){var i,a=t("#content"),s=t("#wp-word-count").find(".word-count"),n=0;function o(){var t,e;t=!i||i.isHidden()?a.val():i.getContent({format:"raw"}),(e=l.count(t))!==n&&s.text(e),n=e}t(document).on("tinymce-editor-init",function(t,e){"content"===e.id&&(i=e).on("nodechange keyup",_.debounce(o,1e3))}),a.on("input keyup",_.debounce(o,1e3)),o()})}(jQuery,new wp.utils.WordCounter); \ No newline at end of file diff --git a/wp-admin/js/set-post-thumbnail.js b/wp-admin/js/set-post-thumbnail.js index 0f3849af34..5f5f565564 100644 --- a/wp-admin/js/set-post-thumbnail.js +++ b/wp-admin/js/set-post-thumbnail.js @@ -2,23 +2,23 @@ * @output wp-admin/js/set-post-thumbnail.js */ -/* global setPostThumbnailL10n, ajaxurl, post_id, alert */ +/* global ajaxurl, post_id, alert */ /* exported WPSetAsThumbnail */ window.WPSetAsThumbnail = function( id, nonce ) { var $link = jQuery('a#wp-post-thumbnail-' + id); - $link.text( setPostThumbnailL10n.saving ); + $link.text( wp.i18n.__( 'Saving…' ) ); jQuery.post(ajaxurl, { action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie ) }, function(str){ var win = window.dialogArguments || opener || parent || top; - $link.text( setPostThumbnailL10n.setThumbnail ); + $link.text( wp.i18n.__( 'Use as featured image' ) ); if ( str == '0' ) { - alert( setPostThumbnailL10n.error ); + alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) ); } else { jQuery('a.wp-post-thumbnail').show(); - $link.text( setPostThumbnailL10n.done ); + $link.text( wp.i18n.__( 'Done' ) ); $link.fadeOut( 2000 ); win.WPSetThumbnailID(id); win.WPSetThumbnailHTML(str); diff --git a/wp-admin/js/set-post-thumbnail.min.js b/wp-admin/js/set-post-thumbnail.min.js index 8ee2aee18b..638d957408 100644 --- a/wp-admin/js/set-post-thumbnail.min.js +++ b/wp-admin/js/set-post-thumbnail.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -window.WPSetAsThumbnail=function(e,t){var o=jQuery("a#wp-post-thumbnail-"+e);o.text(setPostThumbnailL10n.saving),jQuery.post(ajaxurl,{action:"set-post-thumbnail",post_id:post_id,thumbnail_id:e,_ajax_nonce:t,cookie:encodeURIComponent(document.cookie)},function(t){var n=window.dialogArguments||opener||parent||top;o.text(setPostThumbnailL10n.setThumbnail),"0"==t?alert(setPostThumbnailL10n.error):(jQuery("a.wp-post-thumbnail").show(),o.text(setPostThumbnailL10n.done),o.fadeOut(2e3),n.WPSetThumbnailID(e),n.WPSetThumbnailHTML(t))})}; \ No newline at end of file +window.WPSetAsThumbnail=function(n,t){var a=jQuery("a#wp-post-thumbnail-"+n);a.text(wp.i18n.__("Saving\u2026")),jQuery.post(ajaxurl,{action:"set-post-thumbnail",post_id:post_id,thumbnail_id:n,_ajax_nonce:t,cookie:encodeURIComponent(document.cookie)},function(t){var e=window.dialogArguments||opener||parent||top;a.text(wp.i18n.__("Use as featured image")),"0"==t?alert(wp.i18n.__("Could not set that as the thumbnail image. Try a different attachment.")):(jQuery("a.wp-post-thumbnail").show(),a.text(wp.i18n.__("Done")),a.fadeOut(2e3),e.WPSetThumbnailID(n),e.WPSetThumbnailHTML(t))})}; \ No newline at end of file diff --git a/wp-includes/js/media-editor.js b/wp-includes/js/media-editor.js index b74780d928..cc0167682a 100644 --- a/wp-includes/js/media-editor.js +++ b/wp-includes/js/media-editor.js @@ -627,7 +627,7 @@ _wpnonce: settings.post.nonce }).done( function( html ) { if ( '0' === html ) { - window.alert( window.setPostThumbnailL10n.error ); + window.alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) ); return; } $( '.inside', '#postimagediv' ).html( html ); diff --git a/wp-includes/js/media-editor.min.js b/wp-includes/js/media-editor.min.js index e3e2d8f403..1557856f76 100644 --- a/wp-includes/js/media-editor.min.js +++ b/wp-includes/js/media-editor.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(a,l){var i={};wp.media.coerce=function(e,t){return l.isUndefined(e[t])&&!l.isUndefined(this.defaults[t])?e[t]=this.defaults[t]:"true"===e[t]?e[t]=!0:"false"===e[t]&&(e[t]=!1),e[t]},wp.media.string={props:function(e,t){var i,n,a,d,r=wp.media.view.settings.defaultProps;return e=e?l.clone(e):{},t&&t.type&&(e.type=t.type),"image"===e.type&&(e=l.defaults(e||{},{align:r.align||getUserSetting("align","none"),size:r.size||getUserSetting("imgsize","medium"),url:"",classes:[]})),t&&(e.title=e.title||t.title,"file"===(i=e.link||r.link||getUserSetting("urlbutton","file"))||"embed"===i?n=t.url:"post"===i?n=t.link:"custom"===i&&(n=e.linkUrl),e.linkUrl=n||"","image"===t.type?(e.classes.push("wp-image-"+t.id),a=(d=t.sizes)&&d[e.size]?d[e.size]:t,l.extend(e,l.pick(t,"align","caption","alt"),{width:a.width,height:a.height,src:a.url,captionId:"attachment_"+t.id})):"video"===t.type||"audio"===t.type?l.extend(e,l.pick(t,"title","type","icon","mime")):(e.title=e.title||t.filename,e.rel=e.rel||"attachment wp-att-"+t.id)),e},link:function(e,t){var i;return i={tag:"a",content:(e=wp.media.string.props(e,t)).title,attrs:{href:e.linkUrl}},e.rel&&(i.attrs.rel=e.rel),wp.html.string(i)},audio:function(e,t){return wp.media.string._audioVideo("audio",e,t)},video:function(e,t){return wp.media.string._audioVideo("video",e,t)},_audioVideo:function(e,t,i){var n,a;return"embed"!==(t=wp.media.string.props(t,i)).link?wp.media.string.link(t):(n={},"video"===e&&(i.image&&-1===i.image.src.indexOf(i.icon)&&(n.poster=i.image.src),i.width&&(n.width=i.width),i.height&&(n.height=i.height)),a=i.filename.split(".").pop(),l.contains(wp.media.view.settings.embedExts,a)?(n[a]=i.url,wp.shortcode.string({tag:e,attrs:n})):wp.media.string.link(t))},image:function(e,t){var i,n,a,d,r={};return e.type="image",n=(e=wp.media.string.props(e,t)).classes||[],r.src=l.isUndefined(t)?e.url:t.url,l.extend(r,l.pick(e,"width","height","alt")),e.align&&!e.caption&&n.push("align"+e.align),e.size&&n.push("size-"+e.size),r.class=l.compact(n).join(" "),i={tag:"img",attrs:r,single:!0},e.linkUrl&&(i={tag:"a",attrs:{href:e.linkUrl},content:i}),d=wp.html.string(i),e.caption&&(a={},r.width&&(a.width=r.width),e.captionId&&(a.id=e.captionId),e.align&&(a.align="align"+e.align),d=wp.shortcode.string({tag:"caption",attrs:a,content:d+" "+e.caption})),d}},wp.media.embed={coerce:wp.media.coerce,defaults:{url:"",width:"",height:""},edit:function(e,t){var i,n={};return t?n.url=e.replace(/<[^>]+>/g,""):(i=wp.shortcode.next("embed",e).shortcode,n=l.defaults(i.attrs.named,this.defaults),i.content&&(n.url=i.content)),wp.media({frame:"post",state:"embed",metadata:n})},shortcode:function(i){var e,n=this;return l.each(this.defaults,function(e,t){i[t]=n.coerce(i,t),e===i[t]&&delete i[t]}),e=i.url,delete i.url,new wp.shortcode({tag:"embed",attrs:i,content:e})}},wp.media.collection=function(e){var o={};return l.extend({coerce:wp.media.coerce,attachments:function(e){var t,i,n,a,d=e.string(),r=o[d],s=this;return delete o[d],r||(t=l.defaults(e.attrs.named,this.defaults),(i=l.pick(t,"orderby","order")).type=this.type,i.perPage=-1,void 0!==t.orderby&&(t._orderByField=t.orderby),"rand"===t.orderby&&(t._orderbyRandom=!0),t.orderby&&!/^menu_order(?: ID)?$/i.test(t.orderby)||(i.orderby="menuOrder"),t.ids?(i.post__in=t.ids.split(","),i.orderby="post__in"):t.include&&(i.post__in=t.include.split(",")),t.exclude&&(i.post__not_in=t.exclude.split(",")),i.post__in||(i.uploadedTo=t.id),a=l.omit(t,"id","ids","include","exclude","orderby","order"),l.each(this.defaults,function(e,t){a[t]=s.coerce(a,t)}),(n=wp.media.query(i))[this.tag]=new Backbone.Model(a),n)},shortcode:function(e){var t,i,n=e.props.toJSON(),a=l.pick(n,"orderby","order");return e.type&&(a.type=e.type,delete e.type),e[this.tag]&&l.extend(a,e[this.tag].toJSON()),a.ids=e.pluck("id"),n.uploadedTo&&(a.id=n.uploadedTo),delete a.orderby,a._orderbyRandom?a.orderby="rand":a._orderByField&&"rand"!==a._orderByField&&(a.orderby=a._orderByField),delete a._orderbyRandom,delete a._orderByField,a.ids&&"post__in"===a.orderby&&delete a.orderby,a=this.setDefaults(a),t=new wp.shortcode({tag:this.tag,attrs:a,type:"single"}),(i=new wp.media.model.Attachments(e.models,{props:n}))[this.tag]=e[this.tag],o[t.string()]=i,t},edit:function(e){var t,i,n,a=wp.shortcode.next(this.tag,e),d=this.defaults.id;if(a&&a.content===e)return a=a.shortcode,l.isUndefined(a.get("id"))&&!l.isUndefined(d)&&a.set("id",d),t=this.attachments(a),(i=new wp.media.model.Selection(t.models,{props:t.props.toJSON(),multiple:!0}))[this.tag]=t[this.tag],i.more().done(function(){i.props.set({query:!1}),i.unmirror(),i.props.unset("orderby")}),this.frame&&this.frame.dispose(),n=a.attrs.named.type&&"video"===a.attrs.named.type?"video-"+this.tag+"-edit":this.tag+"-edit",this.frame=wp.media({frame:"post",state:n,title:this.editTitle,editing:!0,multiple:!0,selection:i}).open(),this.frame},setDefaults:function(i){var n=this;return l.each(this.defaults,function(e,t){i[t]=n.coerce(i,t),e===i[t]&&delete i[t]}),i}},e)},wp.media._galleryDefaults={itemtag:"dl",icontag:"dt",captiontag:"dd",columns:"3",link:"post",size:"thumbnail",order:"ASC",id:wp.media.view.settings.post&&wp.media.view.settings.post.id,orderby:"menu_order ID"},wp.media.view.settings.galleryDefaults?wp.media.galleryDefaults=l.extend({},wp.media._galleryDefaults,wp.media.view.settings.galleryDefaults):wp.media.galleryDefaults=wp.media._galleryDefaults,wp.media.gallery=new wp.media.collection({tag:"gallery",type:"image",editTitle:wp.media.view.l10n.editGalleryTitle,defaults:wp.media.galleryDefaults,setDefaults:function(i){var n=this,a=!l.isEqual(wp.media.galleryDefaults,wp.media._galleryDefaults);return l.each(this.defaults,function(e,t){i[t]=n.coerce(i,t),e!==i[t]||a&&e!==wp.media._galleryDefaults[t]||delete i[t]}),i}}),wp.media.featuredImage={get:function(){return wp.media.view.settings.post.featuredImageId},set:function(e){var t=wp.media.view.settings;t.post.featuredImageId=e,wp.media.post("get-post-thumbnail-html",{post_id:t.post.id,thumbnail_id:t.post.featuredImageId,_wpnonce:t.post.nonce}).done(function(e){"0"!==e?a(".inside","#postimagediv").html(e):window.alert(window.setPostThumbnailL10n.error)})},remove:function(){wp.media.featuredImage.set(-1)},frame:function(){return this._frame?wp.media.frame=this._frame:(this._frame=wp.media({state:"featured-image",states:[new wp.media.controller.FeaturedImage,new wp.media.controller.EditImage]}),this._frame.on("toolbar:create:featured-image",function(e){this.createSelectToolbar(e,{text:wp.media.view.l10n.setFeaturedImage})},this._frame),this._frame.on("content:render:edit-image",function(){var e=this.state("featured-image").get("selection"),t=new wp.media.view.EditImage({model:e.single(),controller:this}).render();this.content.set(t),t.loadEditor()},this._frame),this._frame.state("featured-image").on("select",this.select)),this._frame},select:function(){var e=this.get("selection").single();wp.media.view.settings.post.featuredImageId&&wp.media.featuredImage.set(e?e.id:-1)},init:function(){a("#postimagediv").on("click","#set-post-thumbnail",function(e){e.preventDefault(),e.stopPropagation(),wp.media.featuredImage.frame().open()}).on("click","#remove-post-thumbnail",function(){return wp.media.featuredImage.remove(),!1})}},a(wp.media.featuredImage.init),wp.media.editor={insert:function(e){var t,i,n=!l.isUndefined(window.tinymce),a=!l.isUndefined(window.QTags);if(i=this.activeEditor?window.wpActiveEditor=this.activeEditor:window.wpActiveEditor,window.send_to_editor)return window.send_to_editor.apply(this,arguments);if(i)n&&(t=tinymce.get(i));else if(n&&tinymce.activeEditor)t=tinymce.activeEditor,i=window.wpActiveEditor=t.id;else if(!a)return!1;if(t&&!t.isHidden()?t.execCommand("mceInsertContent",!1,e):a?QTags.insertContent(e):document.getElementById(i).value+=e,window.tb_remove)try{window.tb_remove()}catch(e){}},add:function(e,t){var n=this.get(e);return n||((n=i[e]=wp.media(l.defaults(t||{},{frame:"post",state:"insert",title:wp.media.view.l10n.addMedia,multiple:!0}))).on("insert",function(e){var i=n.state();(e=e||i.get("selection"))&&a.when.apply(a,e.map(function(e){var t=i.display(e).toJSON();return this.send.attachment(t,e.toJSON())},this)).done(function(){wp.media.editor.insert(l.toArray(arguments).join("\n\n"))})},this),n.state("gallery-edit").on("update",function(e){this.insert(wp.media.gallery.shortcode(e).string())},this),n.state("playlist-edit").on("update",function(e){this.insert(wp.media.playlist.shortcode(e).string())},this),n.state("video-playlist-edit").on("update",function(e){this.insert(wp.media.playlist.shortcode(e).string())},this),n.state("embed").on("select",function(){var e=n.state(),t=e.get("type"),i=e.props.toJSON();i.url=i.url||"","link"===t?(l.defaults(i,{linkText:i.url,linkUrl:i.url}),this.send.link(i).done(function(e){wp.media.editor.insert(e)})):"image"===t&&(l.defaults(i,{title:i.url,linkUrl:"",align:"none",link:"none"}),"none"===i.link?i.linkUrl="":"file"===i.link&&(i.linkUrl=i.url),this.insert(wp.media.string.image(i)))},this),n.state("featured-image").on("select",wp.media.featuredImage.select),n.setState(n.options.state),n)},id:function(e){return e||((e=window.wpActiveEditor)||l.isUndefined(window.tinymce)||!tinymce.activeEditor||(e=tinymce.activeEditor.id),e=e||"")},get:function(e){return e=this.id(e),i[e]},remove:function(e){e=this.id(e),delete i[e]},send:{attachment:function(i,e){var n,t,a=e.caption;return wp.media.view.settings.captions||delete e.caption,i=wp.media.string.props(i,e),n={id:e.id,post_content:e.description,post_excerpt:a},i.linkUrl&&(n.url=i.linkUrl),"image"===e.type?(t=wp.media.string.image(i),l.each({align:"align",size:"image-size",alt:"image_alt"},function(e,t){i[t]&&(n[e]=i[t])})):"video"===e.type?t=wp.media.string.video(i,e):"audio"===e.type?t=wp.media.string.audio(i,e):(t=wp.media.string.link(i),n.post_title=i.title),wp.media.post("send-attachment-to-editor",{nonce:wp.media.view.settings.nonce.sendToEditor,attachment:n,html:t,post_id:wp.media.view.settings.post.id})},link:function(e){return wp.media.post("send-link-to-editor",{nonce:wp.media.view.settings.nonce.sendToEditor,src:e.linkUrl,link_text:e.linkText,html:wp.media.string.link(e),post_id:wp.media.view.settings.post.id})}},open:function(e,t){var i;return t=t||{},e=this.id(e),this.activeEditor=e,(!(i=this.get(e))||i.options&&t.state!==i.options.state)&&(i=this.add(e,t)),(wp.media.frame=i).open()},init:function(){a(document.body).on("click.add-media-button",".insert-media",function(e){var t=a(e.currentTarget),i=t.data("editor"),n={frame:"post",state:"insert",title:wp.media.view.l10n.addMedia,multiple:!0};e.preventDefault(),t.hasClass("gallery")&&(n.state="gallery",n.title=wp.media.view.l10n.createGalleryTitle),wp.media.editor.open(i,n)}),(new wp.media.view.EditorUploader).render()}},l.bindAll(wp.media.editor,"open"),a(wp.media.editor.init)}(jQuery,_); \ No newline at end of file +!function(a,l){var i={};wp.media.coerce=function(e,t){return l.isUndefined(e[t])&&!l.isUndefined(this.defaults[t])?e[t]=this.defaults[t]:"true"===e[t]?e[t]=!0:"false"===e[t]&&(e[t]=!1),e[t]},wp.media.string={props:function(e,t){var i,n,a,d,r=wp.media.view.settings.defaultProps;return e=e?l.clone(e):{},t&&t.type&&(e.type=t.type),"image"===e.type&&(e=l.defaults(e||{},{align:r.align||getUserSetting("align","none"),size:r.size||getUserSetting("imgsize","medium"),url:"",classes:[]})),t&&(e.title=e.title||t.title,"file"===(i=e.link||r.link||getUserSetting("urlbutton","file"))||"embed"===i?n=t.url:"post"===i?n=t.link:"custom"===i&&(n=e.linkUrl),e.linkUrl=n||"","image"===t.type?(e.classes.push("wp-image-"+t.id),a=(d=t.sizes)&&d[e.size]?d[e.size]:t,l.extend(e,l.pick(t,"align","caption","alt"),{width:a.width,height:a.height,src:a.url,captionId:"attachment_"+t.id})):"video"===t.type||"audio"===t.type?l.extend(e,l.pick(t,"title","type","icon","mime")):(e.title=e.title||t.filename,e.rel=e.rel||"attachment wp-att-"+t.id)),e},link:function(e,t){var i;return i={tag:"a",content:(e=wp.media.string.props(e,t)).title,attrs:{href:e.linkUrl}},e.rel&&(i.attrs.rel=e.rel),wp.html.string(i)},audio:function(e,t){return wp.media.string._audioVideo("audio",e,t)},video:function(e,t){return wp.media.string._audioVideo("video",e,t)},_audioVideo:function(e,t,i){var n,a;return"embed"!==(t=wp.media.string.props(t,i)).link?wp.media.string.link(t):(n={},"video"===e&&(i.image&&-1===i.image.src.indexOf(i.icon)&&(n.poster=i.image.src),i.width&&(n.width=i.width),i.height&&(n.height=i.height)),a=i.filename.split(".").pop(),l.contains(wp.media.view.settings.embedExts,a)?(n[a]=i.url,wp.shortcode.string({tag:e,attrs:n})):wp.media.string.link(t))},image:function(e,t){var i,n,a,d,r={};return e.type="image",n=(e=wp.media.string.props(e,t)).classes||[],r.src=l.isUndefined(t)?e.url:t.url,l.extend(r,l.pick(e,"width","height","alt")),e.align&&!e.caption&&n.push("align"+e.align),e.size&&n.push("size-"+e.size),r.class=l.compact(n).join(" "),i={tag:"img",attrs:r,single:!0},e.linkUrl&&(i={tag:"a",attrs:{href:e.linkUrl},content:i}),d=wp.html.string(i),e.caption&&(a={},r.width&&(a.width=r.width),e.captionId&&(a.id=e.captionId),e.align&&(a.align="align"+e.align),d=wp.shortcode.string({tag:"caption",attrs:a,content:d+" "+e.caption})),d}},wp.media.embed={coerce:wp.media.coerce,defaults:{url:"",width:"",height:""},edit:function(e,t){var i,n={};return t?n.url=e.replace(/<[^>]+>/g,""):(i=wp.shortcode.next("embed",e).shortcode,n=l.defaults(i.attrs.named,this.defaults),i.content&&(n.url=i.content)),wp.media({frame:"post",state:"embed",metadata:n})},shortcode:function(i){var e,n=this;return l.each(this.defaults,function(e,t){i[t]=n.coerce(i,t),e===i[t]&&delete i[t]}),e=i.url,delete i.url,new wp.shortcode({tag:"embed",attrs:i,content:e})}},wp.media.collection=function(e){var o={};return l.extend({coerce:wp.media.coerce,attachments:function(e){var t,i,n,a,d=e.string(),r=o[d],s=this;return delete o[d],r||(t=l.defaults(e.attrs.named,this.defaults),(i=l.pick(t,"orderby","order")).type=this.type,i.perPage=-1,void 0!==t.orderby&&(t._orderByField=t.orderby),"rand"===t.orderby&&(t._orderbyRandom=!0),t.orderby&&!/^menu_order(?: ID)?$/i.test(t.orderby)||(i.orderby="menuOrder"),t.ids?(i.post__in=t.ids.split(","),i.orderby="post__in"):t.include&&(i.post__in=t.include.split(",")),t.exclude&&(i.post__not_in=t.exclude.split(",")),i.post__in||(i.uploadedTo=t.id),a=l.omit(t,"id","ids","include","exclude","orderby","order"),l.each(this.defaults,function(e,t){a[t]=s.coerce(a,t)}),(n=wp.media.query(i))[this.tag]=new Backbone.Model(a),n)},shortcode:function(e){var t,i,n=e.props.toJSON(),a=l.pick(n,"orderby","order");return e.type&&(a.type=e.type,delete e.type),e[this.tag]&&l.extend(a,e[this.tag].toJSON()),a.ids=e.pluck("id"),n.uploadedTo&&(a.id=n.uploadedTo),delete a.orderby,a._orderbyRandom?a.orderby="rand":a._orderByField&&"rand"!==a._orderByField&&(a.orderby=a._orderByField),delete a._orderbyRandom,delete a._orderByField,a.ids&&"post__in"===a.orderby&&delete a.orderby,a=this.setDefaults(a),t=new wp.shortcode({tag:this.tag,attrs:a,type:"single"}),(i=new wp.media.model.Attachments(e.models,{props:n}))[this.tag]=e[this.tag],o[t.string()]=i,t},edit:function(e){var t,i,n,a=wp.shortcode.next(this.tag,e),d=this.defaults.id;if(a&&a.content===e)return a=a.shortcode,l.isUndefined(a.get("id"))&&!l.isUndefined(d)&&a.set("id",d),t=this.attachments(a),(i=new wp.media.model.Selection(t.models,{props:t.props.toJSON(),multiple:!0}))[this.tag]=t[this.tag],i.more().done(function(){i.props.set({query:!1}),i.unmirror(),i.props.unset("orderby")}),this.frame&&this.frame.dispose(),n=a.attrs.named.type&&"video"===a.attrs.named.type?"video-"+this.tag+"-edit":this.tag+"-edit",this.frame=wp.media({frame:"post",state:n,title:this.editTitle,editing:!0,multiple:!0,selection:i}).open(),this.frame},setDefaults:function(i){var n=this;return l.each(this.defaults,function(e,t){i[t]=n.coerce(i,t),e===i[t]&&delete i[t]}),i}},e)},wp.media._galleryDefaults={itemtag:"dl",icontag:"dt",captiontag:"dd",columns:"3",link:"post",size:"thumbnail",order:"ASC",id:wp.media.view.settings.post&&wp.media.view.settings.post.id,orderby:"menu_order ID"},wp.media.view.settings.galleryDefaults?wp.media.galleryDefaults=l.extend({},wp.media._galleryDefaults,wp.media.view.settings.galleryDefaults):wp.media.galleryDefaults=wp.media._galleryDefaults,wp.media.gallery=new wp.media.collection({tag:"gallery",type:"image",editTitle:wp.media.view.l10n.editGalleryTitle,defaults:wp.media.galleryDefaults,setDefaults:function(i){var n=this,a=!l.isEqual(wp.media.galleryDefaults,wp.media._galleryDefaults);return l.each(this.defaults,function(e,t){i[t]=n.coerce(i,t),e!==i[t]||a&&e!==wp.media._galleryDefaults[t]||delete i[t]}),i}}),wp.media.featuredImage={get:function(){return wp.media.view.settings.post.featuredImageId},set:function(e){var t=wp.media.view.settings;t.post.featuredImageId=e,wp.media.post("get-post-thumbnail-html",{post_id:t.post.id,thumbnail_id:t.post.featuredImageId,_wpnonce:t.post.nonce}).done(function(e){"0"!==e?a(".inside","#postimagediv").html(e):window.alert(wp.i18n.__("Could not set that as the thumbnail image. Try a different attachment."))})},remove:function(){wp.media.featuredImage.set(-1)},frame:function(){return this._frame?wp.media.frame=this._frame:(this._frame=wp.media({state:"featured-image",states:[new wp.media.controller.FeaturedImage,new wp.media.controller.EditImage]}),this._frame.on("toolbar:create:featured-image",function(e){this.createSelectToolbar(e,{text:wp.media.view.l10n.setFeaturedImage})},this._frame),this._frame.on("content:render:edit-image",function(){var e=this.state("featured-image").get("selection"),t=new wp.media.view.EditImage({model:e.single(),controller:this}).render();this.content.set(t),t.loadEditor()},this._frame),this._frame.state("featured-image").on("select",this.select)),this._frame},select:function(){var e=this.get("selection").single();wp.media.view.settings.post.featuredImageId&&wp.media.featuredImage.set(e?e.id:-1)},init:function(){a("#postimagediv").on("click","#set-post-thumbnail",function(e){e.preventDefault(),e.stopPropagation(),wp.media.featuredImage.frame().open()}).on("click","#remove-post-thumbnail",function(){return wp.media.featuredImage.remove(),!1})}},a(wp.media.featuredImage.init),wp.media.editor={insert:function(e){var t,i,n=!l.isUndefined(window.tinymce),a=!l.isUndefined(window.QTags);if(i=this.activeEditor?window.wpActiveEditor=this.activeEditor:window.wpActiveEditor,window.send_to_editor)return window.send_to_editor.apply(this,arguments);if(i)n&&(t=tinymce.get(i));else if(n&&tinymce.activeEditor)t=tinymce.activeEditor,i=window.wpActiveEditor=t.id;else if(!a)return!1;if(t&&!t.isHidden()?t.execCommand("mceInsertContent",!1,e):a?QTags.insertContent(e):document.getElementById(i).value+=e,window.tb_remove)try{window.tb_remove()}catch(e){}},add:function(e,t){var n=this.get(e);return n||((n=i[e]=wp.media(l.defaults(t||{},{frame:"post",state:"insert",title:wp.media.view.l10n.addMedia,multiple:!0}))).on("insert",function(e){var i=n.state();(e=e||i.get("selection"))&&a.when.apply(a,e.map(function(e){var t=i.display(e).toJSON();return this.send.attachment(t,e.toJSON())},this)).done(function(){wp.media.editor.insert(l.toArray(arguments).join("\n\n"))})},this),n.state("gallery-edit").on("update",function(e){this.insert(wp.media.gallery.shortcode(e).string())},this),n.state("playlist-edit").on("update",function(e){this.insert(wp.media.playlist.shortcode(e).string())},this),n.state("video-playlist-edit").on("update",function(e){this.insert(wp.media.playlist.shortcode(e).string())},this),n.state("embed").on("select",function(){var e=n.state(),t=e.get("type"),i=e.props.toJSON();i.url=i.url||"","link"===t?(l.defaults(i,{linkText:i.url,linkUrl:i.url}),this.send.link(i).done(function(e){wp.media.editor.insert(e)})):"image"===t&&(l.defaults(i,{title:i.url,linkUrl:"",align:"none",link:"none"}),"none"===i.link?i.linkUrl="":"file"===i.link&&(i.linkUrl=i.url),this.insert(wp.media.string.image(i)))},this),n.state("featured-image").on("select",wp.media.featuredImage.select),n.setState(n.options.state),n)},id:function(e){return e||((e=window.wpActiveEditor)||l.isUndefined(window.tinymce)||!tinymce.activeEditor||(e=tinymce.activeEditor.id),e=e||"")},get:function(e){return e=this.id(e),i[e]},remove:function(e){e=this.id(e),delete i[e]},send:{attachment:function(i,e){var n,t,a=e.caption;return wp.media.view.settings.captions||delete e.caption,i=wp.media.string.props(i,e),n={id:e.id,post_content:e.description,post_excerpt:a},i.linkUrl&&(n.url=i.linkUrl),"image"===e.type?(t=wp.media.string.image(i),l.each({align:"align",size:"image-size",alt:"image_alt"},function(e,t){i[t]&&(n[e]=i[t])})):"video"===e.type?t=wp.media.string.video(i,e):"audio"===e.type?t=wp.media.string.audio(i,e):(t=wp.media.string.link(i),n.post_title=i.title),wp.media.post("send-attachment-to-editor",{nonce:wp.media.view.settings.nonce.sendToEditor,attachment:n,html:t,post_id:wp.media.view.settings.post.id})},link:function(e){return wp.media.post("send-link-to-editor",{nonce:wp.media.view.settings.nonce.sendToEditor,src:e.linkUrl,link_text:e.linkText,html:wp.media.string.link(e),post_id:wp.media.view.settings.post.id})}},open:function(e,t){var i;return t=t||{},e=this.id(e),this.activeEditor=e,(!(i=this.get(e))||i.options&&t.state!==i.options.state)&&(i=this.add(e,t)),(wp.media.frame=i).open()},init:function(){a(document.body).on("click.add-media-button",".insert-media",function(e){var t=a(e.currentTarget),i=t.data("editor"),n={frame:"post",state:"insert",title:wp.media.view.l10n.addMedia,multiple:!0};e.preventDefault(),t.hasClass("gallery")&&(n.state="gallery",n.title=wp.media.view.l10n.createGalleryTitle),wp.media.editor.open(i,n)}),(new wp.media.view.EditorUploader).render()}},l.bindAll(wp.media.editor,"open"),a(wp.media.editor.init)}(jQuery,_); \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 04994da384..f0404830bd 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -1186,6 +1186,7 @@ function wp_default_scripts( $scripts ) { $scripts->set_translations( 'media-views' ); $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 ); + $scripts->set_translations( 'media-editor' ); $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 ); $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 ); @@ -1287,16 +1288,7 @@ function wp_default_scripts( $scripts ) { $scripts->set_translations( 'image-edit' ); $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 ); - did_action( 'init' ) && $scripts->localize( - 'set-post-thumbnail', - 'setPostThumbnailL10n', - array( - 'setThumbnail' => __( 'Use as featured image' ), - 'saving' => __( 'Saving...' ), // No ellipsis. - 'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ), - 'done' => __( 'Done' ), - ) - ); + $scripts->set_translations( 'set-post-thumbnail' ); /* * Navigation Menus: Adding underscore as a dependency to utilize _.debounce diff --git a/wp-includes/version.php b/wp-includes/version.php index ee88899410..18567956fb 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-48395'; +$wp_version = '5.5-alpha-48396'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.