Plugin Directory

Changeset 2372409


Ignore:
Timestamp:
08/31/2020 02:08:37 PM (5 years ago)
Author:
giuseppectmobi
Message:

Update to version 1.0.6 from GitHub

Location:
wubtitle
Files:
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wubtitle/tags/1.0.6/build/index.asset.php

    r2371183 r2372409  
    1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => '522b29c2c0236dcac5d26f996c59a0bf');
     1<?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => '4b2a3b394565d4070e2fc070877c460d');
  • wubtitle/tags/1.0.6/build/index.js

    r2371183 r2372409  
    1 !function(t){var e={};function n(r){if(e[r])return e[r].exports;var c=e[r]={i:r,l:!1,exports:{}};return t[r].call(c.exports,c,c.exports,n),c.l=!0,c.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var c in t)n.d(r,c,function(e){return t[e]}.bind(null,c));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=19)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.wp.i18n}()},function(t,e,n){var r=n(14),c=n(15),i=n(16),o=n(18);t.exports=function(t,e){return r(t)||c(t,e)||i(t,e)||o()}},function(t,e){!function(){t.exports=this.wp.components}()},function(t,e){!function(){t.exports=this.wp.data}()},function(t,e){function n(){return t.exports=n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},n.apply(this,arguments)}t.exports=n},function(t,e){!function(){t.exports=this.wp.compose}()},function(t,e){!function(){t.exports=this.wp.hooks}()},function(t,e){!function(){t.exports=this.wp.blockEditor}()},function(t,e){!function(){t.exports=this.wp.apiFetch}()},function(t,e){!function(){t.exports=this.wp.plugins}()},function(t,e){!function(){t.exports=this.wp.editPost}()},function(t,e){!function(){t.exports=this.wp.domReady}()},function(t,e){!function(){t.exports=this.wp.blocks}()},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,c=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(r=(o=a.next()).done)&&(n.push(o.value),!e||n.length!==e);r=!0);}catch(t){c=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(c)throw i}}return n}}},function(t,e,n){var r=n(17);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e,n){"use strict";n.r(e);var r=n(5),c=n.n(r),i=n(0),o=n(6),a=n(7),l=n(2),u=n.n(l),b=n(4),s=n(9),d=n.n(s),p=n(3),f=n(8),_=n(1),j={it:Object(_.__)("Italian","wubtitle"),en:Object(_.__)("English","wubtitle"),es:Object(_.__)("Spanish","wubtitle"),de:Object(_.__)("German","wubtitle"),zh:Object(_.__)("Chinese","wubtitle"),fr:Object(_.__)("French","wubtitle")},O={pending:Object(_.__)("Generating","wubtitle"),draft:Object(_.__)("Draft","wubtitle"),enabled:Object(_.__)("Enabled","wubtitle"),notfound:Object(_.__)("None","wubtitle")},m=[{value:"it",label:Object(_.__)("Italian","wubtitle")},{value:"en",label:Object(_.__)("English","wubtitle")},{value:"es",label:Object(_.__)("Spanish","wubtitle")},{value:"de",label:Object(_.__)("German","wubtitle")},{value:"zh",label:Object(_.__)("Chinese","wubtitle")},{value:"fr",label:Object(_.__)("French","wubtitle")}],w=[{value:"it",label:Object(_.__)("Italian","wubtitle"),disabled:!1},{value:"en",label:Object(_.__)("English","wubtitle"),disabled:!1},{value:"es",label:Object(_.__)("Spanish (Pro only)","wubtitle"),disabled:!0},{value:"de",label:Object(_.__)("German (Pro only)","wubtitle"),disabled:!0},{value:"zh",label:Object(_.__)("Chinese (Pro only)","wubtitle"),disabled:!0},{value:"fr",label:Object(_.__)("French (Pro only)","wubtitle"),disabled:!0}],g=function(t){var e=t.statusText,n=t.langText;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Status:","wubtitle")+" "+O[e]),Object(i.createElement)("div",null,Object(_.__)("Language:","wubtitle")+" "+j[n]))},h=function(t){var e=t.statusText,n=t.langText,r=t.isPublished,c=t.postId,o=Object(i.useState)(""),a=u()(o,2),l=a[0],s=a[1],d=Object(b.useDispatch)("core"),f=function(t){d.editEntityRecord("postType","attachment",c,{meta:{wubtitle_status:t}})};return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("p",{style:{margin:"0"}},Object(_.__)("Status:","wubtitle")+" "+O[e]),Object(i.createElement)("p",{style:{margin:"8px 0"}},Object(_.__)("Language:","wubtitle")+" "+j[n]),Object(i.createElement)(p.ToggleControl,{label:Object(_.__)("Published","wubtitle"),checked:r,onChange:function(){var t;t="draft",!r&&(t="enabled"),f(t),d.saveEditedEntityRecord("postType","attachment",c)}}),Object(i.createElement)(p.Button,{name:"sottotitoli",id:c,isPrimary:!0,onClick:function(){s(Object(_.__)("Getting transcript…","wubtitle")),wp.ajax.send("get_transcript_internal_video",{type:"POST",data:{id:c,_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){s("Done");var e=wp.data.select("core/block-editor").getBlockIndex(wp.data.select("core/block-editor").getSelectedBlock().clientId),n=wp.blocks.createBlock("wubtitle/transcription",{contentId:t});wp.data.dispatch("core/block-editor").insertBlocks(n,e+1)})).fail((function(t){s(t)}))}},Object(_.__)("Get Transcribe","wubtitle")),Object(i.createElement)("p",null,l))},v=function(t){var e,n,r=void 0!==t.id?t.src.substring(t.src.lastIndexOf(".")+1):"mp4",c=("1"===wubtitle_button_object.isFree?["it","en"]:["it","en","es","de","zh"]).includes(wubtitle_button_object.lang)?wubtitle_button_object.lang:"en",o=Object(b.useSelect)((function(e){var n;void 0!==t.id&&(n=e("core").getEntityRecord("postType","attachment",t.id));var r="";return void 0!==n&&(r=e("core").getEditedEntityRecord("postType","attachment",t.id).meta),r}));void 0!==o&&(e=o.wubtitle_lang_video,n=o.wubtitle_status);var a=Object(b.useDispatch)("core/notices"),l=Object(b.useDispatch)("core"),s=Object(i.useState)(c),j=u()(s,2),O=j[0],v=j[1],y="pending"===n||void 0===t.id,E="enabled"===n,x="1"===wubtitle_button_object.isFree?w:m,S=function(){return n="error"===n?Object(_.__)("Error","wubtitle"):Object(_.__)("None","wubtitle"),Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Status:","wubtitle")+" "+n),Object(i.createElement)(p.SelectControl,{label:Object(_.__)("Select the video language","wubtitle"),value:O,onChange:function(t){v(t)},options:x}),Object(i.createElement)(p.Button,{disabled:y,name:"sottotitoli",id:t.id,isPrimary:!0,onClick:k},Object(_.__)("GENERATE SUBTITLES","wubtitle")))},T=function(){return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Unsupported video format for free plan","wubtitle")))};function k(){var e=t.id,n=t.src;d()({url:wubtitle_button_object.ajax_url,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:"action=submitVideo&_ajax_nonce=".concat(wubtitle_button_object.ajaxnonce,"&id_attachment=").concat(e,"&src_attachment=").concat(n,"&lang=").concat(O,"&")}).then((function(e){201===e.data?(a.createNotice("success",Object(_.__)("Subtitle creation successfully started","wubtitle")),l.editEntityRecord("postType","attachment",t.id,{meta:{wubtitle_status:"pending",wubtitle_lang_video:O}})):a.createNotice("error",e.data)}))}return Object(i.createElement)(f.InspectorControls,null,Object(i.createElement)(p.PanelBody,{title:"Wubtitle"},Object(i.createElement)((function(){if("1"===wubtitle_button_object.isFree&&"mp4"!==r)return Object(i.createElement)(T,null);switch(n){case"pending":return Object(i.createElement)(g,{langText:e,statusText:n});case"draft":case"enabled":return Object(i.createElement)(h,{statusText:n,langText:e,isPublished:E,postId:t.id});default:return Object(i.createElement)(S,null)}}),{status:n,languageSaved:e})))},y=Object(o.createHigherOrderComponent)((function(t){return function(e){return"core/video"!==e.name?Object(i.createElement)(t,e):Object(i.createElement)(i.Fragment,null,Object(i.createElement)(t,e),Object(i.createElement)(v,c()({},e.attributes,{setAttributes:e.setAttributes})))}}),"withInspectorControls");Object(a.addFilter)("editor.BlockEdit","wubtitle/with-inspector-controls",y);var E=n(10),x=n(11),S=n(12),T=function(){var t=Object(i.useState)(""),e=u()(t,2),n=e[0],r=e[1],c=Object(i.useState)(""),o=u()(c,2),a=o[0],l=o[1],b=""===a;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(x.PluginDocumentSettingPanel,{name:"transcript-panel",title:"Transcript"},Object(i.createElement)(p.TextControl,{label:"video url",id:"input",value:a,onChange:function(t){l(t)}}),Object(i.createElement)(p.Button,{name:"transcript",isPrimary:!0,onClick:function(){r(Object(_.__)("Getting transcript…","wubtitle")),wp.ajax.send("get_transcript",{type:"POST",data:{url:a,source:"youtube",from:"transcript_post_type",_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){r(Object(_.__)("Done","wubtitle"));var e=wp.blocks.createBlock("core/paragraph",{content:t});wp.data.dispatch("core/block-editor").insertBlocks(e)})).fail((function(t){r(t)}))},disabled:b},Object(_.__)("Get transcript","wubtitle")),Object(i.createElement)("p",null,n)))};n.n(S)()((function(){"transcript"===Object(b.select)("core/editor").getCurrentPostType()&&Object(E.registerPlugin)("transcript-panel",{render:T,icon:""})}));var k=function(t){var e=Object(i.useState)(""),n=u()(e,2),r=n[0],c=n[1],o=Object(i.useState)(Object(_.__)("None","wubtitle")),a=u()(o,2),l=a[0],s=a[1],d=Object(i.useState)(""),j=u()(d,2),O=j[0],m=j[1],w=Object(i.useState)(!1),g=u()(w,2),h=g[0],v=g[1],y=Object(i.useState)([]),E=u()(y,2),x=E[0],S=E[1],T=Object(i.useState)(""),k=u()(T,2),C=k[0],P=k[1],I=Object(i.useState)(!0),B=u()(I,2),F=B[0],A=B[1],G=Object(b.useDispatch)("core/notices");Object(b.useSelect)((function(e){if(void 0!==t.url){var n=e("core").getEntityRecords("postType","transcript",{metaKey:"_video_id",metaValue:t.url}),r=Object(_.__)("Created","wubtitle");n&&n.length>0&&l!==r&&s(r)}}));return Object(i.createElement)(f.InspectorControls,null,Object(i.createElement)(p.PanelBody,{title:"Wubtitle"},Object(i.createElement)("p",{style:{margin:"0",marginBottom:"20px"}},"".concat(Object(_.__)("Transcript status:","wubtitle")," ").concat(l)),t.url&&h?Object(i.createElement)(p.SelectControl,{label:Object(_.__)("Select the video language","wubtitle"),value:O,onChange:function(t){m(t),A("none"===t)},options:x}):void wp.ajax.send("get_video_info",{type:"POST",data:{url:t.url,_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){if(t.languages){c(""),v(!0);var e=t.languages.map((function(t){return{value:t.baseUrl,label:t.name.simpleText}}));e.unshift({value:"none",label:Object(_.__)("Select language","wubtitle")}),S(e),P(t.title)}else c(Object(_.__)("Subtitles not available for this video","wubtitle"))})).fail((function(t){console.log(t)})),Object(i.createElement)(p.Button,{name:"sottotitoli",id:t.id,isPrimary:!0,onClick:function(){var e=wp.data.select("core/block-editor").getBlockIndex(wp.data.select("core/block-editor").getSelectedBlock().clientId);c(Object(_.__)("Getting transcript…","ear2words")),wp.ajax.send("get_transcript_yt",{type:"POST",data:{urlVideo:t.url,urlSubtitle:O,videoTitle:C,from:"default_post_type",_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){var n=wp.blocks.createBlock("wubtitle/transcription",{contentId:t}),r=e+1;wp.data.dispatch("core/block-editor").insertBlocks(n,r),c(""),s(Object(_.__)("Created","wubtitle"))})).fail((function(t){G.createNotice("error",t),c("")}))},disabled:F},Object(_.__)("Get Transcribe","wubtitle")),Object(i.createElement)("p",null,r)))},C=Object(o.createHigherOrderComponent)((function(t){return function(e){return"core-embed/youtube"!==e.name?Object(i.createElement)(t,e):Object(i.createElement)(i.Fragment,null,Object(i.createElement)(t,e),Object(i.createElement)(k,c()({},e.attributes,{setAttributes:e.setAttributes})))}}),"withInspectorControls");Object(a.addFilter)("editor.BlockEdit","wubtitle/with-inspector-controls",C);var P=n(13);function I(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=Object(i.useState)(t),r=u()(n,2),c=r[0],o=r[1];return Object(i.useEffect)((function(){var n=setTimeout((function(){o(t)}),e);return function(){clearTimeout(n)}}),[t]),c}var B=function(t){var e=t.attributes,n=t.setAttributes,r=t.className,c=Object(i.useState)(""),o=u()(c,2),a=o[0],l=o[1],s=Object(i.useState)(""),d=u()(s,2),f=d[0],j=d[1],O=Object(i.useState)([]),m=u()(O,2),w=m[0],g=m[1],h=I(a,500),v=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(e)}))},y=function(t){var e=wp.blocks.createBlock("core/paragraph",{content:t}),n=wp.data.select("core/block-editor").getSelectedBlock().clientId;wp.data.dispatch("core/block-editor").replaceBlocks(n,e),wp.data.dispatch("core/block-editor").clearSelectedBlock()};Object(i.useEffect)((function(){j(h)}),[h]),Object(b.useSelect)((function(t){if(e.contentId&&0===w.length){var n={per_page:1,include:e.contentId},r=t("core").getEntityRecords("postType","transcript",n);if(null!==r){g([r[0].title.rendered]);var c=r[0].content.rendered;c=(c=c.replace("<p>","")).replace("</p>",""),y(c)}}}));for(var E=Object(b.useSelect)((function(t){if(f.length>2){var e={per_page:10,search:f},n=t("core").getEntityRecords("postType","transcript",e);return null!==n?n:[]}return[]})),x=new Map,S=[],T=0;T<E.length;T++)x.set(v(E[T].title.rendered),E[T].id),x.set(v("".concat(E[T].title.rendered," content")),E[T].content.rendered),S[T]=v(E[T].title.rendered);var k="";return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(p.FormTokenField,{className:r,label:Object(_.__)("Wubtitle transcriptions","wubtitle"),value:w,suggestions:S,onChange:function(t){return function(t){if(0===t.length)n({contentId:null}),g(t);else if(S.includes(t[0])){var e=x.get(t[0]),r="".concat(t[0]," content");k=(k=(k=x.get(r)).replace("<p>","")).replace("</p>",""),g(t),n({contentId:e}),y(k)}}(t)},placeholder:Object(_.__)("Insert transcriptions","wubtitle"),onInputChange:function(t){return l(t)},maxLength:1}),Object(i.createElement)("p",{className:"helperText"},Object(_.__)("Enter the title of the video you want to transcribe","wubtitle")))};Object(P.registerBlockType)("wubtitle/transcription",{title:Object(_.__)("Trascription","wubtitle"),icon:"megaphone",description:Object(_.__)("Enter the transcript of your video","wubtitle"),category:"embed",attributes:{contentId:{type:"int"}},edit:B})}]);
     1!function(t){var e={};function n(r){if(e[r])return e[r].exports;var c=e[r]={i:r,l:!1,exports:{}};return t[r].call(c.exports,c,c.exports,n),c.l=!0,c.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var c in t)n.d(r,c,function(e){return t[e]}.bind(null,c));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=19)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.wp.i18n}()},function(t,e,n){var r=n(14),c=n(15),i=n(16),o=n(18);t.exports=function(t,e){return r(t)||c(t,e)||i(t,e)||o()}},function(t,e){!function(){t.exports=this.wp.components}()},function(t,e){!function(){t.exports=this.wp.data}()},function(t,e){function n(){return t.exports=n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},n.apply(this,arguments)}t.exports=n},function(t,e){!function(){t.exports=this.wp.compose}()},function(t,e){!function(){t.exports=this.wp.hooks}()},function(t,e){!function(){t.exports=this.wp.blockEditor}()},function(t,e){!function(){t.exports=this.wp.apiFetch}()},function(t,e){!function(){t.exports=this.wp.plugins}()},function(t,e){!function(){t.exports=this.wp.editPost}()},function(t,e){!function(){t.exports=this.wp.domReady}()},function(t,e){!function(){t.exports=this.wp.blocks}()},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,c=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(r=(o=a.next()).done)&&(n.push(o.value),!e||n.length!==e);r=!0);}catch(t){c=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(c)throw i}}return n}}},function(t,e,n){var r=n(17);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e,n){"use strict";n.r(e);var r=n(5),c=n.n(r),i=n(0),o=n(6),a=n(7),l=n(2),u=n.n(l),b=n(4),s=n(9),d=n.n(s),p=n(3),f=n(8),_=n(1),j={it:Object(_.__)("Italian","wubtitle"),en:Object(_.__)("English","wubtitle"),es:Object(_.__)("Spanish","wubtitle"),de:Object(_.__)("German","wubtitle"),zh:Object(_.__)("Chinese","wubtitle"),fr:Object(_.__)("French","wubtitle")},O={pending:Object(_.__)("Generating","wubtitle"),draft:Object(_.__)("Draft","wubtitle"),enabled:Object(_.__)("Enabled","wubtitle"),notfound:Object(_.__)("None","wubtitle")},m=[{value:"it",label:Object(_.__)("Italian","wubtitle")},{value:"en",label:Object(_.__)("English","wubtitle")},{value:"es",label:Object(_.__)("Spanish","wubtitle")},{value:"de",label:Object(_.__)("German","wubtitle")},{value:"zh",label:Object(_.__)("Chinese","wubtitle")},{value:"fr",label:Object(_.__)("French","wubtitle")}],w=[{value:"it",label:Object(_.__)("Italian","wubtitle"),disabled:!1},{value:"en",label:Object(_.__)("English","wubtitle"),disabled:!1},{value:"es",label:Object(_.__)("Spanish (Pro only)","wubtitle"),disabled:!0},{value:"de",label:Object(_.__)("German (Pro only)","wubtitle"),disabled:!0},{value:"zh",label:Object(_.__)("Chinese (Pro only)","wubtitle"),disabled:!0},{value:"fr",label:Object(_.__)("French (Pro only)","wubtitle"),disabled:!0}],g=function(t){var e=t.statusText,n=t.langText;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Status:","wubtitle")+" "+O[e]),Object(i.createElement)("div",null,Object(_.__)("Language:","wubtitle")+" "+j[n]))},h=function(t){var e=t.statusText,n=t.langText,r=t.isPublished,c=t.postId,o=Object(i.useState)(""),a=u()(o,2),l=a[0],s=a[1],d=Object(b.useDispatch)("core"),f=function(t){d.editEntityRecord("postType","attachment",c,{meta:{wubtitle_status:t}})};return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("p",{style:{margin:"0"}},Object(_.__)("Status:","wubtitle")+" "+O[e]),Object(i.createElement)("p",{style:{margin:"8px 0"}},Object(_.__)("Language:","wubtitle")+" "+j[n]),Object(i.createElement)(p.ToggleControl,{label:Object(_.__)("Published","wubtitle"),checked:r,onChange:function(){var t;t="draft",!r&&(t="enabled"),f(t),d.saveEditedEntityRecord("postType","attachment",c)}}),Object(i.createElement)(p.Button,{name:"sottotitoli",id:c,isPrimary:!0,onClick:function(){s(Object(_.__)("Getting transcript…","wubtitle")),wp.ajax.send("get_transcript_internal_video",{type:"POST",data:{id:c,_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){s("Done");var e=wp.data.select("core/block-editor").getBlockIndex(wp.data.select("core/block-editor").getSelectedBlock().clientId),n=wp.blocks.createBlock("wubtitle/transcription",{contentId:t});wp.data.dispatch("core/block-editor").insertBlocks(n,e+1)})).fail((function(t){s(t)}))}},Object(_.__)("Get Transcribe","wubtitle")),Object(i.createElement)("p",null,l))},v=function(t){var e,n,r=void 0!==t.id?t.src.substring(t.src.lastIndexOf(".")+1):"mp4",c=("1"===wubtitle_button_object.isFree?["it","en"]:["it","en","es","de","zh"]).includes(wubtitle_button_object.lang)?wubtitle_button_object.lang:"en",o=Object(b.useSelect)((function(e){var n;void 0!==t.id&&(n=e("core").getEntityRecord("postType","attachment",t.id));var r="";return void 0!==n&&(r=e("core").getEditedEntityRecord("postType","attachment",t.id).meta),r}));void 0!==o&&(e=o.wubtitle_lang_video,n=o.wubtitle_status);var a=Object(b.useDispatch)("core/notices"),l=Object(b.useDispatch)("core"),s=Object(i.useState)(c),j=u()(s,2),O=j[0],v=j[1],y=Object(i.useState)(!1),E=u()(y,2),x=E[0],S=E[1],T="pending"===n||void 0===t.id||x,k="enabled"===n,C="1"===wubtitle_button_object.isFree?w:m,P=function(){return n="error"===n?Object(_.__)("Error","wubtitle"):Object(_.__)("None","wubtitle"),Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Status:","wubtitle")+" "+n),Object(i.createElement)(p.SelectControl,{label:Object(_.__)("Select the video language","wubtitle"),value:O,onChange:function(t){v(t)},options:C}),Object(i.createElement)(p.Button,{disabled:T,name:"sottotitoli",id:t.id,isPrimary:!0,onClick:B},Object(_.__)("GENERATE SUBTITLES","wubtitle")))},I=function(){return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Unsupported video format for free plan","wubtitle")))};function B(){var e=t.id,n=t.src;S(!0),d()({url:wubtitle_button_object.ajax_url,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:"action=submitVideo&_ajax_nonce=".concat(wubtitle_button_object.ajaxnonce,"&id_attachment=").concat(e,"&src_attachment=").concat(n,"&lang=").concat(O,"&")}).then((function(e){S(!1),201===e.data?(a.createNotice("success",Object(_.__)("Subtitle creation successfully started","wubtitle")),l.editEntityRecord("postType","attachment",t.id,{meta:{wubtitle_status:"pending",wubtitle_lang_video:O}})):a.createNotice("error",e.data)}))}return Object(i.createElement)(f.InspectorControls,null,Object(i.createElement)(p.PanelBody,{title:"Wubtitle"},Object(i.createElement)((function(){if("1"===wubtitle_button_object.isFree&&"mp4"!==r)return Object(i.createElement)(I,null);switch(n){case"pending":return Object(i.createElement)(g,{langText:e,statusText:n});case"draft":case"enabled":return Object(i.createElement)(h,{statusText:n,langText:e,isPublished:k,postId:t.id});default:return Object(i.createElement)(P,null)}}),{status:n,languageSaved:e})))},y=Object(o.createHigherOrderComponent)((function(t){return function(e){return"core/video"!==e.name?Object(i.createElement)(t,e):Object(i.createElement)(i.Fragment,null,Object(i.createElement)(t,e),Object(i.createElement)(v,c()({},e.attributes,{setAttributes:e.setAttributes})))}}),"withInspectorControls");Object(a.addFilter)("editor.BlockEdit","wubtitle/with-inspector-controls",y);var E=n(10),x=n(11),S=n(12),T=function(){var t=Object(i.useState)(""),e=u()(t,2),n=e[0],r=e[1],c=Object(i.useState)(""),o=u()(c,2),a=o[0],l=o[1],b=""===a;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(x.PluginDocumentSettingPanel,{name:"transcript-panel",title:"Transcript"},Object(i.createElement)(p.TextControl,{label:"video url",id:"input",value:a,onChange:function(t){l(t)}}),Object(i.createElement)(p.Button,{name:"transcript",isPrimary:!0,onClick:function(){r(Object(_.__)("Getting transcript…","wubtitle")),wp.ajax.send("get_transcript",{type:"POST",data:{url:a,source:"youtube",from:"transcript_post_type",_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){r(Object(_.__)("Done","wubtitle"));var e=wp.blocks.createBlock("core/paragraph",{content:t});wp.data.dispatch("core/block-editor").insertBlocks(e)})).fail((function(t){r(t)}))},disabled:b},Object(_.__)("Get transcript","wubtitle")),Object(i.createElement)("p",null,n)))};n.n(S)()((function(){"transcript"===Object(b.select)("core/editor").getCurrentPostType()&&Object(E.registerPlugin)("transcript-panel",{render:T,icon:""})}));var k=function(t){var e=Object(i.useState)(""),n=u()(e,2),r=n[0],c=n[1],o=Object(i.useState)(Object(_.__)("None","wubtitle")),a=u()(o,2),l=a[0],s=a[1],d=Object(i.useState)(""),j=u()(d,2),O=j[0],m=j[1],w=Object(i.useState)(!1),g=u()(w,2),h=g[0],v=g[1],y=Object(i.useState)([]),E=u()(y,2),x=E[0],S=E[1],T=Object(i.useState)(""),k=u()(T,2),C=k[0],P=k[1],I=Object(i.useState)(!0),B=u()(I,2),F=B[0],A=B[1],G=Object(b.useDispatch)("core/notices");Object(b.useSelect)((function(e){if(void 0!==t.url){var n=e("core").getEntityRecords("postType","transcript",{metaKey:"_video_id",metaValue:t.url}),r=Object(_.__)("Created","wubtitle");n&&n.length>0&&l!==r&&s(r)}}));return Object(i.createElement)(f.InspectorControls,null,Object(i.createElement)(p.PanelBody,{title:"Wubtitle"},Object(i.createElement)("p",{style:{margin:"0",marginBottom:"20px"}},"".concat(Object(_.__)("Transcript status:","wubtitle")," ").concat(l)),t.url&&h?Object(i.createElement)(p.SelectControl,{label:Object(_.__)("Select the video language","wubtitle"),value:O,onChange:function(t){m(t),A("none"===t)},options:x}):void wp.ajax.send("get_video_info",{type:"POST",data:{url:t.url,_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){if(t.languages){c(""),v(!0);var e=t.languages.map((function(t){return{value:t.baseUrl,label:t.name.simpleText}}));e.unshift({value:"none",label:Object(_.__)("Select language","wubtitle")}),S(e),P(t.title)}else c(Object(_.__)("Subtitles not available for this video","wubtitle"))})).fail((function(t){console.log(t)})),Object(i.createElement)(p.Button,{name:"sottotitoli",id:t.id,isPrimary:!0,onClick:function(){var e=wp.data.select("core/block-editor").getBlockIndex(wp.data.select("core/block-editor").getSelectedBlock().clientId);c(Object(_.__)("Getting transcript…","ear2words")),wp.ajax.send("get_transcript_yt",{type:"POST",data:{urlVideo:t.url,urlSubtitle:O,videoTitle:C,from:"default_post_type",_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){var n=wp.blocks.createBlock("wubtitle/transcription",{contentId:t}),r=e+1;wp.data.dispatch("core/block-editor").insertBlocks(n,r),c(""),s(Object(_.__)("Created","wubtitle"))})).fail((function(t){G.createNotice("error",t),c("")}))},disabled:F},Object(_.__)("Get Transcribe","wubtitle")),Object(i.createElement)("p",null,r)))},C=Object(o.createHigherOrderComponent)((function(t){return function(e){return"core-embed/youtube"!==e.name?Object(i.createElement)(t,e):Object(i.createElement)(i.Fragment,null,Object(i.createElement)(t,e),Object(i.createElement)(k,c()({},e.attributes,{setAttributes:e.setAttributes})))}}),"withInspectorControls");Object(a.addFilter)("editor.BlockEdit","wubtitle/with-inspector-controls",C);var P=n(13);function I(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=Object(i.useState)(t),r=u()(n,2),c=r[0],o=r[1];return Object(i.useEffect)((function(){var n=setTimeout((function(){o(t)}),e);return function(){clearTimeout(n)}}),[t]),c}var B=function(t){var e=t.attributes,n=t.setAttributes,r=t.className,c=Object(i.useState)(""),o=u()(c,2),a=o[0],l=o[1],s=Object(i.useState)(""),d=u()(s,2),f=d[0],j=d[1],O=Object(i.useState)([]),m=u()(O,2),w=m[0],g=m[1],h=I(a,500),v=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(e)}))},y=function(t){var e=wp.blocks.createBlock("core/paragraph",{content:t}),n=wp.data.select("core/block-editor").getSelectedBlock().clientId;wp.data.dispatch("core/block-editor").replaceBlocks(n,e),wp.data.dispatch("core/block-editor").clearSelectedBlock()};Object(i.useEffect)((function(){j(h)}),[h]),Object(b.useSelect)((function(t){if(e.contentId&&0===w.length){var n={per_page:1,include:e.contentId},r=t("core").getEntityRecords("postType","transcript",n);if(null!==r){g([r[0].title.rendered]);var c=r[0].content.rendered;c=(c=c.replace("<p>","")).replace("</p>",""),y(c)}}}));for(var E=Object(b.useSelect)((function(t){if(f.length>2){var e={per_page:10,search:f},n=t("core").getEntityRecords("postType","transcript",e);return null!==n?n:[]}return[]})),x=new Map,S=[],T=0;T<E.length;T++)x.set(v(E[T].title.rendered),E[T].id),x.set(v("".concat(E[T].title.rendered," content")),E[T].content.rendered),S[T]=v(E[T].title.rendered);var k="";return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(p.FormTokenField,{className:r,label:Object(_.__)("Wubtitle transcriptions","wubtitle"),value:w,suggestions:S,onChange:function(t){return function(t){if(0===t.length)n({contentId:null}),g(t);else if(S.includes(t[0])){var e=x.get(t[0]),r="".concat(t[0]," content");k=(k=(k=x.get(r)).replace("<p>","")).replace("</p>",""),g(t),n({contentId:e}),y(k)}}(t)},placeholder:Object(_.__)("Insert transcriptions","wubtitle"),onInputChange:function(t){return l(t)},maxLength:1}),Object(i.createElement)("p",{className:"helperText"},Object(_.__)("Enter the title of the video you want to transcribe","wubtitle")))};Object(P.registerBlockType)("wubtitle/transcription",{title:Object(_.__)("Trascription","wubtitle"),icon:"megaphone",description:Object(_.__)("Enter the transcript of your video","wubtitle"),category:"embed",attributes:{contentId:{type:"int"}},edit:B})}]);
  • wubtitle/tags/1.0.6/includes/Api/ApiLicenseValidation.php

    r2371183 r2372409  
    7070                'permission_callback' => function( $request ) {
    7171                    $headers          = $request->get_headers();
    72                     $token            = $headers['token'][0];
     72                    $token            = $headers['token'][0] ?? '';
     73                    if ( ! defined( 'WP_ADMIN' ) ) {
     74                        define( 'WP_ADMIN', true );
     75                    }
     76                    wp_cache_delete( 'wubtitle_token', 'options' );
     77                    wp_cache_delete( 'wubtitle_token_time', 'options' );
    7378                    $current_token    = get_option( 'wubtitle_token' );
    7479                    $token_expiration = get_option( 'wubtitle_token_time' );
     
    7681                        return false;
    7782                    }
     83                    return true;
    7884                },
    7985            )
  • wubtitle/tags/1.0.6/includes/Api/ApiStoreSubtitle.php

    r2371230 r2372409  
    193193    public function get_jobs_failed( $request ) {
    194194        $params   = $request->get_param( 'data' );
    195         $job_id   = $params['jobId'];
     195        $job_id   = $params['jobId'] ?? '';
    196196        $args     = array(
    197197            'post_type'      => 'attachment',
     
    201201        );
    202202        $job_meta = get_posts( $args );
    203         if ( empty( $job_meta[0] ) ) {
     203        if ( empty( $job_meta[0] ) || empty( $job_id ) ) {
    204204            $response = new WP_REST_Response(
    205205                array(
  • wubtitle/tags/1.0.6/includes/Core/Activation.php

    r2371183 r2372409  
    2222        register_activation_hook( WUBTITLE_FILE_URL, array( $this, 'wubtitle_activation_license_key' ) );
    2323        add_action( '_core_updated_successfully', array( $this, 'wubtitle_activation_license_key' ), 10, 1 );
     24        add_filter( 'upgrader_post_install', array( $this, 'post_install' ), 10, 3 );
     25    }
     26
     27    /**
     28     * After upgrade run plugin activation.
     29     *
     30     * @param array<mixed> ...$args installation result data.
     31     * @return void
     32     */
     33    public function post_install( ...$args ) {
     34        $name_plugin = $args[1]['plugin'];
     35        if ( WUBTITLE_NAME . '/wubtitle.php' === $name_plugin ) {
     36            $this->wubtitle_activation_license_key();
     37        }
    2438    }
    2539
  • wubtitle/tags/1.0.6/includes/Helpers.php

    r2371183 r2372409  
    9595        $jwt            = $headers['jwt'][0];
    9696        $db_license_key = get_option( 'wubtitle_license_key' );
    97         return JWT::decode( $jwt, $db_license_key, array( 'HS256' ) );
     97        try {
     98            JWT::decode( $jwt, $db_license_key, array( 'HS256' ) );
     99        } catch ( \Exception $e ) {
     100            return false;
     101        }
     102        return true;
    98103    }
    99104
  • wubtitle/tags/1.0.6/readme.txt

    r2371230 r2372409  
    9595== Changelog ==
    9696
     97=1.0.6=
     98Release Date: August 28th, 2020
     99
     100Bugfixes:
     101
     102* Stability improvements
     103
    97104=1.0.5=
    98105Release Date: August 28th, 2020
  • wubtitle/tags/1.0.6/vendor/autoload.php

    r2371230 r2372409  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInitf05ef82b0b1abd2e8c27c0dfccfe9299::getLoader();
     7return ComposerAutoloaderInit0a4f33baca50225747f6e54aea59f66d::getLoader();
  • wubtitle/tags/1.0.6/vendor/composer/autoload_real.php

    r2371230 r2372409  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitf05ef82b0b1abd2e8c27c0dfccfe9299
     5class ComposerAutoloaderInit0a4f33baca50225747f6e54aea59f66d
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInitf05ef82b0b1abd2e8c27c0dfccfe9299', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit0a4f33baca50225747f6e54aea59f66d', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    27         spl_autoload_unregister(array('ComposerAutoloaderInitf05ef82b0b1abd2e8c27c0dfccfe9299', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit0a4f33baca50225747f6e54aea59f66d', 'loadClassLoader'));
    2828
    2929        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3131            require_once __DIR__ . '/autoload_static.php';
    3232
    33             call_user_func(\Composer\Autoload\ComposerStaticInitf05ef82b0b1abd2e8c27c0dfccfe9299::getInitializer($loader));
     33            call_user_func(\Composer\Autoload\ComposerStaticInit0a4f33baca50225747f6e54aea59f66d::getInitializer($loader));
    3434        } else {
    3535            $map = require __DIR__ . '/autoload_namespaces.php';
  • wubtitle/tags/1.0.6/vendor/composer/autoload_static.php

    r2371230 r2372409  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitf05ef82b0b1abd2e8c27c0dfccfe9299
     7class ComposerStaticInit0a4f33baca50225747f6e54aea59f66d
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    3232    {
    3333        return \Closure::bind(function () use ($loader) {
    34             $loader->prefixLengthsPsr4 = ComposerStaticInitf05ef82b0b1abd2e8c27c0dfccfe9299::$prefixLengthsPsr4;
    35             $loader->prefixDirsPsr4 = ComposerStaticInitf05ef82b0b1abd2e8c27c0dfccfe9299::$prefixDirsPsr4;
     34            $loader->prefixLengthsPsr4 = ComposerStaticInit0a4f33baca50225747f6e54aea59f66d::$prefixLengthsPsr4;
     35            $loader->prefixDirsPsr4 = ComposerStaticInit0a4f33baca50225747f6e54aea59f66d::$prefixDirsPsr4;
    3636
    3737        }, null, ClassLoader::class);
  • wubtitle/tags/1.0.6/wubtitle.php

    r2371230 r2372409  
    88 * Text Domain:     wubtitle
    99 * Domain Path:     /languages
    10  * Version:         1.0.5
     10 * Version:         1.0.6
    1111 *
    1212 * @package         Wubtitle
     
    2222define( 'WUBTITLE_URL', plugin_dir_url( __FILE__ ) );
    2323define( 'WUBTITLE_NAME', dirname( plugin_basename( __FILE__ ) ) );
    24 define( 'WUBTITLE_VER', '1.0.5' );
     24define( 'WUBTITLE_VER', '1.0.6' );
    2525$endpoint = 'https://api.wubtitle.com/';
    2626if ( defined( 'WP_WUBTITLE_ENV' ) && 'development' === WP_WUBTITLE_ENV ) {
  • wubtitle/trunk/build/index.asset.php

    r2371183 r2372409  
    1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => '522b29c2c0236dcac5d26f996c59a0bf');
     1<?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => '4b2a3b394565d4070e2fc070877c460d');
  • wubtitle/trunk/build/index.js

    r2371183 r2372409  
    1 !function(t){var e={};function n(r){if(e[r])return e[r].exports;var c=e[r]={i:r,l:!1,exports:{}};return t[r].call(c.exports,c,c.exports,n),c.l=!0,c.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var c in t)n.d(r,c,function(e){return t[e]}.bind(null,c));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=19)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.wp.i18n}()},function(t,e,n){var r=n(14),c=n(15),i=n(16),o=n(18);t.exports=function(t,e){return r(t)||c(t,e)||i(t,e)||o()}},function(t,e){!function(){t.exports=this.wp.components}()},function(t,e){!function(){t.exports=this.wp.data}()},function(t,e){function n(){return t.exports=n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},n.apply(this,arguments)}t.exports=n},function(t,e){!function(){t.exports=this.wp.compose}()},function(t,e){!function(){t.exports=this.wp.hooks}()},function(t,e){!function(){t.exports=this.wp.blockEditor}()},function(t,e){!function(){t.exports=this.wp.apiFetch}()},function(t,e){!function(){t.exports=this.wp.plugins}()},function(t,e){!function(){t.exports=this.wp.editPost}()},function(t,e){!function(){t.exports=this.wp.domReady}()},function(t,e){!function(){t.exports=this.wp.blocks}()},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,c=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(r=(o=a.next()).done)&&(n.push(o.value),!e||n.length!==e);r=!0);}catch(t){c=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(c)throw i}}return n}}},function(t,e,n){var r=n(17);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e,n){"use strict";n.r(e);var r=n(5),c=n.n(r),i=n(0),o=n(6),a=n(7),l=n(2),u=n.n(l),b=n(4),s=n(9),d=n.n(s),p=n(3),f=n(8),_=n(1),j={it:Object(_.__)("Italian","wubtitle"),en:Object(_.__)("English","wubtitle"),es:Object(_.__)("Spanish","wubtitle"),de:Object(_.__)("German","wubtitle"),zh:Object(_.__)("Chinese","wubtitle"),fr:Object(_.__)("French","wubtitle")},O={pending:Object(_.__)("Generating","wubtitle"),draft:Object(_.__)("Draft","wubtitle"),enabled:Object(_.__)("Enabled","wubtitle"),notfound:Object(_.__)("None","wubtitle")},m=[{value:"it",label:Object(_.__)("Italian","wubtitle")},{value:"en",label:Object(_.__)("English","wubtitle")},{value:"es",label:Object(_.__)("Spanish","wubtitle")},{value:"de",label:Object(_.__)("German","wubtitle")},{value:"zh",label:Object(_.__)("Chinese","wubtitle")},{value:"fr",label:Object(_.__)("French","wubtitle")}],w=[{value:"it",label:Object(_.__)("Italian","wubtitle"),disabled:!1},{value:"en",label:Object(_.__)("English","wubtitle"),disabled:!1},{value:"es",label:Object(_.__)("Spanish (Pro only)","wubtitle"),disabled:!0},{value:"de",label:Object(_.__)("German (Pro only)","wubtitle"),disabled:!0},{value:"zh",label:Object(_.__)("Chinese (Pro only)","wubtitle"),disabled:!0},{value:"fr",label:Object(_.__)("French (Pro only)","wubtitle"),disabled:!0}],g=function(t){var e=t.statusText,n=t.langText;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Status:","wubtitle")+" "+O[e]),Object(i.createElement)("div",null,Object(_.__)("Language:","wubtitle")+" "+j[n]))},h=function(t){var e=t.statusText,n=t.langText,r=t.isPublished,c=t.postId,o=Object(i.useState)(""),a=u()(o,2),l=a[0],s=a[1],d=Object(b.useDispatch)("core"),f=function(t){d.editEntityRecord("postType","attachment",c,{meta:{wubtitle_status:t}})};return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("p",{style:{margin:"0"}},Object(_.__)("Status:","wubtitle")+" "+O[e]),Object(i.createElement)("p",{style:{margin:"8px 0"}},Object(_.__)("Language:","wubtitle")+" "+j[n]),Object(i.createElement)(p.ToggleControl,{label:Object(_.__)("Published","wubtitle"),checked:r,onChange:function(){var t;t="draft",!r&&(t="enabled"),f(t),d.saveEditedEntityRecord("postType","attachment",c)}}),Object(i.createElement)(p.Button,{name:"sottotitoli",id:c,isPrimary:!0,onClick:function(){s(Object(_.__)("Getting transcript…","wubtitle")),wp.ajax.send("get_transcript_internal_video",{type:"POST",data:{id:c,_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){s("Done");var e=wp.data.select("core/block-editor").getBlockIndex(wp.data.select("core/block-editor").getSelectedBlock().clientId),n=wp.blocks.createBlock("wubtitle/transcription",{contentId:t});wp.data.dispatch("core/block-editor").insertBlocks(n,e+1)})).fail((function(t){s(t)}))}},Object(_.__)("Get Transcribe","wubtitle")),Object(i.createElement)("p",null,l))},v=function(t){var e,n,r=void 0!==t.id?t.src.substring(t.src.lastIndexOf(".")+1):"mp4",c=("1"===wubtitle_button_object.isFree?["it","en"]:["it","en","es","de","zh"]).includes(wubtitle_button_object.lang)?wubtitle_button_object.lang:"en",o=Object(b.useSelect)((function(e){var n;void 0!==t.id&&(n=e("core").getEntityRecord("postType","attachment",t.id));var r="";return void 0!==n&&(r=e("core").getEditedEntityRecord("postType","attachment",t.id).meta),r}));void 0!==o&&(e=o.wubtitle_lang_video,n=o.wubtitle_status);var a=Object(b.useDispatch)("core/notices"),l=Object(b.useDispatch)("core"),s=Object(i.useState)(c),j=u()(s,2),O=j[0],v=j[1],y="pending"===n||void 0===t.id,E="enabled"===n,x="1"===wubtitle_button_object.isFree?w:m,S=function(){return n="error"===n?Object(_.__)("Error","wubtitle"):Object(_.__)("None","wubtitle"),Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Status:","wubtitle")+" "+n),Object(i.createElement)(p.SelectControl,{label:Object(_.__)("Select the video language","wubtitle"),value:O,onChange:function(t){v(t)},options:x}),Object(i.createElement)(p.Button,{disabled:y,name:"sottotitoli",id:t.id,isPrimary:!0,onClick:k},Object(_.__)("GENERATE SUBTITLES","wubtitle")))},T=function(){return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Unsupported video format for free plan","wubtitle")))};function k(){var e=t.id,n=t.src;d()({url:wubtitle_button_object.ajax_url,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:"action=submitVideo&_ajax_nonce=".concat(wubtitle_button_object.ajaxnonce,"&id_attachment=").concat(e,"&src_attachment=").concat(n,"&lang=").concat(O,"&")}).then((function(e){201===e.data?(a.createNotice("success",Object(_.__)("Subtitle creation successfully started","wubtitle")),l.editEntityRecord("postType","attachment",t.id,{meta:{wubtitle_status:"pending",wubtitle_lang_video:O}})):a.createNotice("error",e.data)}))}return Object(i.createElement)(f.InspectorControls,null,Object(i.createElement)(p.PanelBody,{title:"Wubtitle"},Object(i.createElement)((function(){if("1"===wubtitle_button_object.isFree&&"mp4"!==r)return Object(i.createElement)(T,null);switch(n){case"pending":return Object(i.createElement)(g,{langText:e,statusText:n});case"draft":case"enabled":return Object(i.createElement)(h,{statusText:n,langText:e,isPublished:E,postId:t.id});default:return Object(i.createElement)(S,null)}}),{status:n,languageSaved:e})))},y=Object(o.createHigherOrderComponent)((function(t){return function(e){return"core/video"!==e.name?Object(i.createElement)(t,e):Object(i.createElement)(i.Fragment,null,Object(i.createElement)(t,e),Object(i.createElement)(v,c()({},e.attributes,{setAttributes:e.setAttributes})))}}),"withInspectorControls");Object(a.addFilter)("editor.BlockEdit","wubtitle/with-inspector-controls",y);var E=n(10),x=n(11),S=n(12),T=function(){var t=Object(i.useState)(""),e=u()(t,2),n=e[0],r=e[1],c=Object(i.useState)(""),o=u()(c,2),a=o[0],l=o[1],b=""===a;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(x.PluginDocumentSettingPanel,{name:"transcript-panel",title:"Transcript"},Object(i.createElement)(p.TextControl,{label:"video url",id:"input",value:a,onChange:function(t){l(t)}}),Object(i.createElement)(p.Button,{name:"transcript",isPrimary:!0,onClick:function(){r(Object(_.__)("Getting transcript…","wubtitle")),wp.ajax.send("get_transcript",{type:"POST",data:{url:a,source:"youtube",from:"transcript_post_type",_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){r(Object(_.__)("Done","wubtitle"));var e=wp.blocks.createBlock("core/paragraph",{content:t});wp.data.dispatch("core/block-editor").insertBlocks(e)})).fail((function(t){r(t)}))},disabled:b},Object(_.__)("Get transcript","wubtitle")),Object(i.createElement)("p",null,n)))};n.n(S)()((function(){"transcript"===Object(b.select)("core/editor").getCurrentPostType()&&Object(E.registerPlugin)("transcript-panel",{render:T,icon:""})}));var k=function(t){var e=Object(i.useState)(""),n=u()(e,2),r=n[0],c=n[1],o=Object(i.useState)(Object(_.__)("None","wubtitle")),a=u()(o,2),l=a[0],s=a[1],d=Object(i.useState)(""),j=u()(d,2),O=j[0],m=j[1],w=Object(i.useState)(!1),g=u()(w,2),h=g[0],v=g[1],y=Object(i.useState)([]),E=u()(y,2),x=E[0],S=E[1],T=Object(i.useState)(""),k=u()(T,2),C=k[0],P=k[1],I=Object(i.useState)(!0),B=u()(I,2),F=B[0],A=B[1],G=Object(b.useDispatch)("core/notices");Object(b.useSelect)((function(e){if(void 0!==t.url){var n=e("core").getEntityRecords("postType","transcript",{metaKey:"_video_id",metaValue:t.url}),r=Object(_.__)("Created","wubtitle");n&&n.length>0&&l!==r&&s(r)}}));return Object(i.createElement)(f.InspectorControls,null,Object(i.createElement)(p.PanelBody,{title:"Wubtitle"},Object(i.createElement)("p",{style:{margin:"0",marginBottom:"20px"}},"".concat(Object(_.__)("Transcript status:","wubtitle")," ").concat(l)),t.url&&h?Object(i.createElement)(p.SelectControl,{label:Object(_.__)("Select the video language","wubtitle"),value:O,onChange:function(t){m(t),A("none"===t)},options:x}):void wp.ajax.send("get_video_info",{type:"POST",data:{url:t.url,_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){if(t.languages){c(""),v(!0);var e=t.languages.map((function(t){return{value:t.baseUrl,label:t.name.simpleText}}));e.unshift({value:"none",label:Object(_.__)("Select language","wubtitle")}),S(e),P(t.title)}else c(Object(_.__)("Subtitles not available for this video","wubtitle"))})).fail((function(t){console.log(t)})),Object(i.createElement)(p.Button,{name:"sottotitoli",id:t.id,isPrimary:!0,onClick:function(){var e=wp.data.select("core/block-editor").getBlockIndex(wp.data.select("core/block-editor").getSelectedBlock().clientId);c(Object(_.__)("Getting transcript…","ear2words")),wp.ajax.send("get_transcript_yt",{type:"POST",data:{urlVideo:t.url,urlSubtitle:O,videoTitle:C,from:"default_post_type",_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){var n=wp.blocks.createBlock("wubtitle/transcription",{contentId:t}),r=e+1;wp.data.dispatch("core/block-editor").insertBlocks(n,r),c(""),s(Object(_.__)("Created","wubtitle"))})).fail((function(t){G.createNotice("error",t),c("")}))},disabled:F},Object(_.__)("Get Transcribe","wubtitle")),Object(i.createElement)("p",null,r)))},C=Object(o.createHigherOrderComponent)((function(t){return function(e){return"core-embed/youtube"!==e.name?Object(i.createElement)(t,e):Object(i.createElement)(i.Fragment,null,Object(i.createElement)(t,e),Object(i.createElement)(k,c()({},e.attributes,{setAttributes:e.setAttributes})))}}),"withInspectorControls");Object(a.addFilter)("editor.BlockEdit","wubtitle/with-inspector-controls",C);var P=n(13);function I(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=Object(i.useState)(t),r=u()(n,2),c=r[0],o=r[1];return Object(i.useEffect)((function(){var n=setTimeout((function(){o(t)}),e);return function(){clearTimeout(n)}}),[t]),c}var B=function(t){var e=t.attributes,n=t.setAttributes,r=t.className,c=Object(i.useState)(""),o=u()(c,2),a=o[0],l=o[1],s=Object(i.useState)(""),d=u()(s,2),f=d[0],j=d[1],O=Object(i.useState)([]),m=u()(O,2),w=m[0],g=m[1],h=I(a,500),v=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(e)}))},y=function(t){var e=wp.blocks.createBlock("core/paragraph",{content:t}),n=wp.data.select("core/block-editor").getSelectedBlock().clientId;wp.data.dispatch("core/block-editor").replaceBlocks(n,e),wp.data.dispatch("core/block-editor").clearSelectedBlock()};Object(i.useEffect)((function(){j(h)}),[h]),Object(b.useSelect)((function(t){if(e.contentId&&0===w.length){var n={per_page:1,include:e.contentId},r=t("core").getEntityRecords("postType","transcript",n);if(null!==r){g([r[0].title.rendered]);var c=r[0].content.rendered;c=(c=c.replace("<p>","")).replace("</p>",""),y(c)}}}));for(var E=Object(b.useSelect)((function(t){if(f.length>2){var e={per_page:10,search:f},n=t("core").getEntityRecords("postType","transcript",e);return null!==n?n:[]}return[]})),x=new Map,S=[],T=0;T<E.length;T++)x.set(v(E[T].title.rendered),E[T].id),x.set(v("".concat(E[T].title.rendered," content")),E[T].content.rendered),S[T]=v(E[T].title.rendered);var k="";return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(p.FormTokenField,{className:r,label:Object(_.__)("Wubtitle transcriptions","wubtitle"),value:w,suggestions:S,onChange:function(t){return function(t){if(0===t.length)n({contentId:null}),g(t);else if(S.includes(t[0])){var e=x.get(t[0]),r="".concat(t[0]," content");k=(k=(k=x.get(r)).replace("<p>","")).replace("</p>",""),g(t),n({contentId:e}),y(k)}}(t)},placeholder:Object(_.__)("Insert transcriptions","wubtitle"),onInputChange:function(t){return l(t)},maxLength:1}),Object(i.createElement)("p",{className:"helperText"},Object(_.__)("Enter the title of the video you want to transcribe","wubtitle")))};Object(P.registerBlockType)("wubtitle/transcription",{title:Object(_.__)("Trascription","wubtitle"),icon:"megaphone",description:Object(_.__)("Enter the transcript of your video","wubtitle"),category:"embed",attributes:{contentId:{type:"int"}},edit:B})}]);
     1!function(t){var e={};function n(r){if(e[r])return e[r].exports;var c=e[r]={i:r,l:!1,exports:{}};return t[r].call(c.exports,c,c.exports,n),c.l=!0,c.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var c in t)n.d(r,c,function(e){return t[e]}.bind(null,c));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=19)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.wp.i18n}()},function(t,e,n){var r=n(14),c=n(15),i=n(16),o=n(18);t.exports=function(t,e){return r(t)||c(t,e)||i(t,e)||o()}},function(t,e){!function(){t.exports=this.wp.components}()},function(t,e){!function(){t.exports=this.wp.data}()},function(t,e){function n(){return t.exports=n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},n.apply(this,arguments)}t.exports=n},function(t,e){!function(){t.exports=this.wp.compose}()},function(t,e){!function(){t.exports=this.wp.hooks}()},function(t,e){!function(){t.exports=this.wp.blockEditor}()},function(t,e){!function(){t.exports=this.wp.apiFetch}()},function(t,e){!function(){t.exports=this.wp.plugins}()},function(t,e){!function(){t.exports=this.wp.editPost}()},function(t,e){!function(){t.exports=this.wp.domReady}()},function(t,e){!function(){t.exports=this.wp.blocks}()},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,c=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(r=(o=a.next()).done)&&(n.push(o.value),!e||n.length!==e);r=!0);}catch(t){c=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(c)throw i}}return n}}},function(t,e,n){var r=n(17);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e,n){"use strict";n.r(e);var r=n(5),c=n.n(r),i=n(0),o=n(6),a=n(7),l=n(2),u=n.n(l),b=n(4),s=n(9),d=n.n(s),p=n(3),f=n(8),_=n(1),j={it:Object(_.__)("Italian","wubtitle"),en:Object(_.__)("English","wubtitle"),es:Object(_.__)("Spanish","wubtitle"),de:Object(_.__)("German","wubtitle"),zh:Object(_.__)("Chinese","wubtitle"),fr:Object(_.__)("French","wubtitle")},O={pending:Object(_.__)("Generating","wubtitle"),draft:Object(_.__)("Draft","wubtitle"),enabled:Object(_.__)("Enabled","wubtitle"),notfound:Object(_.__)("None","wubtitle")},m=[{value:"it",label:Object(_.__)("Italian","wubtitle")},{value:"en",label:Object(_.__)("English","wubtitle")},{value:"es",label:Object(_.__)("Spanish","wubtitle")},{value:"de",label:Object(_.__)("German","wubtitle")},{value:"zh",label:Object(_.__)("Chinese","wubtitle")},{value:"fr",label:Object(_.__)("French","wubtitle")}],w=[{value:"it",label:Object(_.__)("Italian","wubtitle"),disabled:!1},{value:"en",label:Object(_.__)("English","wubtitle"),disabled:!1},{value:"es",label:Object(_.__)("Spanish (Pro only)","wubtitle"),disabled:!0},{value:"de",label:Object(_.__)("German (Pro only)","wubtitle"),disabled:!0},{value:"zh",label:Object(_.__)("Chinese (Pro only)","wubtitle"),disabled:!0},{value:"fr",label:Object(_.__)("French (Pro only)","wubtitle"),disabled:!0}],g=function(t){var e=t.statusText,n=t.langText;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Status:","wubtitle")+" "+O[e]),Object(i.createElement)("div",null,Object(_.__)("Language:","wubtitle")+" "+j[n]))},h=function(t){var e=t.statusText,n=t.langText,r=t.isPublished,c=t.postId,o=Object(i.useState)(""),a=u()(o,2),l=a[0],s=a[1],d=Object(b.useDispatch)("core"),f=function(t){d.editEntityRecord("postType","attachment",c,{meta:{wubtitle_status:t}})};return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("p",{style:{margin:"0"}},Object(_.__)("Status:","wubtitle")+" "+O[e]),Object(i.createElement)("p",{style:{margin:"8px 0"}},Object(_.__)("Language:","wubtitle")+" "+j[n]),Object(i.createElement)(p.ToggleControl,{label:Object(_.__)("Published","wubtitle"),checked:r,onChange:function(){var t;t="draft",!r&&(t="enabled"),f(t),d.saveEditedEntityRecord("postType","attachment",c)}}),Object(i.createElement)(p.Button,{name:"sottotitoli",id:c,isPrimary:!0,onClick:function(){s(Object(_.__)("Getting transcript…","wubtitle")),wp.ajax.send("get_transcript_internal_video",{type:"POST",data:{id:c,_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){s("Done");var e=wp.data.select("core/block-editor").getBlockIndex(wp.data.select("core/block-editor").getSelectedBlock().clientId),n=wp.blocks.createBlock("wubtitle/transcription",{contentId:t});wp.data.dispatch("core/block-editor").insertBlocks(n,e+1)})).fail((function(t){s(t)}))}},Object(_.__)("Get Transcribe","wubtitle")),Object(i.createElement)("p",null,l))},v=function(t){var e,n,r=void 0!==t.id?t.src.substring(t.src.lastIndexOf(".")+1):"mp4",c=("1"===wubtitle_button_object.isFree?["it","en"]:["it","en","es","de","zh"]).includes(wubtitle_button_object.lang)?wubtitle_button_object.lang:"en",o=Object(b.useSelect)((function(e){var n;void 0!==t.id&&(n=e("core").getEntityRecord("postType","attachment",t.id));var r="";return void 0!==n&&(r=e("core").getEditedEntityRecord("postType","attachment",t.id).meta),r}));void 0!==o&&(e=o.wubtitle_lang_video,n=o.wubtitle_status);var a=Object(b.useDispatch)("core/notices"),l=Object(b.useDispatch)("core"),s=Object(i.useState)(c),j=u()(s,2),O=j[0],v=j[1],y=Object(i.useState)(!1),E=u()(y,2),x=E[0],S=E[1],T="pending"===n||void 0===t.id||x,k="enabled"===n,C="1"===wubtitle_button_object.isFree?w:m,P=function(){return n="error"===n?Object(_.__)("Error","wubtitle"):Object(_.__)("None","wubtitle"),Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Status:","wubtitle")+" "+n),Object(i.createElement)(p.SelectControl,{label:Object(_.__)("Select the video language","wubtitle"),value:O,onChange:function(t){v(t)},options:C}),Object(i.createElement)(p.Button,{disabled:T,name:"sottotitoli",id:t.id,isPrimary:!0,onClick:B},Object(_.__)("GENERATE SUBTITLES","wubtitle")))},I=function(){return Object(i.createElement)(i.Fragment,null,Object(i.createElement)("div",null,Object(_.__)("Unsupported video format for free plan","wubtitle")))};function B(){var e=t.id,n=t.src;S(!0),d()({url:wubtitle_button_object.ajax_url,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:"action=submitVideo&_ajax_nonce=".concat(wubtitle_button_object.ajaxnonce,"&id_attachment=").concat(e,"&src_attachment=").concat(n,"&lang=").concat(O,"&")}).then((function(e){S(!1),201===e.data?(a.createNotice("success",Object(_.__)("Subtitle creation successfully started","wubtitle")),l.editEntityRecord("postType","attachment",t.id,{meta:{wubtitle_status:"pending",wubtitle_lang_video:O}})):a.createNotice("error",e.data)}))}return Object(i.createElement)(f.InspectorControls,null,Object(i.createElement)(p.PanelBody,{title:"Wubtitle"},Object(i.createElement)((function(){if("1"===wubtitle_button_object.isFree&&"mp4"!==r)return Object(i.createElement)(I,null);switch(n){case"pending":return Object(i.createElement)(g,{langText:e,statusText:n});case"draft":case"enabled":return Object(i.createElement)(h,{statusText:n,langText:e,isPublished:k,postId:t.id});default:return Object(i.createElement)(P,null)}}),{status:n,languageSaved:e})))},y=Object(o.createHigherOrderComponent)((function(t){return function(e){return"core/video"!==e.name?Object(i.createElement)(t,e):Object(i.createElement)(i.Fragment,null,Object(i.createElement)(t,e),Object(i.createElement)(v,c()({},e.attributes,{setAttributes:e.setAttributes})))}}),"withInspectorControls");Object(a.addFilter)("editor.BlockEdit","wubtitle/with-inspector-controls",y);var E=n(10),x=n(11),S=n(12),T=function(){var t=Object(i.useState)(""),e=u()(t,2),n=e[0],r=e[1],c=Object(i.useState)(""),o=u()(c,2),a=o[0],l=o[1],b=""===a;return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(x.PluginDocumentSettingPanel,{name:"transcript-panel",title:"Transcript"},Object(i.createElement)(p.TextControl,{label:"video url",id:"input",value:a,onChange:function(t){l(t)}}),Object(i.createElement)(p.Button,{name:"transcript",isPrimary:!0,onClick:function(){r(Object(_.__)("Getting transcript…","wubtitle")),wp.ajax.send("get_transcript",{type:"POST",data:{url:a,source:"youtube",from:"transcript_post_type",_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){r(Object(_.__)("Done","wubtitle"));var e=wp.blocks.createBlock("core/paragraph",{content:t});wp.data.dispatch("core/block-editor").insertBlocks(e)})).fail((function(t){r(t)}))},disabled:b},Object(_.__)("Get transcript","wubtitle")),Object(i.createElement)("p",null,n)))};n.n(S)()((function(){"transcript"===Object(b.select)("core/editor").getCurrentPostType()&&Object(E.registerPlugin)("transcript-panel",{render:T,icon:""})}));var k=function(t){var e=Object(i.useState)(""),n=u()(e,2),r=n[0],c=n[1],o=Object(i.useState)(Object(_.__)("None","wubtitle")),a=u()(o,2),l=a[0],s=a[1],d=Object(i.useState)(""),j=u()(d,2),O=j[0],m=j[1],w=Object(i.useState)(!1),g=u()(w,2),h=g[0],v=g[1],y=Object(i.useState)([]),E=u()(y,2),x=E[0],S=E[1],T=Object(i.useState)(""),k=u()(T,2),C=k[0],P=k[1],I=Object(i.useState)(!0),B=u()(I,2),F=B[0],A=B[1],G=Object(b.useDispatch)("core/notices");Object(b.useSelect)((function(e){if(void 0!==t.url){var n=e("core").getEntityRecords("postType","transcript",{metaKey:"_video_id",metaValue:t.url}),r=Object(_.__)("Created","wubtitle");n&&n.length>0&&l!==r&&s(r)}}));return Object(i.createElement)(f.InspectorControls,null,Object(i.createElement)(p.PanelBody,{title:"Wubtitle"},Object(i.createElement)("p",{style:{margin:"0",marginBottom:"20px"}},"".concat(Object(_.__)("Transcript status:","wubtitle")," ").concat(l)),t.url&&h?Object(i.createElement)(p.SelectControl,{label:Object(_.__)("Select the video language","wubtitle"),value:O,onChange:function(t){m(t),A("none"===t)},options:x}):void wp.ajax.send("get_video_info",{type:"POST",data:{url:t.url,_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){if(t.languages){c(""),v(!0);var e=t.languages.map((function(t){return{value:t.baseUrl,label:t.name.simpleText}}));e.unshift({value:"none",label:Object(_.__)("Select language","wubtitle")}),S(e),P(t.title)}else c(Object(_.__)("Subtitles not available for this video","wubtitle"))})).fail((function(t){console.log(t)})),Object(i.createElement)(p.Button,{name:"sottotitoli",id:t.id,isPrimary:!0,onClick:function(){var e=wp.data.select("core/block-editor").getBlockIndex(wp.data.select("core/block-editor").getSelectedBlock().clientId);c(Object(_.__)("Getting transcript…","ear2words")),wp.ajax.send("get_transcript_yt",{type:"POST",data:{urlVideo:t.url,urlSubtitle:O,videoTitle:C,from:"default_post_type",_ajax_nonce:wubtitle_button_object.ajaxnonce}}).then((function(t){var n=wp.blocks.createBlock("wubtitle/transcription",{contentId:t}),r=e+1;wp.data.dispatch("core/block-editor").insertBlocks(n,r),c(""),s(Object(_.__)("Created","wubtitle"))})).fail((function(t){G.createNotice("error",t),c("")}))},disabled:F},Object(_.__)("Get Transcribe","wubtitle")),Object(i.createElement)("p",null,r)))},C=Object(o.createHigherOrderComponent)((function(t){return function(e){return"core-embed/youtube"!==e.name?Object(i.createElement)(t,e):Object(i.createElement)(i.Fragment,null,Object(i.createElement)(t,e),Object(i.createElement)(k,c()({},e.attributes,{setAttributes:e.setAttributes})))}}),"withInspectorControls");Object(a.addFilter)("editor.BlockEdit","wubtitle/with-inspector-controls",C);var P=n(13);function I(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=Object(i.useState)(t),r=u()(n,2),c=r[0],o=r[1];return Object(i.useEffect)((function(){var n=setTimeout((function(){o(t)}),e);return function(){clearTimeout(n)}}),[t]),c}var B=function(t){var e=t.attributes,n=t.setAttributes,r=t.className,c=Object(i.useState)(""),o=u()(c,2),a=o[0],l=o[1],s=Object(i.useState)(""),d=u()(s,2),f=d[0],j=d[1],O=Object(i.useState)([]),m=u()(O,2),w=m[0],g=m[1],h=I(a,500),v=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(e)}))},y=function(t){var e=wp.blocks.createBlock("core/paragraph",{content:t}),n=wp.data.select("core/block-editor").getSelectedBlock().clientId;wp.data.dispatch("core/block-editor").replaceBlocks(n,e),wp.data.dispatch("core/block-editor").clearSelectedBlock()};Object(i.useEffect)((function(){j(h)}),[h]),Object(b.useSelect)((function(t){if(e.contentId&&0===w.length){var n={per_page:1,include:e.contentId},r=t("core").getEntityRecords("postType","transcript",n);if(null!==r){g([r[0].title.rendered]);var c=r[0].content.rendered;c=(c=c.replace("<p>","")).replace("</p>",""),y(c)}}}));for(var E=Object(b.useSelect)((function(t){if(f.length>2){var e={per_page:10,search:f},n=t("core").getEntityRecords("postType","transcript",e);return null!==n?n:[]}return[]})),x=new Map,S=[],T=0;T<E.length;T++)x.set(v(E[T].title.rendered),E[T].id),x.set(v("".concat(E[T].title.rendered," content")),E[T].content.rendered),S[T]=v(E[T].title.rendered);var k="";return Object(i.createElement)(i.Fragment,null,Object(i.createElement)(p.FormTokenField,{className:r,label:Object(_.__)("Wubtitle transcriptions","wubtitle"),value:w,suggestions:S,onChange:function(t){return function(t){if(0===t.length)n({contentId:null}),g(t);else if(S.includes(t[0])){var e=x.get(t[0]),r="".concat(t[0]," content");k=(k=(k=x.get(r)).replace("<p>","")).replace("</p>",""),g(t),n({contentId:e}),y(k)}}(t)},placeholder:Object(_.__)("Insert transcriptions","wubtitle"),onInputChange:function(t){return l(t)},maxLength:1}),Object(i.createElement)("p",{className:"helperText"},Object(_.__)("Enter the title of the video you want to transcribe","wubtitle")))};Object(P.registerBlockType)("wubtitle/transcription",{title:Object(_.__)("Trascription","wubtitle"),icon:"megaphone",description:Object(_.__)("Enter the transcript of your video","wubtitle"),category:"embed",attributes:{contentId:{type:"int"}},edit:B})}]);
  • wubtitle/trunk/includes/Api/ApiLicenseValidation.php

    r2371183 r2372409  
    7070                'permission_callback' => function( $request ) {
    7171                    $headers          = $request->get_headers();
    72                     $token            = $headers['token'][0];
     72                    $token            = $headers['token'][0] ?? '';
     73                    if ( ! defined( 'WP_ADMIN' ) ) {
     74                        define( 'WP_ADMIN', true );
     75                    }
     76                    wp_cache_delete( 'wubtitle_token', 'options' );
     77                    wp_cache_delete( 'wubtitle_token_time', 'options' );
    7378                    $current_token    = get_option( 'wubtitle_token' );
    7479                    $token_expiration = get_option( 'wubtitle_token_time' );
     
    7681                        return false;
    7782                    }
     83                    return true;
    7884                },
    7985            )
  • wubtitle/trunk/includes/Api/ApiStoreSubtitle.php

    r2371230 r2372409  
    193193    public function get_jobs_failed( $request ) {
    194194        $params   = $request->get_param( 'data' );
    195         $job_id   = $params['jobId'];
     195        $job_id   = $params['jobId'] ?? '';
    196196        $args     = array(
    197197            'post_type'      => 'attachment',
     
    201201        );
    202202        $job_meta = get_posts( $args );
    203         if ( empty( $job_meta[0] ) ) {
     203        if ( empty( $job_meta[0] ) || empty( $job_id ) ) {
    204204            $response = new WP_REST_Response(
    205205                array(
  • wubtitle/trunk/includes/Core/Activation.php

    r2371183 r2372409  
    2222        register_activation_hook( WUBTITLE_FILE_URL, array( $this, 'wubtitle_activation_license_key' ) );
    2323        add_action( '_core_updated_successfully', array( $this, 'wubtitle_activation_license_key' ), 10, 1 );
     24        add_filter( 'upgrader_post_install', array( $this, 'post_install' ), 10, 3 );
     25    }
     26
     27    /**
     28     * After upgrade run plugin activation.
     29     *
     30     * @param array<mixed> ...$args installation result data.
     31     * @return void
     32     */
     33    public function post_install( ...$args ) {
     34        $name_plugin = $args[1]['plugin'];
     35        if ( WUBTITLE_NAME . '/wubtitle.php' === $name_plugin ) {
     36            $this->wubtitle_activation_license_key();
     37        }
    2438    }
    2539
  • wubtitle/trunk/includes/Helpers.php

    r2371183 r2372409  
    9595        $jwt            = $headers['jwt'][0];
    9696        $db_license_key = get_option( 'wubtitle_license_key' );
    97         return JWT::decode( $jwt, $db_license_key, array( 'HS256' ) );
     97        try {
     98            JWT::decode( $jwt, $db_license_key, array( 'HS256' ) );
     99        } catch ( \Exception $e ) {
     100            return false;
     101        }
     102        return true;
    98103    }
    99104
  • wubtitle/trunk/readme.txt

    r2371230 r2372409  
    9595== Changelog ==
    9696
     97=1.0.6=
     98Release Date: August 28th, 2020
     99
     100Bugfixes:
     101
     102* Stability improvements
     103
    97104=1.0.5=
    98105Release Date: August 28th, 2020
  • wubtitle/trunk/vendor/autoload.php

    r2371230 r2372409  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInitf05ef82b0b1abd2e8c27c0dfccfe9299::getLoader();
     7return ComposerAutoloaderInit0a4f33baca50225747f6e54aea59f66d::getLoader();
  • wubtitle/trunk/vendor/composer/autoload_real.php

    r2371230 r2372409  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitf05ef82b0b1abd2e8c27c0dfccfe9299
     5class ComposerAutoloaderInit0a4f33baca50225747f6e54aea59f66d
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInitf05ef82b0b1abd2e8c27c0dfccfe9299', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit0a4f33baca50225747f6e54aea59f66d', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    27         spl_autoload_unregister(array('ComposerAutoloaderInitf05ef82b0b1abd2e8c27c0dfccfe9299', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit0a4f33baca50225747f6e54aea59f66d', 'loadClassLoader'));
    2828
    2929        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3131            require_once __DIR__ . '/autoload_static.php';
    3232
    33             call_user_func(\Composer\Autoload\ComposerStaticInitf05ef82b0b1abd2e8c27c0dfccfe9299::getInitializer($loader));
     33            call_user_func(\Composer\Autoload\ComposerStaticInit0a4f33baca50225747f6e54aea59f66d::getInitializer($loader));
    3434        } else {
    3535            $map = require __DIR__ . '/autoload_namespaces.php';
  • wubtitle/trunk/vendor/composer/autoload_static.php

    r2371230 r2372409  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitf05ef82b0b1abd2e8c27c0dfccfe9299
     7class ComposerStaticInit0a4f33baca50225747f6e54aea59f66d
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    3232    {
    3333        return \Closure::bind(function () use ($loader) {
    34             $loader->prefixLengthsPsr4 = ComposerStaticInitf05ef82b0b1abd2e8c27c0dfccfe9299::$prefixLengthsPsr4;
    35             $loader->prefixDirsPsr4 = ComposerStaticInitf05ef82b0b1abd2e8c27c0dfccfe9299::$prefixDirsPsr4;
     34            $loader->prefixLengthsPsr4 = ComposerStaticInit0a4f33baca50225747f6e54aea59f66d::$prefixLengthsPsr4;
     35            $loader->prefixDirsPsr4 = ComposerStaticInit0a4f33baca50225747f6e54aea59f66d::$prefixDirsPsr4;
    3636
    3737        }, null, ClassLoader::class);
  • wubtitle/trunk/wubtitle.php

    r2371230 r2372409  
    88 * Text Domain:     wubtitle
    99 * Domain Path:     /languages
    10  * Version:         1.0.5
     10 * Version:         1.0.6
    1111 *
    1212 * @package         Wubtitle
     
    2222define( 'WUBTITLE_URL', plugin_dir_url( __FILE__ ) );
    2323define( 'WUBTITLE_NAME', dirname( plugin_basename( __FILE__ ) ) );
    24 define( 'WUBTITLE_VER', '1.0.5' );
     24define( 'WUBTITLE_VER', '1.0.6' );
    2525$endpoint = 'https://api.wubtitle.com/';
    2626if ( defined( 'WP_WUBTITLE_ENV' ) && 'development' === WP_WUBTITLE_ENV ) {
Note: See TracChangeset for help on using the changeset viewer.