Orderassets/js/jquery.jplayer.js000064400000166455147600053410012025 0ustar00;;;!function(t,e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):t.jQuery?e(t.jQuery):e(t.Zepto)}(this,(function(t,e){t.fn.jPlayer=function(s){var i="jPlayer",a="string"==typeof s,o=Array.prototype.slice.call(arguments,1),r=this;return s=!a&&o.length?t.extend.apply(null,[!0,s].concat(o)):s,a&&"_"===s.charAt(0)||(a?this.each((function(){var a=t(this).data(i),n=a&&t.isFunction(a[s])?a[s].apply(a,o):a;if(n!==a&&n!==e)return r=n,!1})):this.each((function(){var e=t(this).data(i);e?e.option(s||{}):t(this).data(i,new t.jPlayer(s,this))}))),r},t.jPlayer=function(e,s){if(arguments.length){this.element=t(s),this.options=t.extend(!0,{},this.options,e);var i=this;this.element.on("remove.jPlayer",(function(){i.destroy()})),this._init()}},"function"!=typeof t.fn.stop&&(t.fn.stop=function(){}),t.jPlayer.emulateMethods="load play pause",t.jPlayer.emulateStatus="src readyState networkState currentTime duration paused ended playbackRate",t.jPlayer.emulateOptions="muted volume",t.jPlayer.reservedEvent="ready flashreset resize repeat error warning",t.jPlayer.event={},t.each(["ready","setmedia","flashreset","resize","repeat","click","error","warning","loadstart","progress","suspend","abort","emptied","stalled","play","pause","loadedmetadata","loadeddata","waiting","playing","canplay","canplaythrough","seeking","seeked","timeupdate","ended","ratechange","durationchange","volumechange"],(function(){t.jPlayer.event[this]="jPlayer_"+this})),t.jPlayer.htmlEvent=["loadstart","abort","emptied","stalled","loadedmetadata","canplay","canplaythrough"],t.jPlayer.pause=function(){t.jPlayer.prototype.destroyRemoved(),t.each(t.jPlayer.prototype.instances,(function(t,e){e.data("jPlayer").status.srcSet&&e.jPlayer("pause")}))},t.jPlayer.timeFormat={showHour:!1,showMin:!0,showSec:!0,padHour:!1,padMin:!0,padSec:!0,sepHour:":",sepMin:":",sepSec:""};var s=function(){this.init()};s.prototype={init:function(){this.options={timeFormat:t.jPlayer.timeFormat}},time:function(t){t=t&&"number"==typeof t?t:0;var e=new Date(1e3*t),s=e.getUTCHours(),i=this.options.timeFormat.showHour?e.getUTCMinutes():e.getUTCMinutes()+60*s,a=this.options.timeFormat.showMin?e.getUTCSeconds():e.getUTCSeconds()+60*i,o=this.options.timeFormat.padHour&&s<10?"0"+s:s,r=this.options.timeFormat.padMin&&i<10?"0"+i:i,n=this.options.timeFormat.padSec&&a<10?"0"+a:a,l="";return l+=this.options.timeFormat.showHour?o+this.options.timeFormat.sepHour:"",l+=this.options.timeFormat.showMin?r+this.options.timeFormat.sepMin:"",l+=this.options.timeFormat.showSec?n+this.options.timeFormat.sepSec:""}};var i=new s;t.jPlayer.convertTime=function(t){return i.time(t)},t.jPlayer.uaBrowser=function(t){var e=t.toLowerCase(),s=/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(e)||[];return{browser:s[1]||"",version:s[2]||"0"}},t.jPlayer.uaPlatform=function(t){var e=t.toLowerCase(),s=/(ipad|iphone|ipod|android|blackberry|playbook|windows ce|webos)/.exec(e)||[],i=/(ipad|playbook)/.exec(e)||!/(mobile)/.exec(e)&&/(android)/.exec(e)||[];return s[1]&&(s[1]=s[1].replace(/\s/g,"_")),{platform:s[1]||"",tablet:i[1]||""}},t.jPlayer.browser={},t.jPlayer.platform={};var a=t.jPlayer.uaBrowser(navigator.userAgent);a.browser&&(t.jPlayer.browser[a.browser]=!0,t.jPlayer.browser.version=a.version);var o=t.jPlayer.uaPlatform(navigator.userAgent);o.platform&&(t.jPlayer.platform[o.platform]=!0,t.jPlayer.platform.mobile=!o.tablet,t.jPlayer.platform.tablet=!!o.tablet),t.jPlayer.getDocMode=function(){var e;return t.jPlayer.browser.msie&&(document.documentMode?e=document.documentMode:(e=5,document.compatMode&&"CSS1Compat"===document.compatMode&&(e=7))),e},t.jPlayer.browser.documentMode=t.jPlayer.getDocMode(),t.jPlayer.nativeFeatures={init:function(){var t,e,s,i=document,a=i.createElement("video"),o={w3c:["fullscreenEnabled","fullscreenElement","requestFullscreen","exitFullscreen","fullscreenchange","fullscreenerror"],moz:["mozFullScreenEnabled","mozFullScreenElement","mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozfullscreenerror"],webkit:["","webkitCurrentFullScreenElement","webkitRequestFullScreen","webkitCancelFullScreen","webkitfullscreenchange",""],webkitVideo:["webkitSupportsFullscreen","webkitDisplayingFullscreen","webkitEnterFullscreen","webkitExitFullscreen","",""],ms:["","msFullscreenElement","msRequestFullscreen","msExitFullscreen","MSFullscreenChange","MSFullscreenError"]},r=["w3c","moz","webkit","webkitVideo","ms"];for(this.fullscreen=t={support:{w3c:!!i[o.w3c[0]],moz:!!i[o.moz[0]],webkit:"function"==typeof i[o.webkit[3]],webkitVideo:"function"==typeof a[o.webkitVideo[2]],ms:"function"==typeof a[o.ms[2]]},used:{}},e=0,s=r.length;e-1,s.flash.canPlay[i]=s.format[i].flashCanPlay&&s.flash.available})),this.html.desired=!1,this.aurora.desired=!1,this.flash.desired=!1,t.each(this.solutions,(function(e,i){if(0===e)s[i].desired=!0;else{var a=!1,o=!1;t.each(s.formats,(function(t,e){s[s.solutions[0]].canPlay[e]&&("video"===s.format[e].media?o=!0:a=!0)})),s[i].desired=s.require.audio&&!a||s.require.video&&!o}})),this.html.support={},this.aurora.support={},this.flash.support={},t.each(this.formats,(function(t,e){s.html.support[e]=s.html.canPlay[e]&&s.html.desired,s.aurora.support[e]=s.aurora.canPlay[e]&&s.aurora.desired,s.flash.support[e]=s.flash.canPlay[e]&&s.flash.desired})),this.html.used=!1,this.aurora.used=!1,this.flash.used=!1,t.each(this.solutions,(function(e,i){t.each(s.formats,(function(t,e){if(s[i].support[e])return s[i].used=!0,!1}))})),this._resetActive(),this._resetGate(),this._cssSelectorAncestor(this.options.cssSelectorAncestor),this.html.used||this.aurora.used||this.flash.used?this.css.jq.noSolution.length&&this.css.jq.noSolution.hide():(this._error({type:t.jPlayer.error.NO_SOLUTION,context:"{solution:'"+this.options.solution+"', supplied:'"+this.options.supplied+"'}",message:t.jPlayer.errorMsg.NO_SOLUTION,hint:t.jPlayer.errorHint.NO_SOLUTION}),this.css.jq.noSolution.length&&this.css.jq.noSolution.show()),this.flash.used){var i,a="jQuery="+encodeURI(this.options.noConflict)+"&id="+encodeURI(this.internal.self.id)+"&vol="+this.options.volume+"&muted="+this.options.muted;if(t.jPlayer.browser.msie&&(Number(t.jPlayer.browser.version)<9||t.jPlayer.browser.documentMode<9)){var o='',r=['','','','',''];i=document.createElement(o);for(var n=0;n0&&(i.internal.cmdsIgnored=!1),i._getHtmlStatus(e),i._updateInterface(),i._trigger(t.jPlayer.event.progress))}),!1),e.addEventListener("loadeddata",(function(){s.gate&&(i.androidFix.setMedia=!1,i.androidFix.play&&(i.androidFix.play=!1,i.play(i.androidFix.time)),i.androidFix.pause&&(i.androidFix.pause=!1,i.pause(i.androidFix.time)),i._trigger(t.jPlayer.event.loadeddata))}),!1),e.addEventListener("timeupdate",(function(){s.gate&&(i._getHtmlStatus(e),i._updateInterface(),i._trigger(t.jPlayer.event.timeupdate))}),!1),e.addEventListener("durationchange",(function(){s.gate&&(i._getHtmlStatus(e),i._updateInterface(),i._trigger(t.jPlayer.event.durationchange))}),!1),e.addEventListener("play",(function(){s.gate&&(i._updateButtons(!0),i._html_checkWaitForPlay(),i._trigger(t.jPlayer.event.play))}),!1),e.addEventListener("playing",(function(){s.gate&&(i._updateButtons(!0),i._seeked(),i._trigger(t.jPlayer.event.playing))}),!1),e.addEventListener("pause",(function(){s.gate&&(i._updateButtons(!1),i._trigger(t.jPlayer.event.pause))}),!1),e.addEventListener("waiting",(function(){s.gate&&(i._seeking(),i._trigger(t.jPlayer.event.waiting))}),!1),e.addEventListener("seeking",(function(){s.gate&&(i._seeking(),i._trigger(t.jPlayer.event.seeking))}),!1),e.addEventListener("seeked",(function(){s.gate&&(i._seeked(),i._trigger(t.jPlayer.event.seeked))}),!1),e.addEventListener("volumechange",(function(){s.gate&&(i.options.volume=e.volume,i.options.muted=e.muted,i._updateMute(),i._updateVolume(),i._trigger(t.jPlayer.event.volumechange))}),!1),e.addEventListener("ratechange",(function(){s.gate&&(i.options.defaultPlaybackRate=e.defaultPlaybackRate,i.options.playbackRate=e.playbackRate,i._updatePlaybackRate(),i._trigger(t.jPlayer.event.ratechange))}),!1),e.addEventListener("suspend",(function(){s.gate&&(i._seeked(),i._trigger(t.jPlayer.event.suspend))}),!1),e.addEventListener("ended",(function(){s.gate&&(t.jPlayer.browser.webkit||(i.htmlElement.media.currentTime=0),i.htmlElement.media.pause(),i._updateButtons(!1),i._getHtmlStatus(e,!0),i._updateInterface(),i._trigger(t.jPlayer.event.ended))}),!1),e.addEventListener("error",(function(){s.gate&&(i._updateButtons(!1),i._seeked(),i.status.srcSet&&(clearTimeout(i.internal.htmlDlyCmdId),i.status.waitForLoad=!0,i.status.waitForPlay=!0,i.status.video&&!i.status.nativeVideoControls&&i.internal.video.jq.css({width:"0px",height:"0px"}),i._validString(i.status.media.poster)&&!i.status.nativeVideoControls&&i.internal.poster.jq.show(),i.css.jq.videoPlay.length&&i.css.jq.videoPlay.show(),i._error({type:t.jPlayer.error.URL,context:i.status.src,message:t.jPlayer.errorMsg.URL,hint:t.jPlayer.errorHint.URL})))}),!1),t.each(t.jPlayer.htmlEvent,(function(a,o){e.addEventListener(this,(function(){s.gate&&i._trigger(t.jPlayer.event[o])}),!1)}))},_addAuroraEventListeners:function(e,s){var i=this;e.volume=100*this.options.volume,e.on("progress",(function(){s.gate&&(i.internal.cmdsIgnored&&this.readyState>0&&(i.internal.cmdsIgnored=!1),i._getAuroraStatus(e),i._updateInterface(),i._trigger(t.jPlayer.event.progress),e.duration>0&&i._trigger(t.jPlayer.event.timeupdate))}),!1),e.on("ready",(function(){s.gate&&i._trigger(t.jPlayer.event.loadeddata)}),!1),e.on("duration",(function(){s.gate&&(i._getAuroraStatus(e),i._updateInterface(),i._trigger(t.jPlayer.event.durationchange))}),!1),e.on("end",(function(){s.gate&&(i._updateButtons(!1),i._getAuroraStatus(e,!0),i._updateInterface(),i._trigger(t.jPlayer.event.ended))}),!1),e.on("error",(function(){s.gate&&(i._updateButtons(!1),i._seeked(),i.status.srcSet&&(i.status.waitForLoad=!0,i.status.waitForPlay=!0,i.status.video&&!i.status.nativeVideoControls&&i.internal.video.jq.css({width:"0px",height:"0px"}),i._validString(i.status.media.poster)&&!i.status.nativeVideoControls&&i.internal.poster.jq.show(),i.css.jq.videoPlay.length&&i.css.jq.videoPlay.show(),i._error({type:t.jPlayer.error.URL,context:i.status.src,message:t.jPlayer.errorMsg.URL,hint:t.jPlayer.errorHint.URL})))}),!1)},_getHtmlStatus:function(t,e){var s=0,i=0,a=0,o=0;isFinite(t.duration)&&(this.status.duration=t.duration),s=t.currentTime,i=this.status.duration>0?100*s/this.status.duration:0,"object"==typeof t.seekable&&t.seekable.length>0?(a=this.status.duration>0?100*t.seekable.end(t.seekable.length-1)/this.status.duration:100,o=this.status.duration>0?100*t.currentTime/t.seekable.end(t.seekable.length-1):0):(a=100,o=i),e&&(s=0,o=0,i=0),this.status.seekPercent=a,this.status.currentPercentRelative=o,this.status.currentPercentAbsolute=i,this.status.currentTime=s,this.status.remaining=this.status.duration-this.status.currentTime,this.status.videoWidth=t.videoWidth,this.status.videoHeight=t.videoHeight,this.status.readyState=t.readyState,this.status.networkState=t.networkState,this.status.playbackRate=t.playbackRate,this.status.ended=t.ended},_getAuroraStatus:function(t,e){var s=0,i=0,a=0,o=0;this.status.duration=t.duration/1e3,s=t.currentTime/1e3,i=this.status.duration>0?100*s/this.status.duration:0,t.buffered>0?(a=this.status.duration>0?t.buffered*this.status.duration/this.status.duration:100,o=this.status.duration>0?s/(t.buffered*this.status.duration):0):(a=100,o=i),e&&(s=0,o=0,i=0),this.status.seekPercent=a,this.status.currentPercentRelative=o,this.status.currentPercentAbsolute=i,this.status.currentTime=s,this.status.remaining=this.status.duration-this.status.currentTime,this.status.readyState=4,this.status.networkState=0,this.status.playbackRate=1,this.status.ended=!1},_resetStatus:function(){this.status=t.extend({},this.status,t.jPlayer.prototype.status)},_trigger:function(e,s,i){var a=t.Event(e);a.jPlayer={},a.jPlayer.version=t.extend({},this.version),a.jPlayer.options=t.extend(!0,{},this.options),a.jPlayer.status=t.extend(!0,{},this.status),a.jPlayer.html=t.extend(!0,{},this.html),a.jPlayer.aurora=t.extend(!0,{},this.aurora),a.jPlayer.flash=t.extend(!0,{},this.flash),s&&(a.jPlayer.error=t.extend({},s)),i&&(a.jPlayer.warning=t.extend({},i)),this.element.trigger(a)},jPlayerFlashEvent:function(e,s){if(e===t.jPlayer.event.ready)if(this.internal.ready){if(this.flash.gate){if(this.status.srcSet){var i=this.status.currentTime,a=this.status.paused;this.setMedia(this.status.media),this.volumeWorker(this.options.volume),i>0&&(a?this.pause(i):this.play(i))}this._trigger(t.jPlayer.event.flashreset)}}else this.internal.ready=!0,this.internal.flash.jq.css({width:"0px",height:"0px"}),this.version.flash=s.version,this.version.needFlash!==this.version.flash&&this._error({type:t.jPlayer.error.VERSION,context:this.version.flash,message:t.jPlayer.errorMsg.VERSION+this.version.flash,hint:t.jPlayer.errorHint.VERSION}),this._trigger(t.jPlayer.event.repeat),this._trigger(e);if(this.flash.gate)switch(e){case t.jPlayer.event.progress:case t.jPlayer.event.timeupdate:this._getFlashStatus(s),this._updateInterface(),this._trigger(e);break;case t.jPlayer.event.play:this._seeked(),this._updateButtons(!0),this._trigger(e);break;case t.jPlayer.event.pause:case t.jPlayer.event.ended:this._updateButtons(!1),this._trigger(e);break;case t.jPlayer.event.click:this._trigger(e);break;case t.jPlayer.event.error:this.status.waitForLoad=!0,this.status.waitForPlay=!0,this.status.video&&this.internal.flash.jq.css({width:"0px",height:"0px"}),this._validString(this.status.media.poster)&&this.internal.poster.jq.show(),this.css.jq.videoPlay.length&&this.status.video&&this.css.jq.videoPlay.show(),this.status.video?this._flash_setVideo(this.status.media):this._flash_setAudio(this.status.media),this._updateButtons(!1),this._error({type:t.jPlayer.error.URL,context:s.src,message:t.jPlayer.errorMsg.URL,hint:t.jPlayer.errorHint.URL});break;case t.jPlayer.event.seeking:this._seeking(),this._trigger(e);break;case t.jPlayer.event.seeked:this._seeked(),this._trigger(e);break;case t.jPlayer.event.ready:break;default:this._trigger(e)}return!1},_getFlashStatus:function(t){this.status.seekPercent=t.seekPercent,this.status.currentPercentRelative=t.currentPercentRelative,this.status.currentPercentAbsolute=t.currentPercentAbsolute,this.status.currentTime=t.currentTime,this.status.duration=t.duration,this.status.remaining=t.duration-t.currentTime,this.status.videoWidth=t.videoWidth,this.status.videoHeight=t.videoHeight,this.status.readyState=4,this.status.networkState=0,this.status.playbackRate=1,this.status.ended=!1},_updateButtons:function(t){t===e?t=!this.status.paused:this.status.paused=!t,t?this.addStateClass("playing"):this.removeStateClass("playing"),!this.status.noFullWindow&&this.options.fullWindow?this.addStateClass("fullScreen"):this.removeStateClass("fullScreen"),this.options.loop?this.addStateClass("looped"):this.removeStateClass("looped"),this.css.jq.play.length&&this.css.jq.pause.length&&(t?(this.css.jq.play.hide(),this.css.jq.pause.show()):(this.css.jq.play.show(),this.css.jq.pause.hide())),this.css.jq.restoreScreen.length&&this.css.jq.fullScreen.length&&(this.status.noFullWindow?(this.css.jq.fullScreen.hide(),this.css.jq.restoreScreen.hide()):this.options.fullWindow?(this.css.jq.fullScreen.hide(),this.css.jq.restoreScreen.show()):(this.css.jq.fullScreen.show(),this.css.jq.restoreScreen.hide())),this.css.jq.repeat.length&&this.css.jq.repeatOff.length&&(this.options.loop?(this.css.jq.repeat.hide(),this.css.jq.repeatOff.show()):(this.css.jq.repeat.show(),this.css.jq.repeatOff.hide()))},_updateInterface:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.width(this.status.seekPercent+"%"),this.css.jq.playBar.length&&(this.options.smoothPlayBar?this.css.jq.playBar.stop().animate({width:this.status.currentPercentAbsolute+"%"},250,"linear"):this.css.jq.playBar.width(this.status.currentPercentRelative+"%"));this.css.jq.currentTime.length&&this._convertTime(this.status.currentTime)!==this.css.jq.currentTime.text()&&this.css.jq.currentTime.text(this._convertTime(this.status.currentTime));var t="",e=this.status.duration,s=this.status.remaining;this.css.jq.duration.length&&("string"==typeof this.status.media.duration?t=this.status.media.duration:("number"==typeof this.status.media.duration&&(s=(e=this.status.media.duration)-this.status.currentTime),t=this.options.remainingDuration?(s>0?"-":"")+this._convertTime(s):this._convertTime(e)),t!==this.css.jq.duration.text()&&this.css.jq.duration.text(t))},_convertTime:s.prototype.time,_seeking:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.addClass("jp-seeking-bg"),this.addStateClass("seeking")},_seeked:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.removeClass("jp-seeking-bg"),this.removeStateClass("seeking")},_resetGate:function(){this.html.audio.gate=!1,this.html.video.gate=!1,this.aurora.gate=!1,this.flash.gate=!1},_resetActive:function(){this.html.active=!1,this.aurora.active=!1,this.flash.active=!1},_escapeHtml:function(t){return t.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")},_qualifyURL:function(t){var e=document.createElement("div");return e.innerHTML='x',e.firstChild.href},_absoluteMediaUrls:function(e){var s=this;return t.each(e,(function(t,i){i&&s.format[t]&&"data:"!==i.substr(0,5)&&(e[t]=s._qualifyURL(i))})),e},addStateClass:function(t){this.ancestorJq.length&&this.ancestorJq.addClass(this.options.stateClass[t])},removeStateClass:function(t){this.ancestorJq.length&&this.ancestorJq.removeClass(this.options.stateClass[t])},setMedia:function(e){var s=this,i=!1,a=this.status.media.poster!==e.poster;this._resetMedia(),this._resetGate(),this._resetActive(),this.androidFix.setMedia=!1,this.androidFix.play=!1,this.androidFix.pause=!1,e=this._absoluteMediaUrls(e),t.each(this.formats,(function(a,o){var r="video"===s.format[o].media;if(t.each(s.solutions,(function(a,n){if(s[n].support[o]&&s._validString(e[o])){var l="html"===n,h="aurora"===n;return r?(l?(s.html.video.gate=!0,s._html_setVideo(e),s.html.active=!0):(s.flash.gate=!0,s._flash_setVideo(e),s.flash.active=!0),s.css.jq.videoPlay.length&&s.css.jq.videoPlay.show(),s.status.video=!0):(l?(s.html.audio.gate=!0,s._html_setAudio(e),s.html.active=!0,t.jPlayer.platform.android&&(s.androidFix.setMedia=!0)):h?(s.aurora.gate=!0,s._aurora_setAudio(e),s.aurora.active=!0):(s.flash.gate=!0,s._flash_setAudio(e),s.flash.active=!0),s.css.jq.videoPlay.length&&s.css.jq.videoPlay.hide(),s.status.video=!1),i=!0,!1}})),i)return!1})),i?(this.status.nativeVideoControls&&this.html.video.gate||this._validString(e.poster)&&(a?this.htmlElement.poster.src=e.poster:this.internal.poster.jq.show()),"string"==typeof e.title&&(this.css.jq.title.length&&this.css.jq.title.html(e.title),this.htmlElement.audio&&this.htmlElement.audio.setAttribute("title",e.title),this.htmlElement.video&&this.htmlElement.video.setAttribute("title",e.title)),this.status.srcSet=!0,this.status.media=t.extend({},e),this._updateButtons(!1),this._updateInterface(),this._trigger(t.jPlayer.event.setmedia)):this._error({type:t.jPlayer.error.NO_SUPPORT,context:"{supplied:'"+this.options.supplied+"'}",message:t.jPlayer.errorMsg.NO_SUPPORT,hint:t.jPlayer.errorHint.NO_SUPPORT})},_resetMedia:function(){this._resetStatus(),this._updateButtons(!1),this._updateInterface(),this._seeked(),this.internal.poster.jq.hide(),clearTimeout(this.internal.htmlDlyCmdId),this.html.active?this._html_resetMedia():this.aurora.active?this._aurora_resetMedia():this.flash.active&&this._flash_resetMedia()},clearMedia:function(){this._resetMedia(),this.html.active?this._html_clearMedia():this.aurora.active?this._aurora_clearMedia():this.flash.active&&this._flash_clearMedia(),this._resetGate(),this._resetActive()},load:function(){this.status.srcSet?this.html.active?this._html_load():this.aurora.active?this._aurora_load():this.flash.active&&this._flash_load():this._urlNotSetError("load")},focus:function(){this.options.keyEnabled&&(t.jPlayer.focus=this)},play:function(t){"object"==typeof t&&this.options.useStateClassSkin&&!this.status.paused?this.pause(t):(t="number"==typeof t?t:NaN,this.status.srcSet?(this.focus(),this.html.active?this._html_play(t):this.aurora.active?this._aurora_play(t):this.flash.active&&this._flash_play(t)):this._urlNotSetError("play"))},videoPlay:function(){this.play()},pause:function(t){t="number"==typeof t?t:NaN,this.status.srcSet?this.html.active?this._html_pause(t):this.aurora.active?this._aurora_pause(t):this.flash.active&&this._flash_pause(t):this._urlNotSetError("pause")},tellOthers:function(e,s){var i=this,a="function"==typeof s,o=Array.prototype.slice.call(arguments);"string"==typeof e&&(a&&o.splice(1,1),t.jPlayer.prototype.destroyRemoved(),t.each(this.instances,(function(){i.element!==this&&(a&&!s.call(this.data("jPlayer"),i)||this.jPlayer.apply(this,o))})))},pauseOthers:function(t){this.tellOthers("pause",(function(){return this.status.srcSet}),t)},stop:function(){this.status.srcSet?this.html.active?this._html_pause(0):this.aurora.active?this._aurora_pause(0):this.flash.active&&this._flash_pause(0):this._urlNotSetError("stop")},playHead:function(t){t=this._limitValue(t,0,100),this.status.srcSet?this.html.active?this._html_playHead(t):this.aurora.active?this._aurora_playHead(t):this.flash.active&&this._flash_playHead(t):this._urlNotSetError("playHead")},_muted:function(t){this.mutedWorker(t),this.options.globalVolume&&this.tellOthers("mutedWorker",(function(){return this.options.globalVolume}),t)},mutedWorker:function(e){this.options.muted=e,this.html.used&&this._html_setProperty("muted",e),this.aurora.used&&this._aurora_mute(e),this.flash.used&&this._flash_mute(e),this.html.video.gate||this.html.audio.gate||(this._updateMute(e),this._updateVolume(this.options.volume),this._trigger(t.jPlayer.event.volumechange))},mute:function(t){"object"==typeof t&&this.options.useStateClassSkin&&this.options.muted?this._muted(!1):(t=t===e||!!t,this._muted(t))},unmute:function(t){t=t===e||!!t,this._muted(!t)},_updateMute:function(t){t===e&&(t=this.options.muted),t?this.addStateClass("muted"):this.removeStateClass("muted"),this.css.jq.mute.length&&this.css.jq.unmute.length&&(this.status.noVolume?(this.css.jq.mute.hide(),this.css.jq.unmute.hide()):t?(this.css.jq.mute.hide(),this.css.jq.unmute.show()):(this.css.jq.mute.show(),this.css.jq.unmute.hide()))},volume:function(t){this.volumeWorker(t),this.options.globalVolume&&this.tellOthers("volumeWorker",(function(){return this.options.globalVolume}),t)},volumeWorker:function(e){e=this._limitValue(e,0,1),this.options.volume=e,this.html.used&&this._html_setProperty("volume",e),this.aurora.used&&this._aurora_volume(e),this.flash.used&&this._flash_volume(e),this.html.video.gate||this.html.audio.gate||(this._updateVolume(e),this._trigger(t.jPlayer.event.volumechange))},volumeBar:function(e){if(this.css.jq.volumeBar.length){var s=t(e.currentTarget),i=s.offset(),a=e.pageX-i.left,o=s.width(),r=s.height()-e.pageY+i.top,n=s.height();this.options.verticalVolume?this.volume(r/n):this.volume(a/o)}this.options.muted&&this._muted(!1)},_updateVolume:function(t){t===e&&(t=this.options.volume),t=this.options.muted?0:t,this.status.noVolume?(this.addStateClass("noVolume"),this.css.jq.volumeBar.length&&this.css.jq.volumeBar.hide(),this.css.jq.volumeBarValue.length&&this.css.jq.volumeBarValue.hide(),this.css.jq.volumeMax.length&&this.css.jq.volumeMax.hide()):(this.removeStateClass("noVolume"),this.css.jq.volumeBar.length&&this.css.jq.volumeBar.show(),this.css.jq.volumeBarValue.length&&(this.css.jq.volumeBarValue.show(),this.css.jq.volumeBarValue[this.options.verticalVolume?"height":"width"](100*t+"%")),this.css.jq.volumeMax.length&&this.css.jq.volumeMax.show())},volumeMax:function(){this.volume(1),this.options.muted&&this._muted(!1)},_cssSelectorAncestor:function(e){var s=this;this.options.cssSelectorAncestor=e,this._removeUiClass(),this.ancestorJq=e?t(e):[],e&&1!==this.ancestorJq.length&&this._warning({type:t.jPlayer.warning.CSS_SELECTOR_COUNT,context:e,message:t.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.ancestorJq.length+" found for cssSelectorAncestor.",hint:t.jPlayer.warningHint.CSS_SELECTOR_COUNT}),this._addUiClass(),t.each(this.options.cssSelector,(function(t,e){s._cssSelector(t,e)})),this._updateInterface(),this._updateButtons(),this._updateAutohide(),this._updateVolume(),this._updateMute()},_cssSelector:function(e,s){var i=this;if("string"==typeof s)if(t.jPlayer.prototype.options.cssSelector[e]){if(this.css.jq[e]&&this.css.jq[e].length&&this.css.jq[e].off(".jPlayer"),this.options.cssSelector[e]=s,this.css.cs[e]=this.options.cssSelectorAncestor+" "+s,this.css.jq[e]=s?t(this.css.cs[e]):[],this.css.jq[e].length&&this[e]){this.css.jq[e].on("click.jPlayer",(function(s){s.preventDefault(),i[e](s),i.options.autoBlur?t(this).trigger("blur"):t(this).trigger("focus")}))}s&&1!==this.css.jq[e].length&&this._warning({type:t.jPlayer.warning.CSS_SELECTOR_COUNT,context:this.css.cs[e],message:t.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.css.jq[e].length+" found for "+e+" method.",hint:t.jPlayer.warningHint.CSS_SELECTOR_COUNT})}else this._warning({type:t.jPlayer.warning.CSS_SELECTOR_METHOD,context:e,message:t.jPlayer.warningMsg.CSS_SELECTOR_METHOD,hint:t.jPlayer.warningHint.CSS_SELECTOR_METHOD});else this._warning({type:t.jPlayer.warning.CSS_SELECTOR_STRING,context:s,message:t.jPlayer.warningMsg.CSS_SELECTOR_STRING,hint:t.jPlayer.warningHint.CSS_SELECTOR_STRING})},duration:function(t){this.options.toggleDuration&&(this.options.captureDuration&&t.stopPropagation(),this._setOption("remainingDuration",!this.options.remainingDuration))},seekBar:function(e){if(this.css.jq.seekBar.length){var s=t(e.currentTarget),i=s.offset(),a=100*(e.pageX-i.left)/s.width();this.playHead(a)}},playbackRate:function(t){this._setOption("playbackRate",t)},playbackRateBar:function(e){if(this.css.jq.playbackRateBar.length){var s,i=t(e.currentTarget),a=i.offset(),o=e.pageX-a.left,r=i.width(),n=i.height()-e.pageY+a.top,l=i.height();s=(this.options.verticalPlaybackRate?n/l:o/r)*(this.options.maxPlaybackRate-this.options.minPlaybackRate)+this.options.minPlaybackRate,this.playbackRate(s)}},_updatePlaybackRate:function(){var t=(this.options.playbackRate-this.options.minPlaybackRate)/(this.options.maxPlaybackRate-this.options.minPlaybackRate);this.status.playbackRateEnabled?(this.css.jq.playbackRateBar.length&&this.css.jq.playbackRateBar.show(),this.css.jq.playbackRateBarValue.length&&(this.css.jq.playbackRateBarValue.show(),this.css.jq.playbackRateBarValue[this.options.verticalPlaybackRate?"height":"width"](100*t+"%"))):(this.css.jq.playbackRateBar.length&&this.css.jq.playbackRateBar.hide(),this.css.jq.playbackRateBarValue.length&&this.css.jq.playbackRateBarValue.hide())},repeat:function(t){"object"==typeof t&&this.options.useStateClassSkin&&this.options.loop?this._loop(!1):this._loop(!0)},repeatOff:function(){this._loop(!1)},_loop:function(e){this.options.loop!==e&&(this.options.loop=e,this._updateButtons(),this._trigger(t.jPlayer.event.repeat))},option:function(s,i){var a=s;if(0===arguments.length)return t.extend(!0,{},this.options);if("string"==typeof s){var o=s.split(".");if(i===e){for(var r=t.extend(!0,{},this.options),n=0;n0||Math.floor(i)>0):a=!0,t.internal.mouse={x:e.pageX,y:e.pageY},a&&t.css.jq.gui.fadeIn(t.options.autohide.fadeIn,(function(){clearTimeout(t.internal.autohideId),t.internal.autohideId=setTimeout((function(){t.css.jq.gui.fadeOut(t.options.autohide.fadeOut)}),t.options.autohide.hold)}))};this.css.jq.gui.length&&(this.css.jq.gui.stop(!0,!0),clearTimeout(this.internal.autohideId),delete this.internal.mouse,this.element.off(e),this.css.jq.gui.off(e),this.status.nativeVideoControls?this.css.jq.gui.hide():this.options.fullWindow&&this.options.autohide.full||!this.options.fullWindow&&this.options.autohide.restored?(this.element.on(s,i),this.css.jq.gui.on(s,i),this.css.jq.gui.hide()):this.css.jq.gui.show())},fullScreen:function(t){"object"==typeof t&&this.options.useStateClassSkin&&this.options.fullScreen?this._setOption("fullScreen",!1):this._setOption("fullScreen",!0)},restoreScreen:function(){this._setOption("fullScreen",!1)},_fullscreenAddEventListeners:function(){var e=this,s=t.jPlayer.nativeFeatures.fullscreen;s.api.fullscreenEnabled&&s.event.fullscreenchange&&("function"!=typeof this.internal.fullscreenchangeHandler&&(this.internal.fullscreenchangeHandler=function(){e._fullscreenchange()}),document.addEventListener(s.event.fullscreenchange,this.internal.fullscreenchangeHandler,!1))},_fullscreenRemoveEventListeners:function(){var e=t.jPlayer.nativeFeatures.fullscreen;this.internal.fullscreenchangeHandler&&document.removeEventListener(e.event.fullscreenchange,this.internal.fullscreenchangeHandler,!1)},_fullscreenchange:function(){this.options.fullScreen&&!t.jPlayer.nativeFeatures.fullscreen.api.fullscreenElement()&&this._setOption("fullScreen",!1)},_requestFullscreen:function(){var e=this.ancestorJq.length?this.ancestorJq[0]:this.element[0],s=t.jPlayer.nativeFeatures.fullscreen;s.used.webkitVideo&&(e=this.htmlElement.video),s.api.fullscreenEnabled&&s.api.requestFullscreen(e)},_exitFullscreen:function(){var e,s=t.jPlayer.nativeFeatures.fullscreen;s.used.webkitVideo&&(e=this.htmlElement.video),s.api.fullscreenEnabled&&s.api.exitFullscreen(e)},_html_initMedia:function(e){var s=t(this.htmlElement.media).empty();t.each(e.track||[],(function(t,e){var i=document.createElement("track");i.setAttribute("kind",e.kind?e.kind:""),i.setAttribute("src",e.src?e.src:""),i.setAttribute("srclang",e.srclang?e.srclang:""),i.setAttribute("label",e.label?e.label:""),e.def&&i.setAttribute("default",e.def),s.append(i)})),this.htmlElement.media.src=this.status.src,"none"!==this.options.preload&&this._html_load(),this._trigger(t.jPlayer.event.timeupdate)},_html_setFormat:function(e){var s=this;t.each(this.formats,(function(t,i){if(s.html.support[i]&&e[i])return s.status.src=e[i],s.status.format[i]=!0,s.status.formatType=i,!1}))},_html_setAudio:function(t){this._html_setFormat(t),this.htmlElement.media=this.htmlElement.audio,this._html_initMedia(t)},_html_setVideo:function(t){this._html_setFormat(t),this.status.nativeVideoControls&&(this.htmlElement.video.poster=this._validString(t.poster)?t.poster:""),this.htmlElement.media=this.htmlElement.video,this._html_initMedia(t)},_html_resetMedia:function(){this.htmlElement.media&&(this.htmlElement.media.id!==this.internal.video.id||this.status.nativeVideoControls||this.internal.video.jq.css({width:"0px",height:"0px"}),this.htmlElement.media.pause())},_html_clearMedia:function(){this.htmlElement.media&&(this.htmlElement.media.src="about:blank",this.htmlElement.media.load())},_html_load:function(){this.status.waitForLoad&&(this.status.waitForLoad=!1,this.htmlElement.media.load()),clearTimeout(this.internal.htmlDlyCmdId)},_html_play:function(t){var e=this,s=this.htmlElement.media;if(this.androidFix.pause=!1,this._html_load(),this.androidFix.setMedia)this.androidFix.play=!0,this.androidFix.time=t;else if(isNaN(t))s.play();else{this.internal.cmdsIgnored&&s.play();try{if(s.seekable&&!("object"==typeof s.seekable&&s.seekable.length>0))throw 1;s.currentTime=t,s.play()}catch(s){return void(this.internal.htmlDlyCmdId=setTimeout((function(){e.play(t)}),250))}}this._html_checkWaitForPlay()},_html_pause:function(t){var e=this,s=this.htmlElement.media;if(this.androidFix.play=!1,t>0?this._html_load():clearTimeout(this.internal.htmlDlyCmdId),s.pause(),this.androidFix.setMedia)this.androidFix.pause=!0,this.androidFix.time=t;else if(!isNaN(t))try{if(s.seekable&&!("object"==typeof s.seekable&&s.seekable.length>0))throw 1;s.currentTime=t}catch(s){return void(this.internal.htmlDlyCmdId=setTimeout((function(){e.pause(t)}),250))}t>0&&this._html_checkWaitForPlay()},_html_playHead:function(t){var e=this,s=this.htmlElement.media;this._html_load();try{if("object"==typeof s.seekable&&s.seekable.length>0)s.currentTime=t*s.seekable.end(s.seekable.length-1)/100;else{if(!(s.duration>0)||isNaN(s.duration))throw"e";s.currentTime=t*s.duration/100}}catch(s){return void(this.internal.htmlDlyCmdId=setTimeout((function(){e.playHead(t)}),250))}this.status.waitForLoad||this._html_checkWaitForPlay()},_html_checkWaitForPlay:function(){this.status.waitForPlay&&(this.status.waitForPlay=!1,this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide(),this.status.video&&(this.internal.poster.jq.hide(),this.internal.video.jq.css({width:this.status.width,height:this.status.height})))},_html_setProperty:function(t,e){this.html.audio.available&&(this.htmlElement.audio[t]=e),this.html.video.available&&(this.htmlElement.video[t]=e)},_aurora_setAudio:function(e){var s=this;t.each(this.formats,(function(t,i){if(s.aurora.support[i]&&e[i])return s.status.src=e[i],s.status.format[i]=!0,s.status.formatType=i,!1})),this.aurora.player=new AV.Player.fromURL(this.status.src),this._addAuroraEventListeners(this.aurora.player,this.aurora),"auto"===this.options.preload&&(this._aurora_load(),this.status.waitForLoad=!1)},_aurora_resetMedia:function(){this.aurora.player&&this.aurora.player.stop()},_aurora_clearMedia:function(){},_aurora_load:function(){this.status.waitForLoad&&(this.status.waitForLoad=!1,this.aurora.player.preload())},_aurora_play:function(e){this.status.waitForLoad||isNaN(e)||this.aurora.player.seek(e),this.aurora.player.playing||this.aurora.player.play(),this.status.waitForLoad=!1,this._aurora_checkWaitForPlay(),this._updateButtons(!0),this._trigger(t.jPlayer.event.play)},_aurora_pause:function(e){isNaN(e)||this.aurora.player.seek(1e3*e),this.aurora.player.pause(),e>0&&this._aurora_checkWaitForPlay(),this._updateButtons(!1),this._trigger(t.jPlayer.event.pause)},_aurora_playHead:function(t){this.aurora.player.duration>0&&this.aurora.player.seek(t*this.aurora.player.duration/100),this.status.waitForLoad||this._aurora_checkWaitForPlay()},_aurora_checkWaitForPlay:function(){this.status.waitForPlay&&(this.status.waitForPlay=!1)},_aurora_volume:function(t){this.aurora.player.volume=100*t},_aurora_mute:function(t){t?(this.aurora.properties.lastvolume=this.aurora.player.volume,this.aurora.player.volume=0):this.aurora.player.volume=this.aurora.properties.lastvolume,this.aurora.properties.muted=t},_flash_setAudio:function(e){var s=this;try{t.each(this.formats,(function(t,i){if(s.flash.support[i]&&e[i]){switch(i){case"m4a":case"fla":s._getMovie().fl_setAudio_m4a(e[i]);break;case"mp3":s._getMovie().fl_setAudio_mp3(e[i]);break;case"rtmpa":s._getMovie().fl_setAudio_rtmp(e[i])}return s.status.src=e[i],s.status.format[i]=!0,s.status.formatType=i,!1}})),"auto"===this.options.preload&&(this._flash_load(),this.status.waitForLoad=!1)}catch(t){this._flashError(t)}},_flash_setVideo:function(e){var s=this;try{t.each(this.formats,(function(t,i){if(s.flash.support[i]&&e[i]){switch(i){case"m4v":case"flv":s._getMovie().fl_setVideo_m4v(e[i]);break;case"rtmpv":s._getMovie().fl_setVideo_rtmp(e[i])}return s.status.src=e[i],s.status.format[i]=!0,s.status.formatType=i,!1}})),"auto"===this.options.preload&&(this._flash_load(),this.status.waitForLoad=!1)}catch(t){this._flashError(t)}},_flash_resetMedia:function(){this.internal.flash.jq.css({width:"0px",height:"0px"}),this._flash_pause(NaN)},_flash_clearMedia:function(){try{this._getMovie().fl_clearMedia()}catch(t){this._flashError(t)}},_flash_load:function(){try{this._getMovie().fl_load()}catch(t){this._flashError(t)}this.status.waitForLoad=!1},_flash_play:function(t){try{this._getMovie().fl_play(t)}catch(t){this._flashError(t)}this.status.waitForLoad=!1,this._flash_checkWaitForPlay()},_flash_pause:function(t){try{this._getMovie().fl_pause(t)}catch(t){this._flashError(t)}t>0&&(this.status.waitForLoad=!1,this._flash_checkWaitForPlay())},_flash_playHead:function(t){try{this._getMovie().fl_play_head(t)}catch(t){this._flashError(t)}this.status.waitForLoad||this._flash_checkWaitForPlay()},_flash_checkWaitForPlay:function(){this.status.waitForPlay&&(this.status.waitForPlay=!1,this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide(),this.status.video&&(this.internal.poster.jq.hide(),this.internal.flash.jq.css({width:this.status.width,height:this.status.height})))},_flash_volume:function(t){try{this._getMovie().fl_volume(t)}catch(t){this._flashError(t)}},_flash_mute:function(t){try{this._getMovie().fl_mute(t)}catch(t){this._flashError(t)}},_getMovie:function(){return document[this.internal.flash.id]},_getFlashPluginVersion:function(){var t,e=0;if(window.ActiveXObject)try{if(t=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")){var s=t.GetVariable("$version");s&&(s=s.split(" ")[1].split(","),e=parseInt(s[0],10)+"."+parseInt(s[1],10))}}catch(t){}else navigator.plugins&&navigator.mimeTypes.length>0&&(t=navigator.plugins["Shockwave Flash"])&&(e=navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/,"$1"));return 1*e},_checkForFlash:function(t){var e=!1;return this._getFlashPluginVersion()>=t&&(e=!0),e},_validString:function(t){return t&&"string"==typeof t},_limitValue:function(t,e,s){return ts?s:t},_urlNotSetError:function(e){this._error({type:t.jPlayer.error.URL_NOT_SET,context:e,message:t.jPlayer.errorMsg.URL_NOT_SET,hint:t.jPlayer.errorHint.URL_NOT_SET})},_flashError:function(e){var s;s=this.internal.ready?"FLASH_DISABLED":"FLASH",this._error({type:t.jPlayer.error[s],context:this.internal.flash.swf,message:t.jPlayer.errorMsg[s]+e.message,hint:t.jPlayer.errorHint[s]}),this.internal.flash.jq.css({width:"1px",height:"1px"})},_error:function(e){this._trigger(t.jPlayer.event.error,e),this.options.errorAlerts&&this._alert("Error!"+(e.message?"\n"+e.message:"")+(e.hint?"\n"+e.hint:"")+"\nContext: "+e.context)},_warning:function(s){this._trigger(t.jPlayer.event.warning,e,s),this.options.warningAlerts&&this._alert("Warning!"+(s.message?"\n"+s.message:"")+(s.hint?"\n"+s.hint:"")+"\nContext: "+s.context)},_alert:function(t){var e="jPlayer "+this.version.script+" : id='"+this.internal.self.id+"' : "+t;this.options.consoleAlerts?window.console&&window.console.log&&window.console.log(e):alert(e)},_emulateHtmlBridge:function(){var e=this;t.each(t.jPlayer.emulateMethods.split(/\s+/g),(function(t,s){e.internal.domNode[s]=function(t){e[s](t)}})),t.each(t.jPlayer.event,(function(s,i){var a=!0;t.each(t.jPlayer.reservedEvent.split(/\s+/g),(function(t,e){if(e===s)return a=!1,!1})),a&&e.element.on(i+".jPlayer.jPlayerHtml",(function(){e._emulateHtmlUpdate();var t=document.createEvent("Event");t.initEvent(s,!1,!0),e.internal.domNode.dispatchEvent(t)}))}))},_emulateHtmlUpdate:function(){var e=this;t.each(t.jPlayer.emulateStatus.split(/\s+/g),(function(t,s){e.internal.domNode[s]=e.status[s]})),t.each(t.jPlayer.emulateOptions.split(/\s+/g),(function(t,s){e.internal.domNode[s]=e.options[s]}))},_destroyHtmlBridge:function(){var e=this;this.element.off(".jPlayerHtml");var s=t.jPlayer.emulateMethods+" "+t.jPlayer.emulateStatus+" "+t.jPlayer.emulateOptions;t.each(s.split(/\s+/g),(function(t,s){delete e.internal.domNode[s]}))}},t.jPlayer.error={FLASH:"e_flash",FLASH_DISABLED:"e_flash_disabled",NO_SOLUTION:"e_no_solution",NO_SUPPORT:"e_no_support",URL:"e_url",URL_NOT_SET:"e_url_not_set",VERSION:"e_version"},t.jPlayer.errorMsg={FLASH:"jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ",FLASH_DISABLED:"jPlayer's Flash fallback has been disabled by the browser due to the CSS rules you have used. Details: ",NO_SOLUTION:"No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.",NO_SUPPORT:"It is not possible to play any media format provided in setMedia() on this browser using your current options.",URL:"Media URL could not be loaded.",URL_NOT_SET:"Attempt to issue media playback commands, while no media url is set.",VERSION:"jPlayer "+t.jPlayer.prototype.version.script+" needs Jplayer.swf version "+t.jPlayer.prototype.version.needFlash+" but found "},t.jPlayer.errorHint={FLASH:"Check your swfPath option and that Jplayer.swf is there.",FLASH_DISABLED:"Check that you have not display:none; the jPlayer entity or any ancestor.",NO_SOLUTION:"Review the jPlayer options: support and supplied.",NO_SUPPORT:"Video or audio formats defined in the supplied option are missing.",URL:"Check media URL is valid.",URL_NOT_SET:"Use setMedia() to set the media URL.",VERSION:"Update jPlayer files."},t.jPlayer.warning={CSS_SELECTOR_COUNT:"e_css_selector_count",CSS_SELECTOR_METHOD:"e_css_selector_method",CSS_SELECTOR_STRING:"e_css_selector_string",OPTION_KEY:"e_option_key"},t.jPlayer.warningMsg={CSS_SELECTOR_COUNT:"The number of css selectors found did not equal one: ",CSS_SELECTOR_METHOD:"The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",CSS_SELECTOR_STRING:"The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",OPTION_KEY:"The option requested in jPlayer('option') is undefined."},t.jPlayer.warningHint={CSS_SELECTOR_COUNT:"Check your css selector and the ancestor.",CSS_SELECTOR_METHOD:"Check your method name.",CSS_SELECTOR_STRING:"Check your css selector is a string.",OPTION_KEY:"Check your option name."}}));assets/js/plugin.js000064400000075500147600053410010325 0ustar00!function (e) { "use strict"; var PENCI = PENCI || {}; e((function () { PENCI.Player = PENCI.Player || {}, PENCI.Player = { set_storage: function (e, t) { var a = this.local_player_abstract; t = Object.assign(a, t); localStorage.setItem(e, JSON.stringify(t)) }, get_storage: function (e) { var t = localStorage.getItem(e); return null !== t && 0 < t.length ? JSON.parse(localStorage.getItem(e)) : {} }, is_object_same: function (e, t) { var a = !0; return JSON.stringify(e) !== JSON.stringify(t) && (a = !1), a }, init: function () { var t = this; t.now = new Date, t.expired_local_storage(), t.container = e("body"), t.tab_key = 1e4 * Math.random(), t.local_player_abstract = { playing: !1, current: 0, current_time: 0, volume: .7, tab_key: t.tab_key, playlist: [], expired: t.now.getTime() + 432e5 }, t.player_shortcode = t.container.find(".pencipdc_player"), t.control = t.player_shortcode.find(".pencipdc_player_controls_wrap"), t.local_player = Object.assign(t.local_player_abstract, t.get_storage(pencipodcast.player_option)), t.set_player(), t.set_event() }, expired_local_storage: function () { var e = this.get_storage(pencipodcast.player_option); "undefined" !== e.expired && e.expired < this.now.getTime() && localStorage.removeItem(pencipodcast.player_option) }, set_player: function () { var t = this; t.player_shortcode.each((function (a, s) { var o = e(s), l = o.find(".pencipdc_jplayer"), i = o.find(".pencipdc_audio"), n = o.parents(".pencipdc_dock_player").hasClass("pencipdc_podcast"), r = o.find(".pencipdc_player_playlist_script"), _ = t.container.find(".jscroll-to-top"), p = t.container.find(".pencipdc_popup_post"), d = r.length > 0 && r.html().length > 0, c = n ? t.local_player.playlist : d ? [t.podcast_data(JSON.parse(r.html()))] : [], u = n && null != t.local_player.current ? t.local_player.current : 0, g = n && null != t.local_player.volume ? t.local_player.volume : .7, y = "#" + i[0].id, f = { jPlayer: "#" + l[0].id, cssSelectorAncestor: y, play: ".pencipdc_player_control__play", pause: ".pencipdc_player_control__pause", stop: ".pencipdc_player_control__stop", seekBar: ".pencipdc_progress_bar__seek", playBar: ".pencipdc_progress_bar__play", mute: ".pencipdc_player_control__mute", unmute: ".pencipdc_player_control__unmute", volumeBar: ".pencipdc_volume_bar", volumeBarValue: ".pencipdc_volume_bar__value", volumeMax: ".pencipdc_volume_max", currentTime: ".pencipdc_player_bar__current_time span", duration: ".pencipdc_player_bar__duration span", title: ".pencipdc_title", repeat: ".pencipdc_player_control__repeat", repeatOff: ".pencipdc_player_control__repeat_off", noSolution: ".pencipdc_no_solution", playlist: ".pencipdc_playlist," + y + " .pencipdc_player_control__playlist", next: ".pencipdc_player_control__next", previous: ".pencipdc_player_control__previous", shuffle: ".pencipdc_player_control__shuffle", shuffleOff: ".pencipdc_player_control__shuffle_off" }; if (new PenciPCPlaylist(f, c, { swfPath: pencipodcast.plugin_url + "/assets/js/jplayer/", supplied: "mp3", wmode: "window", smoothPlayBar: !1, keyEnabled: !0, minPlaybackRate: .1, maxPlaybackRate: 16, volume: g, playlistOptions: { itemSelect: u } }), n) { _.css({ bottom: "90px" }), p.css({ bottom: "140px" }), t.set_body_padding(); var h = e("#" + l.attr("id")); "undefined" != typeof single_podcast_data && h.on("PenciPCPlaylist_init", (function () { c.length < 1 && t.add_episode(single_podcast_data, h) })) } })) }, set_event: function () { var t, a = this, s = a.player_shortcode.find(".pencipdc_progress_bar__seek"), o = a.player_shortcode.find(".pencipdc_volume_bar"), l = a.player_shortcode.find(".pencipdc_mobile_player_wrapper"), i = a.control.find(".pencipdc_player_control__toggle_player"), n = i.find("i"), r = l.find(".pencipdc_player_control__close_player"), _ = a.container.find(".pencipdc_navbar_mobile"), p = a.container.find(".pencipdc_header"), d = a.player_shortcode.parents(".pencipdc_sidecontent .pencipdc_podcast.pencipdc_dock_player.pencipdc_dock_player"); window.addEventListener("mouseover", function (e) { if (a.player_shortcode.parents(".pencipdc_dock_player").hasClass("pencipdc_podcast")) { var t = a.get_storage(pencipodcast.player_option); a.set_current_tab_key(a.tab_key, t) } }.bind(a)), window.addEventListener("storage", function (e) { a.global_player(e) }.bind(a)), s.add(o).on("touchstart mousedown", (function (s) { var o = "touchstart" === s.type ? s.originalEvent.targetTouches[0].pageX : s.pageX; (t = e(this).find(".pencipdc_progress_bar__ball")).addClass("ball_touched"), a.dragged = !0, a.current_dragged_bar = e(this), a.set_draggable_bar(a.current_dragged_bar, o) })), e(document).on("touchend mouseup", (function (s) { if (void 0 !== t ? t.removeClass("ball_touched") : (t = e(this).find(".pencipdc_progress_bar__ball")).removeClass("ball_touched"), a.dragged) { var o = "touchend" === s.type ? s.originalEvent.changedTouches[0].pageX : s.pageX; a.dragged = !1, a.set_draggable_bar(a.current_dragged_bar, o) } })), e(document).on("touchmove mousemove", (function (e) { if (a.dragged) { var t = "touchmove" === e.type ? e.originalEvent.touches[0].pageX : e.pageX; a.set_draggable_bar(a.current_dragged_bar, t) } })), a.player_shortcode.find(".pencipdc_player_control__playlist_toggle").on("click", (function (t) { t.preventDefault(), t.stopPropagation(); var a = e(this), s = e(t.target); "click" == t.type && a.find(t.target).parents(".pencipdc_player_control__playlist_inner").length < 1 && !s.hasClass("penciicon-close-button") && a.find(".pencipdc_player_control__playlist").toggleClass("show") })), e(document).on("click", (function (e) { a.player_shortcode.find(".pencipdc_player_control__playlist").removeClass("show") })), a.player_shortcode.on("jPlayer_ready", (function (t) { a.switch_song(e(this)), a.refresh_playlist(e(this)) })), a.player_shortcode.on("PenciPCPlaylist_select PenciPCPlaylist_playlist", (function (t) { a.switch_song(e(this)) })), a.player_shortcode.on("PenciPCPlaylist_play PenciPCPlaylist_select PenciPCPlaylist_playlist PenciPCPlaylist_currentTime jPlayer_play jPlayer_pause jPlayer_timeupdate jPlayer_volumechange", (function (t) { a.update_status(e(this), t) })), i.on("click", (function (e) { e.preventDefault(), n.hasClass("fa-angle-up") ? (n.addClass("fa-angle-down").removeClass("fa-angle-up"), l.css({ transform: "translateY(0)" }), d.css({ "z-index": "999" }), _.css({ display: "none" }), p.css({ position: "fixed" })) : n.addClass("fa-angle-up").removeClass("fa-angle-down") })), r.on("click", (function () { l.css({ transform: "translateY(100%)" }), d.css({ "z-index": "3" }), n.addClass("fa-angle-up").removeClass("fa-angle-down"), _.css({ display: "block" }), p.css({ position: "relative" }) })) }, set_draggable_bar: function (e, t) { if (e) { var a = e.offset(), s = e.width(), o = e.parents(".audio_player").find(".pencipdc_jplayer"), l = 100 * (t - a.left) / s; if (e.hasClass("pencipdc_progress_bar__seek")) { var i = e.find(".pencipdc_progress_bar__play"), n = o.jPlayer.duration; l < 0 && (l = 0), l > 100 && (l = 100), o.jPlayer("playHead", l), o.jPlayer.currentTime = n * l / 100, o.trigger("PenciPCPlaylist_currentTime") } if (e.hasClass("pencipdc_volume_bar")) { i = e.find(".pencipdc_volume_bar__value"); (l = 100 * (t - a.left) / s) < 0 && (l = 0), l > 100 && (l = 100), o.jPlayer("volume", l / 100) } i.css("width", l + "%") } }, switch_song: function (t) { var a, s, o, l = t.find(".pencipdc_audio"); l.find(".pencipdc_player_control__previous, .pencipdc_player_control__next").removeClass("disabled"), l.find(".pencipdc_progress_bar__ball").on("click", (function () { e(this).trigger("focus") })), l.find(".pencipdc_playlist ul li:last-child").hasClass("pencipdc_playlist_current") && l.find(".pencipdc_player_control__next").addClass("disabled"), l.find(".pencipdc_playlist ul li:first-child").hasClass("pencipdc_playlist_current") && l.find(".pencipdc_player_control__previous").addClass("disabled"), s = (a = l.find(".pencipdc_playlist ul li.pencipdc_playlist_current .pencipdc_playlist_item")).length > 0 ? a.find(".item-cover").html() : "", o = a.length > 0 ? a.find(".item-song").html() : "-", l.find(".pencipdc_player_current_item__cover").html(s), l.find(".pencipdc_player_current_item__title span").html(o) }, refresh_playlist: function (e) { var t = e.find(".pencipdc_audio"); t.find(".pencipdc_player_control__playlist_inner").html(t.find(".pencipdc_playlist ul").html()); }, do_ajax: function (t, a) { var s, o = this, l = a.parents(".pencipdc_media_option"), i = l.hasClass("podcast"), n = i ? "get_episode_data_by_series" : "get_episode_data", r = l.data("id"); if (o.player_shortcode.each((function (t, a) { var o = e(a), l = o.find(".pencipdc_jplayer"); o.parents(".pencipdc_dock_player").hasClass("pencipdc_podcast") && (s = e("#" + l.attr("id"))) })), "play" === t.type || "add_queue" === t.type) return e.ajax({ url: pencipodcast.ajax_url, type: "post", dataType: "json", data: { post_id: r, action: n }, success: function (e) { if (e) switch (t.type) { case "play": if (i) { o.play_series(e, s); break } o.play_episode(e, s); break; case "add_queue": if (i) { o.add_episode_by_series(e, s); break } o.add_episode(e, s) } } }) }, play_episode: function (e, t) { var a, s = t.data("PenciPCPlaylist"), o = s.playlist, l = this.podcast_data(e); (a = o.findIndex((e => e.title === l.title))) > -1 ? s.play(a) : s.add(l, !0) }, play_series: function (e, t) { var a = this, s = [], o = t.data("PenciPCPlaylist"); e.forEach((function (e) { s.push(a.podcast_data(e)) })), o.setPlaylist(s), o.play(0) }, add_episode_by_series: function (e, t) { var a, s = this, o = t.data("PenciPCPlaylist"), l = o.playlist; e.forEach((function (e) { a = s.podcast_data(e), -1 == l.findIndex((e => e.title === a.title)) && o.add(a) })) }, add_episode: function (e, t) { var a = t.data("PenciPCPlaylist"), s = a.playlist, o = this.podcast_data(e); -1 == s.findIndex((e => e.title === o.title)) && a.add(o) }, podcast_data: function (e) { var t = e.post_thumbnail, a = e.series_name, s = e.upload, o = e.post_title, l = '' + o + ""; return { title: '
' + e.post_title + '
' + l + '
", itunes: "", amazon: "", buy: "", download: s, mp3: s } }, update_status: function (e, t) { if ("jPlayer_play" == t.type || "jPlayer_pause" == t.type || "PenciPCPlaylist_play" == t.type || "PenciPCPlaylist_select" == t.type || "PenciPCPlaylist_playlist" == t.type || "PenciPCPlaylist_currentTime" == t.type || "jPlayer_timeupdate" == t.type || "jPlayer_volumechange" == t.type) { var a = this, s = e.parents(".pencipdc_dock_player"), o = s.hasClass("pencipdc_podcast"), l = a.get_storage(pencipodcast.player_option), i = a.container.find(".jscroll-to-top"); if (o) { var n = e.find(".pencipdc_jplayer"), r = n.data("jPlayer"), _ = n.data("PenciPCPlaylist"), p = _.current, d = _.playlist; r.status.paused || (l.current_time = r.status.currentTime, a.set_storage(pencipodcast.player_option, l)), "PenciPCPlaylist_playlist" == t.type && (void 0 !== a.remove_player_timeout && clearTimeout(a.remove_player_timeout), 0 == _.playlist.length ? (a.remove_player_timeout = setTimeout((function () { s.removeClass("show") }), 1e3), i.css({ bottom: "30px" }), a.set_body_padding()) : (i.css({ bottom: "90px" }), s.addClass("show"), a.set_body_padding())), void 0 === l.tab_key && a.set_current_tab_key(a.tab_key, l), l.tab_key == a.tab_key && ("PenciPCPlaylist_play" == t.type && (l.playing = !0, a.set_current_status(p, l)), "PenciPCPlaylist_playlist" == t.type && (a.set_current_status(p, l), a.set_current_playlist(d, l)), "PenciPCPlaylist_select" == t.type && a.set_current_status(p, l), "PenciPCPlaylist_currentTime" == t.type && a.set_current_time(r.status.currentTime, l), "jPlayer_volumechange" == t.type && a.set_current_volume(r.options.volume, l), "jPlayer_play" != t.type && "jPlayer_pause" != t.type || ("jPlayer_play" == t.type && (l.playing = !1, a.set_storage(pencipodcast.player_option, l), l.playing = !0), "jPlayer_pause" == t.type && (l.playing = !0, a.set_storage(pencipodcast.player_option, l), l.playing = !1), a.set_storage(pencipodcast.player_option, l))) } } }, set_current_tab_key: function (e, t) { t.tab_key = e, this.set_storage(pencipodcast.player_option, t) }, set_current_status: function (e, t) { t.current = e, this.set_storage(pencipodcast.player_option, t) }, set_current_time: function (e, t) { t.current_time = e, this.set_storage(pencipodcast.player_option, t) }, set_current_volume: function (e, t) { t.volume = e, this.set_storage(pencipodcast.player_option, t) }, set_current_playlist: function (e, t) { t.playlist = e, this.set_storage(pencipodcast.player_option, t) }, global_player: function (t) { if (t.key === pencipodcast.player_option) { var a, s, o, l, i = this, n = Object.assign({}, i.local_player_abstract), r = Object.assign({}, i.local_player_abstract), _ = JSON.parse(t.newValue), p = JSON.parse(t.oldValue); _ = null === _ ? i.local_player_abstract : Object.assign(n, _), p = null === p ? i.local_player_abstract : Object.assign(r, p), o = _.current !== p.current, a = _.playing !== p.playing, l = _.volume !== p.volume, s = !i.is_object_same(_.playlist, p.playlist), i.player_shortcode.each((function (t, n) { var r = e(n), p = r.parents(".pencipdc_dock_player").hasClass("pencipdc_podcast"), d = navigator.userAgent.toLowerCase(), c = !1; if (-1 !== d.indexOf("safari") && (c = !(d.indexOf("chrome") > -1)), p) { var u = r.find(".pencipdc_jplayer"), g = u.find("audio"), y = u.data("jPlayer"), f = u.data("PenciPCPlaylist"), h = i.is_object_same(i.local_player.playlist, _.playlist), m = i.is_object_same(i.local_player.current, _.current), j = i.is_object_same(i.local_player.volume, _.volume), v = _.current_time / y.status.duration * 100; c || u.jPlayer("playHead", v), u.jPlayer.currentTime = _.current_time, i.tab_key != _.tab_key && (l && null !== _.volume && (j || u.jPlayer("volume", _.volume)), o && null !== _.current && (m || f.select(_.current)), s && (h || f.setPlaylist(_.playlist)), a && _.playing && g.trigger("pause")) } })) } }, set_body_padding: function () { var e = this; e.viewport = e.container.find(".pencipdc_viewport"), e.dock_player = e.container.find(".pencipdc_dock_player"), e.dock_player.length && e.dock_player.hasClass("show") ? e.viewport.addClass("pencipdc_has_player") : e.viewport.removeClass("pencipdc_has_player") } }, PENCI.Player.init() })); var t = function (e, t) { this.element = e, this.module = t }; t.prototype.init = function () { return this.inject_event(), this }, t.prototype.inject_event = function () { var t = e("body"); this.media_option = e(this.element).find(".pencipdc_media_option"), this.play_button = this.media_option.find(".pencipdc_media_button.play"), this.more_button = this.media_option.find(".pencipdc_media_button.more"), this.add_to_queue = this.media_option.find(".add_to_queue"), this.meta_share = this.media_option.find(".pencipdc_meta_share"), this.global_more_button = t.find(".pencipdc_media_button.more"), this.global_meta_share = t.find(".pencipdc_meta_share"), this.media_option_event() }, t.prototype.media_option_event = function () { var t = this, a = e(window), s = "ontouchstart" in window, o = s ? "click" : "mouseenter"; a.on("click", function (a) { if (null !== a.toElement && void 0 !== a.toElement && e(a.toElement.nextElementSibling).hasClass("pencipdc_sharelist_podcast")) return !1; t.global_more_button.removeClass("active") }.bind(t)), t.meta_share.off(o).on(o, (function (o) { var l = e(o.currentTarget), i = l.find(".pencipdc_sharelist_podcast"), n = l.parent().closest(".pencipdc_moreoption").offset(), r = l.parent().closest(".pencipdc_moreoption").position(), _ = l.parent().closest(".pencipdc_moreoption").outerWidth(), p = l.parent().closest(".pencipdc_moreoption").outerHeight() - l.outerHeight(); if (l.parents("[class*=pencipdc_postblock_podcast_]:not(.pencipdc_postblock_podcast_4)").length || l.parents("[class*=pencipdc_postblock_episode_]:not(.pencipdc_postblock_episode_list):not(.pencipdc_postblock_episode_detail)").length) var d = o.clientX + (l.outerWidth() + i.outerWidth()) > a.width() ? l.offset().left + (o.clientX - n.left) + (l.outerWidth() + i.outerWidth()) + 20 - a.width() : 0, c = o.clientY + i.outerHeight() > a.height() ? a.height() + (r.top + i.outerHeight()) - a.height() : 0; else if (n.left || r.top) d = n.left + (l.outerWidth() + i.outerWidth()) > a.width() ? n.left + (l.outerWidth() + i.outerWidth()) + 20 - a.width() : 0, c = r.top + i.outerHeight() > a.height() ? a.height() - (r.top + i.outerHeight()) : 0; if (_ = 0 === d ? _ : "-" + _ + "px", p = c < 0 ? p - 10 + c : p - 10, i.css({ left: _, top: p, opacity: 0, right: "auto" }).animate({ opacity: 1 }, 100), s && l.hasClass("active")) return l.removeClass("active"), !1; t.global_meta_share.removeClass("active"), l.addClass("active").show() })).off("mouseleave").on("mouseleave", (function () { s || t.global_meta_share.removeClass("active") })), t.more_button.off("click").on("click", (function (s) { s.preventDefault(), s.stopPropagation(); var o = e(s.currentTarget), l = o.siblings(".pencipdc_moreoption"), i = s.target.getBoundingClientRect(); if (o.parents("[class*=pencipdc_postblock_podcast_]:not(.pencipdc_postblock_podcast_4)").length || o.parents("[class*=pencipdc_postblock_episode_]:not(.pencipdc_postblock_episode_list):not(.pencipdc_postblock_episode_detail)").length) { var n = o.parents(".pencipdc_block_container"); if (i.left || i.top) { var r = o.offset().left - n.offset().left + (s.clientX - i.left), _ = o.offset().top - n.offset().top + o.outerHeight(); r -= p = s.clientX + l.outerWidth() > a.width() ? o.offset().left + (s.clientX - i.left) + l.outerWidth() + 20 - a.width() : 0, _ -= d = s.clientY + l.outerHeight() > a.height() ? a.height() + l.outerHeight() - a.height() : 0, l.css({ left: r, top: _, opacity: 0, right: "auto" }).animate({ opacity: 1 }, 100) } } else if (i.left || i.top) { r = o.outerWidth() + (s.clientX - i.left), _ = o.outerHeight(); var p = s.clientX + l.outerWidth() > a.width() ? o.offset().left + (s.clientX - i.left) + l.outerWidth() - a.width() : 0, d = s.clientY + (_ + l.height()) > a.height() ? a.height() + (_ + l.height()) - a.height() : 0; (o.parents(".pencipdc_postblock_episode_list").length > 0 || o.parents(".pencipdc_postblock_episode_detail").length > 0) && (r = o.position().left, _ = o.position().top + o.outerHeight()), r -= p, _ -= d, l.css({ left: r, top: _, opacity: 0, right: "auto" }).animate({ opacity: 1 }, 100) } if (o.hasClass("active")) return o.removeClass("active"), !1; t.global_more_button.removeClass("active"), o.addClass("active").show() })).on(t), t.play_button.on("click", (function (t) { t.preventDefault(), t.stopPropagation(); var a = e(this); a.addClass("loading"); var s = PENCI.Player.do_ajax({ type: "play" }, e(this)); null !== s ? s.done((function () { a.removeClass("loading") })) : a.removeClass("loading") })).on(t), t.add_to_queue.on("click", (function (t) { t.preventDefault(), t.stopPropagation(); var a = e(this); a.addClass("loading"); var s = PENCI.Player.do_ajax({ type: "add_queue" }, e(this)); null !== s ? s.done((function () { a.removeClass("loading") })) : a.removeClass("loading") })).on(t) }, e(".penci-item-listp, .pencipdc-item").each(function (a, s) { var o = new t(this, s).init(); e(this).data("podcast", o) }).on("pencipdc_module_ajax", (function () { e(this).data("podcast").inject_event() })), e((function () { var t = e("body"), a = { init: function () { this.container = e(".post-entry .inner-post-entry"), this.meta_share = this.container.find(".pencipdc_meta_share"), this.container.length && this.event() }, event: function () { var t = this; t.window = e(window), t.window.on("click", (function () { t.meta_share.removeClass("loading").removeClass("active") })), t.meta_share.off("click").on("click", (function (t) { t.preventDefault(), t.stopPropagation(); var a = e(t.currentTarget); if (a.hasClass("active")) return a.removeClass("active"), !1; a.removeClass("loading").addClass("active") })) } }; if (t.hasClass("single-podcast") && t.hasClass("pencipdc_global_player")) { var s = t.find(".inner-post-entry").find(".pencipdc_media_option.single_episode"); if (s.length) { var o = s.find(".pencipdc_media_button.play"), l = s.find(".add_to_queue"); o.on("click", (function (t) { t.preventDefault(), t.stopPropagation(); var a = e(this); a.addClass("loading"); var s = PENCI.Player.do_ajax({ type: "play" }, e(this)); null !== s ? s.done((function () { a.removeClass("loading") })) : a.removeClass("loading") })), l.on("click", (function (t) { t.preventDefault(), t.stopPropagation(); var a = e(this), s = a.parents(".pencipdc_media_option"); a.addClass("loading"); var o = PENCI.Player.do_ajax({ type: "add_queue" }, e(this)); if (a.trigger("blur"), null !== o) o.done((function (t) { if (t) { var o = e('"); s.append(o), o.fadeIn(), a.addClass("success"), a.removeClass("loading") } else { o = e('"); s.append(o), o.fadeIn(), a.addClass("failed"), a.removeClass("loading") } setTimeout((function () { o && o.fadeOut((function () { this.remove() })), a.removeClass("loading"), a.removeClass("success"), a.removeClass("failed") }), 1e3) })); else { var l = e('' + pencipodcast.lang.failed + ""); s.append(l), l.fadeIn(), a.addClass("failed"), a.removeClass("loading"), setTimeout((function () { l && l.fadeOut((function () { this.remove() })), a.removeClass("loading"), a.removeClass("success"), a.removeClass("failed") }), 1e3) } })) } } a.init() })) }(jQuery);assets/js/pencipdc.playlist.js000064400000033156147600053410012455 0ustar00;;;! function(s, t) { PenciPCPlaylist = function(t, e, i) { var l = this; this.current = 0, this.loop = !1, this.shuffled = !1, this.removing = !1, this.cssSelector = s.extend({}, this._cssSelector, t), this.options = s.extend(!0, { keyBindings: { next: { key: 221, fn: function() { l.next() } }, previous: { key: 219, fn: function() { l.previous() } }, shuffle: { key: 83, fn: function() { l.shuffle() } } }, stateClass: { shuffled: "jp-state-shuffled" } }, this._options, i), this.playlist = [], this.original = [], this._initPlaylist(e), l.current = this.options.playlistOptions.itemSelect, this.cssSelector.playlist = s(this.cssSelector.cssSelectorAncestor + " " + this.cssSelector.playlist), this.cssSelector.details = this.cssSelector.cssSelectorAncestor + " " + this.cssSelector.details, this.cssSelector.next = this.cssSelector.cssSelectorAncestor + " " + this.cssSelector.next, this.cssSelector.previous = this.cssSelector.cssSelectorAncestor + " " + this.cssSelector.previous, this.cssSelector.shuffle = this.cssSelector.cssSelectorAncestor + " " + this.cssSelector.shuffle, this.cssSelector.shuffleOff = this.cssSelector.cssSelectorAncestor + " " + this.cssSelector.shuffleOff, this.options.cssSelectorAncestor = this.cssSelector.cssSelectorAncestor, this.options.cssSelector = s.extend({}, this.cssSelector), delete this.options.cssSelector.cssSelectorAncestor, delete this.options.cssSelector.jPlayer, this.options.repeat = function(s) { l.loop = s.jPlayer.options.loop }, s(this.cssSelector.jPlayer).on(s.jPlayer.event.ready, (function() { l._init() })), s(this.cssSelector.jPlayer).on(s.jPlayer.event.ended, (function() { l.next() })), s(this.cssSelector.jPlayer).on(s.jPlayer.event.play, (function() { s(this).jPlayer("pauseOthers") })), s(this.cssSelector.jPlayer).on(s.jPlayer.event.resize, (function(t) { t.jPlayer.options.fullScreen ? s(l.cssSelector.details).show() : s(l.cssSelector.details).hide() })), s(this.cssSelector.previous).on("click", (function(s) { s.preventDefault(), l.previous(), l.blur(this) })), s(this.cssSelector.next).on("click", (function(s) { s.preventDefault(), l.next(), l.blur(this) })), s(this.cssSelector.shuffle).on("click", (function(t) { t.preventDefault(), l.shuffled && s(l.cssSelector.jPlayer).jPlayer("option", "useStateClassSkin") ? l.shuffle(!1) : l.shuffle(!0), l.blur(this) })), s(this.cssSelector.shuffleOff).on("click", (function(s) { s.preventDefault(), l.shuffle(!1), l.blur(this) })).hide(), this.options.fullScreen || s(this.cssSelector.details).hide(), this.cssSelector.playlist.find("ul").empty(), this._createItemHandlers(), s(this.cssSelector.jPlayer).jPlayer(this.options) }, PenciPCPlaylist.prototype = { _cssSelector: { jPlayer: "#jquery_jplayer_1", cssSelectorAncestor: "#jp_container_1" }, _options: { playlistOptions: { autoPlay: !1, loopOnPrevious: !1, shuffleOnLoop: !0, enableRemoveControls: !1, displayTime: "slow", addTime: "fast", removeTime: "fast", shuffleTime: "slow", itemClass: "pencipdc_playlist_item", freeGroupClass: "jp-free-media", freeItemClass: "pencipdc_playlist_item_free", removeItemClass: "pencipdc_playlist_item_remove" } }, option: function(s, e) { if (e === t) return this.options.playlistOptions[s]; switch (this.options.playlistOptions[s] = e, s) { case "enableRemoveControls": this._updateControls(); break; case "itemClass": case "freeGroupClass": case "freeItemClass": case "removeItemClass": this._refresh(!0), this._createItemHandlers() } return this }, _init: function() { var t = this; s(this.cssSelector.jPlayer).data("PenciPCPlaylist", this), this._refresh((function() { t.options.playlistOptions.autoPlay ? t.play(t.current) : t.select(t.current) })) }, _initPlaylist: function(t) { this.shuffled = !1, this.removing = !1, this.original = s.extend(!0, [], t), this._originalPlaylist(), 0 == this.original.length && s(this.cssSelector.jPlayer).jPlayer("clearMedia"), s(this.cssSelector.jPlayer).trigger("PenciPCPlaylist_playlist") }, _originalPlaylist: function() { var t = this; this.playlist = [], s.each(this.original, (function(s) { t.playlist[s] = t.original[s] })) }, _refresh: function(t) { var e = this; if (t && !s.isFunction(t)) this.cssSelector.playlist.find("ul").empty(), s.each(this.playlist, (function(s) { e.cssSelector.playlist.find("ul").append(e._createListItem(e.playlist[s])) })), this._updateControls(), s(this.cssSelector.jPlayer).trigger("PenciPCPlaylist_playlist"); else { this.cssSelector.playlist.find("ul").children().length && this.options.playlistOptions.displayTime; this.cssSelector.playlist.find("ul").each((function() { var i = s(this); s(this).empty(), s.each(e.playlist, (function(s) { i.append(e._createListItem(e.playlist[s])) })), e._updateControls(), s.isFunction(t) && t(), e.playlist.length, s(this).show() })), s(this.cssSelector.jPlayer).trigger("PenciPCPlaylist_playlist"), s(this.cssSelector.jPlayer).trigger("PenciPCPlaylist_init") } }, _createListItem: function(t) { var e = this, i = "
  • "; if (i += "', t.free) { var l = !0; i += "(", s.each(t, (function(t, r) { s.jPlayer.prototype.format[t] && (l ? l = !1 : i += " | ", i += "" + t + "") })), i += ")" } return i += "" + t.title + (t.artist ? " " : "") + "", i += "
  • " }, _createItemHandlers: function() { var t = this; this.cssSelector.playlist.off("click", "span." + this.options.playlistOptions.itemClass).on("click", "span." + this.options.playlistOptions.itemClass, (function(e) { e.preventDefault(); var i = s(this).parent().parent().index(); t.current !== i ? t.play(i) : s(t.cssSelector.jPlayer).jPlayer("play"), s(t.cssSelector.jPlayer).trigger("PenciPCPlaylist_play"), t.blur(this) })), this.cssSelector.playlist.off("click", "a." + this.options.playlistOptions.freeItemClass).on("click", "a." + this.options.playlistOptions.freeItemClass, (function(e) { e.preventDefault(), s(this).parent().parent().find("." + t.options.playlistOptions.itemClass).trigger("click"), t.blur(this) })), this.cssSelector.playlist.off("click", "a." + this.options.playlistOptions.removeItemClass).on("click", "a." + this.options.playlistOptions.removeItemClass, (function(e) { e.preventDefault(); var i = s(this).parent().parent(), l = i.index(); i.hasClass("pencipdc_playlist_current") || (t.remove(l), t.blur(this), s(t.cssSelector.jPlayer).trigger("PenciPCPlaylist_playlist")) })) }, _updateControls: function() { this.options.playlistOptions.enableRemoveControls ? this.cssSelector.playlist.find("." + this.options.playlistOptions.removeItemClass).show() : this.cssSelector.playlist.find("." + this.options.playlistOptions.removeItemClass).hide(), this.shuffled ? s(this.cssSelector.jPlayer).jPlayer("addStateClass", "shuffled") : s(this.cssSelector.jPlayer).jPlayer("removeStateClass", "shuffled"), s(this.cssSelector.shuffle).length && s(this.cssSelector.shuffleOff).length && (this.shuffled ? (s(this.cssSelector.shuffleOff).show(), s(this.cssSelector.shuffle).hide()) : (s(this.cssSelector.shuffleOff).hide(), s(this.cssSelector.shuffle).show())) }, _highlight: function(s) { this.playlist.length && s !== t && (this.cssSelector.playlist.find(".pencipdc_playlist_current").removeClass("pencipdc_playlist_current"), this.cssSelector.playlist.find("li:nth-child(" + (s + 1) + ")").addClass("pencipdc_playlist_current").find(".pencipdc_playlist_item").addClass("pencipdc_playlist_current")) }, setPlaylist: function(s) { s.forEach((function(s) { if (s.mp3.length < 1) { var t = s.title.replace('
    ', '
    ,').split(","); t.splice(1, 0, ''), s.title = t.join("") } })), this._initPlaylist(s), this._init() }, add: function(t, e) { if (t.mp3.length < 1) { var i = t.title.replace('
    ', '
    ,').split(","); i.splice(1, 0, ''), t.title = i.join("") } this.cssSelector.playlist.find("ul").append(this._createListItem(t)).find("li:last-child"), this._updateControls(), this.original.push(t), this.playlist.push(t), s(this.cssSelector.jPlayer).trigger("PenciPCPlaylist_playlist"), e ? this.play(this.playlist.length - 1) : 1 === this.original.length && this.select(0) }, remove: function(e) { var i = this; return e === t ? (this._initPlaylist([]), this._refresh((function() { s(i.cssSelector.jPlayer).jPlayer("clearMedia") })), !0) : !this.removing && (0 <= (e = e < 0 ? i.original.length + e : e) && e < this.playlist.length && (this.removing = !0, s(this.cssSelector.playlist[0]).find("li:nth-child(" + (e + 1) + ")").each((function() { if (i.shuffled) { var t = i.playlist[e]; s.each(i.original, (function(s) { if (i.original[s] === t) return i.original.splice(s, 1), !1 })), i.playlist.splice(e, 1) } else i.original.splice(e, 1), i.playlist.splice(e, 1); i.original.length ? e === i.current ? (i.current = e < i.original.length ? i.current : i.original.length - 1, i.select(i.current)) : e < i.current && i.current-- : (s(i.cssSelector.jPlayer).jPlayer("clearMedia"), i.current = 0, i.shuffled = !1, i._updateControls()), i.removing = !1 })), this.cssSelector.playlist.find("li:nth-child(" + (e + 1) + ")").each((function() { s(this).remove() }))), !0) }, select: function(t) { 0 <= (t = t < 0 ? this.original.length + t : t) && t < this.playlist.length ? (this.current = t, this._highlight(t), s(this.cssSelector.jPlayer).jPlayer("setMedia", this.playlist[this.current])) : this.current = 0, s(this.cssSelector.jPlayer).trigger("PenciPCPlaylist_select") }, play: function(e) { 0 <= (e = e < 0 ? this.original.length + e : e) && e < this.playlist.length ? this.playlist.length && (this.select(e), s(this.cssSelector.jPlayer).jPlayer("play")) : e === t && s(this.cssSelector.jPlayer).jPlayer("play"), s(this.cssSelector.jPlayer).trigger("PenciPCPlaylist_play") }, pause: function() { s(this.cssSelector.jPlayer).jPlayer("pause") }, next: function() { var s = this.current + 1 < this.playlist.length ? this.current + 1 : 0; this.loop ? 0 === s && this.shuffled && this.options.playlistOptions.shuffleOnLoop && this.playlist.length > 1 ? this.shuffle(!0, !0) : this.play(s) : s > 0 && this.play(s) }, previous: function() { var s = this.current - 1 >= 0 ? this.current - 1 : this.playlist.length - 1; (this.loop && this.options.playlistOptions.loopOnPrevious || s < this.playlist.length - 1) && this.play(s) }, shuffle: function(e, i) { var l = this; e === t && (e = !this.shuffled), (e || e !== this.shuffled) && this.cssSelector.playlist.find("ul").each((function() { l.shuffled = e, e ? l.playlist.sort((function() { return .5 - Math.random() })) : l._originalPlaylist(), l._refresh(!0), i || !s(l.cssSelector.jPlayer).data("jPlayer").status.paused ? l.play(0) : l.select(0), s(this).show() })) }, blur: function(t) { s(this.cssSelector.jPlayer).jPlayer("option", "autoBlur") && s(t).trigger("blur") } } }(jQuery);assets/style.css000064400000105342147600053410007725 0ustar00.penci-podcast-series-info .pcpd-featured-thumb { margin: 0 0 20px; } .penci-podcast-series-info h1 { margin: 0 0 10px; font-size: 22px; } .penci-podcast-series-info .penci-category-description { margin-bottom: 15px; } .penci-podcast-series-meta { font-size: 12px; color: var(--pcmeta-cl); } .pencipdc_media_option { margin-top: 10px } .pencipdc_media_option ul { font-size: 12px; padding: 6px 0; list-style-type: none } .pencipdc_media_option li { margin-bottom: 0 } .pencipdc_media_option li a, .pencipdc_option_container .pencipdc_sharelist_podcast a { color: var(--pcmeta-cl); font-weight: 400; padding: 6px 20px; display: block; line-height: 22px } .pencipdc_media_option .pencipdc_sharelist_podcast a:hover, .pencipdc_media_option li:hover > :not(.active), .pencipdc_media_option li > .active, .pencipdc_option_container .pencipdc_sharelist_podcast a:hover { background: #f6f6f6; color: var(--pcmeta-cl); } .pencipdc_media_option li:last-child { margin: 0 } .pencipdc_media_option .pencipdc_meta_share { position: unset } .pencipdc_media_option .pencipdc_meta_share .pencipdc_sharelist_podcast, .pencipdc_media_option .pencipdc_moreoption, .pencipdc_option_container .pencipdc_meta_share .pencipdc_sharelist_podcast { padding: 6px 0; margin: 0; list-style: none; position: absolute; background: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .14); min-width: 150px; display: none; z-index: 1041; top: 100% } .pencipdc_media_option .pencipdc_moreoption .add_to_queue .loader { position: relative; margin-left: 0; margin-top: 0; left: auto; top: 0; } .pencipdc_media_option .pencipdc_moreoption li .add_to_queue span:not(:last-of-type), .pencipdc_media_option .pencipdc_moreoption li a > .fa, .pencipdc_option_container .follow-wrapper a > .fa, .pencipdc_option_container .pencipdc_sharelist_podcast a > .fa { margin-right: 6px; font-size: 12px; width: 12px; height: 12px; line-height: 12px } .pencipdc_media_option .pencipdc_media_button.more.active ~ .pencipdc_moreoption, .pencipdc_media_option .pencipdc_meta_share.active .pencipdc_sharelist_podcast, .pencipdc_option_container .pencipdc_meta_share.active .pencipdc_sharelist_podcast { display: block } .pencipdc_media_option .pencipdc_media_button { text-align: center; display: inline-block; font-size: 12px; height: 25px; line-height: 23px; border: 1px solid; border-radius: 5px; transition: 0.3s all ease-in-out; } .pencipdc_media_option .pencipdc_media_button:hover { background-color: var(--pcaccent-cl); border-color: var(--pcaccent-cl); color: #fff; } .pencipdc_media_option .pencipdc_media_button.play, .pencipdc_media_option .pencipdc_media_button.subscribe { padding: 0 15px } .pencipdc_media_option .pencipdc_media_button.add_to_queue, .pencipdc_media_option .pencipdc_media_button.more { margin-left: 10px; width: 26px; border-color: var(--pcborder-cl); } body.rtl .pencipdc_media_option .pencipdc_media_button.add_to_queue, body.rtl .pencipdc_media_option .pencipdc_media_button.more { margin-left: 0; margin-right: 10px; } .pencipdc_media_option .pencipdc_media_button.add_to_queue:not(.success) { color: var(--pcmeta-cl); } .add_to_queue { position: relative; } .add_to_queue .loader { position: absolute; top: 50%; left: 50%; margin-top: -5px; margin-left: -6px; width: 10px; height: 10px; } .add_to_queue .loader:before { opacity: 1; transition: opacity .2s ease; content: ""; display: inline-block; border: 1px solid #bbb; border-top-color: rgb(187, 187, 187); border-left-color: rgb(187, 187, 187); border-left-color: #000; border-top-color: #000; border-radius: 50%; vertical-align: middle; width: 10px; height: 10px; animation: penci-menu-rotate .35s infinite linear; position: absolute; top: 0; left: 0; } .add_to_queue .loader, .add_to_queue .success, .add_to_queue.loading .initial, .add_to_queue.success .initial, .add_to_queue.success .loader, .pencipdc_media_button.play .loader, .pencipdc_media_button.play.loading .initial { display: none } .add_to_queue .initial, .add_to_queue.loading .loader, .add_to_queue.success .success, .pencipdc_media_button.play .initial, .pencipdc_media_button.play.loading .loader { display: inline-block } .pencipdc_media_option .pencipdc_media_button.play span:not(:last-of-type) { width: auto; padding-right: 5px } body.rtl .pencipdc_media_option .pencipdc_media_button.play span:not(:last-of-type) { padding-left: 5px; padding-right: 0; } .pencipdc_media_option.single_episode .pencipdc_episode_length:before { content: '\2022'; margin: 0 5px } .single-post .pencipdc_singlepage .pencipdc_media_option { margin-bottom: 30px } .single-post .pencipdc_singlepage .pencipdc_media_button { font-size: 14px; height: 34px; line-height: 32px } .single-post .pencipdc_singlepage .pencipdc_media_button.play { padding: 0 20px } .single-post .pencipdc_singlepage .pencipdc_media_button.add_to_queue { width: 34px; margin-left: 10px } body.rtl .single-post .pencipdc_singlepage .pencipdc_media_button.add_to_queue { margin-left: 0; margin-right: 10px; } @media only screen and (max-width: 480px) { .single-post .pencipdc_singlepage .pencipdc_media_option { margin-bottom: 20px } } .pencipdc_media_button.more.episode { position: absolute; right: 0; top: 0; border: unset } .pencipdc_media_option.episode .play, .pencipdc_postblock_podcast_4 .pencipdc_media_option .play { padding: 0; width: 26px } .pencipdc_media_option.episode .pencipdc_media_button.play span, .pencipdc_postblock_podcast_4 .pencipdc_media_option .pencipdc_media_button.play span { padding: 0 } .pencipdc_media_option.episode .pencipdc_media_button.play span.initial, .pencipdc_postblock_podcast_4 .pencipdc_media_option .pencipdc_media_button.play span.initial { padding: 0 0 0 3px } .pencipdc_media_option.overlay { z-index: 2; position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, .25); overflow: hidden; width: 100%; height: 100%; transition: .5s ease } .pencipdc_media_option.overlay .pencipdc_media_button { color: #fff; position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); text-align: center; border-radius: 50%; } .pencipdc_global_player .pencipdc_postblock_episode_list .pencipdc_postsmall .pencipdc_post_meta { padding-left: 37px } .pencipdc_global_player .pencipdc_postblock_episode_list .pencipdc_postsmall .pencipdc_post_title { margin: auto; padding: 0 37px } .pencipdc_postblock_episode_list .pencipdc_pl_xs_4 .pencipdc_postblock_content:before { content: unset } .pencipdc_viewport.pencipdc_has_player { padding-bottom: 80px } .pencipdc_playlist { display: none } .pencipdc_podcast.pencipdc_dock_player { width: 100%; z-index: 99; position: fixed; bottom: 0; display: none } .pencipdc_podcast.pencipdc_dock_player.show { display: block; } @media only screen and (max-width: 960px) { .pencipdc_podcast.pencipdc_dock_player { z-index: 999999; } } .pencipdc_player_inner { background-color: #fff; display: flex; flex-direction: column; height: auto; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; box-shadow: 0 4px 14px rgba(0, 0, 0, .14) } .pencipdc_player_controls_wrap { align-items: center; display: flex; flex-direction: row; justify-content: space-between; padding: 0; height: 80px } .pencipdc_inner_content .pencipdc_player { margin-bottom: 30px } .pencipdc_inner_content .pencipdc_player_controls_wrap { padding: 20px 25px; height: auto } @media only screen and (max-width: 480px) { .pencipdc_inner_content .pencipdc_player_controls_wrap { padding: 15px 20px } .pencipdc_inner_content .pencipdc_player { margin-bottom: 20px } } .pencipdc_main_content .pencipdc_player_inner { border-radius: 5px; box-shadow: none; border: 1px solid var(--pcborder-cl); } .pencipdc_control_bar_left { flex: 0 1 15%; max-width: 15% } .pencipdc_main_content .pencipdc_control_bar_left { flex: 0 0 auto; max-width: unset } .pencipdc_control_bar_center { flex: 0 1 70%; max-width: 70% } .pencipdc_main_content .pencipdc_control_bar_center { flex: 0 1 100%; max-width: unset } .pencipdc_control_bar_right, .pencipdc_control_bar_toggle_player { flex: 0 1 15%; max-width: 15%; display: flex; flex-direction: row; justify-content: flex-end } .pencipdc_control_bar_toggle_player { justify-content: center } .pencipdc_main_content .pencipdc_control_bar_toggle_player { display: none } .pencipdc_player_control { display: flex; flex-flow: row nowrap; justify-content: center } .pencipdc_player_inner .pencipdc_player_control a .fa { width: 32px; height: 32px; } .pencipdc_player_inner .pencipdc_player_control a.disabled { cursor: auto; } .pencipdc_player_inner .pencipdc_player_control a.pencipdc_player_control__previous .fa, .pencipdc_player_inner .pencipdc_player_control a.pencipdc_player_control__next .fa { font-size: 18px; } .pencipdc_player_inner .pencipdc_player_control__playlist a .fa { font-size: 13px; } .pencipdc_control_bar_toggle_player .pencipdc_player_control__toggle_player, .pencipdc_control_bar_toggle_player .pencipdc_player_control__toggle_player .fa, .pencipdc_player_control [class*=pencipdc_player_control__] .fa { line-height: 30px; text-align: center } .pencipdc_player_control .pencipdc_player_control__pause .fa, .pencipdc_player_control .pencipdc_player_control__play .fa { border: 1px solid; border-color: inherit; border-radius: 32px } .pencipdc_control_bar_toggle_player .pencipdc_player_control__toggle_player { font-size: 20px } .pencipdc_player_current_item { display: flex; flex-direction: row; justify-content: flex-start; align-items: center; position: relative; transform: translateX(0); transition: transform .25s cubic-bezier(.3, 0, 0, 1) } .pencipdc_player_current_item__cover { width: 56px; height: 56px; position: relative; flex-shrink: 0; overflow: hidden; display: none } .pencipdc_player_current_item__cover img { width: 56px; height: 56px; object-fit: cover } .pencipdc_player_current_item__content { display: flex; flex-direction: column; justify-content: center; margin: 0 20px; width: 100% } .pencipdc_main_content .pencipdc_player_current_item__content { margin-right: 10px } .pencipdc_player_current_item__content, .pencipdc_player_current_item__title { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; text-align: left; } .pencipdc_player_current_item__title span a { color: var(--pcheading-cl); font-family: var(--pchead-font); font-size: 14px; font-weight: var(--pchead-wei); } .pencipdc_main_content .pencipdc_player_current_item__cover, .pencipdc_main_content .pencipdc_player_current_item__title { display: none } .pencipdc_player_bar { display: flex; flex-direction: row; justify-content: space-between; align-items: center } .pencipdc_main_content .pencipdc_player_controls_wrap .pencipdc_player_bar { display: flex } .pencipdc_player_bar.volume { max-width: 136px } .pencipdc_progress_bar, .pencipdc_volume_bar_wrapper { height: 12px; position: relative; width: 100% } .pencipdc_progress_bar { margin: 0 12px } .pencipdc_player_bar__current_time, .pencipdc_player_bar__duration { font-size: 11px; font-weight: 400; line-height: 16px; letter-spacing: normal; text-transform: none; text-align: center; display: flex; justify-content: center; opacity: .6; } .pencipdc_progress_bar__seek, .pencipdc_volume_bar { background-color: #c7c8cd; border-radius: 2px; display: flex; height: 4px; width: 100%; position: absolute; top: 50%; transform: translateY(-50%) } .pencipdc_progress_bar__play, .pencipdc_volume_bar__value { background-color: var(--pcaccent-cl); position: relative; border-radius: 2px } .pencipdc_progress_bar__ball { position: absolute; width: 1px; height: 1px; opacity: 1; top: 50%; left: auto; right: 0; z-index: 3; content: ' '; display: block; transition: left 20ms ease; cursor: pointer; outline: 0 } .pencipdc_progress_bar__ball:before { display: block; content: ' '; margin-top: -6px; margin-left: -6px; transition: width .3s ease, height .3s ease, margin .3s ease; background-color: #fff; border: 0; border-radius: 50%; width: 12px; height: 12px; z-index: 100; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .6); opacity: 0 } .pencipdc_progress_bar__ball:focus:before, [class*=pencipdc_progress_bar__]:hover .pencipdc_progress_bar__ball:before, [class*=pencipdc_volume_bar]:hover .pencipdc_progress_bar__ball:before { opacity: 1 } .pencipdc_player_control__playlist { background-color: var(--pcbg-cl);; z-index: -1; position: absolute; bottom: 80px; right: 0; width: 400px; height: auto; box-shadow: 0 4px 14px rgba(0, 0, 0, .14); visibility: hidden; opacity: 0; transition: visibility 0s linear .3s, opacity .3s; padding: 20px 30px } body.rtl .pencipdc_player_control__playlist { right: auto; left: 0; } .pencipdc_player_control__playlist.show { visibility: visible; opacity: 1; transition: visibility 0s linear 0s, opacity .3s } .pencipdc_player_control__playlist .pencipdc_player_control__close_player { top: 50%; right: 0; left: auto; width: auto; min-width: 0; height: 55px; line-height: 40px; display: inline-block; bottom: 0; transform: translateY(-50%); } body.rtl .pencipdc_player_control__playlist .pencipdc_player_control__close_player { right: auto; left: 0; } .pencipdc_player_control .pencipdc_player_control__playlist .pencipdc_player_control__close_player .fa { font-size: 16px; width: auto; height: auto; line-height: 40px; } .pencipdc_player_control .pencipdc_player_control__playlist .pencipdc_player_control__playlist_inner { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; max-height: 50vh; width: 100%; height: auto; overflow-y: scroll; padding: 0; margin: 0 } .pencipdc_player_control__playlist .pencipdc_block_heading { border-bottom: 2px solid var(--pcborder-cl); margin: 0 0 30px; padding: 0 0 15px; position: relative; } .pencipdc_player_control__playlist .pencipdc_block_heading span { padding: 0; font-size: 16px; } .pencipdc_player_control__playlist_inner .pencipdc_playlist_item, .pencipdc_player_control__playlist_inner > li > div { display: flex; flex-direction: row; justify-content: flex-start; align-items: center; position: relative; transform: translateX(0); transition: transform .25s cubic-bezier(.3, 0, 0, 1); width: 100% } .pencipdc_player_control__playlist_inner > li > div { flex-direction: row-reverse; text-overflow: ellipsis; overflow: hidden; text-align: center; margin-bottom: 14px } .pencipdc_player_control__playlist_inner > li:last-child div { margin-bottom: 0 } .pencipdc_player_control__playlist_inner .item-cover { width: 60px; height: 60px; overflow: hidden; position: relative; flex-shrink: 0 } .pencipdc_player_control__playlist_inner .item-cover, .pencipdc_player_control__playlist_inner .pencipdc_playlist_item_remove { align-self: start } .pencipdc_player_control__playlist_inner .item-title_wrapper { display: flex; flex-direction: column; justify-content: flex-start; text-align: left; margin: 0 14px; width: auto } .pencipdc_playlist_item_remove { display: block !important; width: 40px; height: 50px; line-height: 50px } .pencipdc_playlist_item_remove { font-size: 10px } .pencipdc_playlist_item .fa.fa-lock { display: none } li.pencipdc_playlist_current .pencipdc_playlist_item_remove .penciicon-close-button:before { content: '\f028'; font-family: "FontAwesome"; font-size: 13px; } .pencipdc_player_control__playlist_inner::-webkit-scrollbar { display: none } .pencipdc_player_control__playlist_inner { -ms-overflow-style: none; scrollbar-width: none } .pencipdc_control_bar_center .pencipdc_player_current_item__title span i.fa.fa-lock { margin-right: 10px } .pencipdc_player_control__repeat_off, .pencipdc_player_control__shuffle_off, .pencipdc_dock_player .pencipdc_player_control a { color: var(--pcheading-cl); } .pencipdc_dock_player .pencipdc_player_control a.pencipdc_player_control__repeat, .pencipdc_dock_player .pencipdc_player_control a.pencipdc_player_control__shuffle { color: var(--pcaccent-cl); } .pencipdc_dock_player .pencipdc_player_control a:hover { color: var(--pcaccent-cl) } .pencipdc_player_inner .pencipdc_control_bar_left .pencipdc_player_control .fa { width: 36px; height: 36px; line-height: 34px } .pencipdc_player_inner .pencipdc_control_bar_left .pencipdc_player_control__pause .fa, .pencipdc_player_inner .pencipdc_control_bar_left .pencipdc_player_control__play .fa { font-size: 16px; margin: 0 10px } .pencipdc_control_bar_left .pencipdc_player_control__play .fa { border-color: #e0e0e0 } .pencipdc_mobile_player_wrapper { background: var(--pcbg-cl); display: flex; flex-flow: column; position: fixed; height: 100%; width: 100%; padding: 0; top: 0; left: 0; z-index: 999999; -webkit-transform: translateY(100%); transform: translateY(100%); transition: opacity .2s .25s, max-height .2s, -webkit-transform .3s; transition: transform .3s, opacity .2s .25s, max-height .2s; transition: transform .3s, opacity .2s .25s, max-height .2s, -webkit-transform .3s; transition-timing-function: cubic-bezier(.1, 0, .3, 1) } .pencipdc_player_control__close_player { position: absolute; top: 0; right: 0; float: none; border: none; height: 72px; line-height: 72px; text-align: center; display: inline-block; vertical-align: middle; width: auto; flex-grow: 1; min-width: 42px; color: inherit; cursor: pointer } .pencipdc_player_control__close_player .fa-angle-down { font-size: 20px } .pencipdc_mobile_player_wrapper .pencipdc_player_current_item_cover_container { flex: 0 1 auto; width: 100%; padding: 22px 22px 0 22px; margin: 30px auto 20px auto } .pencipdc_mobile_player_wrapper .pencipdc_player_current_item__cover { margin: auto; width: 35vh; height: 35vh } .pencipdc_mobile_player_wrapper .pencipdc_player_current_item__cover img { width: 100%; height: 100%; object-fit: cover; top: 0; left: 0; max-width: 100% } .pencipdc_mobile_player_wrapper .pencipdc_player_current_item__title_wrapper .pencipdc_player_current_item__title { text-overflow: ellipsis; overflow: hidden; flex: 0 1 auto } .pencipdc_mobile_player_wrapper .pencipdc_player_current_item__title_wrapper { margin-bottom: 10px } .pencipdc_mobile_player_wrapper .pencipdc_player_current_item__title { padding: 0 24px; text-align: center } .pencipdc_mobile_player_wrapper .pencipdc_playlist { flex: 1 1 auto; overflow-y: scroll; display: flex } .pencipdc_mobile_player_wrapper .pencipdc_playlist_inner { display: flex; flex-direction: column; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; width: 100%; padding: 0; margin: 0 } .pencipdc_mobile_player_wrapper li { margin: 0 5px; padding: 5px 5px 6px 12px } .pencipdc_mobile_player_wrapper .pencipdc_playlist_inner .pencipdc_playlist_item, .pencipdc_mobile_player_wrapper .pencipdc_playlist_inner > li > div { display: flex; flex-direction: row; justify-content: flex-start; align-items: center; position: relative; transform: translateX(0); transition: transform .25s cubic-bezier(.3, 0, 0, 1); width: 100% } .pencipdc_mobile_player_wrapper .pencipdc_playlist_inner > li > div { flex-direction: row-reverse; text-overflow: ellipsis; overflow: hidden; text-align: center } .pencipdc_mobile_player_wrapper .pencipdc_playlist_item_remove { opacity: 1 } .pencipdc_mobile_player_wrapper .pencipdc_playlist_inner .item-cover { width: 50px; height: 50px; position: relative; flex-shrink: 0 } .pencipdc_mobile_player_wrapper .pencipdc_playlist_inner .item-title_wrapper { display: flex; flex-direction: column; justify-content: flex-start; text-align: left; margin: 0 14px; width: auto } .pencipdc_mobile_player_wrapper .pencipdc_player_current_item__title span i.fa.fa-lock { margin-right: 10px } .pencipdc_mobile_player_wrapper .pencipdc_player_bar { margin-bottom: 20px; padding: 0 20px } .pencipdc_mobile_player_wrapper .pencipdc_player_control { flex: 0 1 auto; margin: 10px auto; display: block } .pencipdc_mobile_player_wrapper .pencipdc_player_control [class*=pencipdc_player_control__]:not(.pencipdc_player_control__playlist), .pencipdc_mobile_player_wrapper .pencipdc_player_control [class*=pencipdc_player_control__]:not(.pencipdc_player_control__playlist) .fa { width: 36px; height: 36px; line-height: 34px; font-size: 18px; } .pencipdc_mobile_player_wrapper .pencipdc_player_control a { height: 62px; text-align: center; display: inline-block; vertical-align: middle; width: auto; flex-grow: 1; min-width: 30px; cursor: pointer } .pencipdc_mobile_player_wrapper .pencipdc_player_control [class*=pencipdc_player_control__] .fa { line-height: 42px; text-align: center } @media only screen and (min-width: 767px) { .pencipdc_mobile_player_wrapper .pencipdc_player_current_item__cover { margin: auto; width: 20vh; height: 20vh } } .pencipdc_control_bar_right, .pencipdc_no_solution, .pencipdc_player_control__mute, .pencipdc_player_control__next, .pencipdc_player_control__pause, .pencipdc_player_control__previous, .pencipdc_player_control__repeat_off, .pencipdc_player_control__shuffle_off, .pencipdc_player_control__stop, .pencipdc_player_controls_wrap .pencipdc_player_bar, .pencipdc_playlist { display: none } body.rtl .pencipdc_player_control__next i:before { content: "\f048"; } body.rtl .pencipdc_player_control__previous i:before { content: "\f051"; } @media only screen and (min-width: 960px) { .pencipdc_control_bar_left { flex-basis: 10%; max-width: 10% } .pencipdc_control_bar_center { flex-basis: 90%; max-width: 90% } .pencipdc_dock_player .pencipdc_control_bar_left { flex-basis: 30%; max-width: 30% } .pencipdc_dock_player .pencipdc_control_bar_center { flex-basis: 40%; max-width: 40% } .pencipdc_dock_player .pencipdc_control_bar_right, .pencipdc_dock_player .pencipdc_control_bar_toggle_player { flex-basis: 30%; max-width: 30% } .pencipdc_control_bar_toggle_player { display: none } .pencipdc_dock_player .pencipdc_player_controls_wrap { padding: 0 25px } .pencipdc_player_controls_wrap .pencipdc_player_bar, .pencipdc_dock_player .pencipdc_control_bar_right { display: flex } .pencipdc_dock_player .pencipdc_player_control { justify-content: flex-start } .pencipdc_dock_player .pencipdc_player_control.last { flex-basis: 80%; flex-direction: row; justify-content: flex-end } .pencipdc_dock_player .pencipdc_player_bar.volume { flex-basis: 20% } .pencipdc_dock_player .pencipdc_player_control__next, .pencipdc_dock_player .pencipdc_player_control__previous, .pencipdc_dock_player .pencipdc_player_control__stop { display: inline } .pencipdc_player_current_item__title { text-align: center } .pencipdc_playlist_item_remove { opacity: 0; transition: .3s } .pencipdc_player_control__playlist_inner li:hover .pencipdc_playlist_item_remove, li.pencipdc_playlist_current .pencipdc_playlist_item_remove { opacity: 1 } } @media only screen and (min-width: 960px) { .pencipdc_player_current_item__cover { display: inline-block } .pencipdc_sidecontent .pencipdc_podcast.pencipdc_dock_player { z-index: 3 } .pencipdc_sidecontent .pencipdc_dock_player_inner { margin-left: 340px; box-shadow: none } } @media only screen and (min-width: 960px) { .pencipdc_boxed .pencipdc_dock_player .pencipdc_player_inner { box-shadow: none } .pencipdc_boxed .pencipdc_dock_player_inner { max-width: 1230px; margin: 0 auto; position: relative } .pencipdc_boxed .pencipdc_dock_player_inner .pencipdc_player_inner:before { content: ''; width: 100%; height: 7px; position: absolute; bottom: 100%; left: 0; background: -moz-linear-gradient(bottom, rgba(0, 0, 0, .05) 0, rgba(0, 0, 0, 0) 100%); background: -webkit-linear-gradient(bottom, rgba(0, 0, 0, .05) 0, rgba(0, 0, 0, 0) 100%); background: linear-gradient(to top, rgba(0, 0, 0, .05) 0, rgba(0, 0, 0, 0) 100%) } } .pencipdc-splaylist .content-list-right.content-list-center { position: relative; overflow: visible !important; justify-content: space-between !important; align-items: center !important; display: flex !important; } .pencipdc-splaylist .content-list-right.content-list-center .pencipdc_media_option { margin-top: 0; } .pencipdc-splaylist .pencipdc_block_container.penci-grid .thumbnail { width: 90px !important; } .pencipdc-splaylist .thumbnail .pencipdc_media_option { margin: 0; } .pencipdc-splaylist .pencipdc-splaylist-top.img-top { display: block; } .pencipdc-splaylist .pencipdc-splaylist-top.img-top .pcpd-splaylist-thumb { margin: 0 0 15px; } .pencipdc-categories-wrapper, .pencipdc-item-wrapper { position: relative; display: flex; flex-wrap: wrap; flex-direction: row; margin-left: -15px; margin-right: -15px; } .pencipdc-categories-wrapper .pencipdc-categories-item, .pencipdc-item-wrapper .pencipdc-item { float: left; width: calc(100% / 2); padding-left: 15px; padding-right: 15px; margin-bottom: 30px; } .pencipdc-item-wrapper.col-3 .pencipdc-item, .pencipdc-categories-wrapper.col-3 .pencipdc-categories-item { width: calc(100% / 3); } .pencipdc-item-wrapper.col-4 .pencipdc-item, .pencipdc-categories-wrapper.col-4 .pencipdc-categories-item { width: calc(100% / 4); } .pencipdc-item-wrapper.col-5 .pencipdc-item, .pencipdc-categories-wrapper.col-5 .pencipdc-categories-item { width: calc(100% / 5); } @media only screen and (max-width: 767px) { .pencipdc-item-wrapper.col-3 .pencipdc-item, .pencipdc-categories-wrapper .pencipdc-categories-item, .pencipdc-categories-wrapper.mobile-col-2 .pencipdc-categories-item { width: calc(100% / 2); } .pencipdc-item-wrapper.mobile-col-3 .pencipdc-item, .pencipdc-categories-wrapper.mobile-col-3 .pencipdc-categories-item { width: calc(100% / 3); } .pencipdc-item-wrapper.mobile-col-4 .pencipdc-item, .pencipdc-categories-wrapper.mobile-col-4 .pencipdc-categories-item { width: calc(100% / 4); } .pencipdc-item-wrapper.mobile-col-1 .pencipdc-item, .pencipdc-categories-wrapper.mobile-col-1 .pencipdc-categories-item { width: 100%; } } @media only screen and (min-width: 768px) and (max-width: 1169px) { .pencipdc-item-wrapper.tablet-col-2 .pencipdc-item, .pencipdc-categories-wrapper.tablet-col-2 .pencipdc-categories-item { width: calc(100% / 2); } .pencipdc-item-wrapper .pencipdc-item, .pencipdc-item-wrapper.tablet-col-3 .pencipdc-item, .pencipdc-categories-wrapper .pencipdc-categories-item, .pencipdc-categories-wrapper.tablet-col-3 .pencipdc-categories-item { width: calc(100% / 3); } .pencipdc-item-wrapper.tablet-col-4 .pencipdc-item, .pencipdc-categories-wrapper.tablet-col-4 .pencipdc-categories-item { width: calc(100% / 4); } .pencipdc-item-wrapper.tablet-col-1 .pencipdc-item, .pencipdc-categories-wrapper.tablet-col-1 .pencipdc-categories-item { width: 100%; } } .pencipdc-item .pencipdc-title { margin-bottom: 10px; font-size: 21px; } .pencipdc-item .pencipdc-title a { color: var(--pcheading-cl); } .pencipdc-item .pencipdc-title a:hover { color: var(--pcaccent-cl); } .pencipdc-item .pencipdc-meta-desc { margin-top: 10px; } .pencipdc-item .pencipdc-meta { color: var(--pcmeta-cl); font-size: 12px; margin: 0; } .pencipdc-item .pencipdc-thumb { margin-bottom: 15px; } .left-thumb .pencipdc-item { display: flex; } .left-thumb .pencipdc-item .pencipdc-thumb { flex: 0 0 110px; margin-right: 20px; height: auto; } @media only screen and (max-width: 767px) { .left-thumb .pencipdc-item { display: block; } } body.rtl .left-thumb .pencipdc-item .pencipdc-thumb { margin-right: 0; margin-left: 20px; } .left-thumb .pencipdc-item .pencipdc-title { font-size: 16px; } .left-thumb .pencipdc-item .pencipdc-meta-desc, .left-thumb .pencipdc-item .pencipdc-meta-desc p { font-size: 14px; } .penci_podcast_post_option { margin-top: 25px; } .penci_podcast_post_option .follow-wrapper a { display: inline-block; padding: 0 15px; line-height: 30px; font-size: 12px; font-weight: bold; color: var(--pcheading-cl); border: 1px solid var(--pcborder-cl); vertical-align: middle; transition: all 0.3s ease-in-out; } .penci_podcast_post_option .follow-wrapper a i { margin-right: 5px; } body.rtl .penci_podcast_post_option .follow-wrapper a i { margin-right: 0; margin-left: 5px; } .penci_podcast_post_option .follow-wrapper a:hover { color: #fff; border-color: var(--pcaccent-cl); background-color: var(--pcaccent-cl); } .pencipdc_media_option.single_episode { margin: 0 0 30px; } .pencipdc_media_option.single_episode a, .pencipdc_media_option.single_episode a:hover { text-decoration: none; } .pencipdc_media_option.single_episode .pencipdc_media_button { height: 35px; line-height: 35px; vertical-align: top; } .pencipdc_media_option.single_episode .pencipdc_media_button.add_to_queue { width: 35px; } .pencipdc_media_option .pcpdc_added_queue { margin-left: 10px; } body.rtl .pencipdc_media_option .pcpdc_added_queue { margin-right: 10px; margin-left: 0; } .pencipdc-item .pencipdc_media_option { position: relative; } .pencipdc_playlist_inner .item-song.pencipdc_post_title a, .pencipdc_player_control__playlist_inner .item-song.pencipdc_post_title { font-size: 14px; font-weight: bold; color: var(--pcheading-cl); margin: 0 0 5px; } .pencipdc_mobile_player_wrapper a:hover, .pencipdc_playlist_inner .item-song.pencipdc_post_title a:hover { color: var(--pcaccent-cl); } .pencipdc_playlist_inner .pencipdc_post_meta, .pencipdc_player_control__playlist_inner .pencipdc_post_meta { font-size: 12px; color: var(--pcheading-cl); opacity: .6; } .pencipdc-splaylist a:hover { text-decoration: none !important; } .pencipdc-splaylist .pencipdc-splaylist-top { display: flex; margin-bottom: 15px; } .pencipdc-splaylist .pencipdc-splaylist-top .pcpd-splaylist-thumb { flex: 0 0 120px; margin-right: 15px; } body.rtl .pencipdc-splaylist .pencipdc-splaylist-top .pcpd-splaylist-thumb { margin-right: 0; margin-left: 15px; } .pencipdc-splaylist .pencipdc-splaylist-top h3 { font-size: 16px; line-height: 1.2; } .pencipdc-splaylist .pencipdc-splaylist-top .penci-podcast-series-meta { margin: 0; } .pencipdc-splaylist .pencipdc-splaylist-top .penci_podcast_post_option { margin: 10px 0 0; } .pencipdc-splaylist .penci-category-description { font-size: 14px; line-height: 1.6; margin: 0; } .pencipdc-splaylist .pencipdc_postblock_episode_detail { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--pcmeta-cl); } .pencipdc-splaylist .grid-post-box-meta { margin: 0; } .pencipdc-splaylist li.penci-item-listp { margin-bottom: 5px !important; padding-bottom: 5px !important; } .pencipdc-splaylist li.penci-item-listp .content-list-right .header-list-style { flex: 0 0 calc(100% - 46px); padding-right: 31px; } .pencipdc-splaylist li.penci-item-listp .pencipdc_media_option li, .pencipdc-splaylist li.penci-item-listp .pencipdc_media_option li a { font-size: 12px; } .pencipdc-splaylist li.penci-item-listp .left-play-btn { margin-top: 0; } .pencipdc-splaylist li.penci-item-listp .left-play-btn .pencipdc_media_option { position: relative; z-index: 9; } .pencipdc-categories-item { position: relative; overflow: hidden; } .pencipdc-categories-item .pencipdc-content { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 9; display: flex; justify-content: center; align-items: center; flex-direction: column; text-decoration: none; padding: 40px; text-align: center; } .pencipdc-categories-item .pencipdc-content:hover { text-decoration: none; } .pencipdc-categories-item .pencipdc-content h4 { margin-bottom: 0; color: #fff; font-size: 18px; } @media only screen and (max-width: 767px) { .pencipdc-categories-item .pencipdc-content h4 { font-size: 16px; } } .pencipdc-categories-item .pencipdc-content p, .pencipdc-categories-item .pencipdc-content span { color: #fff; text-align: center; margin-top: 6px; font-size: 15px; } .pencipdc-categories-item .pencipdc-content p { font-size: 14px; margin: 10px 0 0; color: #fff; line-height: 1.4; } .pencipdc-categories-item .pencipdc-thumb { position: relative; } .pencipdc-categories-item .pencipdc-thumb:before { content: ''; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); position: absolute; z-index: 1; transition: all 0.3s ease-in-out; } .pencipdc_postblock_episode_detail .content-list-right { position: relative; } .pencipdc_postblock_episode_detail .pencipdc_media_option { margin: 0; } .pencipdc_postblock_episode_detail .pencipdc_media_option .pencipdc_moreoption { right: 0 !important; left: auto !important; } .pencipdc_postblock_episode_detail .pencipdc_media_option.episode { position: absolute; top: 0; bottom: 0; right: 0; } body.rtl .pencipdc_postblock_episode_detail .pencipdc_media_option.episode { right: auto; left: 0; } body.rtl .pencipdc_block_container .header-list-style { text-align: right; }builder/elementor/podcast_listing.php000064400000046310147600053410014067 0ustar00get_name(); } public function get_name() { return 'penci-podcast-listing'; } protected function register_controls() { $this->start_controls_section( 'content_section', [ 'label' => esc_html__( 'General', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'number', array( 'label' => __( 'Number of Posts', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => '5', ) ); $this->add_control( 'podcast_cat', [ 'label' => esc_html__( 'Categories', 'penci-podcast' ), 'type' => 'penci_el_autocomplete', 'search' => 'penci_get_taxonomies_by_query', 'render' => 'penci_get_taxonomies_title_by_id', 'taxonomy' => 'podcast-category', 'multiple' => true, 'label_block' => true, ] ); $this->add_control( 'podcast_series', [ 'label' => esc_html__( 'Series', 'penci-podcast' ), 'type' => 'penci_el_autocomplete', 'search' => 'penci_get_taxonomies_by_query', 'render' => 'penci_get_taxonomies_title_by_id', 'taxonomy' => 'podcast-series', 'multiple' => true, 'label_block' => true, ] ); $this->end_controls_section(); $this->start_controls_section( 'layout_section', [ 'label' => esc_html__( 'Layout', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'columns', array( 'label' => __( 'Columns', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '2', 'options' => array( '2' => esc_html__( '2 Columns', 'penci-podcast' ), '3' => esc_html__( '3 Columns', 'penci-podcast' ), '4' => esc_html__( '4 Columns', 'penci-podcast' ), '5' => esc_html__( '5 Columns', 'penci-podcast' ), ), ) ); $this->add_control( 'tablet_columns', array( 'label' => __( 'Tablet Columns', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '2', 'options' => array( '2' => esc_html__( '2 Columns', 'penci-podcast' ), '3' => esc_html__( '3 Columns', 'penci-podcast' ), '4' => esc_html__( '4 Columns', 'penci-podcast' ), ), ) ); $this->add_control( 'mobile_columns', array( 'label' => __( 'Mobile Columns', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '1', 'options' => array( '1' => esc_html__( '1 Column', 'penci-podcast' ), '2' => esc_html__( '2 Columns', 'penci-podcast' ), '3' => esc_html__( '3 Columns', 'penci-podcast' ), ), ) ); $this->add_responsive_control( 'item_gap', array( 'label' => __( 'Items Gap', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'selectors' => array( '{{WRAPPER}} .pencipdc-item-wrapper' => 'margin-left: -{{SIZE}}px;margin-right: -{{SIZE}}px;margin-bottom: -{{SIZE}}px;', '{{WRAPPER}} .pencipdc-item-wrapper .pencipdc-item' => 'padding-left: {{SIZE}}px;padding-right: {{SIZE}}px;margin-bottom: {{SIZE}}px;', ), ) ); $this->add_control( 'featured_image', array( 'label' => __( 'Image Position', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'top', 'options' => array( 'top' => esc_html__( 'Top', 'penci-podcast' ), 'left' => esc_html__( 'Left', 'penci-podcast' ), ) ) ); $this->add_control( 'featured_image_size', array( 'label' => __( 'Featured Image Size', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => $this->get_list_image_sizes( true ), ) ); $this->add_responsive_control( 'featured_image_width', array( 'label' => __( 'Featured Image Width', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 0, 'max' => 2000, ) ), 'selectors' => array( '{{WRAPPER}} .pencipdc-item .pencipdc-thumb' => 'flex: 0 0 {{SIZE}}px;' ), 'condition' => [ 'featured_image' => 'left' ], ) ); $this->add_responsive_control( 'featured_image_ratio', array( 'label' => __( 'Featured Image Ratio', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 0, 'max' => 2000, ) ), 'selectors' => array( '{{WRAPPER}} .pencipdc-item .pencipdc-thumb .penci-image-holder:before' => 'padding-top: {{SIZE}}px;' ), ) ); $this->add_responsive_control( 'featured_image_bradius', array( 'label' => __( 'Featured Boder Radius', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'selectors' => array( '{{WRAPPER}} .pencipdc-item .pencipdc-thumb .penci-image-holder' => 'border-radius: {{SIZE}}px;overflow:hidden;' ), ) ); $this->end_controls_section(); $this->start_controls_section( 'meta_section', [ 'label' => esc_html__( 'Podcast Meta', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'meta_author', array( 'label' => __( 'Show Author', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_control( 'meta_episode', array( 'label' => __( 'Show Episode Count', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_control( 'meta_desc', array( 'label' => __( 'Show Description', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_control( 'meta_media', array( 'label' => __( 'Show Media Options', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->end_controls_section(); $this->register_block_title_section_controls(); $this->start_controls_section( 'style_section', [ 'label' => esc_html__( 'Podcast Style', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( '_heading_typo_heading', array( 'label' => __( 'Title', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_heading_typo', 'label' => __( 'Title Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc-item .pencipdc-title a', ) ); $this->add_control( '_heading_typo_link', array( 'label' => __( 'Title Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-item .pencipdc-title a' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_heading_typo_linkc', array( 'label' => __( 'Title Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-item .pencipdc-title a:hover' => 'color: {{VALUE}};' ), ) ); // meta $this->add_control( '_meta_typo_heading', array( 'label' => __( 'Meta', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_meta_typo', 'label' => __( 'Meta Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc-meta span', ) ); $this->add_control( '_meta_typo_color', array( 'label' => __( 'Meta Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-meta span' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_meta_typo_link', array( 'label' => __( 'Meta Link Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-meta span a' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_meta_typo_linkh', array( 'label' => __( 'Meta Link Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-meta span a:hover' => 'color: {{VALUE}};' ), ) ); // desc $this->add_control( '_desc_typo_heading', array( 'label' => __( 'Description', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_desc_typo', 'label' => __( 'Description Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc-meta-desc p', ) ); $this->add_control( '_desc_typo_color', array( 'label' => __( 'Description Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-meta-desc p' => 'color: {{VALUE}};' ), ) ); // play buttons $this->add_control( '_button_typo_heading', array( 'label' => __( 'Play Button', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_button_typo', 'label' => __( 'Buttons Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play', ) ); $this->add_control( '_button_typo_color', array( 'label' => __( 'Button Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_button_typo_hcolor', array( 'label' => __( 'Button Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play:hover' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_button_typo_bgcolor', array( 'label' => __( 'Button Background Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play' => 'background-color: {{VALUE}};' ), ) ); $this->add_control( '_button_typo_bghcolor', array( 'label' => __( 'Button Background Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play:hover' => 'background-color: {{VALUE}};' ), ) ); $this->add_control( '_button_typo_bdcolor', array( 'label' => __( 'Button Border Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play' => 'border-color: {{VALUE}};' ), ) ); $this->add_control( '_button_typo_bdhcolor', array( 'label' => __( 'Button Border Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play:hover' => 'border-color: {{VALUE}};' ), ) ); // more buttons $this->add_control( '_more_button_typo_heading', array( 'label' => __( 'More Button', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_more_button_typo', 'label' => __( 'Buttons Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more', ) ); $this->add_control( '_more_button_typo_color', array( 'label' => __( 'Button Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_more_button_typo_hcolor', array( 'label' => __( 'Button Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more:hover' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_more_button_typo_bgcolor', array( 'label' => __( 'Button Background Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more' => 'background-color: {{VALUE}};' ), ) ); $this->add_control( '_more_button_typo_bghcolor', array( 'label' => __( 'Button Background Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more:hover' => 'background-color: {{VALUE}};' ), ) ); $this->add_control( '_more_button_typo_bdcolor', array( 'label' => __( 'Button Border Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more' => 'border-color: {{VALUE}};' ), ) ); $this->add_control( '_more_button_typo_bdhcolor', array( 'label' => __( 'Button Border Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more:hover' => 'border-color: {{VALUE}};' ), ) ); $this->end_controls_section(); $this->register_block_title_style_section_controls(); } protected function render() { $settings = $this->get_settings(); $list_series = []; if ( ! empty( $settings['podcast_cat'] ) ) { foreach ( $settings['podcast_cat'] as $cat_id ) { $series_ids = pencipdc_get_podcast_by_category( $cat_id ); if ( is_array( $series_ids ) ) { $list_series = array_merge( $list_series, $series_ids ); } } } if ( ! empty( $settings['podcast_series'] ) ) { $list_series = array_unique( array_merge( $settings['podcast_series'], $list_series ) ); } $css_cl_class = 'col-' . $settings['columns'] . ' mobile-col-' . $settings['mobile_columns'] . ' tablet-col-' . $settings['tablet_columns']; if ( ! empty( $list_series ) ) { $class = $settings['featured_image'] . '-thumb'; $this->markup_block_title( $settings, $this ); ?>
    name; $total = sprintf( _n( '%s Episode', '%s Episodes', $term->count ), number_format_i18n( $term->count ) ); ?>

    description && $settings['meta_desc'] ): ?>

    description, get_theme_mod( 'pencipodcast_single_excerpt_length', 20 ) ); ?>

    get_all_image_sizes(); $image_sizes = array(); if ( $default ) { $image_sizes[''] = esc_html__( 'Default', 'soledad' ); } foreach ( $wp_image_sizes as $size_key => $size_attributes ) { $control_title = ucwords( str_replace( '_', ' ', $size_key ) ); if ( is_array( $size_attributes ) ) { $control_title .= sprintf( ' - %d x %d', $size_attributes['width'], $size_attributes['height'] ); } $image_sizes[ $size_key ] = $control_title; } $image_sizes['full'] = esc_html__( 'Full', 'soledad' ); return $image_sizes; } public function get_all_image_sizes() { global $_wp_additional_image_sizes; $default_image_sizes = [ 'thumbnail', 'medium', 'medium_large', 'large' ]; $image_sizes = []; foreach ( $default_image_sizes as $size ) { $image_sizes[ $size ] = [ 'width' => (int) get_option( $size . '_size_w' ), 'height' => (int) get_option( $size . '_size_h' ), 'crop' => (bool) get_option( $size . '_crop' ), ]; } if ( $_wp_additional_image_sizes ) { $image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes ); } return $image_sizes; } } builder/elementor/podcast_categories.php000064400000026652147600053410014552 0ustar00get_name(); } public function get_name() { return 'penci-podcast-categories'; } protected function register_controls() { $this->start_controls_section( 'content_section', [ 'label' => esc_html__( 'General', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'podcast_cat', [ 'label' => esc_html__( 'Categories', 'penci-podcast' ), 'type' => 'penci_el_autocomplete', 'search' => 'penci_get_taxonomies_by_query', 'render' => 'penci_get_taxonomies_title_by_id', 'taxonomy' => 'podcast-category', 'multiple' => true, 'label_block' => true, ] ); $this->end_controls_section(); $this->start_controls_section( 'layout_section', [ 'label' => esc_html__( 'Layout', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'columns', array( 'label' => __( 'Columns', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '3', 'options' => array( '2' => esc_html__( '2 Columns', 'penci-podcast' ), '3' => esc_html__( '3 Columns', 'penci-podcast' ), '4' => esc_html__( '4 Columns', 'penci-podcast' ), '5' => esc_html__( '5 Columns', 'penci-podcast' ), ), ) ); $this->add_control( 'tablet_columns', array( 'label' => __( 'Tablet Columns', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '2', 'options' => array( '1' => esc_html__( '1 Columns', 'penci-podcast' ), '2' => esc_html__( '2 Columns', 'penci-podcast' ), '3' => esc_html__( '3 Columns', 'penci-podcast' ), ), ) ); $this->add_control( 'mobile_columns', array( 'label' => __( 'Mobile Columns', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '1', 'options' => array( '1' => esc_html__( '1 Columns', 'penci-podcast' ), '2' => esc_html__( '2 Columns', 'penci-podcast' ), '3' => esc_html__( '3 Columns', 'penci-podcast' ), ), ) ); $this->add_responsive_control( 'item_gap', array( 'label' => __( 'Items Gap', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'selectors' => array( '{{WRAPPER}} .pencipdc-categories-wrapper' => 'margin-left: -{{SIZE}}px;margin-right: -{{SIZE}}px;margin-bottom: -{{SIZE}}px;', '{{WRAPPER}} .pencipdc-categories-wrapper .pencipdc-categories-item' => 'padding-left: {{SIZE}}px;padding-right: {{SIZE}}px;margin-bottom: {{SIZE}}px;', ), ) ); $this->add_control( 'featured_image_size', array( 'label' => __( 'Featured Image Size', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => $this->get_list_image_sizes( true ), ) ); $this->add_responsive_control( 'featured_image_ratio', array( 'label' => __( 'Featured Image Ratio', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 0, 'max' => 2000, ) ), 'selectors' => array( '{{WRAPPER}} .pencipdc-categories-item .pencipdc-thumb .penci-image-holder:before' => 'padding-top: {{SIZE}}px;' ), ) ); $this->add_responsive_control( 'featured_image_bradius', array( 'label' => __( 'Items Boder Radius', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'selectors' => array( '{{WRAPPER}} .pencipdc-categories-item .pencipdc-thumb' => 'border-radius: {{SIZE}}px;overflow:hidden;' ), ) ); $this->end_controls_section(); $this->start_controls_section( 'meta_section', [ 'label' => esc_html__( 'Podcast Meta', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'meta_episode', array( 'label' => __( 'Show Episode Count', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_control( 'meta_desc', array( 'label' => __( 'Show Description', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->end_controls_section(); $this->register_block_title_section_controls(); $this->start_controls_section( 'style_section', [ 'label' => esc_html__( 'Content Style', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( '_heading_typo_heading', array( 'label' => __( 'Title', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_heading_typo', 'label' => __( 'Title Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc-categories-item .pencipdc-content h4', ) ); $this->add_control( '_heading_typo_link', array( 'label' => __( 'Title Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-categories-item .pencipdc-content h4' => 'color: {{VALUE}};' ), ) ); // meta $this->add_control( '_meta_typo_heading', array( 'label' => __( 'Meta', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, 'condition' => [ 'meta_episode' => 'yes' ], ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_meta_typo', 'label' => __( 'Meta Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc-categories-item .pencipdc-cat-meta', 'condition' => [ 'meta_episode' => 'yes' ], ) ); $this->add_control( '_meta_typo_color', array( 'label' => __( 'Meta Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-categories-item .pencipdc-cat-meta' => 'color: {{VALUE}};' ), 'condition' => [ 'meta_episode' => 'yes' ], ) ); // desc $this->add_control( '_desc_typo_heading', array( 'label' => __( 'Description', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, 'condition' => [ 'meta_desc' => 'yes' ], ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_desc_typo', 'label' => __( 'Description Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc-categories-item .pencipdc-content p', 'condition' => [ 'meta_desc' => 'yes' ], ) ); $this->add_control( '_desc_typo_color', array( 'label' => __( 'Description Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-categories-item .pencipdc-content p' => 'color: {{VALUE}};' ), 'condition' => [ 'meta_desc' => 'yes' ], ) ); // overlay $this->add_control( '_overlay_heading', array( 'label' => __( 'Overlay', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_control( '_o_color', array( 'label' => __( 'Overlay Background Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-categories-item .pencipdc-thumb:before' => 'background: {{VALUE}};' ), ) ); $this->add_control( '_o_hcolor', array( 'label' => __( 'Hover Overlay Background Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-categories-item:hover .pencipdc-thumb:before' => 'background: {{VALUE}};' ), ) ); $this->end_controls_section(); $this->register_block_title_style_section_controls(); } protected function render() { $settings = $this->get_settings(); if ( empty( $settings['podcast_cat'] ) ) { return false; } $css_cl_class = 'col-' . $settings['columns'] . ' mobile-col-' . $settings['mobile_columns'] . ' tablet-col-' . $settings['tablet_columns']; $this->markup_block_title( $settings, $this ); echo '
    '; foreach ( $settings['podcast_cat'] as $cat ) { $cat_data = get_term( $cat ); $cat_url = get_term_link( $cat_data ); $title = $cat_data->name; $total = sprintf( _n( '%s Episode', '%s Episodes', $cat_data->count ), number_format_i18n( $cat_data->count ) ); ?> '; } /** * Get image sizes. * * Retrieve available image sizes after filtering `include` and `exclude` arguments. */ public function get_list_image_sizes( $default = false ) { $wp_image_sizes = $this->get_all_image_sizes(); $image_sizes = array(); if ( $default ) { $image_sizes[''] = esc_html__( 'Default', 'soledad' ); } foreach ( $wp_image_sizes as $size_key => $size_attributes ) { $control_title = ucwords( str_replace( '_', ' ', $size_key ) ); if ( is_array( $size_attributes ) ) { $control_title .= sprintf( ' - %d x %d', $size_attributes['width'], $size_attributes['height'] ); } $image_sizes[ $size_key ] = $control_title; } $image_sizes['full'] = esc_html__( 'Full', 'soledad' ); return $image_sizes; } public function get_all_image_sizes() { global $_wp_additional_image_sizes; $default_image_sizes = [ 'thumbnail', 'medium', 'medium_large', 'large' ]; $image_sizes = []; foreach ( $default_image_sizes as $size ) { $image_sizes[ $size ] = [ 'width' => (int) get_option( $size . '_size_w' ), 'height' => (int) get_option( $size . '_size_h' ), 'crop' => (bool) get_option( $size . '_crop' ), ]; } if ( $_wp_additional_image_sizes ) { $image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes ); } return $image_sizes; } } builder/elementor/podcast_series.php000064400000050664147600053410013717 0ustar00get_name(); } public function get_name() { return 'penci-podcast-series'; } protected function register_controls() { $this->start_controls_section( 'content_section', [ 'label' => esc_html__( 'General', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'number', array( 'label' => __( 'Number of Posts', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => '5', ) ); $this->add_control( 'podcast_series', [ 'label' => esc_html__( 'Series', 'penci-podcast' ), 'type' => 'penci_el_autocomplete', 'search' => 'penci_get_taxonomies_by_query', 'render' => 'penci_get_taxonomies_title_by_id', 'taxonomy' => 'podcast-series', 'multiple' => false, 'label_block' => true, ] ); $this->end_controls_section(); $this->start_controls_section( 'layout_section', [ 'label' => esc_html__( 'Layout', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'featured_image', array( 'label' => __( 'Image Position', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'left', 'options' => array( 'top' => esc_html__( 'Top', 'penci-podcast' ), 'left' => esc_html__( 'Left', 'penci-podcast' ), ) ) ); $this->add_control( 'featured_image_size', array( 'label' => __( 'Featured Image Size', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => $this->get_list_image_sizes( true ), ) ); $this->add_responsive_control( 'featured_image_ratio', array( 'label' => __( 'Featured Image Ratio', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 0, 'max' => 2000, ) ), 'selectors' => array( '{{WRAPPER}} .pencipdc-splaylist .pencipdc-splaylist-top .pcpd-splaylist-thumb .penci-image-holder:before' => 'padding-top: {{SIZE}}px;' ), ) ); $this->add_responsive_control( 'featured_image_width', array( 'label' => __( 'Featured Image Width', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => array( 'px' => array( 'min' => 0, 'max' => 2000, ) ), 'selectors' => array( '{{WRAPPER}} .pencipdc-splaylist .pencipdc-splaylist-top .pcpd-splaylist-thumb' => 'flex: 0 0 {{SIZE}}px;' ), 'condition' => [ 'featured_image' => 'left' ], ) ); $this->add_responsive_control( 'featured_image_bradius', array( 'label' => __( 'Featured Boder Radius', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'selectors' => array( '{{WRAPPER}} .pencipdc-splaylist .pencipdc-splaylist-top .pcpd-splaylist-thumb .penci-image-holder' => 'border-radius: {{SIZE}}px;overflow:hidden;' ), ) ); $this->end_controls_section(); $this->start_controls_section( 'meta_section', [ 'label' => esc_html__( 'Podcast Meta', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'meta_author', array( 'label' => __( 'Show Author', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_control( 'meta_episode', array( 'label' => __( 'Show Episode Count', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_control( 'meta_desc', array( 'label' => __( 'Show Description', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_control( 'meta_sub', array( 'label' => __( 'Show Subscribe Button', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->end_controls_section(); $this->register_block_title_section_controls(); $this->start_controls_section( 'style_section', [ 'label' => esc_html__( 'Podcast Style', 'penci-podcast' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( '_heading_typo_heading', array( 'label' => __( 'Title', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_heading_typo', 'label' => __( 'Title Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc-splaylist .pencipdc-splaylist-top h3', ) ); $this->add_control( '_heading_typo_link', array( 'label' => __( 'Title Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-splaylist .pencipdc-splaylist-top h3,{{WRAPPER}} .pencipdc-splaylist .pencipdc-splaylist-top h3 a' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_sheading_typo_heading', array( 'label' => __( 'Listing Title', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_sheading_typo', 'label' => __( 'Listing Title Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .header-list-style .grid-title', ) ); $this->add_control( '_sheading_typo_link', array( 'label' => __( 'Listing Title Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .header-list-style .grid-title a,{{WRAPPER}} .header-list-style .grid-title' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_sheading_typo_hlink', array( 'label' => __( 'Listing Title Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .header-list-style .grid-title a:hover' => 'color: {{VALUE}};' ), ) ); // meta $this->add_control( '_meta_typo_heading', array( 'label' => __( 'Meta', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_meta_typo', 'label' => __( 'Meta Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc-splaylist .pencipdc-splaylist-top .penci-podcast-series-meta', ) ); $this->add_control( '_meta_typo_color', array( 'label' => __( 'Meta Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-splaylist .pencipdc-splaylist-top .penci-podcast-series-meta span' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_meta_typo_link', array( 'label' => __( 'Meta Link Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-splaylist .pencipdc-splaylist-top .penci-podcast-series-meta span a' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_meta_typo_linkh', array( 'label' => __( 'Meta Link Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-splaylist .pencipdc-splaylist-top .penci-podcast-series-meta span a:hover' => 'color: {{VALUE}};' ), ) ); // desc $this->add_control( '_desc_typo_heading', array( 'label' => __( 'Description', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, 'condition' => [ 'meta_desc' => 'yes' ], ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_desc_typo', 'label' => __( 'Description Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc-splaylist .penci-category-description', 'condition' => [ 'meta_desc' => 'yes' ], ) ); $this->add_control( '_desc_typo_color', array( 'label' => __( 'Description Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-splaylist .penci-category-description, {{WRAPPER}} .pencipdc-splaylist .penci-category-description p' => 'color: {{VALUE}};' ), 'condition' => [ 'meta_desc' => 'yes' ], ) ); // listmeta $this->add_control( '_smeta_typo_heading', array( 'label' => __( 'Item Meta', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_smeta_typo', 'label' => __( 'Meta Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc-splaylist .grid-post-box-meta', ) ); $this->add_control( '_smeta_typo_color', array( 'label' => __( 'Meta Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-splaylist .grid-post-box-meta span' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_smeta_typo_link', array( 'label' => __( 'Meta Link Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc-splaylist .grid-post-box-meta span a' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_smeta_typo_linkh', array( 'label' => __( 'Meta Link Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .post-entry li.penci-slistp .grid-post-box-meta span a:hover' => 'color: {{VALUE}};' ), ) ); // subscribe buttons $this->add_control( '_sbutton_typo_heading', array( 'label' => __( 'Subscribe Button', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, 'condition' => [ 'meta_sub' => 'yes' ], ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_sbutton_typo', 'label' => __( 'Buttons Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .penci_podcast_post_option .follow-wrapper a', 'condition' => [ 'meta_sub' => 'yes' ], ) ); $this->add_control( '_sbutton_typo_color', array( 'label' => __( 'Button Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .penci_podcast_post_option .follow-wrapper a' => 'color: {{VALUE}};' ), 'condition' => [ 'meta_sub' => 'yes' ], ) ); $this->add_control( '_sbutton_typo_hcolor', array( 'label' => __( 'Button Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .penci_podcast_post_option .follow-wrapper a:hover' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_sbutton_typo_bgcolor', array( 'label' => __( 'Button Background Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .penci_podcast_post_option .follow-wrapper a' => 'background-color: {{VALUE}};' ), 'condition' => [ 'meta_sub' => 'yes' ], ) ); $this->add_control( '_sbutton_typo_bghcolor', array( 'label' => __( 'Button Background Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .penci_podcast_post_option .follow-wrapper a:hover' => 'background-color: {{VALUE}};' ), 'condition' => [ 'meta_sub' => 'yes' ], ) ); $this->add_control( '_sbutton_typo_bdcolor', array( 'label' => __( 'Button Border Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .penci_podcast_post_option .follow-wrapper a' => 'border-color: {{VALUE}};' ), 'condition' => [ 'meta_sub' => 'yes' ], ) ); $this->add_control( '_sbutton_typo_bdhcolor', array( 'label' => __( 'Button Border Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .penci_podcast_post_option .follow-wrapper a:hover' => 'border-color: {{VALUE}};' ), 'condition' => [ 'meta_sub' => 'yes' ], ) ); // play buttons $this->add_control( '_button_typo_heading', array( 'label' => __( 'Play Button', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_button_typo', 'label' => __( 'Buttons Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play', ) ); $this->add_control( '_button_typo_color', array( 'label' => __( 'Button Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_button_typo_hcolor', array( 'label' => __( 'Button Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play:hover' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_button_typo_bgcolor', array( 'label' => __( 'Button Background Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play' => 'background-color: {{VALUE}};' ), ) ); $this->add_control( '_button_typo_bghcolor', array( 'label' => __( 'Button Background Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play:hover' => 'background-color: {{VALUE}};' ), ) ); $this->add_control( '_button_typo_bdcolor', array( 'label' => __( 'Button Border Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play' => 'border-color: {{VALUE}};' ), ) ); $this->add_control( '_button_typo_bdhcolor', array( 'label' => __( 'Button Border Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.play:hover' => 'border-color: {{VALUE}};' ), ) ); // more buttons $this->add_control( '_more_button_typo_heading', array( 'label' => __( 'More Button', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => '_more_button_typo', 'label' => __( 'Buttons Typography', 'penci-podcast' ), 'selector' => '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more', ) ); $this->add_control( '_more_button_typo_color', array( 'label' => __( 'Button Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_more_button_typo_hcolor', array( 'label' => __( 'Button Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more:hover' => 'color: {{VALUE}};' ), ) ); $this->add_control( '_more_button_typo_bgcolor', array( 'label' => __( 'Button Background Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more' => 'background-color: {{VALUE}};' ), ) ); $this->add_control( '_more_button_typo_bghcolor', array( 'label' => __( 'Button Background Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more:hover' => 'background-color: {{VALUE}};' ), ) ); $this->add_control( '_more_button_typo_bdcolor', array( 'label' => __( 'Button Border Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more' => 'border-color: {{VALUE}};' ), ) ); $this->add_control( '_more_button_typo_bdhcolor', array( 'label' => __( 'Button Border Hover Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .pencipdc_media_option .pencipdc_media_button.more:hover' => 'border-color: {{VALUE}};' ), ) ); // line border $this->add_control( '_line_border', array( 'label' => __( 'Borders', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::HEADING, ) ); $this->add_control( '_line_border_cl', array( 'label' => __( 'General Border Color', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} .penci-grid li.list-post,{{WRAPPER}} .pencipdc-splaylist .penci-category-description,{{WRAPPER}} .pencipdc-splaylist .pencipdc_postblock_episode_detail' => 'border-color: {{VALUE}};' ), ) ); $this->add_control( '_line_spacing', array( 'label' => __( 'Listing Spacing', 'penci-podcast' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'selectors' => array( '{{WRAPPER}} .penci-grid li.list-post.penci-slistp' => 'padding-bottom: {{SIZE}}px!important;margin-bottom: {{SIZE}}px!important;', '{{WRAPPER}} .pencipdc-splaylist .pencipdc_postblock_episode_detail' => 'padding-top: {{SIZE}}px;', ), ) ); $this->end_controls_section(); $this->register_block_title_style_section_controls(); } protected function render() { $settings = $this->get_settings(); $img_pos = $settings['featured_image']; $size = $settings['featured_image_size']; $author = $settings['meta_author']; $episode = $settings['meta_episode']; $sub = $settings['meta_sub']; $desc = $settings['meta_desc']; $num = $settings['number']; if ( ! empty( $settings['podcast_series'] ) ) { $this->markup_block_title( $settings, $this ); $id = $settings['podcast_series']; echo do_shortcode( '[podcast num="' . $num . '" desc="' . $desc . '" size="' . $size . '" sub="' . $sub . '" author="' . $author . '" episode="' . $episode . '" img_pos="' . $img_pos . '" id="' . $id . '"]' ); } } /** * Get image sizes. * * Retrieve available image sizes after filtering `include` and `exclude` arguments. */ public function get_list_image_sizes( $default = false ) { $wp_image_sizes = $this->get_all_image_sizes(); $image_sizes = array(); if ( $default ) { $image_sizes[''] = esc_html__( 'Default', 'soledad' ); } foreach ( $wp_image_sizes as $size_key => $size_attributes ) { $control_title = ucwords( str_replace( '_', ' ', $size_key ) ); if ( is_array( $size_attributes ) ) { $control_title .= sprintf( ' - %d x %d', $size_attributes['width'], $size_attributes['height'] ); } $image_sizes[ $size_key ] = $control_title; } $image_sizes['full'] = esc_html__( 'Full', 'soledad' ); return $image_sizes; } public function get_all_image_sizes() { global $_wp_additional_image_sizes; $default_image_sizes = [ 'thumbnail', 'medium', 'medium_large', 'large' ]; $image_sizes = []; foreach ( $default_image_sizes as $size ) { $image_sizes[ $size ] = [ 'width' => (int) get_option( $size . '_size_w' ), 'height' => (int) get_option( $size . '_size_h' ), 'crop' => (bool) get_option( $size . '_crop' ), ]; } if ( $_wp_additional_image_sizes ) { $image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes ); } return $image_sizes; } } customizer/penci_podcast_category_section.php000064400000010431147600053410015714 0ustar00 'pencipodcast_single_podcast', 'type' => 'soledad-fw-header', 'label' => esc_html__( 'Template & Layout Settings', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_items_position', 'transport' => 'postMessage', 'default' => 'top', 'type' => 'soledad-fw-select', 'label' => esc_html__( 'Featured Image Position', 'penci-podcast' ), 'choices' => array( 'top' => 'Top', 'left' => 'Left', ), ); $options[] = array( 'id' => 'pencipodcast_items_col', 'transport' => 'postMessage', 'default' => '2', 'type' => 'soledad-fw-select', 'label' => esc_html__( 'Podcast Template', 'penci-podcast' ), 'description' => esc_html__( 'Choose your single podcast template.', 'penci-podcast' ), 'choices' => array( '2' => '2 Columns', '3' => '3 Columns', '4' => '4 Columns', '5' => '5 Columns', ), ); $options[] = array( 'id' => 'pencipodcast_single_layout', 'transport' => 'postMessage', 'default' => 'left-sidebar', 'type' => 'soledad-fw-select', 'label' => esc_html__( 'Podcast Layout', 'penci-podcast' ), 'description' => esc_html__( 'Choose your single podcast layout', 'penci-podcast' ), 'choices' => array( 'left-sidebar' => 'Left Sidebar', 'right-sidebar' => 'Right Sidebar', 'two-sidebar' => 'Two Sidebar', 'no-sidebar' => 'No Sidebar', ), ); $options[] = array( 'id' => 'pencipodcast_single_podcast_element_settings', 'type' => 'soledad-fw-header', 'label' => esc_html__( 'Podcast Elements', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_single_show_featured', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Show Featured Image', 'penci-podcast' ), 'description' => esc_html__( 'Show featured image single podcast.', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_single_show_podcast_author', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Show Podcast Author', 'penci-podcast' ), 'description' => esc_html__( 'Show podcast author on podcast meta container.', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_single_show_podcast_total_episode', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Show Episode Counter', 'penci-podcast' ), 'description' => wp_kses( __( 'Show or hide episode counter', 'penci-podcast' ), wp_kses_allowed_html() ), ); $options[] = array( 'id' => 'pencipodcast_single_show_post_option', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Show Podcast Meta Option', 'penci-podcast' ), 'description' => esc_html__( 'Show Podcast meta option on podcast aside.', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_single_show_subscribe', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Show Subscribe Button', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_single_enable_post_excerpt', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Enable Post Excerpt', 'penci-podcast' ), 'description' => esc_html__( 'Show post excerpt on this block.', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_single_excerpt_length', 'transport' => 'postMessage', 'default' => 20, 'type' => 'soledad-fw-number', 'label' => esc_html__( 'Excerpt Length', 'penci-podcast' ), 'description' => esc_html__( 'Set the word length of excerpt on post.', 'penci-podcast' ), 'choices' => array( 'min' => '0', 'max' => '200', 'step' => '1', ), ); $options[] = array( 'id' => 'pencipodcast_single_excerpt_ellipsis', 'transport' => 'postMessage', 'default' => '...', 'type' => 'soledad-fw-text', 'label' => esc_html__( 'Excerpt Ellipsis', 'penci-podcast' ), 'description' => esc_html__( 'Define excerpt ellipsis', 'penci-podcast' ), ); return $options; customizer/panel.php000064400000002154147600053410010562 0ustar00set_panel(); $this->set_section(); } public function set_panel() { $this->customizer->add_panel( [ 'id' => $this->panelID, 'title' => esc_html__( 'Podcast', 'soledad' ), 'priority' => $this->id, ] ); } public function set_section() { $this->add_lazy_section( 'penci_podcast_general_section', esc_html__( 'General Settings', 'soledad' ), $this->panelID ); $this->add_lazy_section( 'penci_podcast_category_section', esc_html__( 'Categories Layout', 'soledad' ), $this->panelID ); $this->add_lazy_section( 'penci_podcast_series_section', esc_html__( 'Series Layout', 'soledad' ), $this->panelID ); $this->add_lazy_section( 'penci_podcast_colors_section', esc_html__( 'Colors', 'soledad' ), $this->panelID ); $this->add_lazy_section( 'penci_podcast_translate_section', esc_html__( 'Text Translation', 'soledad' ), $this->panelID ); } }customizer/settings.php000064400000003142147600053410011321 0ustar00customizer = \SoledadFW\Customizer\Customizer::get_instance(); } if ( is_customize_preview() || ! is_admin() ) { add_filter( 'soledad_fw_register_lazy_section', array( $this, 'register_lazy_section' ) ); add_action( 'soledad_fw_register_customizer_option', array( $this, 'load_customizer' ), 95 ); } } /** * @return Customizer */ public static function getInstance() { if ( null === static::$instance ) { static::$instance = new static(); } return static::$instance; } public function register_lazy_section( $result ) { $array = $this->list_section; $path = dirname( __DIR__ ) . '/customizer/'; foreach ( $array as $id ) { $result[ $id ][] = "{$path}{$id}.php"; } return $result; } public function load_customizer() { $this->customizer = Customizer\Customizer::get_instance(); new Customizer\PenciPodCastOption( $this->customizer, 207 ); } } customizer/penci_podcast_general_section.php000064400000002073147600053410015517 0ustar00 'pencipodcast_general_header', 'type' => 'soledad-fw-header', 'label' => esc_html__( 'General Setting', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_podcast_enable_player', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Enable Podcast Player', 'penci-podcast' ), 'description' => esc_html__( 'Enable this feature will show podcast player.', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_podcast_global_player', 'transport' => 'postMessage', 'default' => false, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Enable Global Player', 'penci-podcast' ), 'description' => esc_html__( 'Enable this feature will show podcast player globaly.', 'penci-podcast' ), 'active_callback' => array( array( 'setting' => 'pencipodcast_podcast_enable_player', 'operator' => '==', 'value' => true, ), ), ); return $options; customizer/penci_podcast_translate_section.php000064400000000547147600053410016103 0ustar00 $translate ) { $options[] = array( 'id' => "pencipdc_translate_{$mod}", 'transport' => 'postMessage', 'default' => $translate, 'type' => 'soledad-fw-text', 'label' => esc_html__( "Text: {$translate}", 'penci-podcast' ), ); } return $options; customizer/penci_podcast_series_section.php000064400000003515147600053410015376 0ustar00 'pencipodcast_series_podcast_element_settings', 'type' => 'soledad-fw-header', 'label' => esc_html__( 'Podcast Elements', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_series_show_featured', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Show Featured Image', 'penci-podcast' ), 'description' => esc_html__( 'Show featured image single podcast.', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_series_show_podcast_author', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Show Podcast Author', 'penci-podcast' ), 'description' => esc_html__( 'Show podcast author on podcast meta container.', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_series_show_podcast_total_episode', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Show Episode Counter', 'penci-podcast' ), 'description' => wp_kses( __( 'Show or hide episode counter', 'penci-podcast' ), wp_kses_allowed_html() ), ); $options[] = array( 'id' => 'pencipodcast_series_show_subscribe', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Show Subscribe Button', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_series_enable_post_excerpt', 'transport' => 'postMessage', 'default' => true, 'type' => 'soledad-fw-toggle', 'label' => esc_html__( 'Enable Post Excerpt', 'penci-podcast' ), 'description' => esc_html__( 'Show post excerpt on this block.', 'penci-podcast' ), ); return $options; customizer/penci_podcast_colors_section.php000064400000002137147600053410015404 0ustar00 'pencipodcast_player_bgcolor', 'transport' => 'postMessage', 'type' => 'soledad-fw-color', 'label' => esc_html__( 'Player Background Color', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_player_textcolor', 'transport' => 'postMessage', 'type' => 'soledad-fw-color', 'label' => esc_html__( 'Player Text Color', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_player_activecolor', 'transport' => 'postMessage', 'type' => 'soledad-fw-color', 'label' => esc_html__( 'Player Text Active Color', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_player_boderscolor', 'transport' => 'postMessage', 'type' => 'soledad-fw-color', 'label' => esc_html__( 'Player Borders Color', 'penci-podcast' ), ); $options[] = array( 'id' => 'pencipodcast_player_trackbgcolor', 'transport' => 'postMessage', 'type' => 'soledad-fw-color', 'label' => esc_html__( 'Audio Tracking Background Color', 'penci-podcast' ), ); return $options; inc/importer/app/Helper/Importer/FeedItem.php000064400000025112147600053410015152 0ustar00 '', 'post_content' => '', 'post_date' => '', 'post_excerpt' => '', 'post_status' => '', 'post_type' => '', 'post_title' => '', ]; public $audio_url; public $audio_feed_url = ''; public $audio_feed_host = ''; public $audio_embed_html = ''; // Can be shortcode only. public $audio_is_whitelisted = false; /** * @param PPI_Helper_Importer $importer * @param $feed_item */ public function __construct( PPI_Helper_Importer $importer, $feed_item ) { $this->importer = $importer; $this->feed_item = $feed_item; $this->feed_item_itunes = $this->feed_item->children( 'http://www.itunes.com/dtds/podcast-1.0.dtd' ); $this->_guid = pencipdc_importer_sanitize_feed_value( $this->feed_item->guid ); // Create the post global $wpdb; $this->current_post_id = intval( $wpdb->get_var( 'SELECT post_id FROM ' . $wpdb->postmeta . ' WHERE ( meta_key = "pencipdc_imported_guid" AND meta_value LIKE "%' . esc_sql( $wpdb->esc_like( $this->_guid ) ) . '%")' ) ); $this->episode_number = pencipdc_importer_sanitize_feed_value( $this->feed_item_itunes->episode ); $this->season_number = pencipdc_importer_sanitize_feed_value( $this->feed_item_itunes->season ); $this->filesize = '' . number_format( $this->feed_item->enclosure['length'] / 1048576, 2 ) . 'M'; $this->duration = pencipdc_importer_sanitize_feed_value( $this->feed_item_itunes->duration ); if ( ! empty( $this->duration ) ) { if ( strpos( $this->duration, ':' ) === false ) { $this->duration = gmdate( "H:i:s", $this->duration ); } } else { $this->duration = ''; } $this->current_post_information['post_author'] = $this->importer->post_author; $this->current_post_information['post_date'] = date( 'Y-m-d H:i:s', ( strtotime( (string) $this->feed_item->pubDate ) < current_time( 'timestamp' ) ? strtotime( (string) $this->feed_item->pubDate ) : current_time( 'timestamp' ) ) ); $this->current_post_information['post_type'] = $this->importer->post_type; $this->current_post_information['post_status'] = $this->importer->post_status; $this->current_post_information['post_title'] = pencipdc_importer_sanitize_feed_value( $feed_item->title ); if ( $this->importer->import_episode_number && $this->episode_number !== '' ) { $this->current_post_information['post_title'] = $this->episode_number . ': ' . $this->current_post_information['post_title']; } if ( $this->importer->import_prepend_title !== '' ) { $this->current_post_information['post_title'] = str_replace( '[podcast_title]', pencipdc_importer_sanitize_feed_value( $this->importer->feedXML->channel->title ), $this->importer->import_prepend_title ) . ' ' . $this->current_post_information['post_title']; } if ( $this->current_post_id === 0 ) { $this->current_post_id = \post_exists( $this->current_post_information['post_title'], "", "", $this->importer->post_type ); } $this->current_post_information['post_excerpt'] = pencipdc_importer_sanitize_feed_value( $this->feed_item_itunes->subtitle ); $this->_set_audio_information(); } private function _set_audio_information() { $this->audio_url = (string) $this->feed_item->enclosure['url']; if ( $this->importer->import_embed_player ) { if ( strpos( $this->audio_url, 'dts.podtrac.com/redirect.mp3/' ) !== false ) { $this->audio_url = str_replace( 'dts.podtrac.com/redirect.mp3/', '', $this->audio_url ); } } $this->audio_url = preg_replace( '/(?s:.*)(https?:\/\/(?:[\w\-\.]+[^#?\s]+)(?:\.mp3))(?s:.*)/', '$1', $this->audio_url ); $this->audio_url = preg_replace( '/(?s:.*)(https?:\/\/(?:[\w\-\.]+[^#?\s]+)(?:\.m4a))(?s:.*)/', '$1', $this->audio_url ); $this->audio_feed_url = (string) $this->importer->feed_link; $this->item_link_url = (string) $this->feed_item->link; if ( ! empty( $this->audio_feed_url ) ) { $this->audio_feed_host = parse_url( $this->audio_feed_url )['host']; } else { $this->audio_feed_host = parse_url( $this->audio_url )['host']; } if ( $this->importer->import_embed_player && ! empty( $this->audio_feed_host ) ) { if ( preg_match( '/fireside.fm/i', $this->importer->feed_link ) ) { $this->item_link_url = (string) $this->feed_item->children( 'fireside', true )->playerEmbedCode; } else if ( preg_match( '/omny.fm/i', $this->importer->feed_link ) || preg_match( '/omnycontent.com/i', $this->importer->feed_link ) ) { $this->item_link_url = (string) $this->feed_item->children( 'media', true )->content->children( 'media', true )->player->attributes()->url; } else if ( preg_match( '/libsyn.com/i', $this->importer->feed_link ) || preg_match( '/omnycontent.com/i', $this->importer->feed_link ) ) { $this->item_link_url = (string) $this->feed_item->children( 'libsyn', true )->itemId; } else if ( preg_match( '/sounder.fm/i', $this->audio_feed_url ) ) { $this->item_link_url = (string) $this->feed_item->enclosure['url']; } $this->audio_embed_html = PPI_Helper_Embed::get_embed_content( $this->audio_feed_host, $this->item_link_url, $this->audio_url, $this->importer->feed_link, $this->_guid ); $this->audio_is_whitelisted = podcast_importer_is_whitelisted_host( $this->audio_feed_host, $this->audio_feed_url ); } $this->current_post_information['post_content'] = ''; if ( $this->importer->import_content_truncate === false || $this->importer->import_content_truncate >= 1 ) { if ( ! empty( $this->feed_item->children( 'itunes', true )->summary ) && $this->importer->import_content_tag === 'itunes:summary' ) { $this->current_post_information['post_content'] = pencipdc_importer_sanitize_feed_value( $this->feed_item->children( 'itunes', true )->summary ); } elseif ( ! empty( $this->feed_item->children( 'itunes', true )->encoded ) && $this->importer->import_content_tag === 'content:encoded' ) { $this->current_post_information['post_content'] = pencipdc_importer_sanitize_feed_value( $this->feed_item->children( 'content', true )->encoded ); } elseif ( ! empty( $this->feed_item->description ) && $this->importer->import_content_tag === 'description' ) { $this->current_post_information['post_content'] = pencipdc_importer_sanitize_feed_value( $this->feed_item->description ); } elseif ( ! empty( $this->feed_item->children( 'content', true )->encoded ) ) { $this->current_post_information['post_content'] = pencipdc_importer_sanitize_feed_value( $this->feed_item->children( 'content', true )->encoded ); } elseif ( ! empty( $this->feed_item->description ) ) { $this->current_post_information['post_content'] = pencipdc_importer_sanitize_feed_value( $this->feed_item->description ); } else { $this->current_post_information['post_content'] = pencipdc_importer_sanitize_feed_value( $this->feed_item_itunes->summary ); } if ( $this->importer->import_content_truncate !== false ) { $this->current_post_information['post_content'] = substr( $this->current_post_information['post_content'], 0, $this->importer->import_content_truncate ); } } if ( apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_feed_item_has_player_in_content', pencipdc_importer_append_player_to_content(), $this ) ) { $this->current_post_information['post_content'] = $this->audio_embed_html . $this->current_post_information['post_content']; } } public function import() { $this->current_post_id = wp_insert_post( $this->current_post_information ); if ( is_wp_error( $this->current_post_id ) ) { return $this->current_post_id; } $this->_set_post_information(); return true; } public function sync() { if ( $this->current_post_id === 0 ) { return false; } $response = wp_update_post( [ 'ID' => $this->current_post_id ] + $this->current_post_information, true ); if ( is_wp_error( $response ) ) { return $response; } $this->_set_post_information(); return true; } private function _set_post_information() { update_post_meta( $this->current_post_id, 'pencipdc_imported_guid', $this->_guid ); update_post_meta( $this->current_post_id, 'pencipc_media_url', $this->audio_url ); update_post_meta( $this->current_post_id, 'pencipc_media_duration', $this->duration ); $categories_map = apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_feed_item_import_category_map', $this->importer->get_post_categories_import_map(), $this ); foreach ( $categories_map as $taxonomy => $taxonomy_tags ) { wp_set_post_terms( $this->current_post_id, $taxonomy_tags, $taxonomy, false ); } $series_map = apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_feed_item_import_series_map', $this->importer->get_post_series_import_map(), $this ); foreach ( $series_map as $taxonomy => $taxonomy_tags ) { wp_set_post_terms( $this->current_post_id, $taxonomy_tags, $taxonomy, false ); } if ( ! empty( $this->importer->import_parent_show ) ) { update_post_meta( $this->current_post_id, 'pencipdc_themes_parent_show_post', $this->importer->import_parent_show ); } if ( apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_feed_item_import_images', ( isset( $this->importer->import_images ) && $this->importer->import_images ), $this ) ) { $this->_handle_image_import(); } do_action( PENCI_PODCAST_IMPORTER_ALIAS . '_feed_item_imported', $this ); // Old Actions, leaving for backward compatibility. do_action( 'pencipdc_after_post_import', $this->current_post_id, $this->importer->feed_link, $this->feed_item ); } private function _handle_image_import() { $image_url = false; if ( isset( $this->importer->import_images ) && $this->feed_item_itunes && isset( $this->feed_item_itunes->image ) && $this->feed_item_itunes->image->attributes() && isset( $this->feed_item_itunes->image->attributes()->href ) ) { $image_url = (string) $this->feed_item_itunes->image->attributes()->href; } if ( $image_url === false ) { return; } as_enqueue_async_action( PENCI_PODCAST_IMPORTER_ALIAS . '_scheduler_image_sync', [ $this->current_post_id, $image_url ], PENCI_PODCAST_IMPORTER_ALIAS ); } }inc/importer/app/Helper/FeedForm.php000064400000020512147600053410013355 0ustar00 $field_definition ) { if ( ! isset( $field_definition['storage'] ) ) { continue; } if ( isset( $field_definition['views'] ) ) { if ( ! in_array( 'add', $field_definition['views'] ) && ! is_numeric( $post_id ) ) { continue; } if ( ! in_array( 'edit', $field_definition['views'] ) && is_numeric( $post_id ) ) { continue; } unset( $field_definition['views'] ); } $storage = $field_definition['storage']; unset( $field_definition['storage'] ); if ( is_numeric( $post_id ) ) { $field_definition['value'] = null; if ( $storage['type'] === 'meta' ) { $field_definition['value'] = get_post_meta( $post_id, $storage['meta'], ( $storage['meta_is_single'] ?? true ) ); } if ( isset( $field_definition['options'] ) && ! is_array( $field_definition['value'] ) && ! isset( $field_definition['options'][ $field_definition['value'] ] ) && ! empty( $field_definition['value'] ) ) { $field_definition['options'] = [ $field_definition['value'] => $field_definition['value'] ] + $field_definition['options']; } } if ( ( ! isset( $field_definition['value'] ) || $field_definition['value'] === null ) && isset( $field_definition['default'] ) ) { $field_definition['value'] = $field_definition['default']; } unset( $field_definition['default'] ); $response[ $key ] = $field_definition; } return apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_feed_form_for_render', $response, $field_definitions ); } public static function field_definitions(): array { $response = []; $response['feed_url'] = [ 'label' => __( 'Podcast Feed URL', 'penci-podcast' ), 'name' => 'feed_url', 'type' => 'url', 'required' => 1, 'placeholder' => 'https://anchor.fm/s/98e888/podcast/rss', 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_rss_feed' ] ]; $post_type_options = []; foreach ( pencipdc_importer_supported_post_types() as $post_type ) { $post_type_options[ $post_type ] = get_post_type_object( $post_type )->labels->singular_name; } $response['post_status'] = [ 'label' => __( 'Podcast Status', 'penci-podcast' ), 'name' => 'post_status', 'type' => 'select', 'options' => [ 'publish' => __( 'Publish', 'penci-podcast' ), 'draft' => __( 'Save as Draft', 'penci-podcast' ) ], 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_import_publish' ] ]; $response['post_author'] = [ 'label' => __( 'Podcast Author', 'penci-podcast' ), 'name' => 'post_author', 'type' => 'wp_dropdown_users', 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_import_author' ] ]; $response['post_taxonomies'] = [ 'label' => __( 'Categories', 'penci-podcast' ), 'name' => 'post_taxonomies', 'type' => 'multiple_select', 'options' => pencipdc_importer_get_taxonomies_select_definition( array_keys( $post_type_options ), true ), 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_import_category' ] ]; $response['post_series'] = [ 'label' => __( 'Series', 'penci-podcast' ), 'name' => 'post_series', 'type' => 'multiple_select', 'options' => pencipdc_importer_get_taxonomies_select_definition( array_keys( $post_type_options ), false ), 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_import_series' ] ]; if ( ! pencipdc_importer_feed_limit_reached() ) { $response['import_continuous'] = [ 'label' => __( 'Ongoing Import (Enable to continuously import future episodes)', 'penci-podcast' ), 'name' => 'import_continuous', 'type' => 'checkbox', 'value_unchecked' => 'off', 'value_checked' => 'on', 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_import_continuous' ], 'views' => [ 'add' ] ]; } $response['import_images'] = [ 'label' => __( 'Import Episode Featured Images', 'penci-podcast' ), 'name' => 'import_images', 'type' => 'checkbox', 'value_unchecked' => 'off', 'value_checked' => 'on', 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_import_images' ] ]; $response['import_embed_player'] = [ 'label' => __( 'Use an embed audio player instead of the default Penci Podcast Player (depending on your podcast host)', 'penci-podcast' ), 'name' => 'import_embed_player', 'type' => 'checkbox', 'value_unchecked' => 'off', 'value_checked' => 'on', 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_import_embed_player' ] ]; $response['import_date_from'] = [ 'label' => __( 'Date Limit', 'penci-podcast' ), 'name' => 'import_date_from', 'type' => 'date', 'placeholder' => __( '01-01-2019', 'penci-podcast' ), 'description' => __( 'Optional: only import episodes after a certain date.', 'penci-podcast' ), 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_import_date_from' ] ]; $response['import_content_tag'] = [ 'label' => __( 'Imported Content Tag', 'penci-podcast' ), 'name' => 'import_content_tag', 'type' => 'select', 'options' => [ 'content:encoded' => 'content:encoded', 'description' => 'description', 'itunes:summary' => 'itunes:summary' ], 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_content_tag' ] ]; $response['import_truncate_post'] = [ 'label' => __( 'Truncate Post Content', 'penci-podcast' ), 'name' => 'import_truncate_post', 'type' => 'number', 'description' => __( 'Optional: Will trim the post content when imported to the character amount below.', 'penci-podcast' ) . __( 'Leave empty to skip trimming, set to 0 to skip content import.', 'penci-podcast' ), 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_truncate_post' ] ]; $response['import_episode_number'] = [ 'label' => __( 'Append episode number to post title', 'penci-podcast' ), 'name' => 'import_episode_number', 'type' => 'checkbox', 'value_unchecked' => 'off', 'value_checked' => 'on', 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_import_episode_number' ] ]; $response['import_prepend_title'] = [ 'label' => __( 'Append custom text to post title', 'penci-podcast' ), 'name' => 'import_prepend_title', 'type' => 'text', 'placeholder' => __( 'Ex: My Podcast', 'penci-podcast' ), 'description' => sprintf( __( 'Optional: Add %s to display the show name.', 'penci-podcast' ), '[podcast_title]' ), 'value_unchecked' => 'off', 'value_checked' => 'on', 'storage' => [ 'type' => 'meta', 'meta' => 'pencipdc_prepend_title' ] ]; return apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_feed_form_definitions', $response ); } public static function request_data_to_meta_map( $request_data ): array { $field_definitions = self::field_definitions(); $response = []; foreach ( $field_definitions as $field_definition ) { if ( ! isset( $field_definition['storage']['meta'] ) ) { continue; } if ( isset( $request_data[ $field_definition['name'] ] ) ) { if ( is_array( $request_data[ $field_definition['name'] ] ) ) { $response[ $field_definition['storage']['meta'] ] = array_map( 'intval', $request_data[ $field_definition['name'] ] ); continue; } $response[ $field_definition['storage']['meta'] ] = sanitize_text_field( $request_data[ $field_definition['name'] ] ); continue; } if ( isset( $field_definition['default'] ) ) { $request_data[ $field_definition['storage']['meta'] ] = $field_definition['default']; } else if ( isset( $field_definition['value_unchecked'] ) ) { $request_data[ $field_definition['storage']['meta'] ] = $field_definition['value_unchecked']; } } return apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_feed_form_request_data_to_meta_map', $response, $request_data, $field_definitions ); } }inc/importer/app/Helper/Importer.php000064400000023626147600053410013500 0ustar00import_append_audio_html_to_content = pencipdc_importer_append_player_to_content(); $this->feed_link = esc_url( $feed_link, [ 'http', 'https' ] ); foreach ( $settings as $k => $v ) { if ( ! isset( $this->$k ) ) { $this->additional_settings[ $k ] = $v; continue; } $this->$k = $v; } if ( $this->import_date_from !== false ) { $this->import_date_from = ! is_numeric( $this->import_date_from ) ? strtotime( $this->import_date_from ) : intval( $this->import_date_from ); } require_once( ABSPATH . 'wp-admin/includes/media.php' ); require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); if ( ! function_exists( 'post_exists' ) ) { require_once( ABSPATH . 'wp-admin/includes/post.php' ); } } private function _loadXML() { $this->feedXML = @simplexml_load_file( $this->feed_link ); if ( empty( $this->feedXML ) ) { $ch = curl_init( $this->feed_link ); curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0' ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); $result = curl_exec( $ch ); if ( substr( $result, 0, 5 ) == "feedXML = simplexml_load_string( $result ); } curl_close( $ch ); } if ( $this->feedXML->channel->item ) { $this->_current_feed_episode_count = count( $this->feedXML->channel->item ); } do_action( PENCI_PODCAST_IMPORTER_ALIAS . '_importer_after_load_xml', $this ); } public function get_current_feed_episode_count() { if ( empty( $this->feed_link ) ) { return false; } if ( empty( $this->feedXML ) ) { $this->_loadXML(); if ( empty( $this->feedXML ) ) { return false; } } return intval( $this->_current_feed_episode_count ); } public function import_current_feed() { do_action( PENCI_PODCAST_IMPORTER_ALIAS . '_importer_before_import_current_feed', $this ); if ( empty( $this->feed_link ) ) { return false; } if ( empty( $this->feedXML ) ) { $this->_loadXML(); if ( empty( $this->feedXML ) ) { return false; } } if ( $this->_current_feed_episode_count === 0 ) { return false; } if ( empty( $this->_post_categories_import_map ) ) { foreach ( $this->post_categories as $post_category ) { $term = get_term( $post_category ); if ( ! isset( $term->taxonomy ) ) { continue; } if ( ! isset( $this->_post_categories_import_map[ $term->taxonomy ] ) ) { $this->_post_categories_import_map[ $term->taxonomy ] = []; } $this->_post_categories_import_map[ $term->taxonomy ][] = $post_category; } } if ( empty( $this->_post_series_import_map ) ) { foreach ( $this->post_series as $post_series_item ) { $term = get_term( $post_series_item ); if ( ! isset( $term->taxonomy ) ) { continue; } if ( ! isset( $this->_post_series_import_map[ $term->taxonomy ] ) ) { $this->_post_series_import_map[ $term->taxonomy ] = []; } $this->_post_series_import_map[ $term->taxonomy ][] = $post_series_item; } } $this->_current_imported_count = 0; set_time_limit( 360 ); $synced_count = 0; $skipped_count = 0; $additional_errors = []; $offset = ( empty( $this->import_segmentation_offset ) ? 0 : $this->import_segmentation_offset ); $limit = ( empty( $this->import_segmentation_limit ) ? $this->_current_feed_episode_count : ( $this->_current_feed_episode_count - $this->import_segmentation_offset < $this->import_segmentation_limit ? $this->_current_feed_episode_count - $this->import_segmentation_offset : $this->import_segmentation_limit ) ); for ( $i = $offset; $i < $offset + $limit; $i ++ ) { if ( $this->import_date_from !== false ) { if ( strtotime( (string) $this->feedXML->channel->item[ $i ]->pubDate ) < $this->import_date_from ) { $skipped_count ++; continue; } } $feedItemInstance = new PPI_Helper_Importer_FeedItem( $this, $this->feedXML->channel->item[ $i ] ); if ( $feedItemInstance->current_post_id !== 0 ) { if ( $this->import_allow_sync ) { $sync_response = $feedItemInstance->sync(); if ( is_wp_error( $sync_response ) ) { $additional_errors[] = $sync_response->get_error_message(); unset( $feedItemInstance ); continue; } $synced_count ++; } $this->_current_feed_url_to_post_id_map[ $feedItemInstance->audio_feed_url ] = $feedItemInstance->current_post_id; unset( $feedItemInstance ); continue; } $import_response = $feedItemInstance->import(); if ( is_wp_error( $import_response ) ) { $additional_errors[] = $import_response->get_error_message(); unset( $feedItemInstance ); continue; } $this->_current_feed_url_to_post_id_map[ $feedItemInstance->audio_feed_url ] = $feedItemInstance->current_post_id; $this->_current_imported_count ++; unset( $feedItemInstance ); } do_action( PENCI_PODCAST_IMPORTER_ALIAS . '_importer_after_import_current_feed', $this ); return [ 'episode_count' => $this->_current_feed_episode_count, 'skipped_count' => $skipped_count, 'synced_count' => $synced_count, 'current_import' => $this->_current_imported_count, 'additional_errors' => $additional_errors ]; } public function get_post_categories_import_map(): array { return $this->_post_categories_import_map; } public function get_post_series_import_map(): array { return $this->_post_series_import_map; } public function get_feed_title() { if ( empty( $this->feed_link ) ) { return false; } if ( empty( $this->feedXML ) ) { $this->_loadXML(); if ( empty( $this->feedXML ) ) { return false; } } return ( isset( $this->feedXML->channel ) && isset( $this->feedXML->channel->title ) ? pencipdc_importer_sanitize_feed_value( $this->feedXML->channel->title ) : md5( $this->feed_link ) ); } }inc/importer/app/Helper/Scheduler.php000064400000004054147600053410013607 0ustar00 $post_id, 'timestamp' => strtotime( 'now' ), 'interval_in_seconds' => ( 1 * HOUR_IN_SECONDS ), 'hook' => PENCI_PODCAST_IMPORTER_SCHEDULER_FEED_PREFIX . $post_id, 'args' => [ $post_id ], 'group' => PENCI_PODCAST_IMPORTER_SCHEDULER_FEED_GROUP ]; $args = apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_scheduler_feed_args', $args ); self::set_schedule( $args[ 'timestamp' ], $args[ 'interval_in_seconds' ], $args[ 'hook' ], $args[ 'args' ], $args[ 'group' ] ); } public static function schedule_posts() { $post_ids = get_posts( [ 'post_type' => PENCI_PODCAST_IMPORTER_POST_TYPE_IMPORT, 'posts_per_page' => -1, 'fields' => 'ids' ] ); foreach( $post_ids as $post_id ) self::schedule_post_id( $post_id ); } public static function is_everything_scheduled() { $post_ids = get_posts( [ 'post_type' => PENCI_PODCAST_IMPORTER_POST_TYPE_IMPORT, 'posts_per_page' => -1, 'fields' => 'ids' ] ); foreach( $post_ids as $post_id ) if( !self::is_action_scheduled( PENCI_PODCAST_IMPORTER_SCHEDULER_FEED_PREFIX . $post_id ) ) return false; return true; } }inc/importer/app/Helper/Embed.php000064400000014376147600053410012715 0ustar00'; } elseif (strpos($feed_host_url, 'anchor.fm') !== false) { $fixed_share_url = str_replace('/episodes/', '/embed/episodes/', $embed_url); $response = ''; } elseif (strpos($plugin_feed_url, 'simplecast.com') !== false) { $extract_sc_url = explode('/audio/', $audio_url); $fixed_share_url = explode('/', $extract_sc_url[1]); $response = ''; } elseif (strpos($feed_host_url, 'podcastpage.io') !== false) { $fixed_share_url = str_replace('/episode/', '/?pp_mode=preview/', $embed_url); $response = ''; } elseif (strpos($feed_host_url, 'whooshkaa.com') !== false) { $whooshkaa_audio_id = substr($embed_url, strpos($embed_url, "?id=") + 4); $fixed_share_url = 'https://webplayer.whooshkaa.com/player/episode/id/' . $whooshkaa_audio_id . '?theme=light'; $response = ''; } elseif ((strpos($plugin_feed_url, 'omny.fm') !== false) || (strpos($plugin_feed_url, 'omnycontent.com') !== false)) { $response = ''; } elseif (strpos($feed_host_url, 'podbean.com') !== false) { $response = wp_oembed_get(esc_url($embed_url)); // oEmbed } elseif (strpos($plugin_feed_url, 'megaphone.fm') !== false) { $megaphone_audio_link = explode('megaphone.fm/', $audio_url); $megaphone_audio_id = explode('.', $megaphone_audio_link[1]); $fixed_share_url = 'https://playlist.megaphone.fm/?e=' . $megaphone_audio_id[0]; $response = ''; } elseif (strpos($plugin_feed_url, 'captivate.fm') !== false) { $captivate_audio_link = explode('media/', $audio_url); $captivate_audio_id = explode('/', $captivate_audio_link[1]); $fixed_share_url = 'https://player.captivate.fm/episode/' . $captivate_audio_id[0]; $response = ''; } elseif (strpos($audio_url, 'buzzsprout.com') !== false) { $buzzsprout_audio_url = explode('.mp3', $audio_url); $fixed_share_url = $buzzsprout_audio_url[0] . '?iframe=true'; $response = ''; } elseif (strpos($audio_url, 'pinecast.com') !== false) { $pinecast_audio_url = explode('.mp3', $audio_url); $pinecast_episode_url = str_replace('/listen/', '/player/', $pinecast_audio_url[0]); $fixed_share_url = $pinecast_episode_url . '?theme=flat'; $response = ''; } elseif (strpos($plugin_feed_url, 'feed.ausha.co') !== false) { $ausha_audio_link = explode('audio.ausha.co/', $audio_url); $ausha_audio_id = explode('.mp3', $ausha_audio_link[1]); $podcastId = $ausha_audio_id[0]; $response = ''; } elseif (strpos($plugin_feed_url, 'sounder.fm') !== false) { $sounder_audio_link = explode('audio--', $embed_url); $sounder_audio_id = explode('--', $sounder_audio_link[1]); $podcastId = $sounder_audio_id[0]; $response = ''; } elseif (strpos($plugin_feed_url, 'spreaker.com') !== false) { $fixed_share_url = explode('/episode/', $guid); if(isset($fixed_share_url[1])) { $response = ''; } } elseif (strpos($plugin_feed_url, 'fireside.fm') !== false) { $response = $embed_url . ''; } elseif (strpos($plugin_feed_url, 'libsyn.com') !== false) { $response = ''; } elseif (strpos($plugin_feed_url, 'audioboom.com') !== false) { $fixed_share_url = str_replace('/posts/', '/boos/', $embed_url); $response = ''; } return $response; } }inc/importer/app/RestAPI/ACL.php000064400000001477147600053410012326 0ustar00 401 ] ); } return true; } }inc/importer/app/RestAPI/Response.php000064400000010523147600053410013515 0ustar00get( '_admin_notice_dismissed_map' ); $current_notice_dismiss_map[ get_current_user_id() ] = time(); PPI_Settings::instance()->update( '_admin_notice_dismissed_map', $current_notice_dismiss_map ); return rest_ensure_response( true ); } public static function get_feed_summary( $request ) { $request_data = $request->get_params(); $importer = PPI_Helper_Importer::from_meta_map( PPI_Helper_FeedForm::request_data_to_meta_map( $request_data ) ); return [ 'episode_count' => $importer->get_current_feed_episode_count() ]; } public static function save_feed( $request ) { $request_data = $request->get_params(); $messages = []; $meta_map = PPI_Helper_FeedForm::request_data_to_meta_map( $request_data ); if( isset( $request_data[ 'post_id' ] ) ) { foreach( $meta_map as $k => $v ) update_post_meta( intval( $request_data[ 'post_id' ] ), $k, $v ); PPI_Helper_Scheduler::schedule_post_id( intval( $request_data[ 'post_id' ] ) ); $messages[] = [ 'type' => 'success', 'message' => __( 'Updated settings.', 'penci-podcast' ) ]; } else if( isset( $meta_map[ 'pencipdc_import_continuous' ] ) && $meta_map[ 'pencipdc_import_continuous' ] == 'on' ) { $importer = PPI_Helper_Importer::from_meta_map( $meta_map ); $title = $importer->get_feed_title(); if( 0 === post_exists($title , "", "", PENCI_PODCAST_IMPORTER_POST_TYPE_IMPORT ) ) { $import_post = [ 'post_title' => $title, 'post_type' => PENCI_PODCAST_IMPORTER_POST_TYPE_IMPORT, 'post_status' => 'publish', ]; $post_import_id = wp_insert_post( $import_post ); foreach( $meta_map as $k => $v ) update_post_meta( $post_import_id, $k, $v ); PPI_Helper_Scheduler::schedule_post_id( intval( $post_import_id ) ); $messages[] = [ 'type' => 'success', 'message' => __( 'Saved podcast feed for continuous import.', 'penci-podcast' ) ]; } else { $messages[] = [ 'type' => 'danger', 'message' => __('This podcast is already scheduled for import. Delete the previous schedule to create a new one.', 'penci-podcast' ) ]; } } return rest_ensure_response( [ 'messages' => $messages ] ); } public static function import_feed( $request ) { $request_data = $request->get_params(); $messages = []; $meta_map = PPI_Helper_FeedForm::request_data_to_meta_map( $request_data ); $importer = PPI_Helper_Importer::from_meta_map( $meta_map ); if( $request->has_param( 'episode_offset' ) ) $importer->import_segmentation_offset = intval( $request->get_param( 'episode_offset' ) ); if( $request->has_param( 'episode_limit' ) ) $importer->import_segmentation_limit = intval( $request->get_param( 'episode_limit' ) ); $import_current_feed = $importer->import_current_feed(); if( isset( $import_current_feed[ 'additional_errors' ] ) && is_array( $import_current_feed[ 'additional_errors' ] ) ) foreach( $import_current_feed[ 'additional_errors' ] as $additional_error ) $messages[] = [ 'type' => 'danger', 'message' => $additional_error ]; unset( $import_current_feed[ 'additional_errors' ] ); return rest_ensure_response( [ 'messages' => $messages, 'summary' => $import_current_feed ] ); } public static function sync_feed( $request ) { $all_meta = get_post_meta( intval( $request[ 'id' ] ) ); $meta_map = []; foreach( $all_meta as $k => $v ) { if( is_array( $v ) && count( $v ) === 1 ) $v = maybe_unserialize( $v[ 0 ] ); $meta_map[ $k ] = $v; } // Maybe deleted after queued, need to ensure it's fine. if( isset( $meta_map[ 'pencipdc_rss_feed' ] ) ) { $importer = PPI_Helper_Importer::from_meta_map( $meta_map ); $response = $importer->import_current_feed(); } return true; } }inc/importer/app/AdminAssets.php000064400000005063147600053410012666 0ustar00 esc_url_raw( rest_url() ), 'rest_nonce' => wp_create_nonce( 'wp_rest' ), 'import_limit' => PENCI_PODCAST_IMPORTER_SETUP_IMPORT_PER_REQUEST, 'lang_import_progress' => __( "Processed %s episodes out of %s", 'penci-podcast' ), 'lang_import_summary_progress' => __( 'Success! Re-synced %s previously imported episodes.', 'penci-podcast' ), 'lang_import_summary_progress_with_skips' => __( 'Success! Re-synced %s previously imported episodes, and skipped %s based on rules.', 'penci-podcast' ), 'lang_import_summary_progress_skips' => __( "Skipped %s episode imports, based on rules.", 'penci-podcast' ), 'lang_import_summary_no_imports' => __( 'No new episodes imported - all episodes already existing in WordPress!', 'penci-podcast' ) . '
    ' . __( 'If you have existing draft, private or trashed posts with the same title as your episodes, delete those and run the importer again.', 'penci-podcast' ), 'lang_import_summary_no_episodes' => __( 'Error! Your feed does not contain any episodes.', 'penci-podcast' ), 'lang_import_summary_success' => __( 'Success! Imported %s out of %s episodes', 'penci-podcast' ), 'lang_import_summary_success_resynced' => __( "%s previously imported episodes re-synced", 'penci-podcast' ) ] ); wp_enqueue_script( 'pencipdc_admin_scripts' ); } }inc/importer/app/PostTypes.php000064400000002460147600053410012423 0ustar00 [ 'name' => __( 'Podcast Imports', 'penci-podcast' ), 'singular_name' => __( 'Podcast Import', 'penci-podcast' ) ], 'public' => true, 'has_archive' => false, 'supports' => [ 'title' ], 'can_export' => false, 'exclude_from_search' => true, 'show_in_admin_bar' => false, 'show_in_nav_menus' => false, 'publicly_queryable' => false, ] ); add_action( 'admin_menu', [ $this, '_admin_menu' ] ); } public function _admin_menu() { if( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] === 'trash' ) return; if( isset( $_GET[ 'post_type' ] ) && $_GET[ 'post_type' ] === PENCI_PODCAST_IMPORTER_POST_TYPE_IMPORT ) return; remove_menu_page( 'edit.php?post_type=' . PENCI_PODCAST_IMPORTER_POST_TYPE_IMPORT ); } }inc/importer/app/AdminMenu.php000064400000002347147600053410012332 0ustar00' . esc_attr__( 'Import Podcast', 'penci-podcast' ) . ''; return $response; } }inc/importer/app/RestAPI.php000064400000003663147600053410011726 0ustar00 WP_REST_Server::EDITABLE, 'callback' => 'PenciPodcast\RestAPI\Response::admin_dismiss_notice', 'permission_callback' => 'PenciPodcast\RestAPI\ACL::admin_dismiss_notice', ] ); register_rest_route( PENCI_PODCAST_IMPORTER_REST_API_PREFIX . '/v1', '/get-feed-summary', [ 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'PenciPodcast\RestAPI\Response::get_feed_summary', 'permission_callback' => 'PenciPodcast\RestAPI\ACL::get_feed_summary', ] ); register_rest_route( PENCI_PODCAST_IMPORTER_REST_API_PREFIX . '/v1', '/save-feed', [ 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'PenciPodcast\RestAPI\Response::save_feed', 'permission_callback' => 'PenciPodcast\RestAPI\ACL::save_feed', ] ); register_rest_route( PENCI_PODCAST_IMPORTER_REST_API_PREFIX . '/v1', '/import-feed', [ 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'PenciPodcast\RestAPI\Response::import_feed', 'permission_callback' => 'PenciPodcast\RestAPI\ACL::import_feed', ] ); register_rest_route( PENCI_PODCAST_IMPORTER_REST_API_PREFIX . '/v1', '/sync-feed/(?P\d+)', [ 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'PenciPodcast\RestAPI\Response::sync_feed', 'permission_callback' => 'PenciPodcast\RestAPI\ACL::sync_feed', ] ); } }inc/importer/app/Hooks.php000064400000002140147600053410011527 0ustar00 true, 'height' => true, 'width' => true, 'style' => true, 'frameborder' => true, 'allowfullscreen' => true, 'scrolling' => true, 'seamless' => true, ); return $tags; } public function _oembed_providers( $providers ) { $providers['#https?://(.+).podbean.com/e/.+#i'] = [ 'https://api.podbean.com/v1/oembed', true ]; return $providers; } }inc/importer/app/ActionScheduler.php000064400000006636147600053410013536 0ustar00_added_events ) return; $post_ids = get_posts( [ 'post_type' => PENCI_PODCAST_IMPORTER_POST_TYPE_IMPORT, 'posts_per_page' => -1, 'fields' => 'ids' ] ); foreach( $post_ids as $post_id ) add_action( PENCI_PODCAST_IMPORTER_SCHEDULER_FEED_PREFIX . $post_id, [ $this, '_feed_sync' ], 10, 2 ); $this->_added_events = true; } public function _feed_sync( $feed_post_id ) { $all_meta = get_post_meta( $feed_post_id ); $meta_map = []; foreach( $all_meta as $k => $v ) { if( is_array( $v ) && count( $v ) === 1 ) $v = maybe_unserialize( $v[ 0 ] ); $meta_map[ $k ] = $v; } // Maybe deleted after queued, need to ensure it's fine. if( isset( $meta_map[ 'pencipdc_rss_feed' ] ) ) { $importer = PPI_Helper_Importer::from_meta_map( $meta_map ); $response = $importer->import_current_feed(); } } public function _image_sync( $post_id, $image_path ) { if( !function_exists( 'media_sideload_image' ) ) { require_once( ABSPATH . 'wp-admin/includes/media.php' ); require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); } $image_contents = wp_remote_get( $image_path ); $image_contents = wp_remote_retrieve_body( $image_contents ); global $wpdb; $post_id = intval( $post_id ); $attachment_post_id = $wpdb->get_var( 'SELECT post_id FROM ' . $wpdb->postmeta . ' WHERE meta_key = "pencipdc_attachment_md5" AND meta_value = ' . $wpdb->prepare( "%s", md5( $image_contents ) ) ); if( null === $attachment_post_id ) { $attachment_post_id = media_sideload_image($image_path, $post_id, get_the_title( $post_id ), 'id' ); update_post_meta( $attachment_post_id, 'pencipdc_attachment_md5', md5( $image_contents ) ); } else { $attachment_post_id = intval( $attachment_post_id ); } set_post_thumbnail( $post_id, $attachment_post_id ); } public function _images_md5_checksum( $attachment_ids ) { foreach( $attachment_ids as $attachment_id ) { $url = wp_get_attachment_url( $attachment_id ); if( empty( $url ) || is_array( $url ) ) continue; $image_contents = wp_remote_get( $url ); $image_contents = wp_remote_retrieve_body( $image_contents ); update_post_meta( $attachment_id, 'pencipdc_attachment_md5', md5( $image_contents ) ); } } }inc/importer/app/SiteHealth.php000064400000003547147600053410012512 0ustar00 __( '%s - Scheduled Imports', 'penci-podcast' ), 'test' => [ $this, 'test_action_scheduler_jobs' ], ]; return $tests; } public function test_action_scheduler_jobs(): array { $default = [ 'description' => '

    ' . sprintf( __( "%s runs the imports using the action scheduler.", 'penci-podcast' ), PENCI_PODCAST_IMPORTER_NAME ) . '

    ', 'test' => PENCI_PODCAST_IMPORTER_ALIAS . '_test_scheduler', ]; if( Helper_Scheduler::is_everything_scheduled() ) return [ 'label' => sprintf( __( "%s - All Actions Scheduled.", 'penci-podcast' ), PENCI_PODCAST_IMPORTER_NAME ), 'status' => 'good', 'badge' => [ 'label' => __( 'Performance', 'penci-podcast' ), 'color' => 'green', ], ] + $default; return [ 'label' => sprintf( __( "%s - Missing Actions in schedule.", 'penci-podcast' ), PENCI_PODCAST_IMPORTER_NAME ), 'status' => 'performance', 'badge' => [ 'label' => __( 'Performance', 'penci-podcast' ), 'color' => 'red', ], 'actions' => sprintf( '

    %s

    ', esc_url( admin_url( '?' . PENCI_PODCAST_IMPORTER_ALIAS . '-action=reset-scheduled-posts' ) ), __( "Reset Schedules", 'penci-podcast' ) ) ] + $default; } }inc/importer/app/Settings.php000064400000002210147600053410012242 0ustar00 [], '_did_migration' => '0.0.0' ]; public $settings = []; public function __construct() { $this->settings = get_option( PENCI_PODCAST_IMPORTER_ALIAS . '_settings', [] ); } public function get( $key, $default_value = null ) { if( isset( $this->settings[ $key ] ) ) return $this->settings[ $key ]; if( $default_value !== null ) return $default_value; return ( $this->_default_settings[$key] ?? null ); } public function update( $key, $value ) { if( isset( $this->_default_settings[ $key ] ) && $this->_default_settings[ $key ] === $value ) unset( $this->settings[ $key ] ); else $this->settings[ $key ] = $value; update_option( PENCI_PODCAST_IMPORTER_ALIAS . '_settings', $this->settings ); } }inc/importer/app/Controller.php000064400000001723147600053410012575 0ustar00%s does not exist.', $located ), '1.0.0' ); return; } // Allow 3rd party plugin filter template file from their plugin $located = apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_get_template', $located, $template_name, $args, $template_path, $default_path ); do_action( PENCI_PODCAST_IMPORTER_ALIAS . '_before_template_part', $template_name, $template_path, $located, $args ); include( $located ); do_action( PENCI_PODCAST_IMPORTER_ALIAS . '_after_template_part', $template_name, $template_path, $located, $args ); } public static function locate_template( $template_name, $template_path = '', $default_path = '' ) { if ( ! $template_path ) $template_path = self::template_path(); if ( ! $default_path ) $default_path = PENCI_PODCAST_IMPORTER_BASE_PATH . '/templates/'; $template = locate_template( [ trailingslashit( $template_path ) . $template_name ] ); // Get default template if ( ! $template ) $template = $default_path . $template_name; // Return what we found return apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_locate_template', $template, $template_name, $template_path ); } public static function template_path() { return apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_template_path', PENCI_PODCAST_IMPORTER_ALIAS . '/' ); } } inc/importer/assets/css/admin.css000064400000023707147600053410013063 0ustar00.pencipdc-importer .pencipdc_import_buttons_container { display: flex; align-content: center; align-items: center } .pencipdc-importer .pencipdc_import_buttons_container > a { margin: 0 0 0 5px } .pencipdc-importer .pencipdc_import_buttons_container > a:first-child { margin: 0 0 0 auto; min-width: 5rem; text-align: center; } .pencipdc-importer > h1 { display: flex; align-content: flex-start } .pencipdc-importer > h1 > a { margin: 0 0 0 auto } .pencipdc-importer .nav-tab-wrapper { margin: 0 0 10px 0 } .pencipdc-importer .wp-list-table td { vertical-align: middle; } .pencipdc-importer .main-container-pencipdc { padding: 20px 25px; background: #fff; border-radius: 5px; display: flex; align-items: flex-start; } .pencipdc-importer .upgrade-cta { width: 340px; max-width: 100%; text-align: center; background: #f0f0f1; border-radius: 5px; padding: 20px 40px; border: 2px solid #2271b1; } .pencipdc-importer .upgrade-cta h3 { display: block; } .pencipdc-importer .pencipdc_import_form { width: 100%; } .pencipdc-importer .pencipdc_import_form > .pis-application-loader-progress-bar { width: 100%; max-width: 70%; height: 82px; margin: 65px auto; background-color: #f7f7f7; outline: 1px solid gainsboro; box-shadow: 0 2px 6px rgb(0 0 0 / 20%); position: relative; border-radius: 5px; } .pencipdc-importer .pencipdc_import_form > .pis-application-loader-progress-bar > .pis-application-loader-progress-bar-background { width: 1%; height: 82px; background-color: #72b7e0; transition: width 0.3s cubic-bezier(0, .96, 0, .96); } .pencipdc-importer .pencipdc_import_form > .pis-application-loader-progress-bar > p { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; max-width: 100%; } .pencipdc-importer .pencipdc_import_form > .pis-application-loader-progress-bar > .pis-application-loader-wrapper { position: absolute; top: 5px; left: 20px; } .pencipdc-importer .pencipdc_import_form > .pis-application-loader-progress-bar > .pis-application-loader-wrapper div { border-left-color: #fff !important; } .pencipdc-importer .pencipdc_import_form > .pencipdc_import_wrapper { width: 70%; } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row { display: block; margin: 0 0 20px 0; } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row > label { display: block; font-size: 14px; font-weight: 500; margin: 0 0 4px 0; } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row > select, .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row input:not([type="checkbox"]) { max-width: 90%; width: 30rem; } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row.pencipdc_import_field_row-checkbox > label { width: 100%; } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row .pencipdc_import_field_description { margin-top: 3px; width: auto; } .pencipdc-importer .pencipdc_import_form .pencipdc_import_advanced_settings_container .pencipdc_import_advanced_settings_toggle { cursor: pointer; display: flex; align-content: center; align-items: center } .pencipdc-importer .pencipdc_import_form .pencipdc_import_advanced_settings_container .pencipdc_import_advanced_settings_toggle > i { border: solid black; border-width: 0 3px 3px 0; display: inline-block; padding: 3px; margin: 0 10px; transform: rotate(-45deg); -webkit-transform: rotate(-45deg) } .pencipdc-importer .pencipdc_import_form .pencipdc_import_advanced_settings_container .pencipdc_import_advanced_settings_toggle.active > i { transform: rotate(45deg); -webkit-transform: rotate(45deg) } .pencipdc-importer .pencipdc_import_form .pencipdc_import_advanced_settings_container .pencipdc_import_advanced_settings { display: none } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row.pencipdc_import_field_row-multiple_select { align-content: flex-start; align-items: flex-start } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_media_image_handler { display: flex; flex-direction: column } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_media_image_handler > img { max-width: 300px; margin: 0; padding: 0 } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_media_image_handler .button-primary { margin: 0 auto 0 0 } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_media_image_handler .button-secondary { margin: 10px auto 0 0 } .pencipdc-importer .pencipdc_import_form .pencipdc_import_advanced_settings > h3 { font-size: 20px; margin: 0 0 10px 0 } .pencipdc-importer .pencipdc_import_form > .button.button-primary { padding: 12px 36px; height: auto; line-height: 1.4285714; font-size: 14px; min-height: 46px; white-space: normal; } @media screen and (max-width: 767px) { .upgrade-cta { display: none; } .pencipdc-importer .pencipdc_import_form { width: 100%; } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row { flex-direction: column; align-content: flex-start; align-items: flex-start } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row > label { width: 100%; margin: 0 0 10px 0 } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row > select, .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row input:not([type="checkbox"]) { width: 100%; max-width: 100% } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row.pencipdc_import_field_row-checkbox { margin: 0 0 10px 0 } .pencipdc-importer .pencipdc_import_form .pencipdc_import_field_row .pencipdc_import_field_description { margin: 10px 0 0 0; width: 100% } } .pencipdc-importer [data-pencipdc-import-notification] { border: none; padding: 20px; display: block; letter-spacing: 0; position: relative; text-decoration: none; font-size: 16px; margin: 10px 0; font-weight: 500; text-align: center; } .pencipdc-importer [data-pencipdc-import-notification] > p { margin: 0; padding: 0 } .pencipdc-importer [data-pencipdc-import-notification] a { margin: 0; padding: 0; border: none; cursor: pointer; text-decoration: underline } .pencipdc-importer [data-pencipdc-import-notification] a:hover { border: none } .pencipdc-importer [data-pencipdc-import-notification]:after { clear: both; content: ""; display: block } .pencipdc-importer [data-pencipdc-import-notification][data-pencipdc-import-notification="danger"] { color: #F44336; background: rgba(244, 67, 54, 0.05) } .pencipdc-importer [data-pencipdc-import-notification][data-pencipdc-import-notification="danger"] a, .pencipdc-importer [data-pencipdc-import-notification][data-pencipdc-import-notification="danger"] span { color: #F44336 } .pencipdc-importer [data-pencipdc-import-notification][data-pencipdc-import-notification="success"] { color: #2BBF16; background: rgba(43, 191, 22, 0.05) } .pencipdc-importer [data-pencipdc-import-notification][data-pencipdc-import-notification="success"] a, .pencipdc-importer [data-pencipdc-import-notification][data-pencipdc-import-notification="success"] span { color: #2BBF16 } .pencipdc-importer [data-pencipdc-import-notification][data-pencipdc-import-notification="progress"] { color: #72b7e0; background: rgba(114, 183, 224, 0.05); } @keyframes pencipdc_importer_application_loader_rotate_kf { 0% { transform: rotate(0deg) } 50% { transform: rotate(180deg) } 100% { transform: rotate(360deg) } } .pencipdc-importer .pis-application-loader-wrapper { box-sizing: border-box; position: relative; margin: 50px auto; width: 150px; height: 150px; display: block; overflow: hidden; will-change: transform } .pencipdc-importer .pis-application-loader-wrapper div { box-sizing: border-box; will-change: transform; height: 100%; box-sizing: border-box } .pencipdc-importer .pis-application-loader-wrapper[data-pis-loader-type="mini"] { margin: 5px auto; width: 62px; height: 62px; } .pencipdc-importer .pis-application-loader-wrapper[data-pis-loader-type="mini"], .pencipdc-importer .pis-application-loader-wrapper div { border-radius: 50%; padding: 8px; border: 2px solid transparent; animation: pencipdc_importer_application_loader_rotate_kf linear 3.5s infinite; border-top-color: #2f61cc; border-left-color: #72b7e0; animation-timing-function: cubic-bezier(0.55, 0.38, 0.21, 0.88); animation-duration: 3s } .pencipdc-importer .pis-application-loader-wrapper[data-pis-loader-type="mini"], .pencipdc-importer .pis-application-loader-wrapper[data-pis-loader-type="mini"] div { padding: 2px } .pencipdc-importer .pis-application-loader-wrapper:hover, .pencipdc-importer .pis-application-loader-wrapper div:hover { animation-play-state: paused } .pencipdc-importer .pencipdc_import_buttons_container .button-secondary.button-delete { color: #d72b3f; border-color: #d72b3f; } input#pci_pro_license_key { margin-right: 1rem; } a.tagline-powered-by { font-size: 13px; font-style: italic; display: block; padding: 5px 0 0 0 !important; } .pencipdc-importer > [data-pencipdc-import-notification="info"] { padding: 0; margin: 25px 0; text-align: left; } .upgrade-cta h2 { margin: 0; } .upgrade-cta h5 { margin: 8px 0 0 0; font-size: 12px; font-style: italic; } .upgrade-cta ul, .upgrade-pencipdc ul { text-align: left; list-style: disc; } .upgrade-pencipdc { padding: 0 20px; } .pencipdc-importer .button.pencipdc_upgrade_cta { padding: 12px 36px; height: auto; line-height: 1.4285714; font-size: 14px; min-height: 46px; white-space: normal; }inc/importer/assets/js/admin.js000064400000035150147600053410012526 0ustar00let PenciPodcastImporter = {}; PenciPodcastImporter.API = { post : function( path, request_data, callback ) { return this.__request( path, 'POST', request_data, callback ); }, fetch : function( action, request_data, callback ) { return this.__request( action, 'GET', request_data, callback ); }, __request : function( path, method, request_data, callback ) { return jQuery.ajax( { url : window.podcast_import_settings.rest_url + path, method : method, beforeSend : function ( xhr ) { xhr.setRequestHeader( 'X-WP-Nonce', window.podcast_import_settings.rest_nonce ); }, data : request_data } ).done( function ( response, statusText, xhr ) { callback( response ); } ).fail( function( $xhr ) { callback( $xhr.responseJSON ); }); }, }; PenciPodcastImporter.Submission = { handle_import : function( request_data, callback_completed, callback_progress ) { PenciPodcastImporter.API.post( "pencipdc-importer/v1/get-feed-summary", request_data, function( response ) { if( typeof response.episode_count === 'undefined' ) { callback_completed( response ); return; } if( typeof request_data.post_id !== 'undefined' || ( typeof request_data.import_continuous !== 'undefined' && request_data.import_continuous === 'on' ) ) { PenciPodcastImporter.API.post( "pencipdc-importer/v1/save-feed", request_data, function( response_save ) { callback_progress( response_save.messages, false, 0, response.episode_count ); PenciPodcastImporter.Submission._handleImportRecursion( request_data, response.episode_count, 0, callback_completed, callback_progress ); }); } else { PenciPodcastImporter.Submission._handleImportRecursion( request_data, response.episode_count, 0, callback_completed, callback_progress ); } } ); }, _handleImportRecursion : function( request_data, episode_count, episode_offset, callback_completed, callback_progress ) { PenciPodcastImporter.API.post( "pencipdc-importer/v1/import-feed", jQuery.extend( true, { episode_offset : episode_offset, episode_limit : window.podcast_import_settings.import_limit }, request_data ), function( response ) { if( episode_count < episode_offset + parseInt( window.podcast_import_settings.import_limit ) ) { callback_completed( response ); } else { callback_progress( response.messages, response.summary, episode_offset + parseInt( window.podcast_import_settings.import_limit ), episode_count ); PenciPodcastImporter.Submission._handleImportRecursion( request_data, episode_count, episode_offset + parseInt( window.podcast_import_settings.import_limit ), callback_completed, callback_progress ); } } ); } }; function pencipdc_importer_element_loader( type ) { let response = ''; response += '
    '; if( type === 'mini' ) { response += '
    '; } else { response += '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    '; } response += '
    '; return response; } jQuery(document).ready( function() { jQuery( "#podtcast-importer-pencipdc-dismissible" ).on( "click", ".notice-dismiss", function( event ) { event.preventDefault(); event.stopImmediatePropagation(); PenciPodcastImporter.API.post( "pencipdc-importer/v1/admin-dismiss-notice", {}, function() {} ); }); jQuery( "[data-pencipdc-import-rest-api-request]" ).off( "click" ).on( "click", function() { let request_path = jQuery(this).attr( 'data-pencipdc-import-rest-api-request' ), trigger = jQuery(this), trigger_text = trigger.html(); trigger.attr( "disabled", "disabled" ).html( pencipdc_importer_element_loader( "mini" ) ); PenciPodcastImporter.API.post( request_path, {}, function( response ) { if ( typeof trigger.attr( "data-pencipdc-import-success-message" ) !== 'undefined' ) trigger.html( trigger.attr( "data-pencipdc-import-success-message" ) ); else trigger.html( trigger_text ); }); }); jQuery( '.pencipdc_import_form' ).each( function() { let formObject = jQuery(this), summaryTotalData = {}, notificationsContainerObject = formObject.find( ".pencipdc_import_notifications" ), wrapperContainerObject = formObject.find( '.pencipdc_import_wrapper' ), _attachSummaryTotalData = function( notificationsContainerObject, summary, display_notifications ) { if( summary === false ) return; jQuery.each( summary, function( _k, _v ) { if( typeof summaryTotalData[ _k ] === 'undefined' ) summaryTotalData[ _k ] = parseInt( _v ); else if( _k !== 'episode_count' ) summaryTotalData[ _k ] += parseInt( _v ); }); if( !display_notifications ) return; let message_html = ''; if( summaryTotalData.current_import === 0 && summaryTotalData.episode_count !== 0) { if( summaryTotalData.synced_count !== 0 ) { if( summaryTotalData.skipped_count !== 0 ) { message_html = '
    ' + window.podcast_import_settings.lang_import_summary_progress_with_skips.replace( "%s", summaryTotalData.synced_count ).replace( "%s", summaryTotalData.skipped_count ) + '
    '; } else { message_html = '
    ' + window.podcast_import_settings.lang_import_summary_progress.replace( "%s", summaryTotalData.synced_count ) + '
    '; } } else { if( parseInt( summaryTotalData.skipped_count ) !== 0 ) { message_html = '
    ' + window.podcast_import_settings.lang_import_summary_progress_skips.replace( "%s", summaryTotalData.skipped_count ) + '
    '; } else { message_html = '
    ' + window.podcast_import_settings.lang_import_summary_no_imports + '
    '; } } } else if ( summaryTotalData.episode_count === 0 ) { // No episodes existing within feed. message_html = '
    ' + window.podcast_import_settings.lang_import_summary_no_episodes + '
    '; } else { message_html = '
    ' + window.podcast_import_settings.lang_import_summary_success.replace( "%s", summaryTotalData.current_import ).replace( "%s", summaryTotalData.episode_count ) + ( summaryTotalData.synced_count !== 0 ? window.podcast_import_settings.lang_import_summary_success_resynced.replace( "%s", summaryTotalData.synced_count ) : '' ) + '
    '; } notificationsContainerObject.find( '.pencipdc_import_summary' ).remove(); notificationsContainerObject.append( message_html ); }; formObject.find( '[data-pencipdc-conditional-display]' ).each( function() { let conditionalDisplayContainer = jQuery(this), attr = jQuery(this).attr( 'data-pencipdc-conditional-display' ), target = attr.substr( 0, attr.indexOf( ":" ) ), allow_list = attr.substr( attr.indexOf( ":" ) + 1 ).split( ',' ), val = ( formObject.find( target ).is( ':checkbox' ) ? ( formObject.find( target ).is(':checked') ? '1' : '0' ) : formObject.find( target ).val() ); if( !allow_list.includes( val ) ) conditionalDisplayContainer.hide(); if (!attr || !val) conditionalDisplayContainer.show(); formObject.find( target ).on( "change", function() { if( !allow_list.includes( ( jQuery(this).is( ':checkbox' ) ? ( jQuery(this).is(':checked') ? '1' : '0' ) : jQuery(this).val() ) ) ) conditionalDisplayContainer.hide(); else conditionalDisplayContainer.show(); }); }); formObject.find( '.pencipdc_import_advanced_settings_toggle' ).on( "click", function() { if( jQuery(this).hasClass( "active" ) ) { jQuery(this).parent().find( ' > .pencipdc_import_advanced_settings' ).slideUp( "slow" ); jQuery(this).removeClass( "active" ); } else { jQuery(this).parent().find( ' > .pencipdc_import_advanced_settings' ).slideDown( "slow" ); jQuery(this).addClass( "active" ); } }); formObject.find( '.pencipdc_import_field_media_image_handler .button-primary' ).on( "click", function( event ) { event.preventDefault(); event.stopImmediatePropagation(); let image_container = jQuery(this).parents( '.pencipdc_import_field_media_image_handler:first' ); let image = wp.media({ title: 'Upload Image File', multiple: false }).open().on('select', function(e){ let uploaded_file = image.state().get('selection').first(); if( typeof uploaded_file.toJSON().id === 'undefined' ) { alert( "Missing Image ID, it needs to be uploaded on the server" ); return; } image_container.find( 'input[type="hidden"]' ).val( uploaded_file.toJSON().id ); if( image_container.find( " img " ).length !== 0 ) image_container.find( " img " ).attr( 'src', uploaded_file.toJSON().url ); else image_container.prepend( '' ); image_container.find( '.button-secondary' ).show(); }); }); formObject.find( '.pencipdc_import_field_media_image_handler .button-secondary' ).on( "click", function( event ) { event.preventDefault(); event.stopImmediatePropagation(); let image_handler = jQuery(this).parents( '.pencipdc_import_field_media_image_handler:first' ); image_handler.find( '.button-secondary' ).hide(); image_handler.find( 'img' ).remove(); image_handler.find( 'input[type="hidden"]' ).val( '' ); }); formObject.on( "submit", function( event ) { event.preventDefault(); event.stopImmediatePropagation(); notificationsContainerObject.show(); notificationsContainerObject.find( '[data-pencipdc-import-notification]' ).remove(); let request_data = {}; // Hidden inputs are defaults for the checkboxes, PHP way of achieving it, and emulating it here. formObject.find( 'input:not([type="checkbox"]), select:not([multiple])' ).each( function() { request_data[ jQuery(this).attr( "name" ) ] = jQuery(this).val(); }); formObject.find( 'input[type="checkbox"]:checked' ).each( function() { request_data[ jQuery(this).attr( "name" ) ] = jQuery(this).val(); }); formObject.find( 'select[multiple]' ).each( function() { request_data[ jQuery(this).attr( "name" ).replace( '[]', '' ) ] = jQuery(this).val(); }); wrapperContainerObject.slideUp( "slow" ); formObject.prepend( pencipdc_importer_element_loader() ); summaryTotalData = {}; PenciPodcastImporter.Submission.handle_import( request_data, function( response ) { formObject.find( '.pis-application-loader-wrapper' ).remove(); formObject.find( '.pis-application-loader-progress-bar' ).remove(); if( typeof response === 'undefined' ) { notificationsContainerObject.prepend( '
    Server Error
    '); } else if( typeof response.data !== 'undefined' && ( response.data.status > 400 || response.data.status < 300 ) ) { notificationsContainerObject.prepend( '
    ' + response.message + '
    '); } else if( typeof response.message !== 'undefined' ) { notificationsContainerObject.prepend( '
    ' + response.message + '
    '); } if( typeof response.messages !== 'undefined' ) { jQuery.each( response.messages, function( k, message_data ) { notificationsContainerObject.prepend( '
    ' + message_data.message + '
    ' ); }); } _attachSummaryTotalData( notificationsContainerObject, response.summary, true ); wrapperContainerObject.slideDown( "slow" ); }, function( messages, summary, processed_items, total_items ) { let loaderProgressBarObject = formObject.find( '.pis-application-loader-progress-bar' ), loader_message = window.podcast_import_settings.lang_import_progress.replace( '%s', processed_items ).replace( '%s', total_items ); if( loaderProgressBarObject.length === 0 ) { formObject.find( '.pis-application-loader-wrapper' ).before( '
    ' + '
    ' + pencipdc_importer_element_loader( 'mini' ) + '

    ' + '
    ' ); loaderProgressBarObject = formObject.find( '.pis-application-loader-progress-bar' ); } loaderProgressBarObject.find( ' > p' ).html( loader_message ); loaderProgressBarObject.find( ' > .pis-application-loader-progress-bar-background' ).css( 'width', '' + ( processed_items / total_items * 100 ) + '%' ); formObject.find( '.pis-application-loader-wrapper' ).not( '[data-pis-loader-type="mini"]' ).remove(); jQuery.each( messages, function( k, message_data ) { notificationsContainerObject.prepend( '
    ' + message_data.message + '
    ' ); }); _attachSummaryTotalData( notificationsContainerObject, summary, false ); } ); }); }); });inc/importer/lib/action-scheduler/classes/WP_CLI/Migration_Command.php000064400000011304147600053410021726 0ustar00 'Migrates actions to the DB tables store', 'synopsis' => [ [ 'type' => 'assoc', 'name' => 'batch-size', 'optional' => true, 'default' => 100, 'description' => 'The number of actions to process in each batch', ], [ 'type' => 'assoc', 'name' => 'free-memory-on', 'optional' => true, 'default' => 50, 'description' => 'The number of actions to process between freeing memory. 0 disables freeing memory', ], [ 'type' => 'assoc', 'name' => 'pause', 'optional' => true, 'default' => 0, 'description' => 'The number of seconds to pause when freeing memory', ], [ 'type' => 'flag', 'name' => 'dry-run', 'optional' => true, 'description' => 'Reports on the actions that would have been migrated, but does not change any data', ], ], ] ); } /** * Process the data migration. * * @param array $positional_args Required for WP CLI. Not used in migration. * @param array $assoc_args Optional arguments. * * @return void */ public function migrate( $positional_args, $assoc_args ) { $this->init_logging(); $config = $this->get_migration_config( $assoc_args ); $runner = new Runner( $config ); $runner->init_destination(); $batch_size = isset( $assoc_args[ 'batch-size' ] ) ? (int) $assoc_args[ 'batch-size' ] : 100; $free_on = isset( $assoc_args[ 'free-memory-on' ] ) ? (int) $assoc_args[ 'free-memory-on' ] : 50; $sleep = isset( $assoc_args[ 'pause' ] ) ? (int) $assoc_args[ 'pause' ] : 0; \ActionScheduler_DataController::set_free_ticks( $free_on ); \ActionScheduler_DataController::set_sleep_time( $sleep ); do { $actions_processed = $runner->run( $batch_size ); $this->total_processed += $actions_processed; } while ( $actions_processed > 0 ); if ( ! $config->get_dry_run() ) { // let the scheduler know that there's nothing left to do $scheduler = new Scheduler(); $scheduler->mark_complete(); } WP_CLI::success( sprintf( '%s complete. %d actions processed.', $config->get_dry_run() ? 'Dry run' : 'Migration', $this->total_processed ) ); } /** * Build the config object used to create the Runner * * @param array $args Optional arguments. * * @return ActionScheduler\Migration\Config */ private function get_migration_config( $args ) { $args = wp_parse_args( $args, [ 'dry-run' => false, ] ); $config = Controller::instance()->get_migration_config_object(); $config->set_dry_run( ! empty( $args[ 'dry-run' ] ) ); return $config; } /** * Hook command line logging into migration actions. */ private function init_logging() { add_action( 'action_scheduler/migrate_action_dry_run', function ( $action_id ) { WP_CLI::debug( sprintf( 'Dry-run: migrated action %d', $action_id ) ); }, 10, 1 ); add_action( 'action_scheduler/no_action_to_migrate', function ( $action_id ) { WP_CLI::debug( sprintf( 'No action found to migrate for ID %d', $action_id ) ); }, 10, 1 ); add_action( 'action_scheduler/migrate_action_failed', function ( $action_id ) { WP_CLI::warning( sprintf( 'Failed migrating action with ID %d', $action_id ) ); }, 10, 1 ); add_action( 'action_scheduler/migrate_action_incomplete', function ( $source_id, $destination_id ) { WP_CLI::warning( sprintf( 'Unable to remove source action with ID %d after migrating to new ID %d', $source_id, $destination_id ) ); }, 10, 2 ); add_action( 'action_scheduler/migrated_action', function ( $source_id, $destination_id ) { WP_CLI::debug( sprintf( 'Migrated source action with ID %d to new store with ID %d', $source_id, $destination_id ) ); }, 10, 2 ); add_action( 'action_scheduler/migration_batch_starting', function ( $batch ) { WP_CLI::debug( 'Beginning migration of batch: ' . print_r( $batch, true ) ); }, 10, 1 ); add_action( 'action_scheduler/migration_batch_complete', function ( $batch ) { WP_CLI::log( sprintf( 'Completed migration of %d actions', count( $batch ) ) ); }, 10, 1 ); } } inc/importer/lib/action-scheduler/classes/WP_CLI/ProgressBar.php000064400000004720147600053410020574 0ustar00total_ticks = 0; $this->message = $message; $this->count = $count; $this->interval = $interval; } /** * Increment the progress bar ticks. */ public function tick() { if ( null === $this->progress_bar ) { $this->setup_progress_bar(); } $this->progress_bar->tick(); $this->total_ticks++; do_action( 'action_scheduler/progress_tick', $this->total_ticks ); } /** * Get the progress bar tick count. * * @return int */ public function current() { return $this->progress_bar ? $this->progress_bar->current() : 0; } /** * Finish the current progress bar. */ public function finish() { if ( null !== $this->progress_bar ) { $this->progress_bar->finish(); } $this->progress_bar = null; } /** * Set the message used when creating the progress bar. * * @param string $message The message to be used when the next progress bar is created. */ public function set_message( $message ) { $this->message = $message; } /** * Set the count for a new progress bar. * * @param integer $count The total number of ticks expected to complete. */ public function set_count( $count ) { $this->count = $count; $this->finish(); } /** * Set up the progress bar. */ protected function setup_progress_bar() { $this->progress_bar = \WP_CLI\Utils\make_progress_bar( $this->message, $this->count, $this->interval ); } } inc/importer/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php000064400000012007147600053410026046 0ustar00] * : The maximum number of actions to run. Defaults to 100. * * [--batches=] * : Limit execution to a number of batches. Defaults to 0, meaning batches will continue being executed until all actions are complete. * * [--cleanup-batch-size=] * : The maximum number of actions to clean up. Defaults to the value of --batch-size. * * [--hooks=] * : Only run actions with the specified hook. Omitting this option runs actions with any hook. Define multiple hooks as a comma separated string (without spaces), e.g. `--hooks=hook_one,hook_two,hook_three` * * [--group=] * : Only run actions from the specified group. Omitting this option runs actions from all groups. * * [--free-memory-on=] * : The number of actions to process between freeing memory. 0 disables freeing memory. Default 50. * * [--pause=] * : The number of seconds to pause when freeing memory. Default no pause. * * [--force] * : Whether to force execution despite the maximum number of concurrent processes being exceeded. * * @param array $args Positional arguments. * @param array $assoc_args Keyed arguments. * @throws \WP_CLI\ExitException When an error occurs. * * @subcommand run */ public function run( $args, $assoc_args ) { // Handle passed arguments. $batch = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batch-size', 100 ) ); $batches = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batches', 0 ) ); $clean = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'cleanup-batch-size', $batch ) ); $hooks = explode( ',', WP_CLI\Utils\get_flag_value( $assoc_args, 'hooks', '' ) ); $hooks = array_filter( array_map( 'trim', $hooks ) ); $group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'group', '' ); $free_on = \WP_CLI\Utils\get_flag_value( $assoc_args, 'free-memory-on', 50 ); $sleep = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pause', 0 ); $force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force', false ); ActionScheduler_DataController::set_free_ticks( $free_on ); ActionScheduler_DataController::set_sleep_time( $sleep ); $batches_completed = 0; $actions_completed = 0; $unlimited = $batches === 0; try { // Custom queue cleaner instance. $cleaner = new ActionScheduler_QueueCleaner( null, $clean ); // Get the queue runner instance $runner = new ActionScheduler_WPCLI_QueueRunner( null, null, $cleaner ); // Determine how many tasks will be run in the first batch. $total = $runner->setup( $batch, $hooks, $group, $force ); // Run actions for as long as possible. while ( $total > 0 ) { $this->print_total_actions( $total ); $actions_completed += $runner->run(); $batches_completed++; // Maybe set up tasks for the next batch. $total = ( $unlimited || $batches_completed < $batches ) ? $runner->setup( $batch, $hooks, $group, $force ) : 0; } } catch ( Exception $e ) { $this->print_error( $e ); } $this->print_total_batches( $batches_completed ); $this->print_success( $actions_completed ); } /** * Print WP CLI message about how many actions are about to be processed. * * @author Jeremy Pry * * @param int $total */ protected function print_total_actions( $total ) { WP_CLI::log( sprintf( /* translators: %d refers to how many scheduled taks were found to run */ _n( 'Found %d scheduled task', 'Found %d scheduled tasks', $total, 'action-scheduler' ), number_format_i18n( $total ) ) ); } /** * Print WP CLI message about how many batches of actions were processed. * * @author Jeremy Pry * * @param int $batches_completed */ protected function print_total_batches( $batches_completed ) { WP_CLI::log( sprintf( /* translators: %d refers to the total number of batches executed */ _n( '%d batch executed.', '%d batches executed.', $batches_completed, 'action-scheduler' ), number_format_i18n( $batches_completed ) ) ); } /** * Convert an exception into a WP CLI error. * * @author Jeremy Pry * * @param Exception $e The error object. * * @throws \WP_CLI\ExitException */ protected function print_error( Exception $e ) { WP_CLI::error( sprintf( /* translators: %s refers to the exception error message */ __( 'There was an error running the action scheduler: %s', 'action-scheduler' ), $e->getMessage() ) ); } /** * Print a success message with the number of completed actions. * * @author Jeremy Pry * * @param int $actions_completed */ protected function print_success( $actions_completed ) { WP_CLI::success( sprintf( /* translators: %d refers to the total number of taskes completed */ _n( '%d scheduled task completed.', '%d scheduled tasks completed.', $actions_completed, 'action-scheduler' ), number_format_i18n( $actions_completed ) ) ); } } inc/importer/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php000064400000014245147600053410024716 0ustar00run_cleanup(); $this->add_hooks(); // Check to make sure there aren't too many concurrent processes running. if ( $this->has_maximum_concurrent_batches() ) { if ( $force ) { WP_CLI::warning( __( 'There are too many concurrent batches, but the run is forced to continue.', 'action-scheduler' ) ); } else { WP_CLI::error( __( 'There are too many concurrent batches.', 'action-scheduler' ) ); } } // Stake a claim and store it. $this->claim = $this->store->stake_claim( $batch_size, null, $hooks, $group ); $this->monitor->attach( $this->claim ); $this->actions = $this->claim->get_actions(); return count( $this->actions ); } /** * Add our hooks to the appropriate actions. * * @author Jeremy Pry */ protected function add_hooks() { add_action( 'action_scheduler_before_execute', array( $this, 'before_execute' ) ); add_action( 'action_scheduler_after_execute', array( $this, 'after_execute' ), 10, 2 ); add_action( 'action_scheduler_failed_execution', array( $this, 'action_failed' ), 10, 2 ); } /** * Set up the WP CLI progress bar. * * @author Jeremy Pry */ protected function setup_progress_bar() { $count = count( $this->actions ); $this->progress_bar = new ProgressBar( /* translators: %d: amount of actions */ sprintf( _n( 'Running %d action', 'Running %d actions', $count, 'action-scheduler' ), number_format_i18n( $count ) ), $count ); } /** * Process actions in the queue. * * @author Jeremy Pry * * @param string $context Optional runner context. Default 'WP CLI'. * * @return int The number of actions processed. */ public function run( $context = 'WP CLI' ) { do_action( 'action_scheduler_before_process_queue' ); $this->setup_progress_bar(); foreach ( $this->actions as $action_id ) { // Error if we lost the claim. if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $this->claim->get_id() ) ) ) { WP_CLI::warning( __( 'The claim has been lost. Aborting current batch.', 'action-scheduler' ) ); break; } $this->process_action( $action_id, $context ); $this->progress_bar->tick(); } $completed = $this->progress_bar->current(); $this->progress_bar->finish(); $this->store->release_claim( $this->claim ); do_action( 'action_scheduler_after_process_queue' ); return $completed; } /** * Handle WP CLI message when the action is starting. * * @author Jeremy Pry * * @param $action_id */ public function before_execute( $action_id ) { /* translators: %s refers to the action ID */ WP_CLI::log( sprintf( __( 'Started processing action %s', 'action-scheduler' ), $action_id ) ); } /** * Handle WP CLI message when the action has completed. * * @author Jeremy Pry * * @param int $action_id * @param null|ActionScheduler_Action $action The instance of the action. Default to null for backward compatibility. */ public function after_execute( $action_id, $action = null ) { // backward compatibility if ( null === $action ) { $action = $this->store->fetch_action( $action_id ); } /* translators: 1: action ID 2: hook name */ WP_CLI::log( sprintf( __( 'Completed processing action %1$s with hook: %2$s', 'action-scheduler' ), $action_id, $action->get_hook() ) ); } /** * Handle WP CLI message when the action has failed. * * @author Jeremy Pry * * @param int $action_id * @param Exception $exception * @throws \WP_CLI\ExitException With failure message. */ public function action_failed( $action_id, $exception ) { WP_CLI::error( /* translators: 1: action ID 2: exception message */ sprintf( __( 'Error processing action %1$s: %2$s', 'action-scheduler' ), $action_id, $exception->getMessage() ), false ); } /** * Sleep and help avoid hitting memory limit * * @param int $sleep_time Amount of seconds to sleep * @deprecated 3.0.0 */ protected function stop_the_insanity( $sleep_time = 0 ) { _deprecated_function( 'ActionScheduler_WPCLI_QueueRunner::stop_the_insanity', '3.0.0', 'ActionScheduler_DataController::free_memory' ); ActionScheduler_DataController::free_memory(); } /** * Maybe trigger the stop_the_insanity() method to free up memory. */ protected function maybe_stop_the_insanity() { // The value returned by progress_bar->current() might be padded. Remove padding, and convert to int. $current_iteration = intval( trim( $this->progress_bar->current() ) ); if ( 0 === $current_iteration % 50 ) { $this->stop_the_insanity(); } } } inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php000064400000006146147600053410027714 0ustar00start - and logic to calculate the next run date after * that - @see $this->calculate_next(). The $first_date property also keeps a record of when the very * first instance of this chain of schedules ran. * * @var DateTime */ private $first_date = NULL; /** * Timestamp equivalent of @see $this->first_date * * @var int */ protected $first_timestamp = NULL; /** * The recurrance between each time an action is run using this schedule. * Used to calculate the start date & time. Can be a number of seconds, in the * case of ActionScheduler_IntervalSchedule, or a cron expression, as in the * case of ActionScheduler_CronSchedule. Or something else. * * @var mixed */ protected $recurrence; /** * @param DateTime $date The date & time to run the action. * @param mixed $recurrence The data used to determine the schedule's recurrance. * @param DateTime|null $first (Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance. */ public function __construct( DateTime $date, $recurrence, DateTime $first = null ) { parent::__construct( $date ); $this->first_date = empty( $first ) ? $date : $first; $this->recurrence = $recurrence; } /** * @return bool */ public function is_recurring() { return true; } /** * Get the date & time of the first schedule in this recurring series. * * @return DateTime|null */ public function get_first_date() { return clone $this->first_date; } /** * @return string */ public function get_recurrence() { return $this->recurrence; } /** * For PHP 5.2 compat, since DateTime objects can't be serialized * @return array */ public function __sleep() { $sleep_params = parent::__sleep(); $this->first_timestamp = $this->first_date->getTimestamp(); return array_merge( $sleep_params, array( 'first_timestamp', 'recurrence' ) ); } /** * Unserialize recurring schedules serialized/stored prior to AS 3.0.0 * * Prior to Action Scheduler 3.0.0, schedules used different property names to refer * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp * was the same as ActionScheduler_SimpleSchedule::timestamp. This was addressed in * Action Scheduler 3.0.0, where properties and property names were aligned for better * inheritance. To maintain backward compatibility with scheduled serialized and stored * prior to 3.0, we need to correctly map the old property names. */ public function __wakeup() { parent::__wakeup(); if ( $this->first_timestamp > 0 ) { $this->first_date = as_get_datetime_object( $this->first_timestamp ); } else { $this->first_date = $this->get_date(); } } } inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Store.php000064400000030446147600053410023550 0ustar00 null, 'status' => self::STATUS_PENDING, 'group' => '', ) ); // These params are fixed for this method. $params['hook'] = $hook; $params['orderby'] = 'date'; $params['per_page'] = 1; if ( ! empty( $params['status'] ) ) { if ( self::STATUS_PENDING === $params['status'] ) { $params['order'] = 'ASC'; // Find the next action that matches. } else { $params['order'] = 'DESC'; // Find the most recent action that matches. } } $results = $this->query_actions( $params ); return empty( $results ) ? null : $results[0]; } /** * Query for action count or list of action IDs. * * @since x.x.x $query['status'] accepts array of statuses instead of a single status. * * @param array $query { * Query filtering options. * * @type string $hook The name of the actions. Optional. * @type string|array $status The status or statuses of the actions. Optional. * @type array $args The args array of the actions. Optional. * @type DateTime $date The scheduled date of the action. Used in UTC timezone. Optional. * @type string $date_compare Operator for selecting by $date param. Accepted values are '!=', '>', '>=', '<', '<=', '='. Defaults to '<='. * @type DateTime $modified The last modified date of the action. Used in UTC timezone. Optional. * @type string $modified_compare Operator for comparing $modified param. Accepted values are '!=', '>', '>=', '<', '<=', '='. Defaults to '<='. * @type string $group The group the action belongs to. Optional. * @type bool|int $claimed TRUE to find claimed actions, FALSE to find unclaimed actions, an int to find a specific claim ID. Optional. * @type int $per_page Number of results to return. Defaults to 5. * @type int $offset The query pagination offset. Defaults to 0. * @type int $orderby Accepted values are 'hook', 'group', 'modified', 'date' or 'none'. Defaults to 'date'. * @type string $order Accepted values are 'ASC' or 'DESC'. Defaults to 'ASC'. * } * @param string $query_type Whether to select or count the results. Default, select. * * @return string|array|null The IDs of actions matching the query. Null on failure. */ abstract public function query_actions( $query = array(), $query_type = 'select' ); /** * Run query to get a single action ID. * * @since x.x.x * * @see ActionScheduler_Store::query_actions for $query arg usage but 'per_page' and 'offset' can't be used. * * @param array $query Query parameters. * * @return int|null */ public function query_action( $query ) { $query['per_page'] = 1; $query['offset'] = 0; $results = $this->query_actions( $query ); if ( empty( $results ) ) { return null; } else { return (int) $results[0]; } } /** * Get a count of all actions in the store, grouped by status * * @return array */ abstract public function action_counts(); /** * @param string $action_id */ abstract public function cancel_action( $action_id ); /** * @param string $action_id */ abstract public function delete_action( $action_id ); /** * @param string $action_id * * @return DateTime The date the action is schedule to run, or the date that it ran. */ abstract public function get_date( $action_id ); /** * @param int $max_actions * @param DateTime $before_date Claim only actions schedule before the given date. Defaults to now. * @param array $hooks Claim only actions with a hook or hooks. * @param string $group Claim only actions in the given group. * * @return ActionScheduler_ActionClaim */ abstract public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ); /** * @return int */ abstract public function get_claim_count(); /** * @param ActionScheduler_ActionClaim $claim */ abstract public function release_claim( ActionScheduler_ActionClaim $claim ); /** * @param string $action_id */ abstract public function unclaim_action( $action_id ); /** * @param string $action_id */ abstract public function mark_failure( $action_id ); /** * @param string $action_id */ abstract public function log_execution( $action_id ); /** * @param string $action_id */ abstract public function mark_complete( $action_id ); /** * @param string $action_id * * @return string */ abstract public function get_status( $action_id ); /** * @param string $action_id * @return mixed */ abstract public function get_claim_id( $action_id ); /** * @param string $claim_id * @return array */ abstract public function find_actions_by_claim_id( $claim_id ); /** * @param string $comparison_operator * @return string */ protected function validate_sql_comparator( $comparison_operator ) { if ( in_array( $comparison_operator, array('!=', '>', '>=', '<', '<=', '=') ) ) { return $comparison_operator; } return '='; } /** * Get the time MySQL formated date/time string for an action's (next) scheduled date. * * @param ActionScheduler_Action $action * @param DateTime $scheduled_date (optional) * @return string */ protected function get_scheduled_date_string( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) { $next = null === $scheduled_date ? $action->get_schedule()->get_date() : $scheduled_date; if ( ! $next ) { return '0000-00-00 00:00:00'; } $next->setTimezone( new DateTimeZone( 'UTC' ) ); return $next->format( 'Y-m-d H:i:s' ); } /** * Get the time MySQL formated date/time string for an action's (next) scheduled date. * * @param ActionScheduler_Action $action * @param DateTime $scheduled_date (optional) * @return string */ protected function get_scheduled_date_string_local( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) { $next = null === $scheduled_date ? $action->get_schedule()->get_date() : $scheduled_date; if ( ! $next ) { return '0000-00-00 00:00:00'; } ActionScheduler_TimezoneHelper::set_local_timezone( $next ); return $next->format( 'Y-m-d H:i:s' ); } /** * Validate that we could decode action arguments. * * @param mixed $args The decoded arguments. * @param int $action_id The action ID. * * @throws ActionScheduler_InvalidActionException When the decoded arguments are invalid. */ protected function validate_args( $args, $action_id ) { // Ensure we have an array of args. if ( ! is_array( $args ) ) { throw ActionScheduler_InvalidActionException::from_decoding_args( $action_id ); } // Validate JSON decoding if possible. if ( function_exists( 'json_last_error' ) && JSON_ERROR_NONE !== json_last_error() ) { throw ActionScheduler_InvalidActionException::from_decoding_args( $action_id, $args ); } } /** * Validate a ActionScheduler_Schedule object. * * @param mixed $schedule The unserialized ActionScheduler_Schedule object. * @param int $action_id The action ID. * * @throws ActionScheduler_InvalidActionException When the schedule is invalid. */ protected function validate_schedule( $schedule, $action_id ) { if ( empty( $schedule ) || ! is_a( $schedule, 'ActionScheduler_Schedule' ) ) { throw ActionScheduler_InvalidActionException::from_schedule( $action_id, $schedule ); } } /** * InnoDB indexes have a maximum size of 767 bytes by default, which is only 191 characters with utf8mb4. * * Previously, AS wasn't concerned about args length, as we used the (unindex) post_content column. However, * with custom tables, we use an indexed VARCHAR column instead. * * @param ActionScheduler_Action $action Action to be validated. * @throws InvalidArgumentException When json encoded args is too long. */ protected function validate_action( ActionScheduler_Action $action ) { if ( strlen( json_encode( $action->get_args() ) ) > static::$max_args_length ) { throw new InvalidArgumentException( sprintf( __( 'ActionScheduler_Action::$args too long. To ensure the args column can be indexed, action args should not be more than %d characters when encoded as JSON.', 'action-scheduler' ), static::$max_args_length ) ); } } /** * Cancel pending actions by hook. * * @since 3.0.0 * * @param string $hook Hook name. * * @return void */ public function cancel_actions_by_hook( $hook ) { $action_ids = true; while ( ! empty( $action_ids ) ) { $action_ids = $this->query_actions( array( 'hook' => $hook, 'status' => self::STATUS_PENDING, 'per_page' => 1000, 'orderby' => 'action_id', ) ); $this->bulk_cancel_actions( $action_ids ); } } /** * Cancel pending actions by group. * * @since 3.0.0 * * @param string $group Group slug. * * @return void */ public function cancel_actions_by_group( $group ) { $action_ids = true; while ( ! empty( $action_ids ) ) { $action_ids = $this->query_actions( array( 'group' => $group, 'status' => self::STATUS_PENDING, 'per_page' => 1000, 'orderby' => 'action_id', ) ); $this->bulk_cancel_actions( $action_ids ); } } /** * Cancel a set of action IDs. * * @since 3.0.0 * * @param array $action_ids List of action IDs. * * @return void */ private function bulk_cancel_actions( $action_ids ) { foreach ( $action_ids as $action_id ) { $this->cancel_action( $action_id ); } do_action( 'action_scheduler_bulk_cancel_actions', $action_ids ); } /** * @return array */ public function get_status_labels() { return array( self::STATUS_COMPLETE => __( 'Complete', 'action-scheduler' ), self::STATUS_PENDING => __( 'Pending', 'action-scheduler' ), self::STATUS_RUNNING => __( 'In-progress', 'action-scheduler' ), self::STATUS_FAILED => __( 'Failed', 'action-scheduler' ), self::STATUS_CANCELED => __( 'Canceled', 'action-scheduler' ), ); } /** * Check if there are any pending scheduled actions due to run. * * @param ActionScheduler_Action $action * @param DateTime $scheduled_date (optional) * @return string */ public function has_pending_actions_due() { $pending_actions = $this->query_actions( array( 'date' => as_get_datetime_object(), 'status' => ActionScheduler_Store::STATUS_PENDING, 'orderby' => 'none', ) ); return ! empty( $pending_actions ); } /** * Callable initialization function optionally overridden in derived classes. */ public function init() {} /** * Callable function to mark an action as migrated optionally overridden in derived classes. */ public function mark_migrated( $action_id ) {} /** * @return ActionScheduler_Store */ public static function instance() { if ( empty( self::$store ) ) { $class = apply_filters( 'action_scheduler_store_class', self::DEFAULT_CLASS ); self::$store = new $class(); } return self::$store; } } inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler.php000064400000021060147600053410022364 0ustar00init(); $store->init(); $logger->init(); $runner->init(); } if ( apply_filters( 'action_scheduler_load_deprecated_functions', true ) ) { require_once( self::plugin_path( 'deprecated/functions.php' ) ); } if ( defined( 'WP_CLI' ) && WP_CLI ) { WP_CLI::add_command( 'action-scheduler', 'ActionScheduler_WPCLI_Scheduler_command' ); if ( ! ActionScheduler_DataController::is_migration_complete() && Controller::instance()->allow_migration() ) { $command = new Migration_Command(); $command->register(); } } self::$data_store_initialized = true; /** * Handle WP comment cleanup after migration. */ if ( is_a( $logger, 'ActionScheduler_DBLogger' ) && ActionScheduler_DataController::is_migration_complete() && ActionScheduler_WPCommentCleaner::has_logs() ) { ActionScheduler_WPCommentCleaner::init(); } add_action( 'action_scheduler/migration_complete', 'ActionScheduler_WPCommentCleaner::maybe_schedule_cleanup' ); } /** * Check whether the AS data store has been initialized. * * @param string $function_name The name of the function being called. Optional. Default `null`. * @return bool */ public static function is_initialized( $function_name = null ) { if ( ! self::$data_store_initialized && ! empty( $function_name ) ) { $message = sprintf( __( '%s() was called before the Action Scheduler data store was initialized', 'action-scheduler' ), esc_attr( $function_name ) ); error_log( $message, E_WARNING ); } return self::$data_store_initialized; } /** * Determine if the class is one of our abstract classes. * * @since 3.0.0 * * @param string $class The class name. * * @return bool */ protected static function is_class_abstract( $class ) { static $abstracts = array( 'ActionScheduler' => true, 'ActionScheduler_Abstract_ListTable' => true, 'ActionScheduler_Abstract_QueueRunner' => true, 'ActionScheduler_Abstract_Schedule' => true, 'ActionScheduler_Abstract_RecurringSchedule' => true, 'ActionScheduler_Lock' => true, 'ActionScheduler_Logger' => true, 'ActionScheduler_Abstract_Schema' => true, 'ActionScheduler_Store' => true, 'ActionScheduler_TimezoneHelper' => true, ); return isset( $abstracts[ $class ] ) && $abstracts[ $class ]; } /** * Determine if the class is one of our migration classes. * * @since 3.0.0 * * @param string $class The class name. * * @return bool */ protected static function is_class_migration( $class ) { static $migration_segments = array( 'ActionMigrator' => true, 'BatchFetcher' => true, 'DBStoreMigrator' => true, 'DryRun' => true, 'LogMigrator' => true, 'Config' => true, 'Controller' => true, 'Runner' => true, 'Scheduler' => true, ); $segments = explode( '_', $class ); $segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class; return isset( $migration_segments[ $segment ] ) && $migration_segments[ $segment ]; } /** * Determine if the class is one of our WP CLI classes. * * @since 3.0.0 * * @param string $class The class name. * * @return bool */ protected static function is_class_cli( $class ) { static $cli_segments = array( 'QueueRunner' => true, 'Command' => true, 'ProgressBar' => true, ); $segments = explode( '_', $class ); $segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class; return isset( $cli_segments[ $segment ] ) && $cli_segments[ $segment ]; } final public function __clone() { trigger_error("Singleton. No cloning allowed!", E_USER_ERROR); } final public function __wakeup() { trigger_error("Singleton. No serialization allowed!", E_USER_ERROR); } final private function __construct() {} /** Deprecated **/ public static function get_datetime_object( $when = null, $timezone = 'UTC' ) { _deprecated_function( __METHOD__, '2.0', 'wcs_add_months()' ); return as_get_datetime_object( $when, $timezone ); } /** * Issue deprecated warning if an Action Scheduler function is called in the shutdown hook. * * @param string $function_name The name of the function being called. * @deprecated 3.1.6. */ public static function check_shutdown_hook( $function_name ) { _deprecated_function( __FUNCTION__, '3.1.6' ); } } inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_TimezoneHelper.php000064400000010476147600053410025407 0ustar00format( 'U' ) ); } if ( get_option( 'timezone_string' ) ) { $date->setTimezone( new DateTimeZone( self::get_local_timezone_string() ) ); } else { $date->setUtcOffset( self::get_local_timezone_offset() ); } return $date; } /** * Helper to retrieve the timezone string for a site until a WP core method exists * (see https://core.trac.wordpress.org/ticket/24730). * * Adapted from wc_timezone_string() and https://secure.php.net/manual/en/function.timezone-name-from-abbr.php#89155. * * If no timezone string is set, and its not possible to match the UTC offset set for the site to a timezone * string, then an empty string will be returned, and the UTC offset should be used to set a DateTime's * timezone. * * @since 2.1.0 * @return string PHP timezone string for the site or empty if no timezone string is available. */ protected static function get_local_timezone_string( $reset = false ) { // If site timezone string exists, return it. $timezone = get_option( 'timezone_string' ); if ( $timezone ) { return $timezone; } // Get UTC offset, if it isn't set then return UTC. $utc_offset = intval( get_option( 'gmt_offset', 0 ) ); if ( 0 === $utc_offset ) { return 'UTC'; } // Adjust UTC offset from hours to seconds. $utc_offset *= 3600; // Attempt to guess the timezone string from the UTC offset. $timezone = timezone_name_from_abbr( '', $utc_offset ); if ( $timezone ) { return $timezone; } // Last try, guess timezone string manually. foreach ( timezone_abbreviations_list() as $abbr ) { foreach ( $abbr as $city ) { if ( (bool) date( 'I' ) === (bool) $city['dst'] && $city['timezone_id'] && intval( $city['offset'] ) === $utc_offset ) { return $city['timezone_id']; } } } // No timezone string return ''; } /** * Get timezone offset in seconds. * * @since 2.1.0 * @return float */ protected static function get_local_timezone_offset() { $timezone = get_option( 'timezone_string' ); if ( $timezone ) { $timezone_object = new DateTimeZone( $timezone ); return $timezone_object->getOffset( new DateTime( 'now' ) ); } else { return floatval( get_option( 'gmt_offset', 0 ) ) * HOUR_IN_SECONDS; } } /** * @deprecated 2.1.0 */ public static function get_local_timezone( $reset = FALSE ) { _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); if ( $reset ) { self::$local_timezone = NULL; } if ( !isset(self::$local_timezone) ) { $tzstring = get_option('timezone_string'); if ( empty($tzstring) ) { $gmt_offset = get_option('gmt_offset'); if ( $gmt_offset == 0 ) { $tzstring = 'UTC'; } else { $gmt_offset *= HOUR_IN_SECONDS; $tzstring = timezone_name_from_abbr( '', $gmt_offset, 1 ); // If there's no timezone string, try again with no DST. if ( false === $tzstring ) { $tzstring = timezone_name_from_abbr( '', $gmt_offset, 0 ); } // Try mapping to the first abbreviation we can find. if ( false === $tzstring ) { $is_dst = date( 'I' ); foreach ( timezone_abbreviations_list() as $abbr ) { foreach ( $abbr as $city ) { if ( $city['dst'] == $is_dst && $city['offset'] == $gmt_offset ) { // If there's no valid timezone ID, keep looking. if ( null === $city['timezone_id'] ) { continue; } $tzstring = $city['timezone_id']; break 2; } } } } // If we still have no valid string, then fall back to UTC. if ( false === $tzstring ) { $tzstring = 'UTC'; } } } self::$local_timezone = new DateTimeZone($tzstring); } return self::$local_timezone; } } inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_Schema.php000064400000011041147600053410025465 0ustar00tables as $table ) { $wpdb->tables[] = $table; $name = $this->get_full_table_name( $table ); $wpdb->$table = $name; } // create the tables if ( $this->schema_update_required() || $force_update ) { foreach ( $this->tables as $table ) { /** * Allow custom processing before updating a table schema. * * @param string $table Name of table being updated. * @param string $db_version Existing version of the table being updated. */ do_action( 'action_scheduler_before_schema_update', $table, $this->db_version ); $this->update_table( $table ); } $this->mark_schema_update_complete(); } } /** * @param string $table The name of the table * * @return string The CREATE TABLE statement, suitable for passing to dbDelta */ abstract protected function get_table_definition( $table ); /** * Determine if the database schema is out of date * by comparing the integer found in $this->schema_version * with the option set in the WordPress options table * * @return bool */ private function schema_update_required() { $option_name = 'schema-' . static::class; $this->db_version = get_option( $option_name, 0 ); // Check for schema option stored by the Action Scheduler Custom Tables plugin in case site has migrated from that plugin with an older schema if ( 0 === $this->db_version ) { $plugin_option_name = 'schema-'; switch ( static::class ) { case 'ActionScheduler_StoreSchema' : $plugin_option_name .= 'Action_Scheduler\Custom_Tables\DB_Store_Table_Maker'; break; case 'ActionScheduler_LoggerSchema' : $plugin_option_name .= 'Action_Scheduler\Custom_Tables\DB_Logger_Table_Maker'; break; } $this->db_version = get_option( $plugin_option_name, 0 ); delete_option( $plugin_option_name ); } return version_compare( $this->db_version, $this->schema_version, '<' ); } /** * Update the option in WordPress to indicate that * our schema is now up to date * * @return void */ private function mark_schema_update_complete() { $option_name = 'schema-' . static::class; // work around race conditions and ensure that our option updates $value_to_save = (string) $this->schema_version . '.0.' . time(); update_option( $option_name, $value_to_save ); } /** * Update the schema for the given table * * @param string $table The name of the table to update * * @return void */ private function update_table( $table ) { require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); $definition = $this->get_table_definition( $table ); if ( $definition ) { $updated = dbDelta( $definition ); foreach ( $updated as $updated_table => $update_description ) { if ( strpos( $update_description, 'Created table' ) === 0 ) { do_action( 'action_scheduler/created_table', $updated_table, $table ); } } } } /** * @param string $table * * @return string The full name of the table, including the * table prefix for the current blog */ protected function get_full_table_name( $table ) { return $GLOBALS[ 'wpdb' ]->prefix . $table; } /** * Confirms that all of the tables registered by this schema class have been created. * * @return bool */ public function tables_exist() { global $wpdb; $existing_tables = $wpdb->get_col( 'SHOW TABLES' ); $expected_tables = array_map( function ( $table_name ) use ( $wpdb ) { return $wpdb->prefix . $table_name; }, $this->tables ); return count( array_intersect( $existing_tables, $expected_tables ) ) === count( $expected_tables ); } } inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php000064400000020013147600053410026542 0ustar00created_time = microtime( true ); $this->store = $store ? $store : ActionScheduler_Store::instance(); $this->monitor = $monitor ? $monitor : new ActionScheduler_FatalErrorMonitor( $this->store ); $this->cleaner = $cleaner ? $cleaner : new ActionScheduler_QueueCleaner( $this->store ); } /** * Process an individual action. * * @param int $action_id The action ID to process. * @param string $context Optional identifer for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' * Generally, this should be capitalised and not localised as it's a proper noun. */ public function process_action( $action_id, $context = '' ) { try { $valid_action = false; do_action( 'action_scheduler_before_execute', $action_id, $context ); if ( ActionScheduler_Store::STATUS_PENDING !== $this->store->get_status( $action_id ) ) { do_action( 'action_scheduler_execution_ignored', $action_id, $context ); return; } $valid_action = true; do_action( 'action_scheduler_begin_execute', $action_id, $context ); $action = $this->store->fetch_action( $action_id ); $this->store->log_execution( $action_id ); $action->execute(); do_action( 'action_scheduler_after_execute', $action_id, $action, $context ); $this->store->mark_complete( $action_id ); } catch ( Exception $e ) { if ( $valid_action ) { $this->store->mark_failure( $action_id ); do_action( 'action_scheduler_failed_execution', $action_id, $e, $context ); } else { do_action( 'action_scheduler_failed_validation', $action_id, $e, $context ); } } if ( isset( $action ) && is_a( $action, 'ActionScheduler_Action' ) && $action->get_schedule()->is_recurring() ) { $this->schedule_next_instance( $action, $action_id ); } } /** * Schedule the next instance of the action if necessary. * * @param ActionScheduler_Action $action * @param int $action_id */ protected function schedule_next_instance( ActionScheduler_Action $action, $action_id ) { try { ActionScheduler::factory()->repeat( $action ); } catch ( Exception $e ) { do_action( 'action_scheduler_failed_to_schedule_next_instance', $action_id, $e, $action ); } } /** * Run the queue cleaner. * * @author Jeremy Pry */ protected function run_cleanup() { $this->cleaner->clean( 10 * $this->get_time_limit() ); } /** * Get the number of concurrent batches a runner allows. * * @return int */ public function get_allowed_concurrent_batches() { return apply_filters( 'action_scheduler_queue_runner_concurrent_batches', 1 ); } /** * Check if the number of allowed concurrent batches is met or exceeded. * * @return bool */ public function has_maximum_concurrent_batches() { return $this->store->get_claim_count() >= $this->get_allowed_concurrent_batches(); } /** * Get the maximum number of seconds a batch can run for. * * @return int The number of seconds. */ protected function get_time_limit() { $time_limit = 30; // Apply deprecated filter from deprecated get_maximum_execution_time() method if ( has_filter( 'action_scheduler_maximum_execution_time' ) ) { _deprecated_function( 'action_scheduler_maximum_execution_time', '2.1.1', 'action_scheduler_queue_runner_time_limit' ); $time_limit = apply_filters( 'action_scheduler_maximum_execution_time', $time_limit ); } return absint( apply_filters( 'action_scheduler_queue_runner_time_limit', $time_limit ) ); } /** * Get the number of seconds the process has been running. * * @return int The number of seconds. */ protected function get_execution_time() { $execution_time = microtime( true ) - $this->created_time; // Get the CPU time if the hosting environment uses it rather than wall-clock time to calculate a process's execution time. if ( function_exists( 'getrusage' ) && apply_filters( 'action_scheduler_use_cpu_execution_time', defined( 'PANTHEON_ENVIRONMENT' ) ) ) { $resource_usages = getrusage(); if ( isset( $resource_usages['ru_stime.tv_usec'], $resource_usages['ru_stime.tv_usec'] ) ) { $execution_time = $resource_usages['ru_stime.tv_sec'] + ( $resource_usages['ru_stime.tv_usec'] / 1000000 ); } } return $execution_time; } /** * Check if the host's max execution time is (likely) to be exceeded if processing more actions. * * @param int $processed_actions The number of actions processed so far - used to determine the likelihood of exceeding the time limit if processing another action * @return bool */ protected function time_likely_to_be_exceeded( $processed_actions ) { $execution_time = $this->get_execution_time(); $max_execution_time = $this->get_time_limit(); $time_per_action = $execution_time / $processed_actions; $estimated_time = $execution_time + ( $time_per_action * 3 ); $likely_to_be_exceeded = $estimated_time > $max_execution_time; return apply_filters( 'action_scheduler_maximum_execution_time_likely_to_be_exceeded', $likely_to_be_exceeded, $this, $processed_actions, $execution_time, $max_execution_time ); } /** * Get memory limit * * Based on WP_Background_Process::get_memory_limit() * * @return int */ protected function get_memory_limit() { if ( function_exists( 'ini_get' ) ) { $memory_limit = ini_get( 'memory_limit' ); } else { $memory_limit = '128M'; // Sensible default, and minimum required by WooCommerce } if ( ! $memory_limit || -1 === $memory_limit || '-1' === $memory_limit ) { // Unlimited, set to 32GB. $memory_limit = '32G'; } return ActionScheduler_Compatibility::convert_hr_to_bytes( $memory_limit ); } /** * Memory exceeded * * Ensures the batch process never exceeds 90% of the maximum WordPress memory. * * Based on WP_Background_Process::memory_exceeded() * * @return bool */ protected function memory_exceeded() { $memory_limit = $this->get_memory_limit() * 0.90; $current_memory = memory_get_usage( true ); $memory_exceeded = $current_memory >= $memory_limit; return apply_filters( 'action_scheduler_memory_exceeded', $memory_exceeded, $this ); } /** * See if the batch limits have been exceeded, which is when memory usage is almost at * the maximum limit, or the time to process more actions will exceed the max time limit. * * Based on WC_Background_Process::batch_limits_exceeded() * * @param int $processed_actions The number of actions processed so far - used to determine the likelihood of exceeding the time limit if processing another action * @return bool */ protected function batch_limits_exceeded( $processed_actions ) { return $this->memory_exceeded() || $this->time_likely_to_be_exceeded( $processed_actions ); } /** * Process actions in the queue. * * @author Jeremy Pry * @param string $context Optional identifer for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' * Generally, this should be capitalised and not localised as it's a proper noun. * @return int The number of actions processed. */ abstract public function run( $context = '' ); } inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_ListTable.php000064400000047460147600053410026166 0ustar00 value pair. The * key must much the table column name and the value is the label, which is * automatically translated. */ protected $columns = array(); /** * Defines the row-actions. It expects an array where the key * is the column name and the value is an array of actions. * * The array of actions are key => value, where key is the method name * (with the prefix row_action_) and the value is the label * and title. */ protected $row_actions = array(); /** * The Primary key of our table */ protected $ID = 'ID'; /** * Enables sorting, it expects an array * of columns (the column names are the values) */ protected $sort_by = array(); protected $filter_by = array(); /** * @var array The status name => count combinations for this table's items. Used to display status filters. */ protected $status_counts = array(); /** * @var array Notices to display when loading the table. Array of arrays of form array( 'class' => {updated|error}, 'message' => 'This is the notice text display.' ). */ protected $admin_notices = array(); /** * @var string Localised string displayed in the

    element above the able. */ protected $table_header; /** * Enables bulk actions. It must be an array where the key is the action name * and the value is the label (which is translated automatically). It is important * to notice that it will check that the method exists (`bulk_$name`) and will throw * an exception if it does not exists. * * This class will automatically check if the current request has a bulk action, will do the * validations and afterwards will execute the bulk method, with two arguments. The first argument * is the array with primary keys, the second argument is a string with a list of the primary keys, * escaped and ready to use (with `IN`). */ protected $bulk_actions = array(); /** * Makes translation easier, it basically just wraps * `_x` with some default (the package name). * * @deprecated 3.0.0 */ protected function translate( $text, $context = '' ) { return $text; } /** * Reads `$this->bulk_actions` and returns an array that WP_List_Table understands. It * also validates that the bulk method handler exists. It throws an exception because * this is a library meant for developers and missing a bulk method is a development-time error. */ protected function get_bulk_actions() { $actions = array(); foreach ( $this->bulk_actions as $action => $label ) { if ( ! is_callable( array( $this, 'bulk_' . $action ) ) ) { throw new RuntimeException( "The bulk action $action does not have a callback method" ); } $actions[ $action ] = $label; } return $actions; } /** * Checks if the current request has a bulk action. If that is the case it will validate and will * execute the bulk method handler. Regardless if the action is valid or not it will redirect to * the previous page removing the current arguments that makes this request a bulk action. */ protected function process_bulk_action() { global $wpdb; // Detect when a bulk action is being triggered. $action = $this->current_action(); if ( ! $action ) { return; } check_admin_referer( 'bulk-' . $this->_args['plural'] ); $method = 'bulk_' . $action; if ( array_key_exists( $action, $this->bulk_actions ) && is_callable( array( $this, $method ) ) && ! empty( $_GET['ID'] ) && is_array( $_GET['ID'] ) ) { $ids_sql = '(' . implode( ',', array_fill( 0, count( $_GET['ID'] ), '%s' ) ) . ')'; $this->$method( $_GET['ID'], $wpdb->prepare( $ids_sql, $_GET['ID'] ) ); } wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'ID', 'action', 'action2' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); exit; } /** * Default code for deleting entries. * validated already by process_bulk_action() */ protected function bulk_delete( array $ids, $ids_sql ) { $store = ActionScheduler::store(); foreach ( $ids as $action_id ) { $store->delete( $action_id ); } } /** * Prepares the _column_headers property which is used by WP_Table_List at rendering. * It merges the columns and the sortable columns. */ protected function prepare_column_headers() { $this->_column_headers = array( $this->get_columns(), get_hidden_columns( $this->screen ), $this->get_sortable_columns(), ); } /** * Reads $this->sort_by and returns the columns name in a format that WP_Table_List * expects */ public function get_sortable_columns() { $sort_by = array(); foreach ( $this->sort_by as $column ) { $sort_by[ $column ] = array( $column, true ); } return $sort_by; } /** * Returns the columns names for rendering. It adds a checkbox for selecting everything * as the first column */ public function get_columns() { $columns = array_merge( array( 'cb' => '' ), $this->columns ); return $columns; } /** * Get prepared LIMIT clause for items query * * @global wpdb $wpdb * * @return string Prepared LIMIT clause for items query. */ protected function get_items_query_limit() { global $wpdb; $per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page ); return $wpdb->prepare( 'LIMIT %d', $per_page ); } /** * Returns the number of items to offset/skip for this current view. * * @return int */ protected function get_items_offset() { $per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page ); $current_page = $this->get_pagenum(); if ( 1 < $current_page ) { $offset = $per_page * ( $current_page - 1 ); } else { $offset = 0; } return $offset; } /** * Get prepared OFFSET clause for items query * * @global wpdb $wpdb * * @return string Prepared OFFSET clause for items query. */ protected function get_items_query_offset() { global $wpdb; return $wpdb->prepare( 'OFFSET %d', $this->get_items_offset() ); } /** * Prepares the ORDER BY sql statement. It uses `$this->sort_by` to know which * columns are sortable. This requests validates the orderby $_GET parameter is a valid * column and sortable. It will also use order (ASC|DESC) using DESC by default. */ protected function get_items_query_order() { if ( empty( $this->sort_by ) ) { return ''; } $orderby = esc_sql( $this->get_request_orderby() ); $order = esc_sql( $this->get_request_order() ); return "ORDER BY {$orderby} {$order}"; } /** * Return the sortable column specified for this request to order the results by, if any. * * @return string */ protected function get_request_orderby() { $valid_sortable_columns = array_values( $this->sort_by ); if ( ! empty( $_GET['orderby'] ) && in_array( $_GET['orderby'], $valid_sortable_columns ) ) { $orderby = sanitize_text_field( $_GET['orderby'] ); } else { $orderby = $valid_sortable_columns[0]; } return $orderby; } /** * Return the sortable column order specified for this request. * * @return string */ protected function get_request_order() { if ( ! empty( $_GET['order'] ) && 'desc' === strtolower( $_GET['order'] ) ) { $order = 'DESC'; } else { $order = 'ASC'; } return $order; } /** * Return the status filter for this request, if any. * * @return string */ protected function get_request_status() { $status = ( ! empty( $_GET['status'] ) ) ? $_GET['status'] : ''; return $status; } /** * Return the search filter for this request, if any. * * @return string */ protected function get_request_search_query() { $search_query = ( ! empty( $_GET['s'] ) ) ? $_GET['s'] : ''; return $search_query; } /** * Process and return the columns name. This is meant for using with SQL, this means it * always includes the primary key. * * @return array */ protected function get_table_columns() { $columns = array_keys( $this->columns ); if ( ! in_array( $this->ID, $columns ) ) { $columns[] = $this->ID; } return $columns; } /** * Check if the current request is doing a "full text" search. If that is the case * prepares the SQL to search texts using LIKE. * * If the current request does not have any search or if this list table does not support * that feature it will return an empty string. * * TODO: * - Improve search doing LIKE by word rather than by phrases. * * @return string */ protected function get_items_query_search() { global $wpdb; if ( empty( $_GET['s'] ) || empty( $this->search_by ) ) { return ''; } $filter = array(); foreach ( $this->search_by as $column ) { $filter[] = $wpdb->prepare('`' . $column . '` like "%%s%"', esc_sql($wpdb->esc_like( $_GET['s'] ))); } return implode( ' OR ', $filter ); } /** * Prepares the SQL to filter rows by the options defined at `$this->filter_by`. Before trusting * any data sent by the user it validates that it is a valid option. */ protected function get_items_query_filters() { global $wpdb; if ( ! $this->filter_by || empty( $_GET['filter_by'] ) || ! is_array( $_GET['filter_by'] ) ) { return ''; } $filter = array(); foreach ( $this->filter_by as $column => $options ) { if ( empty( $_GET['filter_by'][ $column ] ) || empty( $options[ $_GET['filter_by'][ $column ] ] ) ) { continue; } $filter[] = $wpdb->prepare( "`$column` = %s", $_GET['filter_by'][ $column ] ); } return implode( ' AND ', $filter ); } /** * Prepares the data to feed WP_Table_List. * * This has the core for selecting, sorting and filting data. To keep the code simple * its logic is split among many methods (get_items_query_*). * * Beside populating the items this function will also count all the records that matches * the filtering criteria and will do fill the pagination variables. */ public function prepare_items() { global $wpdb; $this->process_bulk_action(); $this->process_row_actions(); if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { // _wp_http_referer is used only on bulk actions, we remove it to keep the $_GET shorter wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); exit; } $this->prepare_column_headers(); $limit = $this->get_items_query_limit(); $offset = $this->get_items_query_offset(); $order = $this->get_items_query_order(); $where = array_filter(array( $this->get_items_query_search(), $this->get_items_query_filters(), )); $columns = '`' . implode( '`, `', $this->get_table_columns() ) . '`'; if ( ! empty( $where ) ) { $where = 'WHERE ('. implode( ') AND (', $where ) . ')'; } else { $where = ''; } $sql = "SELECT $columns FROM {$this->table_name} {$where} {$order} {$limit} {$offset}"; $this->set_items( $wpdb->get_results( $sql, ARRAY_A ) ); $query_count = "SELECT COUNT({$this->ID}) FROM {$this->table_name} {$where}"; $total_items = $wpdb->get_var( $query_count ); $per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page ); $this->set_pagination_args( array( 'total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil( $total_items / $per_page ), ) ); } public function extra_tablenav( $which ) { if ( ! $this->filter_by || 'top' !== $which ) { return; } echo '
    '; foreach ( $this->filter_by as $id => $options ) { $default = ! empty( $_GET['filter_by'][ $id ] ) ? $_GET['filter_by'][ $id ] : ''; if ( empty( $options[ $default ] ) ) { $default = ''; } echo ''; } submit_button( esc_html__( 'Filter', 'action-scheduler' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); echo '
    '; } /** * Set the data for displaying. It will attempt to unserialize (There is a chance that some columns * are serialized). This can be override in child classes for futher data transformation. */ protected function set_items( array $items ) { $this->items = array(); foreach ( $items as $item ) { $this->items[ $item[ $this->ID ] ] = array_map( 'maybe_unserialize', $item ); } } /** * Renders the checkbox for each row, this is the first column and it is named ID regardless * of how the primary key is named (to keep the code simpler). The bulk actions will do the proper * name transformation though using `$this->ID`. */ public function column_cb( $row ) { return ''; } /** * Renders the row-actions. * * This method renders the action menu, it reads the definition from the $row_actions property, * and it checks that the row action method exists before rendering it. * * @param array $row Row to render * @param $column_name Current row * @return */ protected function maybe_render_actions( $row, $column_name ) { if ( empty( $this->row_actions[ $column_name ] ) ) { return; } $row_id = $row[ $this->ID ]; $actions = '
    '; $action_count = 0; foreach ( $this->row_actions[ $column_name ] as $action_key => $action ) { $action_count++; if ( ! method_exists( $this, 'row_action_' . $action_key ) ) { continue; } $action_link = ! empty( $action['link'] ) ? $action['link'] : add_query_arg( array( 'row_action' => $action_key, 'row_id' => $row_id, 'nonce' => wp_create_nonce( $action_key . '::' . $row_id ) ) ); $span_class = ! empty( $action['class'] ) ? $action['class'] : $action_key; $separator = ( $action_count < count( $this->row_actions[ $column_name ] ) ) ? ' | ' : ''; $actions .= sprintf( '', esc_attr( $span_class ) ); $actions .= sprintf( '%3$s', esc_url( $action_link ), esc_attr( $action['desc'] ), esc_html( $action['name'] ) ); $actions .= sprintf( '%s', $separator ); } $actions .= '
    '; return $actions; } protected function process_row_actions() { $parameters = array( 'row_action', 'row_id', 'nonce' ); foreach ( $parameters as $parameter ) { if ( empty( $_REQUEST[ $parameter ] ) ) { return; } } $method = 'row_action_' . $_REQUEST['row_action']; if ( $_REQUEST['nonce'] === wp_create_nonce( $_REQUEST[ 'row_action' ] . '::' . $_REQUEST[ 'row_id' ] ) && method_exists( $this, $method ) ) { $this->$method( $_REQUEST['row_id'] ); } wp_redirect( remove_query_arg( array( 'row_id', 'row_action', 'nonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); exit; } /** * Default column formatting, it will escape everythig for security. */ public function column_default( $item, $column_name ) { $column_html = esc_html( $item[ $column_name ] ); $column_html .= $this->maybe_render_actions( $item, $column_name ); return $column_html; } /** * Display the table heading and search query, if any */ protected function display_header() { echo '

    ' . esc_attr( $this->table_header ) . '

    '; if ( $this->get_request_search_query() ) { /* translators: %s: search query */ echo '' . esc_attr( sprintf( __( 'Search results for "%s"', 'action-scheduler' ), $this->get_request_search_query() ) ) . ''; } echo '
    '; } /** * Display the table heading and search query, if any */ protected function display_admin_notices() { foreach ( $this->admin_notices as $notice ) { echo '
    '; echo '

    ' . wp_kses_post( $notice['message'] ) . '

    '; echo '
    '; } } /** * Prints the available statuses so the user can click to filter. */ protected function display_filter_by_status() { $status_list_items = array(); $request_status = $this->get_request_status(); // Helper to set 'all' filter when not set on status counts passed in if ( ! isset( $this->status_counts['all'] ) ) { $this->status_counts = array( 'all' => array_sum( $this->status_counts ) ) + $this->status_counts; } foreach ( $this->status_counts as $status_name => $count ) { if ( 0 === $count ) { continue; } if ( $status_name === $request_status || ( empty( $request_status ) && 'all' === $status_name ) ) { $status_list_item = '
  • %3$s (%4$d)
  • '; } else { $status_list_item = '
  • %3$s (%4$d)
  • '; } $status_filter_url = ( 'all' === $status_name ) ? remove_query_arg( 'status' ) : add_query_arg( 'status', $status_name ); $status_filter_url = remove_query_arg( array( 'paged', 's' ), $status_filter_url ); $status_list_items[] = sprintf( $status_list_item, esc_attr( $status_name ), esc_url( $status_filter_url ), esc_html( ucfirst( $status_name ) ), absint( $count ) ); } if ( $status_list_items ) { echo '
      '; echo implode( " | \n", $status_list_items ); echo '
    '; } } /** * Renders the table list, we override the original class to render the table inside a form * and to render any needed HTML (like the search box). By doing so the callee of a function can simple * forget about any extra HTML. */ protected function display_table() { echo '
    '; foreach ( $_GET as $key => $value ) { if ( '_' === $key[0] || 'paged' === $key || 'ID' === $key ) { continue; } echo ''; } if ( ! empty( $this->search_by ) ) { echo $this->search_box( $this->get_search_box_button_text(), 'plugin' ); // WPCS: XSS OK } parent::display(); echo '
    '; } /** * Process any pending actions. */ public function process_actions() { $this->process_bulk_action(); $this->process_row_actions(); if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { // _wp_http_referer is used only on bulk actions, we remove it to keep the $_GET shorter wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); exit; } } /** * Render the list table page, including header, notices, status filters and table. */ public function display_page() { $this->prepare_items(); echo '
    '; $this->display_header(); $this->display_admin_notices(); $this->display_filter_by_status(); $this->display_table(); echo '
    '; } /** * Get the text to display in the search box on the list table. */ protected function get_search_box_placeholder() { return esc_html__( 'Search', 'action-scheduler' ); } } inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_Schedule.php000064400000003426147600053410026031 0ustar00scheduled_date * * @var int */ protected $scheduled_timestamp = NULL; /** * @param DateTime $date The date & time to run the action. */ public function __construct( DateTime $date ) { $this->scheduled_date = $date; } /** * Check if a schedule should recur. * * @return bool */ abstract public function is_recurring(); /** * Calculate when the next instance of this schedule would run based on a given date & time. * * @param DateTime $after * @return DateTime */ abstract protected function calculate_next( DateTime $after ); /** * Get the next date & time when this schedule should run after a given date & time. * * @param DateTime $after * @return DateTime|null */ public function get_next( DateTime $after ) { $after = clone $after; if ( $after > $this->scheduled_date ) { $after = $this->calculate_next( $after ); return $after; } return clone $this->scheduled_date; } /** * Get the date & time the schedule is set to run. * * @return DateTime|null */ public function get_date() { return $this->scheduled_date; } /** * For PHP 5.2 compat, since DateTime objects can't be serialized * @return array */ public function __sleep() { $this->scheduled_timestamp = $this->scheduled_date->getTimestamp(); return array( 'scheduled_timestamp', ); } public function __wakeup() { $this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp ); unset( $this->scheduled_timestamp ); } } inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Lock.php000064400000003133147600053410023335 0ustar00get_expiration( $lock_type ) >= time() ); } /** * Set a lock. * * @param string $lock_type A string to identify different lock types. * @return bool */ abstract public function set( $lock_type ); /** * If a lock is set, return the timestamp it was set to expiry. * * @param string $lock_type A string to identify different lock types. * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire. */ abstract public function get_expiration( $lock_type ); /** * Get the amount of time to set for a given lock. 60 seconds by default. * * @param string $lock_type A string to identify different lock types. * @return int */ protected function get_duration( $lock_type ) { return apply_filters( 'action_scheduler_lock_duration', self::$lock_duration, $lock_type ); } /** * @return ActionScheduler_Lock */ public static function instance() { if ( empty( self::$locker ) ) { $class = apply_filters( 'action_scheduler_lock_class', 'ActionScheduler_OptionLock' ); self::$locker = new $class(); } return self::$locker; } } inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php000064400000014122147600053410023664 0ustar00hook_stored_action(); add_action( 'action_scheduler_canceled_action', array( $this, 'log_canceled_action' ), 10, 1 ); add_action( 'action_scheduler_begin_execute', array( $this, 'log_started_action' ), 10, 2 ); add_action( 'action_scheduler_after_execute', array( $this, 'log_completed_action' ), 10, 3 ); add_action( 'action_scheduler_failed_execution', array( $this, 'log_failed_action' ), 10, 3 ); add_action( 'action_scheduler_failed_action', array( $this, 'log_timed_out_action' ), 10, 2 ); add_action( 'action_scheduler_unexpected_shutdown', array( $this, 'log_unexpected_shutdown' ), 10, 2 ); add_action( 'action_scheduler_reset_action', array( $this, 'log_reset_action' ), 10, 1 ); add_action( 'action_scheduler_execution_ignored', array( $this, 'log_ignored_action' ), 10, 2 ); add_action( 'action_scheduler_failed_fetch_action', array( $this, 'log_failed_fetch_action' ), 10, 2 ); add_action( 'action_scheduler_failed_to_schedule_next_instance', array( $this, 'log_failed_schedule_next_instance' ), 10, 2 ); add_action( 'action_scheduler_bulk_cancel_actions', array( $this, 'bulk_log_cancel_actions' ), 10, 1 ); } public function hook_stored_action() { add_action( 'action_scheduler_stored_action', array( $this, 'log_stored_action' ) ); } public function unhook_stored_action() { remove_action( 'action_scheduler_stored_action', array( $this, 'log_stored_action' ) ); } public function log_stored_action( $action_id ) { $this->log( $action_id, __( 'action created', 'action-scheduler' ) ); } public function log_canceled_action( $action_id ) { $this->log( $action_id, __( 'action canceled', 'action-scheduler' ) ); } public function log_started_action( $action_id, $context = '' ) { if ( ! empty( $context ) ) { /* translators: %s: context */ $message = sprintf( __( 'action started via %s', 'action-scheduler' ), $context ); } else { $message = __( 'action started', 'action-scheduler' ); } $this->log( $action_id, $message ); } public function log_completed_action( $action_id, $action = NULL, $context = '' ) { if ( ! empty( $context ) ) { /* translators: %s: context */ $message = sprintf( __( 'action complete via %s', 'action-scheduler' ), $context ); } else { $message = __( 'action complete', 'action-scheduler' ); } $this->log( $action_id, $message ); } public function log_failed_action( $action_id, Exception $exception, $context = '' ) { if ( ! empty( $context ) ) { /* translators: 1: context 2: exception message */ $message = sprintf( __( 'action failed via %1$s: %2$s', 'action-scheduler' ), $context, $exception->getMessage() ); } else { /* translators: %s: exception message */ $message = sprintf( __( 'action failed: %s', 'action-scheduler' ), $exception->getMessage() ); } $this->log( $action_id, $message ); } public function log_timed_out_action( $action_id, $timeout ) { /* translators: %s: amount of time */ $this->log( $action_id, sprintf( __( 'action timed out after %s seconds', 'action-scheduler' ), $timeout ) ); } public function log_unexpected_shutdown( $action_id, $error ) { if ( ! empty( $error ) ) { /* translators: 1: error message 2: filename 3: line */ $this->log( $action_id, sprintf( __( 'unexpected shutdown: PHP Fatal error %1$s in %2$s on line %3$s', 'action-scheduler' ), $error['message'], $error['file'], $error['line'] ) ); } } public function log_reset_action( $action_id ) { $this->log( $action_id, __( 'action reset', 'action-scheduler' ) ); } public function log_ignored_action( $action_id, $context = '' ) { if ( ! empty( $context ) ) { /* translators: %s: context */ $message = sprintf( __( 'action ignored via %s', 'action-scheduler' ), $context ); } else { $message = __( 'action ignored', 'action-scheduler' ); } $this->log( $action_id, $message ); } /** * @param string $action_id * @param Exception|NULL $exception The exception which occured when fetching the action. NULL by default for backward compatibility. * * @return ActionScheduler_LogEntry[] */ public function log_failed_fetch_action( $action_id, Exception $exception = NULL ) { if ( ! is_null( $exception ) ) { /* translators: %s: exception message */ $log_message = sprintf( __( 'There was a failure fetching this action: %s', 'action-scheduler' ), $exception->getMessage() ); } else { $log_message = __( 'There was a failure fetching this action', 'action-scheduler' ); } $this->log( $action_id, $log_message ); } public function log_failed_schedule_next_instance( $action_id, Exception $exception ) { /* translators: %s: exception message */ $this->log( $action_id, sprintf( __( 'There was a failure scheduling the next instance of this action: %s', 'action-scheduler' ), $exception->getMessage() ) ); } /** * Bulk add cancel action log entries. * * Implemented here for backward compatibility. Should be implemented in parent loggers * for more performant bulk logging. * * @param array $action_ids List of action ID. */ public function bulk_log_cancel_actions( $action_ids ) { if ( empty( $action_ids ) ) { return; } foreach ( $action_ids as $action_id ) { $this->log_canceled_action( $action_id ); } } } inc/importer/lib/action-scheduler/classes/actions/ActionScheduler_CanceledAction.php000064400000001316147600053410024754 0ustar00set_schedule( new ActionScheduler_NullSchedule() ); } } } inc/importer/lib/action-scheduler/classes/actions/ActionScheduler_NullAction.php000064400000000534147600053410024171 0ustar00set_schedule( new ActionScheduler_NullSchedule() ); } public function execute() { // don't execute } } inc/importer/lib/action-scheduler/classes/actions/ActionScheduler_FinishedAction.php000064400000000350147600053410025004 0ustar00set_hook($hook); $this->set_schedule($schedule); $this->set_args($args); $this->set_group($group); } public function execute() { return do_action_ref_array( $this->get_hook(), array_values( $this->get_args() ) ); } /** * @param string $hook */ protected function set_hook( $hook ) { $this->hook = $hook; } public function get_hook() { return $this->hook; } protected function set_schedule( ActionScheduler_Schedule $schedule ) { $this->schedule = $schedule; } /** * @return ActionScheduler_Schedule */ public function get_schedule() { return $this->schedule; } protected function set_args( array $args ) { $this->args = $args; } public function get_args() { return $this->args; } /** * @param string $group */ protected function set_group( $group ) { $this->group = $group; } /** * @return string */ public function get_group() { return $this->group; } /** * @return bool If the action has been finished */ public function is_finished() { return FALSE; } } inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBLogger.php000064400000007706147600053410024344 0ustar00format( 'Y-m-d H:i:s' ); ActionScheduler_TimezoneHelper::set_local_timezone( $date ); $date_local = $date->format( 'Y-m-d H:i:s' ); /** @var \wpdb $wpdb */ global $wpdb; $wpdb->insert( $wpdb->actionscheduler_logs, [ 'action_id' => $action_id, 'message' => $message, 'log_date_gmt' => $date_gmt, 'log_date_local' => $date_local, ], [ '%d', '%s', '%s', '%s' ] ); return $wpdb->insert_id; } /** * Retrieve an action log entry. * * @param int $entry_id Log entry ID. * * @return ActionScheduler_LogEntry */ public function get_entry( $entry_id ) { /** @var \wpdb $wpdb */ global $wpdb; $entry = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->actionscheduler_logs} WHERE log_id=%d", $entry_id ) ); return $this->create_entry_from_db_record( $entry ); } /** * Create an action log entry from a database record. * * @param object $record Log entry database record object. * * @return ActionScheduler_LogEntry */ private function create_entry_from_db_record( $record ) { if ( empty( $record ) ) { return new ActionScheduler_NullLogEntry(); } if ( is_null( $record->log_date_gmt ) ) { $date = as_get_datetime_object( ActionScheduler_StoreSchema::DEFAULT_DATE ); } else { $date = as_get_datetime_object( $record->log_date_gmt ); } return new ActionScheduler_LogEntry( $record->action_id, $record->message, $date ); } /** * Retrieve the an action's log entries from the database. * * @param int $action_id Action ID. * * @return ActionScheduler_LogEntry[] */ public function get_logs( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $records = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->actionscheduler_logs} WHERE action_id=%d", $action_id ) ); return array_map( [ $this, 'create_entry_from_db_record' ], $records ); } /** * Initialize the data store. * * @codeCoverageIgnore */ public function init() { $table_maker = new ActionScheduler_LoggerSchema(); $table_maker->init(); $table_maker->register_tables(); parent::init(); add_action( 'action_scheduler_deleted_action', [ $this, 'clear_deleted_action_logs' ], 10, 1 ); } /** * Delete the action logs for an action. * * @param int $action_id Action ID. */ public function clear_deleted_action_logs( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $wpdb->delete( $wpdb->actionscheduler_logs, [ 'action_id' => $action_id, ], [ '%d' ] ); } /** * Bulk add cancel action log entries. * * @param array $action_ids List of action ID. */ public function bulk_log_cancel_actions( $action_ids ) { if ( empty( $action_ids ) ) { return; } /** @var \wpdb $wpdb */ global $wpdb; $date = as_get_datetime_object(); $date_gmt = $date->format( 'Y-m-d H:i:s' ); ActionScheduler_TimezoneHelper::set_local_timezone( $date ); $date_local = $date->format( 'Y-m-d H:i:s' ); $message = __( 'action canceled', 'action-scheduler' ); $format = '(%d, ' . $wpdb->prepare( '%s, %s, %s', $message, $date_gmt, $date_local ) . ')'; $sql_query = "INSERT {$wpdb->actionscheduler_logs} (action_id, message, log_date_gmt, log_date_local) VALUES "; $value_rows = []; foreach ( $action_ids as $action_id ) { $value_rows[] = $wpdb->prepare( $format, $action_id ); } $sql_query .= implode( ',', $value_rows ); $wpdb->query( $sql_query ); } } lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostStatusRegistrar.php000064400000003445147600053410031241 0ustar00inc/importerpost_status_args(), $this->post_status_running_labels() ) ); register_post_status( ActionScheduler_Store::STATUS_FAILED, array_merge( $this->post_status_args(), $this->post_status_failed_labels() ) ); } /** * Build the args array for the post type definition * * @return array */ protected function post_status_args() { $args = array( 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, ); return apply_filters( 'action_scheduler_post_status_args', $args ); } /** * Build the args array for the post type definition * * @return array */ protected function post_status_failed_labels() { $labels = array( 'label' => _x( 'Failed', 'post', 'action-scheduler' ), /* translators: %s: count */ 'label_count' => _n_noop( 'Failed (%s)', 'Failed (%s)', 'action-scheduler' ), ); return apply_filters( 'action_scheduler_post_status_failed_labels', $labels ); } /** * Build the args array for the post type definition * * @return array */ protected function post_status_running_labels() { $labels = array( 'label' => _x( 'In-Progress', 'post', 'action-scheduler' ), /* translators: %s: count */ 'label_count' => _n_noop( 'In-Progress (%s)', 'In-Progress (%s)', 'action-scheduler' ), ); return apply_filters( 'action_scheduler_post_status_running_labels', $labels ); } } inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_HybridStore.php000064400000027366147600053410025161 0ustar00demarkation_id = (int) get_option( self::DEMARKATION_OPTION, 0 ); if ( empty( $config ) ) { $config = Controller::instance()->get_migration_config_object(); } $this->primary_store = $config->get_destination_store(); $this->secondary_store = $config->get_source_store(); $this->migration_runner = new Runner( $config ); } /** * Initialize the table data store tables. * * @codeCoverageIgnore */ public function init() { add_action( 'action_scheduler/created_table', [ $this, 'set_autoincrement' ], 10, 2 ); $this->primary_store->init(); $this->secondary_store->init(); remove_action( 'action_scheduler/created_table', [ $this, 'set_autoincrement' ], 10 ); } /** * When the actions table is created, set its autoincrement * value to be one higher than the posts table to ensure that * there are no ID collisions. * * @param string $table_name * @param string $table_suffix * * @return void * @codeCoverageIgnore */ public function set_autoincrement( $table_name, $table_suffix ) { if ( ActionScheduler_StoreSchema::ACTIONS_TABLE === $table_suffix ) { if ( empty( $this->demarkation_id ) ) { $this->demarkation_id = $this->set_demarkation_id(); } /** @var \wpdb $wpdb */ global $wpdb; /** * A default date of '0000-00-00 00:00:00' is invalid in MySQL 5.7 when configured with * sql_mode including both STRICT_TRANS_TABLES and NO_ZERO_DATE. */ $default_date = new DateTime( 'tomorrow' ); $null_action = new ActionScheduler_NullAction(); $date_gmt = $this->get_scheduled_date_string( $null_action, $default_date ); $date_local = $this->get_scheduled_date_string_local( $null_action, $default_date ); $row_count = $wpdb->insert( $wpdb->{ActionScheduler_StoreSchema::ACTIONS_TABLE}, [ 'action_id' => $this->demarkation_id, 'hook' => '', 'status' => '', 'scheduled_date_gmt' => $date_gmt, 'scheduled_date_local' => $date_local, 'last_attempt_gmt' => $date_gmt, 'last_attempt_local' => $date_local, ] ); if ( $row_count > 0 ) { $wpdb->delete( $wpdb->{ActionScheduler_StoreSchema::ACTIONS_TABLE}, [ 'action_id' => $this->demarkation_id ] ); } } } /** * Store the demarkation id in WP options. * * @param int $id The ID to set as the demarkation point between the two stores * Leave null to use the next ID from the WP posts table. * * @return int The new ID. * * @codeCoverageIgnore */ private function set_demarkation_id( $id = null ) { if ( empty( $id ) ) { /** @var \wpdb $wpdb */ global $wpdb; $id = (int) $wpdb->get_var( "SELECT MAX(ID) FROM $wpdb->posts" ); $id ++; } update_option( self::DEMARKATION_OPTION, $id ); return $id; } /** * Find the first matching action from the secondary store. * If it exists, migrate it to the primary store immediately. * After it migrates, the secondary store will logically contain * the next matching action, so return the result thence. * * @param string $hook * @param array $params * * @return string */ public function find_action( $hook, $params = [] ) { $found_unmigrated_action = $this->secondary_store->find_action( $hook, $params ); if ( ! empty( $found_unmigrated_action ) ) { $this->migrate( [ $found_unmigrated_action ] ); } return $this->primary_store->find_action( $hook, $params ); } /** * Find actions matching the query in the secondary source first. * If any are found, migrate them immediately. Then the secondary * store will contain the canonical results. * * @param array $query * @param string $query_type Whether to select or count the results. Default, select. * * @return int[] */ public function query_actions( $query = [], $query_type = 'select' ) { $found_unmigrated_actions = $this->secondary_store->query_actions( $query, 'select' ); if ( ! empty( $found_unmigrated_actions ) ) { $this->migrate( $found_unmigrated_actions ); } return $this->primary_store->query_actions( $query, $query_type ); } /** * Get a count of all actions in the store, grouped by status * * @return array Set of 'status' => int $count pairs for statuses with 1 or more actions of that status. */ public function action_counts() { $unmigrated_actions_count = $this->secondary_store->action_counts(); $migrated_actions_count = $this->primary_store->action_counts(); $actions_count_by_status = array(); foreach ( $this->get_status_labels() as $status_key => $status_label ) { $count = 0; if ( isset( $unmigrated_actions_count[ $status_key ] ) ) { $count += $unmigrated_actions_count[ $status_key ]; } if ( isset( $migrated_actions_count[ $status_key ] ) ) { $count += $migrated_actions_count[ $status_key ]; } $actions_count_by_status[ $status_key ] = $count; } $actions_count_by_status = array_filter( $actions_count_by_status ); return $actions_count_by_status; } /** * If any actions would have been claimed by the secondary store, * migrate them immediately, then ask the primary store for the * canonical claim. * * @param int $max_actions * @param DateTime|null $before_date * * @return ActionScheduler_ActionClaim */ public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ) { $claim = $this->secondary_store->stake_claim( $max_actions, $before_date, $hooks, $group ); $claimed_actions = $claim->get_actions(); if ( ! empty( $claimed_actions ) ) { $this->migrate( $claimed_actions ); } $this->secondary_store->release_claim( $claim ); return $this->primary_store->stake_claim( $max_actions, $before_date, $hooks, $group ); } /** * Migrate a list of actions to the table data store. * * @param array $action_ids List of action IDs. */ private function migrate( $action_ids ) { $this->migration_runner->migrate_actions( $action_ids ); } /** * Save an action to the primary store. * * @param ActionScheduler_Action $action Action object to be saved. * @param DateTime $date Optional. Schedule date. Default null. * * @return int The action ID */ public function save_action( ActionScheduler_Action $action, DateTime $date = null ) { return $this->primary_store->save_action( $action, $date ); } /** * Retrieve an existing action whether migrated or not. * * @param int $action_id Action ID. */ public function fetch_action( $action_id ) { $store = $this->get_store_from_action_id( $action_id, true ); if ( $store ) { return $store->fetch_action( $action_id ); } else { return new ActionScheduler_NullAction(); } } /** * Cancel an existing action whether migrated or not. * * @param int $action_id Action ID. */ public function cancel_action( $action_id ) { $store = $this->get_store_from_action_id( $action_id ); if ( $store ) { $store->cancel_action( $action_id ); } } /** * Delete an existing action whether migrated or not. * * @param int $action_id Action ID. */ public function delete_action( $action_id ) { $store = $this->get_store_from_action_id( $action_id ); if ( $store ) { $store->delete_action( $action_id ); } } /** * Get the schedule date an existing action whether migrated or not. * * @param int $action_id Action ID. */ public function get_date( $action_id ) { $store = $this->get_store_from_action_id( $action_id ); if ( $store ) { return $store->get_date( $action_id ); } else { return null; } } /** * Mark an existing action as failed whether migrated or not. * * @param int $action_id Action ID. */ public function mark_failure( $action_id ) { $store = $this->get_store_from_action_id( $action_id ); if ( $store ) { $store->mark_failure( $action_id ); } } /** * Log the execution of an existing action whether migrated or not. * * @param int $action_id Action ID. */ public function log_execution( $action_id ) { $store = $this->get_store_from_action_id( $action_id ); if ( $store ) { $store->log_execution( $action_id ); } } /** * Mark an existing action complete whether migrated or not. * * @param int $action_id Action ID. */ public function mark_complete( $action_id ) { $store = $this->get_store_from_action_id( $action_id ); if ( $store ) { $store->mark_complete( $action_id ); } } /** * Get an existing action status whether migrated or not. * * @param int $action_id Action ID. */ public function get_status( $action_id ) { $store = $this->get_store_from_action_id( $action_id ); if ( $store ) { return $store->get_status( $action_id ); } return null; } /** * Return which store an action is stored in. * * @param int $action_id ID of the action. * @param bool $primary_first Optional flag indicating search the primary store first. * @return ActionScheduler_Store */ protected function get_store_from_action_id( $action_id, $primary_first = false ) { if ( $primary_first ) { $stores = [ $this->primary_store, $this->secondary_store, ]; } elseif ( $action_id < $this->demarkation_id ) { $stores = [ $this->secondary_store, $this->primary_store, ]; } else { $stores = [ $this->primary_store, ]; } foreach ( $stores as $store ) { $action = $store->fetch_action( $action_id ); if ( ! is_a( $action, 'ActionScheduler_NullAction' ) ) { return $store; } } return null; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * All claim-related functions should operate solely * on the primary store. * * * * * * * * * * * * * * * * * * * * * * * * * * */ /** * Get the claim count from the table data store. */ public function get_claim_count() { return $this->primary_store->get_claim_count(); } /** * Retrieve the claim ID for an action from the table data store. * * @param int $action_id Action ID. */ public function get_claim_id( $action_id ) { return $this->primary_store->get_claim_id( $action_id ); } /** * Release a claim in the table data store. * * @param ActionScheduler_ActionClaim $claim Claim object. */ public function release_claim( ActionScheduler_ActionClaim $claim ) { $this->primary_store->release_claim( $claim ); } /** * Release claims on an action in the table data store. * * @param int $action_id Action ID. */ public function unclaim_action( $action_id ) { $this->primary_store->unclaim_action( $action_id ); } /** * Retrieve a list of action IDs by claim. * * @param int $claim_id Claim ID. */ public function find_actions_by_claim_id( $claim_id ) { return $this->primary_store->find_actions_by_claim_id( $claim_id ); } } importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php000064400000003415147600053410030674 0ustar00incpost_type_args() ); } /** * Build the args array for the post type definition * * @return array */ protected function post_type_args() { $args = array( 'label' => __( 'Scheduled Actions', 'action-scheduler' ), 'description' => __( 'Scheduled actions are hooks triggered on a cetain date and time.', 'action-scheduler' ), 'public' => false, 'map_meta_cap' => true, 'hierarchical' => false, 'supports' => array('title', 'editor','comments'), 'rewrite' => false, 'query_var' => false, 'can_export' => true, 'ep_mask' => EP_NONE, 'labels' => array( 'name' => __( 'Scheduled Actions', 'action-scheduler' ), 'singular_name' => __( 'Scheduled Action', 'action-scheduler' ), 'menu_name' => _x( 'Scheduled Actions', 'Admin menu name', 'action-scheduler' ), 'add_new' => __( 'Add', 'action-scheduler' ), 'add_new_item' => __( 'Add New Scheduled Action', 'action-scheduler' ), 'edit' => __( 'Edit', 'action-scheduler' ), 'edit_item' => __( 'Edit Scheduled Action', 'action-scheduler' ), 'new_item' => __( 'New Scheduled Action', 'action-scheduler' ), 'view' => __( 'View Action', 'action-scheduler' ), 'view_item' => __( 'View Action', 'action-scheduler' ), 'search_items' => __( 'Search Scheduled Actions', 'action-scheduler' ), 'not_found' => __( 'No actions found', 'action-scheduler' ), 'not_found_in_trash' => __( 'No actions found in trash', 'action-scheduler' ), ), ); $args = apply_filters('action_scheduler_post_type_args', $args); return $args; } } inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpCommentLogger.php000064400000015233147600053410026022 0ustar00create_wp_comment( $action_id, $message, $date ); return $comment_id; } protected function create_wp_comment( $action_id, $message, DateTime $date ) { $comment_date_gmt = $date->format('Y-m-d H:i:s'); ActionScheduler_TimezoneHelper::set_local_timezone( $date ); $comment_data = array( 'comment_post_ID' => $action_id, 'comment_date' => $date->format('Y-m-d H:i:s'), 'comment_date_gmt' => $comment_date_gmt, 'comment_author' => self::AGENT, 'comment_content' => $message, 'comment_agent' => self::AGENT, 'comment_type' => self::TYPE, ); return wp_insert_comment($comment_data); } /** * @param string $entry_id * * @return ActionScheduler_LogEntry */ public function get_entry( $entry_id ) { $comment = $this->get_comment( $entry_id ); if ( empty($comment) || $comment->comment_type != self::TYPE ) { return new ActionScheduler_NullLogEntry(); } $date = as_get_datetime_object( $comment->comment_date_gmt ); ActionScheduler_TimezoneHelper::set_local_timezone( $date ); return new ActionScheduler_LogEntry( $comment->comment_post_ID, $comment->comment_content, $date ); } /** * @param string $action_id * * @return ActionScheduler_LogEntry[] */ public function get_logs( $action_id ) { $status = 'all'; if ( get_post_status($action_id) == 'trash' ) { $status = 'post-trashed'; } $comments = get_comments(array( 'post_id' => $action_id, 'orderby' => 'comment_date_gmt', 'order' => 'ASC', 'type' => self::TYPE, 'status' => $status, )); $logs = array(); foreach ( $comments as $c ) { $entry = $this->get_entry( $c ); if ( !empty($entry) ) { $logs[] = $entry; } } return $logs; } protected function get_comment( $comment_id ) { return get_comment( $comment_id ); } /** * @param WP_Comment_Query $query */ public function filter_comment_queries( $query ) { foreach ( array('ID', 'parent', 'post_author', 'post_name', 'post_parent', 'type', 'post_type', 'post_id', 'post_ID') as $key ) { if ( !empty($query->query_vars[$key]) ) { return; // don't slow down queries that wouldn't include action_log comments anyway } } $query->query_vars['action_log_filter'] = TRUE; add_filter( 'comments_clauses', array( $this, 'filter_comment_query_clauses' ), 10, 2 ); } /** * @param array $clauses * @param WP_Comment_Query $query * * @return array */ public function filter_comment_query_clauses( $clauses, $query ) { if ( !empty($query->query_vars['action_log_filter']) ) { $clauses['where'] .= $this->get_where_clause(); } return $clauses; } /** * Make sure Action Scheduler logs are excluded from comment feeds, which use WP_Query, not * the WP_Comment_Query class handled by @see self::filter_comment_queries(). * * @param string $where * @param WP_Query $query * * @return string */ public function filter_comment_feed( $where, $query ) { if ( is_comment_feed() ) { $where .= $this->get_where_clause(); } return $where; } /** * Return a SQL clause to exclude Action Scheduler comments. * * @return string */ protected function get_where_clause() { global $wpdb; return sprintf( " AND {$wpdb->comments}.comment_type != '%s'", self::TYPE ); } /** * Remove action log entries from wp_count_comments() * * @param array $stats * @param int $post_id * * @return object */ public function filter_comment_count( $stats, $post_id ) { global $wpdb; if ( 0 === $post_id ) { $stats = $this->get_comment_count(); } return $stats; } /** * Retrieve the comment counts from our cache, or the database if the cached version isn't set. * * @return object */ protected function get_comment_count() { global $wpdb; $stats = get_transient( 'as_comment_count' ); if ( ! $stats ) { $stats = array(); $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN('order_note','action_log') GROUP BY comment_approved", ARRAY_A ); $total = 0; $stats = array(); $approved = array( '0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed' ); foreach ( (array) $count as $row ) { // Don't count post-trashed toward totals if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { $total += $row['num_comments']; } if ( isset( $approved[ $row['comment_approved'] ] ) ) { $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; } } $stats['total_comments'] = $total; $stats['all'] = $total; foreach ( $approved as $key ) { if ( empty( $stats[ $key ] ) ) { $stats[ $key ] = 0; } } $stats = (object) $stats; set_transient( 'as_comment_count', $stats ); } return $stats; } /** * Delete comment count cache whenever there is new comment or the status of a comment changes. Cache * will be regenerated next time ActionScheduler_wpCommentLogger::filter_comment_count() is called. */ public function delete_comment_count_cache() { delete_transient( 'as_comment_count' ); } /** * @codeCoverageIgnore */ public function init() { add_action( 'action_scheduler_before_process_queue', array( $this, 'disable_comment_counting' ), 10, 0 ); add_action( 'action_scheduler_after_process_queue', array( $this, 'enable_comment_counting' ), 10, 0 ); parent::init(); add_action( 'pre_get_comments', array( $this, 'filter_comment_queries' ), 10, 1 ); add_action( 'wp_count_comments', array( $this, 'filter_comment_count' ), 20, 2 ); // run after WC_Comments::wp_count_comments() to make sure we exclude order notes and action logs add_action( 'comment_feed_where', array( $this, 'filter_comment_feed' ), 10, 2 ); // Delete comments count cache whenever there is a new comment or a comment status changes add_action( 'wp_insert_comment', array( $this, 'delete_comment_count_cache' ) ); add_action( 'wp_set_comment_status', array( $this, 'delete_comment_count_cache' ) ); } public function disable_comment_counting() { wp_defer_comment_counting(true); } public function enable_comment_counting() { wp_defer_comment_counting(false); } } importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php000064400000001212147600053410030714 0ustar00inctaxonomy_args() ); } protected function taxonomy_args() { $args = array( 'label' => __( 'Action Group', 'action-scheduler' ), 'public' => false, 'hierarchical' => false, 'show_admin_column' => true, 'query_var' => false, 'rewrite' => false, ); $args = apply_filters( 'action_scheduler_taxonomy_args', $args ); return $args; } } inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php000064400000071535147600053410025231 0ustar00validate_action( $action ); $post_array = $this->create_post_array( $action, $scheduled_date ); $post_id = $this->save_post_array( $post_array ); $this->save_post_schedule( $post_id, $action->get_schedule() ); $this->save_action_group( $post_id, $action->get_group() ); do_action( 'action_scheduler_stored_action', $post_id ); return $post_id; } catch ( Exception $e ) { throw new RuntimeException( sprintf( __( 'Error saving action: %s', 'action-scheduler' ), $e->getMessage() ), 0 ); } } protected function create_post_array( ActionScheduler_Action $action, DateTime $scheduled_date = NULL ) { $post = array( 'post_type' => self::POST_TYPE, 'post_title' => $action->get_hook(), 'post_content' => json_encode($action->get_args()), 'post_status' => ( $action->is_finished() ? 'publish' : 'pending' ), 'post_date_gmt' => $this->get_scheduled_date_string( $action, $scheduled_date ), 'post_date' => $this->get_scheduled_date_string_local( $action, $scheduled_date ), ); return $post; } protected function save_post_array( $post_array ) { add_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10, 1 ); add_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10, 5 ); $has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' ); if ( $has_kses ) { // Prevent KSES from corrupting JSON in post_content. kses_remove_filters(); } $post_id = wp_insert_post($post_array); if ( $has_kses ) { kses_init_filters(); } remove_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10 ); remove_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10 ); if ( is_wp_error($post_id) || empty($post_id) ) { throw new RuntimeException( __( 'Unable to save action.', 'action-scheduler' ) ); } return $post_id; } public function filter_insert_post_data( $postdata ) { if ( $postdata['post_type'] == self::POST_TYPE ) { $postdata['post_author'] = 0; if ( $postdata['post_status'] == 'future' ) { $postdata['post_status'] = 'publish'; } } return $postdata; } /** * Create a (probably unique) post name for scheduled actions in a more performant manner than wp_unique_post_slug(). * * When an action's post status is transitioned to something other than 'draft', 'pending' or 'auto-draft, like 'publish' * or 'failed' or 'trash', WordPress will find a unique slug (stored in post_name column) using the wp_unique_post_slug() * function. This is done to ensure URL uniqueness. The approach taken by wp_unique_post_slug() is to iterate over existing * post_name values that match, and append a number 1 greater than the largest. This makes sense when manually creating a * post from the Edit Post screen. It becomes a bottleneck when automatically processing thousands of actions, with a * database containing thousands of related post_name values. * * WordPress 5.1 introduces the 'pre_wp_unique_post_slug' filter for plugins to address this issue. * * We can short-circuit WordPress's wp_unique_post_slug() approach using the 'pre_wp_unique_post_slug' filter. This * method is available to be used as a callback on that filter. It provides a more scalable approach to generating a * post_name/slug that is probably unique. Because Action Scheduler never actually uses the post_name field, or an * action's slug, being probably unique is good enough. * * For more backstory on this issue, see: * - https://github.com/woocommerce/action-scheduler/issues/44 and * - https://core.trac.wordpress.org/ticket/21112 * * @param string $override_slug Short-circuit return value. * @param string $slug The desired slug (post_name). * @param int $post_ID Post ID. * @param string $post_status The post status. * @param string $post_type Post type. * @return string */ public function set_unique_post_slug( $override_slug, $slug, $post_ID, $post_status, $post_type ) { if ( self::POST_TYPE == $post_type ) { $override_slug = uniqid( self::POST_TYPE . '-', true ) . '-' . wp_generate_password( 32, false ); } return $override_slug; } protected function save_post_schedule( $post_id, $schedule ) { update_post_meta( $post_id, self::SCHEDULE_META_KEY, $schedule ); } protected function save_action_group( $post_id, $group ) { if ( empty($group) ) { wp_set_object_terms( $post_id, array(), self::GROUP_TAXONOMY, FALSE ); } else { wp_set_object_terms( $post_id, array($group), self::GROUP_TAXONOMY, FALSE ); } } public function fetch_action( $action_id ) { $post = $this->get_post( $action_id ); if ( empty($post) || $post->post_type != self::POST_TYPE ) { return $this->get_null_action(); } try { $action = $this->make_action_from_post( $post ); } catch ( ActionScheduler_InvalidActionException $exception ) { do_action( 'action_scheduler_failed_fetch_action', $post->ID, $exception ); return $this->get_null_action(); } return $action; } protected function get_post( $action_id ) { if ( empty($action_id) ) { return NULL; } return get_post($action_id); } protected function get_null_action() { return new ActionScheduler_NullAction(); } protected function make_action_from_post( $post ) { $hook = $post->post_title; $args = json_decode( $post->post_content, true ); $this->validate_args( $args, $post->ID ); $schedule = get_post_meta( $post->ID, self::SCHEDULE_META_KEY, true ); $this->validate_schedule( $schedule, $post->ID ); $group = wp_get_object_terms( $post->ID, self::GROUP_TAXONOMY, array('fields' => 'names') ); $group = empty( $group ) ? '' : reset($group); return ActionScheduler::factory()->get_stored_action( $this->get_action_status_by_post_status( $post->post_status ), $hook, $args, $schedule, $group ); } /** * @param string $post_status * * @throws InvalidArgumentException if $post_status not in known status fields returned by $this->get_status_labels() * @return string */ protected function get_action_status_by_post_status( $post_status ) { switch ( $post_status ) { case 'publish' : $action_status = self::STATUS_COMPLETE; break; case 'trash' : $action_status = self::STATUS_CANCELED; break; default : if ( ! array_key_exists( $post_status, $this->get_status_labels() ) ) { throw new InvalidArgumentException( sprintf( 'Invalid post status: "%s". No matching action status available.', $post_status ) ); } $action_status = $post_status; break; } return $action_status; } /** * @param string $action_status * @throws InvalidArgumentException if $post_status not in known status fields returned by $this->get_status_labels() * @return string */ protected function get_post_status_by_action_status( $action_status ) { switch ( $action_status ) { case self::STATUS_COMPLETE : $post_status = 'publish'; break; case self::STATUS_CANCELED : $post_status = 'trash'; break; default : if ( ! array_key_exists( $action_status, $this->get_status_labels() ) ) { throw new InvalidArgumentException( sprintf( 'Invalid action status: "%s".', $action_status ) ); } $post_status = $action_status; break; } return $post_status; } /** * Returns the SQL statement to query (or count) actions. * * @param array $query Filtering options * @param string $select_or_count Whether the SQL should select and return the IDs or just the row count * @throws InvalidArgumentException if $select_or_count not count or select * @return string SQL statement. The returned SQL is already properly escaped. */ protected function get_query_actions_sql( array $query, $select_or_count = 'select' ) { if ( ! in_array( $select_or_count, array( 'select', 'count' ) ) ) { throw new InvalidArgumentException( __( 'Invalid schedule. Cannot save action.', 'action-scheduler' ) ); } $query = wp_parse_args( $query, array( 'hook' => '', 'args' => NULL, 'date' => NULL, 'date_compare' => '<=', 'modified' => NULL, 'modified_compare' => '<=', 'group' => '', 'status' => '', 'claimed' => NULL, 'per_page' => 5, 'offset' => 0, 'orderby' => 'date', 'order' => 'ASC', 'search' => '', ) ); /** @var wpdb $wpdb */ global $wpdb; $sql = ( 'count' === $select_or_count ) ? 'SELECT count(p.ID)' : 'SELECT p.ID '; $sql .= "FROM {$wpdb->posts} p"; $sql_params = array(); if ( empty( $query['group'] ) && 'group' === $query['orderby'] ) { $sql .= " LEFT JOIN {$wpdb->term_relationships} tr ON tr.object_id=p.ID"; $sql .= " LEFT JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id=tt.term_taxonomy_id"; $sql .= " LEFT JOIN {$wpdb->terms} t ON tt.term_id=t.term_id"; } elseif ( ! empty( $query['group'] ) ) { $sql .= " INNER JOIN {$wpdb->term_relationships} tr ON tr.object_id=p.ID"; $sql .= " INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id=tt.term_taxonomy_id"; $sql .= " INNER JOIN {$wpdb->terms} t ON tt.term_id=t.term_id"; $sql .= " AND t.slug=%s"; $sql_params[] = $query['group']; } $sql .= " WHERE post_type=%s"; $sql_params[] = self::POST_TYPE; if ( $query['hook'] ) { $sql .= " AND p.post_title=%s"; $sql_params[] = $query['hook']; } if ( !is_null($query['args']) ) { $sql .= " AND p.post_content=%s"; $sql_params[] = json_encode($query['args']); } if ( $query['status'] ) { $post_statuses = array_map( array( $this, 'get_post_status_by_action_status' ), (array) $query['status'] ); $placeholders = array_fill( 0, count( $post_statuses ), '%s' ); $sql .= ' AND p.post_status IN (' . join( ', ', $placeholders ) . ')'; $sql_params = array_merge( $sql_params, array_values( $post_statuses ) ); } if ( $query['date'] instanceof DateTime ) { $date = clone $query['date']; $date->setTimezone( new DateTimeZone('UTC') ); $date_string = $date->format('Y-m-d H:i:s'); $comparator = $this->validate_sql_comparator($query['date_compare']); $sql .= " AND p.post_date_gmt $comparator %s"; $sql_params[] = $date_string; } if ( $query['modified'] instanceof DateTime ) { $modified = clone $query['modified']; $modified->setTimezone( new DateTimeZone('UTC') ); $date_string = $modified->format('Y-m-d H:i:s'); $comparator = $this->validate_sql_comparator($query['modified_compare']); $sql .= " AND p.post_modified_gmt $comparator %s"; $sql_params[] = $date_string; } if ( $query['claimed'] === TRUE ) { $sql .= " AND p.post_password != ''"; } elseif ( $query['claimed'] === FALSE ) { $sql .= " AND p.post_password = ''"; } elseif ( !is_null($query['claimed']) ) { $sql .= " AND p.post_password = %s"; $sql_params[] = $query['claimed']; } if ( ! empty( $query['search'] ) ) { $sql .= " AND (p.post_title LIKE %s OR p.post_content LIKE %s OR p.post_password LIKE %s)"; for( $i = 0; $i < 3; $i++ ) { $sql_params[] = sprintf( '%%%s%%', $query['search'] ); } } if ( 'select' === $select_or_count ) { switch ( $query['orderby'] ) { case 'hook': $orderby = 'p.post_title'; break; case 'group': $orderby = 't.name'; break; case 'status': $orderby = 'p.post_status'; break; case 'modified': $orderby = 'p.post_modified'; break; case 'claim_id': $orderby = 'p.post_password'; break; case 'schedule': case 'date': default: $orderby = 'p.post_date_gmt'; break; } if ( 'ASC' === strtoupper( $query['order'] ) ) { $order = 'ASC'; } else { $order = 'DESC'; } $sql .= " ORDER BY $orderby $order"; if ( $query['per_page'] > 0 ) { $sql .= " LIMIT %d, %d"; $sql_params[] = $query['offset']; $sql_params[] = $query['per_page']; } } return $wpdb->prepare( $sql, $sql_params ); } /** * Query for action count or list of action IDs. * * @since x.x.x $query['status'] accepts array of statuses instead of a single status. * * @see ActionScheduler_Store::query_actions for $query arg usage. * * @param array $query Query filtering options. * @param string $query_type Whether to select or count the results. Defaults to select. * * @return string|array|null The IDs of actions matching the query. Null on failure. */ public function query_actions( $query = array(), $query_type = 'select' ) { /** @var wpdb $wpdb */ global $wpdb; $sql = $this->get_query_actions_sql( $query, $query_type ); return ( 'count' === $query_type ) ? $wpdb->get_var( $sql ) : $wpdb->get_col( $sql ); } /** * Get a count of all actions in the store, grouped by status * * @return array */ public function action_counts() { $action_counts_by_status = array(); $action_stati_and_labels = $this->get_status_labels(); $posts_count_by_status = (array) wp_count_posts( self::POST_TYPE, 'readable' ); foreach ( $posts_count_by_status as $post_status_name => $count ) { try { $action_status_name = $this->get_action_status_by_post_status( $post_status_name ); } catch ( Exception $e ) { // Ignore any post statuses that aren't for actions continue; } if ( array_key_exists( $action_status_name, $action_stati_and_labels ) ) { $action_counts_by_status[ $action_status_name ] = $count; } } return $action_counts_by_status; } /** * @param string $action_id * * @throws InvalidArgumentException */ public function cancel_action( $action_id ) { $post = get_post( $action_id ); if ( empty( $post ) || ( $post->post_type != self::POST_TYPE ) ) { throw new InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'action-scheduler' ), $action_id ) ); } do_action( 'action_scheduler_canceled_action', $action_id ); add_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10, 5 ); wp_trash_post( $action_id ); remove_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10 ); } public function delete_action( $action_id ) { $post = get_post( $action_id ); if ( empty( $post ) || ( $post->post_type != self::POST_TYPE ) ) { throw new InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'action-scheduler' ), $action_id ) ); } do_action( 'action_scheduler_deleted_action', $action_id ); wp_delete_post( $action_id, TRUE ); } /** * @param string $action_id * * @throws InvalidArgumentException * @return ActionScheduler_DateTime The date the action is schedule to run, or the date that it ran. */ public function get_date( $action_id ) { $next = $this->get_date_gmt( $action_id ); return ActionScheduler_TimezoneHelper::set_local_timezone( $next ); } /** * @param string $action_id * * @throws InvalidArgumentException * @return ActionScheduler_DateTime The date the action is schedule to run, or the date that it ran. */ public function get_date_gmt( $action_id ) { $post = get_post( $action_id ); if ( empty( $post ) || ( $post->post_type != self::POST_TYPE ) ) { throw new InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'action-scheduler' ), $action_id ) ); } if ( $post->post_status == 'publish' ) { return as_get_datetime_object( $post->post_modified_gmt ); } else { return as_get_datetime_object( $post->post_date_gmt ); } } /** * @param int $max_actions * @param DateTime $before_date Jobs must be schedule before this date. Defaults to now. * @param array $hooks Claim only actions with a hook or hooks. * @param string $group Claim only actions in the given group. * * @return ActionScheduler_ActionClaim * @throws RuntimeException When there is an error staking a claim. * @throws InvalidArgumentException When the given group is not valid. */ public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ) { $this->claim_before_date = $before_date; $claim_id = $this->generate_claim_id(); $this->claim_actions( $claim_id, $max_actions, $before_date, $hooks, $group ); $action_ids = $this->find_actions_by_claim_id( $claim_id ); $this->claim_before_date = null; return new ActionScheduler_ActionClaim( $claim_id, $action_ids ); } /** * @return int */ public function get_claim_count(){ global $wpdb; $sql = "SELECT COUNT(DISTINCT post_password) FROM {$wpdb->posts} WHERE post_password != '' AND post_type = %s AND post_status IN ('in-progress','pending')"; $sql = $wpdb->prepare( $sql, array( self::POST_TYPE ) ); return $wpdb->get_var( $sql ); } protected function generate_claim_id() { $claim_id = md5(microtime(true) . rand(0,1000)); return substr($claim_id, 0, 20); // to fit in db field with 20 char limit } /** * @param string $claim_id * @param int $limit * @param DateTime $before_date Should use UTC timezone. * @param array $hooks Claim only actions with a hook or hooks. * @param string $group Claim only actions in the given group. * * @return int The number of actions that were claimed * @throws RuntimeException When there is a database error. * @throws InvalidArgumentException When the group is invalid. */ protected function claim_actions( $claim_id, $limit, DateTime $before_date = null, $hooks = array(), $group = '' ) { // Set up initial variables. $date = null === $before_date ? as_get_datetime_object() : clone $before_date; $limit_ids = ! empty( $group ); $ids = $limit_ids ? $this->get_actions_by_group( $group, $limit, $date ) : array(); // If limiting by IDs and no posts found, then return early since we have nothing to update. if ( $limit_ids && 0 === count( $ids ) ) { return 0; } /** @var wpdb $wpdb */ global $wpdb; /* * Build up custom query to update the affected posts. Parameters are built as a separate array * to make it easier to identify where they are in the query. * * We can't use $wpdb->update() here because of the "ID IN ..." clause. */ $update = "UPDATE {$wpdb->posts} SET post_password = %s, post_modified_gmt = %s, post_modified = %s"; $params = array( $claim_id, current_time( 'mysql', true ), current_time( 'mysql' ), ); // Build initial WHERE clause. $where = "WHERE post_type = %s AND post_status = %s AND post_password = ''"; $params[] = self::POST_TYPE; $params[] = ActionScheduler_Store::STATUS_PENDING; if ( ! empty( $hooks ) ) { $placeholders = array_fill( 0, count( $hooks ), '%s' ); $where .= ' AND post_title IN (' . join( ', ', $placeholders ) . ')'; $params = array_merge( $params, array_values( $hooks ) ); } /* * Add the IDs to the WHERE clause. IDs not escaped because they came directly from a prior DB query. * * If we're not limiting by IDs, then include the post_date_gmt clause. */ if ( $limit_ids ) { $where .= ' AND ID IN (' . join( ',', $ids ) . ')'; } else { $where .= ' AND post_date_gmt <= %s'; $params[] = $date->format( 'Y-m-d H:i:s' ); } // Add the ORDER BY clause and,ms limit. $order = 'ORDER BY menu_order ASC, post_date_gmt ASC, ID ASC LIMIT %d'; $params[] = $limit; // Run the query and gather results. $rows_affected = $wpdb->query( $wpdb->prepare( "{$update} {$where} {$order}", $params ) ); if ( $rows_affected === false ) { throw new RuntimeException( __( 'Unable to claim actions. Database error.', 'action-scheduler' ) ); } return (int) $rows_affected; } /** * Get IDs of actions within a certain group and up to a certain date/time. * * @param string $group The group to use in finding actions. * @param int $limit The number of actions to retrieve. * @param DateTime $date DateTime object representing cutoff time for actions. Actions retrieved will be * up to and including this DateTime. * * @return array IDs of actions in the appropriate group and before the appropriate time. * @throws InvalidArgumentException When the group does not exist. */ protected function get_actions_by_group( $group, $limit, DateTime $date ) { // Ensure the group exists before continuing. if ( ! term_exists( $group, self::GROUP_TAXONOMY )) { throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) ); } // Set up a query for post IDs to use later. $query = new WP_Query(); $query_args = array( 'fields' => 'ids', 'post_type' => self::POST_TYPE, 'post_status' => ActionScheduler_Store::STATUS_PENDING, 'has_password' => false, 'posts_per_page' => $limit * 3, 'suppress_filters' => true, 'no_found_rows' => true, 'orderby' => array( 'menu_order' => 'ASC', 'date' => 'ASC', 'ID' => 'ASC', ), 'date_query' => array( 'column' => 'post_date_gmt', 'before' => $date->format( 'Y-m-d H:i' ), 'inclusive' => true, ), 'tax_query' => array( array( 'taxonomy' => self::GROUP_TAXONOMY, 'field' => 'slug', 'terms' => $group, 'include_children' => false, ), ), ); return $query->query( $query_args ); } /** * @param string $claim_id * @return array */ public function find_actions_by_claim_id( $claim_id ) { /** @var wpdb $wpdb */ global $wpdb; $sql = "SELECT ID, post_date_gmt FROM {$wpdb->posts} WHERE post_type = %s AND post_password = %s"; $sql = $wpdb->prepare( $sql, array( self::POST_TYPE, $claim_id ) ); $action_ids = array(); $before_date = isset( $this->claim_before_date ) ? $this->claim_before_date : as_get_datetime_object(); $cut_off = $before_date->format( 'Y-m-d H:i:s' ); // Verify that the scheduled date for each action is within the expected bounds (in some unusual // cases, we cannot depend on MySQL to honor all of the WHERE conditions we specify). foreach ( $wpdb->get_results( $sql ) as $claimed_action ) { if ( $claimed_action->post_date_gmt <= $cut_off ) { $action_ids[] = absint( $claimed_action->ID ); } } return $action_ids; } public function release_claim( ActionScheduler_ActionClaim $claim ) { $action_ids = $this->find_actions_by_claim_id( $claim->get_id() ); if ( empty( $action_ids ) ) { return; // nothing to do } $action_id_string = implode( ',', array_map( 'intval', $action_ids ) ); /** @var wpdb $wpdb */ global $wpdb; $sql = "UPDATE {$wpdb->posts} SET post_password = '' WHERE ID IN ($action_id_string) AND post_password = %s"; $sql = $wpdb->prepare( $sql, array( $claim->get_id() ) ); $result = $wpdb->query( $sql ); if ( $result === false ) { /* translators: %s: claim ID */ throw new RuntimeException( sprintf( __( 'Unable to unlock claim %s. Database error.', 'action-scheduler' ), $claim->get_id() ) ); } } /** * @param string $action_id */ public function unclaim_action( $action_id ) { /** @var wpdb $wpdb */ global $wpdb; $sql = "UPDATE {$wpdb->posts} SET post_password = '' WHERE ID = %d AND post_type = %s"; $sql = $wpdb->prepare( $sql, $action_id, self::POST_TYPE ); $result = $wpdb->query( $sql ); if ( $result === false ) { /* translators: %s: action ID */ throw new RuntimeException( sprintf( __( 'Unable to unlock claim on action %s. Database error.', 'action-scheduler' ), $action_id ) ); } } public function mark_failure( $action_id ) { /** @var wpdb $wpdb */ global $wpdb; $sql = "UPDATE {$wpdb->posts} SET post_status = %s WHERE ID = %d AND post_type = %s"; $sql = $wpdb->prepare( $sql, self::STATUS_FAILED, $action_id, self::POST_TYPE ); $result = $wpdb->query( $sql ); if ( $result === false ) { /* translators: %s: action ID */ throw new RuntimeException( sprintf( __( 'Unable to mark failure on action %s. Database error.', 'action-scheduler' ), $action_id ) ); } } /** * Return an action's claim ID, as stored in the post password column * * @param string $action_id * @return mixed */ public function get_claim_id( $action_id ) { return $this->get_post_column( $action_id, 'post_password' ); } /** * Return an action's status, as stored in the post status column * * @param string $action_id * @return mixed */ public function get_status( $action_id ) { $status = $this->get_post_column( $action_id, 'post_status' ); if ( $status === null ) { throw new InvalidArgumentException( __( 'Invalid action ID. No status found.', 'action-scheduler' ) ); } return $this->get_action_status_by_post_status( $status ); } private function get_post_column( $action_id, $column_name ) { /** @var \wpdb $wpdb */ global $wpdb; return $wpdb->get_var( $wpdb->prepare( "SELECT {$column_name} FROM {$wpdb->posts} WHERE ID=%d AND post_type=%s", $action_id, self::POST_TYPE ) ); } /** * @param string $action_id */ public function log_execution( $action_id ) { /** @var wpdb $wpdb */ global $wpdb; $sql = "UPDATE {$wpdb->posts} SET menu_order = menu_order+1, post_status=%s, post_modified_gmt = %s, post_modified = %s WHERE ID = %d AND post_type = %s"; $sql = $wpdb->prepare( $sql, self::STATUS_RUNNING, current_time('mysql', true), current_time('mysql'), $action_id, self::POST_TYPE ); $wpdb->query($sql); } /** * Record that an action was completed. * * @param int $action_id ID of the completed action. * @throws InvalidArgumentException|RuntimeException */ public function mark_complete( $action_id ) { $post = get_post( $action_id ); if ( empty( $post ) || ( $post->post_type != self::POST_TYPE ) ) { throw new InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'action-scheduler' ), $action_id ) ); } add_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10, 1 ); add_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10, 5 ); $result = wp_update_post(array( 'ID' => $action_id, 'post_status' => 'publish', ), TRUE); remove_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10 ); remove_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10 ); if ( is_wp_error( $result ) ) { throw new RuntimeException( $result->get_error_message() ); } } /** * Mark action as migrated when there is an error deleting the action. * * @param int $action_id Action ID. */ public function mark_migrated( $action_id ) { wp_update_post( array( 'ID' => $action_id, 'post_status' => 'migrated' ) ); } /** * Determine whether the post store can be migrated. * * @return bool */ public function migration_dependencies_met( $setting ) { global $wpdb; $dependencies_met = get_transient( self::DEPENDENCIES_MET ); if ( empty( $dependencies_met ) ) { $maximum_args_length = apply_filters( 'action_scheduler_maximum_args_length', 191 ); $found_action = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND CHAR_LENGTH(post_content) > %d LIMIT 1", $maximum_args_length, self::POST_TYPE ) ); $dependencies_met = $found_action ? 'no' : 'yes'; set_transient( self::DEPENDENCIES_MET, $dependencies_met, DAY_IN_SECONDS ); } return 'yes' == $dependencies_met ? $setting : false; } /** * InnoDB indexes have a maximum size of 767 bytes by default, which is only 191 characters with utf8mb4. * * Previously, AS wasn't concerned about args length, as we used the (unindex) post_content column. However, * as we prepare to move to custom tables, and can use an indexed VARCHAR column instead, we want to warn * developers of this impending requirement. * * @param ActionScheduler_Action $action */ protected function validate_action( ActionScheduler_Action $action ) { try { parent::validate_action( $action ); } catch ( Exception $e ) { $message = sprintf( __( '%s Support for strings longer than this will be removed in a future version.', 'action-scheduler' ), $e->getMessage() ); _doing_it_wrong( 'ActionScheduler_Action::$args', $message, '2.1.0' ); } } /** * @codeCoverageIgnore */ public function init() { add_filter( 'action_scheduler_migration_dependencies_met', array( $this, 'migration_dependencies_met' ) ); $post_type_registrar = new ActionScheduler_wpPostStore_PostTypeRegistrar(); $post_type_registrar->register(); $post_status_registrar = new ActionScheduler_wpPostStore_PostStatusRegistrar(); $post_status_registrar->register(); $taxonomy_registrar = new ActionScheduler_wpPostStore_TaxonomyRegistrar(); $taxonomy_registrar->register(); } } inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php000064400000057542147600053410024224 0ustar00init(); $table_maker->register_tables(); } /** * Save an action. * * @param ActionScheduler_Action $action Action object. * @param DateTime $date Optional schedule date. Default null. * * @return int Action ID. */ public function save_action( ActionScheduler_Action $action, \DateTime $date = null ) { try { $this->validate_action( $action ); /** @var \wpdb $wpdb */ global $wpdb; $data = [ 'hook' => $action->get_hook(), 'status' => ( $action->is_finished() ? self::STATUS_COMPLETE : self::STATUS_PENDING ), 'scheduled_date_gmt' => $this->get_scheduled_date_string( $action, $date ), 'scheduled_date_local' => $this->get_scheduled_date_string_local( $action, $date ), 'schedule' => serialize( $action->get_schedule() ), 'group_id' => $this->get_group_id( $action->get_group() ), ]; $args = wp_json_encode( $action->get_args() ); if ( strlen( $args ) <= static::$max_index_length ) { $data['args'] = $args; } else { $data['args'] = $this->hash_args( $args ); $data['extended_args'] = $args; } $table_name = ! empty( $wpdb->actionscheduler_actions ) ? $wpdb->actionscheduler_actions : $wpdb->prefix . 'actionscheduler_actions'; $wpdb->insert( $table_name, $data ); $action_id = $wpdb->insert_id; if ( is_wp_error( $action_id ) ) { throw new RuntimeException( $action_id->get_error_message() ); } elseif ( empty( $action_id ) ) { throw new RuntimeException( $wpdb->last_error ? $wpdb->last_error : __( 'Database error.', 'action-scheduler' ) ); } do_action( 'action_scheduler_stored_action', $action_id ); return $action_id; } catch ( \Exception $e ) { /* translators: %s: error message */ throw new \RuntimeException( sprintf( __( 'Error saving action: %s', 'action-scheduler' ), $e->getMessage() ), 0 ); } } /** * Generate a hash from json_encoded $args using MD5 as this isn't for security. * * @param string $args JSON encoded action args. * @return string */ protected function hash_args( $args ) { return md5( $args ); } /** * Get action args query param value from action args. * * @param array $args Action args. * @return string */ protected function get_args_for_query( $args ) { $encoded = wp_json_encode( $args ); if ( strlen( $encoded ) <= static::$max_index_length ) { return $encoded; } return $this->hash_args( $encoded ); } /** * Get a group's ID based on its name/slug. * * @param string $slug The string name of a group. * @param bool $create_if_not_exists Whether to create the group if it does not already exist. Default, true - create the group. * * @return int The group's ID, if it exists or is created, or 0 if it does not exist and is not created. */ protected function get_group_id( $slug, $create_if_not_exists = true ) { if ( empty( $slug ) ) { return 0; } /** @var \wpdb $wpdb */ global $wpdb; $group_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT group_id FROM {$wpdb->actionscheduler_groups} WHERE slug=%s", $slug ) ); if ( empty( $group_id ) && $create_if_not_exists ) { $group_id = $this->create_group( $slug ); } return $group_id; } /** * Create an action group. * * @param string $slug Group slug. * * @return int Group ID. */ protected function create_group( $slug ) { /** @var \wpdb $wpdb */ global $wpdb; $wpdb->insert( $wpdb->actionscheduler_groups, [ 'slug' => $slug ] ); return (int) $wpdb->insert_id; } /** * Retrieve an action. * * @param int $action_id Action ID. * * @return ActionScheduler_Action */ public function fetch_action( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $data = $wpdb->get_row( $wpdb->prepare( "SELECT a.*, g.slug AS `group` FROM {$wpdb->actionscheduler_actions} a LEFT JOIN {$wpdb->actionscheduler_groups} g ON a.group_id=g.group_id WHERE a.action_id=%d", $action_id ) ); if ( empty( $data ) ) { return $this->get_null_action(); } if ( ! empty( $data->extended_args ) ) { $data->args = $data->extended_args; unset( $data->extended_args ); } // Convert NULL dates to zero dates. $date_fields = [ 'scheduled_date_gmt', 'scheduled_date_local', 'last_attempt_gmt', 'last_attempt_gmt' ]; foreach( $date_fields as $date_field ) { if ( is_null( $data->$date_field ) ) { $data->$date_field = ActionScheduler_StoreSchema::DEFAULT_DATE; } } try { $action = $this->make_action_from_db_record( $data ); } catch ( ActionScheduler_InvalidActionException $exception ) { do_action( 'action_scheduler_failed_fetch_action', $action_id, $exception ); return $this->get_null_action(); } return $action; } /** * Create a null action. * * @return ActionScheduler_NullAction */ protected function get_null_action() { return new ActionScheduler_NullAction(); } /** * Create an action from a database record. * * @param object $data Action database record. * * @return ActionScheduler_Action|ActionScheduler_CanceledAction|ActionScheduler_FinishedAction */ protected function make_action_from_db_record( $data ) { $hook = $data->hook; $args = json_decode( $data->args, true ); $schedule = unserialize( $data->schedule ); $this->validate_args( $args, $data->action_id ); $this->validate_schedule( $schedule, $data->action_id ); if ( empty( $schedule ) ) { $schedule = new ActionScheduler_NullSchedule(); } $group = $data->group ? $data->group : ''; return ActionScheduler::factory()->get_stored_action( $data->status, $data->hook, $args, $schedule, $group ); } /** * Returns the SQL statement to query (or count) actions. * * @since x.x.x $query['status'] accepts array of statuses instead of a single status. * * @param array $query Filtering options. * @param string $select_or_count Whether the SQL should select and return the IDs or just the row count. * * @return string SQL statement already properly escaped. */ protected function get_query_actions_sql( array $query, $select_or_count = 'select' ) { if ( ! in_array( $select_or_count, array( 'select', 'count' ) ) ) { throw new InvalidArgumentException( __( 'Invalid value for select or count parameter. Cannot query actions.', 'action-scheduler' ) ); } $query = wp_parse_args( $query, [ 'hook' => '', 'args' => null, 'date' => null, 'date_compare' => '<=', 'modified' => null, 'modified_compare' => '<=', 'group' => '', 'status' => '', 'claimed' => null, 'per_page' => 5, 'offset' => 0, 'orderby' => 'date', 'order' => 'ASC', ] ); /** @var \wpdb $wpdb */ global $wpdb; $sql = ( 'count' === $select_or_count ) ? 'SELECT count(a.action_id)' : 'SELECT a.action_id'; $sql .= " FROM {$wpdb->actionscheduler_actions} a"; $sql_params = []; if ( ! empty( $query[ 'group' ] ) || 'group' === $query[ 'orderby' ] ) { $sql .= " LEFT JOIN {$wpdb->actionscheduler_groups} g ON g.group_id=a.group_id"; } $sql .= " WHERE 1=1"; if ( ! empty( $query[ 'group' ] ) ) { $sql .= " AND g.slug=%s"; $sql_params[] = $query[ 'group' ]; } if ( $query[ 'hook' ] ) { $sql .= " AND a.hook=%s"; $sql_params[] = $query[ 'hook' ]; } if ( ! is_null( $query[ 'args' ] ) ) { $sql .= " AND a.args=%s"; $sql_params[] = $this->get_args_for_query( $query[ 'args' ] ); } if ( $query['status'] ) { $statuses = (array) $query['status']; $placeholders = array_fill( 0, count( $statuses ), '%s' ); $sql .= ' AND a.status IN (' . join( ', ', $placeholders ) . ')'; $sql_params = array_merge( $sql_params, array_values( $statuses ) ); } if ( $query[ 'date' ] instanceof \DateTime ) { $date = clone $query[ 'date' ]; $date->setTimezone( new \DateTimeZone( 'UTC' ) ); $date_string = $date->format( 'Y-m-d H:i:s' ); $comparator = $this->validate_sql_comparator( $query[ 'date_compare' ] ); $sql .= " AND a.scheduled_date_gmt $comparator %s"; $sql_params[] = $date_string; } if ( $query[ 'modified' ] instanceof \DateTime ) { $modified = clone $query[ 'modified' ]; $modified->setTimezone( new \DateTimeZone( 'UTC' ) ); $date_string = $modified->format( 'Y-m-d H:i:s' ); $comparator = $this->validate_sql_comparator( $query[ 'modified_compare' ] ); $sql .= " AND a.last_attempt_gmt $comparator %s"; $sql_params[] = $date_string; } if ( $query[ 'claimed' ] === true ) { $sql .= " AND a.claim_id != 0"; } elseif ( $query[ 'claimed' ] === false ) { $sql .= " AND a.claim_id = 0"; } elseif ( ! is_null( $query[ 'claimed' ] ) ) { $sql .= " AND a.claim_id = %d"; $sql_params[] = $query[ 'claimed' ]; } if ( ! empty( $query['search'] ) ) { $sql .= " AND (a.hook LIKE %s OR (a.extended_args IS NULL AND a.args LIKE %s) OR a.extended_args LIKE %s"; for( $i = 0; $i < 3; $i++ ) { $sql_params[] = sprintf( '%%%s%%', $query['search'] ); } $search_claim_id = (int) $query['search']; if ( $search_claim_id ) { $sql .= ' OR a.claim_id = %d'; $sql_params[] = $search_claim_id; } $sql .= ')'; } if ( 'select' === $select_or_count ) { if ( 'ASC' === strtoupper( $query['order'] ) ) { $order = 'ASC'; } else { $order = 'DESC'; } switch ( $query['orderby'] ) { case 'hook': $sql .= " ORDER BY a.hook $order"; break; case 'group': $sql .= " ORDER BY g.slug $order"; break; case 'modified': $sql .= " ORDER BY a.last_attempt_gmt $order"; break; case 'none': break; case 'action_id': $sql .= " ORDER BY a.action_id $order"; break; case 'date': default: $sql .= " ORDER BY a.scheduled_date_gmt $order"; break; } if ( $query[ 'per_page' ] > 0 ) { $sql .= " LIMIT %d, %d"; $sql_params[] = $query[ 'offset' ]; $sql_params[] = $query[ 'per_page' ]; } } if ( ! empty( $sql_params ) ) { $sql = $wpdb->prepare( $sql, $sql_params ); } return $sql; } /** * Query for action count or list of action IDs. * * @since x.x.x $query['status'] accepts array of statuses instead of a single status. * * @see ActionScheduler_Store::query_actions for $query arg usage. * * @param array $query Query filtering options. * @param string $query_type Whether to select or count the results. Defaults to select. * * @return string|array|null The IDs of actions matching the query. Null on failure. */ public function query_actions( $query = [], $query_type = 'select' ) { /** @var wpdb $wpdb */ global $wpdb; $sql = $this->get_query_actions_sql( $query, $query_type ); return ( 'count' === $query_type ) ? $wpdb->get_var( $sql ) : $wpdb->get_col( $sql ); } /** * Get a count of all actions in the store, grouped by status. * * @return array Set of 'status' => int $count pairs for statuses with 1 or more actions of that status. */ public function action_counts() { global $wpdb; $sql = "SELECT a.status, count(a.status) as 'count'"; $sql .= " FROM {$wpdb->actionscheduler_actions} a"; $sql .= " GROUP BY a.status"; $actions_count_by_status = array(); $action_stati_and_labels = $this->get_status_labels(); foreach ( $wpdb->get_results( $sql ) as $action_data ) { // Ignore any actions with invalid status if ( array_key_exists( $action_data->status, $action_stati_and_labels ) ) { $actions_count_by_status[ $action_data->status ] = $action_data->count; } } return $actions_count_by_status; } /** * Cancel an action. * * @param int $action_id Action ID. * * @return void */ public function cancel_action( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $updated = $wpdb->update( $wpdb->actionscheduler_actions, [ 'status' => self::STATUS_CANCELED ], [ 'action_id' => $action_id ], [ '%s' ], [ '%d' ] ); if ( empty( $updated ) ) { /* translators: %s: action ID */ throw new \InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'action-scheduler' ), $action_id ) ); } do_action( 'action_scheduler_canceled_action', $action_id ); } /** * Cancel pending actions by hook. * * @since 3.0.0 * * @param string $hook Hook name. * * @return void */ public function cancel_actions_by_hook( $hook ) { $this->bulk_cancel_actions( [ 'hook' => $hook ] ); } /** * Cancel pending actions by group. * * @param string $group Group slug. * * @return void */ public function cancel_actions_by_group( $group ) { $this->bulk_cancel_actions( [ 'group' => $group ] ); } /** * Bulk cancel actions. * * @since 3.0.0 * * @param array $query_args Query parameters. */ protected function bulk_cancel_actions( $query_args ) { /** @var \wpdb $wpdb */ global $wpdb; if ( ! is_array( $query_args ) ) { return; } // Don't cancel actions that are already canceled. if ( isset( $query_args['status'] ) && $query_args['status'] == self::STATUS_CANCELED ) { return; } $action_ids = true; $query_args = wp_parse_args( $query_args, [ 'per_page' => 1000, 'status' => self::STATUS_PENDING, 'orderby' => 'action_id', ] ); while ( $action_ids ) { $action_ids = $this->query_actions( $query_args ); if ( empty( $action_ids ) ) { break; } $format = array_fill( 0, count( $action_ids ), '%d' ); $query_in = '(' . implode( ',', $format ) . ')'; $parameters = $action_ids; array_unshift( $parameters, self::STATUS_CANCELED ); $wpdb->query( $wpdb->prepare( // wpcs: PreparedSQLPlaceholders replacement count ok. "UPDATE {$wpdb->actionscheduler_actions} SET status = %s WHERE action_id IN {$query_in}", $parameters ) ); do_action( 'action_scheduler_bulk_cancel_actions', $action_ids ); } } /** * Delete an action. * * @param int $action_id Action ID. */ public function delete_action( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $deleted = $wpdb->delete( $wpdb->actionscheduler_actions, [ 'action_id' => $action_id ], [ '%d' ] ); if ( empty( $deleted ) ) { throw new \InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'action-scheduler' ), $action_id ) ); } do_action( 'action_scheduler_deleted_action', $action_id ); } /** * Get the schedule date for an action. * * @param string $action_id Action ID. * * @throws \InvalidArgumentException * @return \DateTime The local date the action is scheduled to run, or the date that it ran. */ public function get_date( $action_id ) { $date = $this->get_date_gmt( $action_id ); ActionScheduler_TimezoneHelper::set_local_timezone( $date ); return $date; } /** * Get the GMT schedule date for an action. * * @param int $action_id Action ID. * * @throws \InvalidArgumentException * @return \DateTime The GMT date the action is scheduled to run, or the date that it ran. */ protected function get_date_gmt( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $record = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->actionscheduler_actions} WHERE action_id=%d", $action_id ) ); if ( empty( $record ) ) { throw new \InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'action-scheduler' ), $action_id ) ); } if ( $record->status == self::STATUS_PENDING ) { return as_get_datetime_object( $record->scheduled_date_gmt ); } else { return as_get_datetime_object( $record->last_attempt_gmt ); } } /** * Stake a claim on actions. * * @param int $max_actions Maximum number of action to include in claim. * @param \DateTime $before_date Jobs must be schedule before this date. Defaults to now. * * @return ActionScheduler_ActionClaim */ public function stake_claim( $max_actions = 10, \DateTime $before_date = null, $hooks = array(), $group = '' ) { $claim_id = $this->generate_claim_id(); $this->claim_before_date = $before_date; $this->claim_actions( $claim_id, $max_actions, $before_date, $hooks, $group ); $action_ids = $this->find_actions_by_claim_id( $claim_id ); $this->claim_before_date = null; return new ActionScheduler_ActionClaim( $claim_id, $action_ids ); } /** * Generate a new action claim. * * @return int Claim ID. */ protected function generate_claim_id() { /** @var \wpdb $wpdb */ global $wpdb; $now = as_get_datetime_object(); $wpdb->insert( $wpdb->actionscheduler_claims, [ 'date_created_gmt' => $now->format( 'Y-m-d H:i:s' ) ] ); return $wpdb->insert_id; } /** * Mark actions claimed. * * @param string $claim_id Claim Id. * @param int $limit Number of action to include in claim. * @param \DateTime $before_date Should use UTC timezone. * * @return int The number of actions that were claimed. * @throws \RuntimeException */ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = null, $hooks = array(), $group = '' ) { /** @var \wpdb $wpdb */ global $wpdb; $now = as_get_datetime_object(); $date = is_null( $before_date ) ? $now : clone $before_date; // can't use $wpdb->update() because of the <= condition $update = "UPDATE {$wpdb->actionscheduler_actions} SET claim_id=%d, last_attempt_gmt=%s, last_attempt_local=%s"; $params = array( $claim_id, $now->format( 'Y-m-d H:i:s' ), current_time( 'mysql' ), ); $where = "WHERE claim_id = 0 AND scheduled_date_gmt <= %s AND status=%s"; $params[] = $date->format( 'Y-m-d H:i:s' ); $params[] = self::STATUS_PENDING; if ( ! empty( $hooks ) ) { $placeholders = array_fill( 0, count( $hooks ), '%s' ); $where .= ' AND hook IN (' . join( ', ', $placeholders ) . ')'; $params = array_merge( $params, array_values( $hooks ) ); } if ( ! empty( $group ) ) { $group_id = $this->get_group_id( $group, false ); // throw exception if no matching group found, this matches ActionScheduler_wpPostStore's behaviour if ( empty( $group_id ) ) { /* translators: %s: group name */ throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) ); } $where .= ' AND group_id = %d'; $params[] = $group_id; } $order = "ORDER BY attempts ASC, scheduled_date_gmt ASC, action_id ASC LIMIT %d"; $params[] = $limit; $sql = $wpdb->prepare( "{$update} {$where} {$order}", $params ); $rows_affected = $wpdb->query( $sql ); if ( $rows_affected === false ) { throw new \RuntimeException( __( 'Unable to claim actions. Database error.', 'action-scheduler' ) ); } return (int) $rows_affected; } /** * Get the number of active claims. * * @return int */ public function get_claim_count() { global $wpdb; $sql = "SELECT COUNT(DISTINCT claim_id) FROM {$wpdb->actionscheduler_actions} WHERE claim_id != 0 AND status IN ( %s, %s)"; $sql = $wpdb->prepare( $sql, [ self::STATUS_PENDING, self::STATUS_RUNNING ] ); return (int) $wpdb->get_var( $sql ); } /** * Return an action's claim ID, as stored in the claim_id column. * * @param string $action_id Action ID. * @return mixed */ public function get_claim_id( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $sql = "SELECT claim_id FROM {$wpdb->actionscheduler_actions} WHERE action_id=%d"; $sql = $wpdb->prepare( $sql, $action_id ); return (int) $wpdb->get_var( $sql ); } /** * Retrieve the action IDs of action in a claim. * * @return int[] */ public function find_actions_by_claim_id( $claim_id ) { /** @var \wpdb $wpdb */ global $wpdb; $action_ids = array(); $before_date = isset( $this->claim_before_date ) ? $this->claim_before_date : as_get_datetime_object(); $cut_off = $before_date->format( 'Y-m-d H:i:s' ); $sql = $wpdb->prepare( "SELECT action_id, scheduled_date_gmt FROM {$wpdb->actionscheduler_actions} WHERE claim_id = %d", $claim_id ); // Verify that the scheduled date for each action is within the expected bounds (in some unusual // cases, we cannot depend on MySQL to honor all of the WHERE conditions we specify). foreach ( $wpdb->get_results( $sql ) as $claimed_action ) { if ( $claimed_action->scheduled_date_gmt <= $cut_off ) { $action_ids[] = absint( $claimed_action->action_id ); } } return $action_ids; } /** * Release actions from a claim and delete the claim. * * @param ActionScheduler_ActionClaim $claim Claim object. */ public function release_claim( ActionScheduler_ActionClaim $claim ) { /** @var \wpdb $wpdb */ global $wpdb; $wpdb->update( $wpdb->actionscheduler_actions, [ 'claim_id' => 0 ], [ 'claim_id' => $claim->get_id() ], [ '%d' ], [ '%d' ] ); $wpdb->delete( $wpdb->actionscheduler_claims, [ 'claim_id' => $claim->get_id() ], [ '%d' ] ); } /** * Remove the claim from an action. * * @param int $action_id Action ID. * * @return void */ public function unclaim_action( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $wpdb->update( $wpdb->actionscheduler_actions, [ 'claim_id' => 0 ], [ 'action_id' => $action_id ], [ '%s' ], [ '%d' ] ); } /** * Mark an action as failed. * * @param int $action_id Action ID. */ public function mark_failure( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $updated = $wpdb->update( $wpdb->actionscheduler_actions, [ 'status' => self::STATUS_FAILED ], [ 'action_id' => $action_id ], [ '%s' ], [ '%d' ] ); if ( empty( $updated ) ) { throw new \InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'action-scheduler' ), $action_id ) ); } } /** * Add execution message to action log. * * @param int $action_id Action ID. * * @return void */ public function log_execution( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $sql = "UPDATE {$wpdb->actionscheduler_actions} SET attempts = attempts+1, status=%s, last_attempt_gmt = %s, last_attempt_local = %s WHERE action_id = %d"; $sql = $wpdb->prepare( $sql, self::STATUS_RUNNING, current_time( 'mysql', true ), current_time( 'mysql' ), $action_id ); $wpdb->query( $sql ); } /** * Mark an action as complete. * * @param int $action_id Action ID. * * @return void */ public function mark_complete( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $updated = $wpdb->update( $wpdb->actionscheduler_actions, [ 'status' => self::STATUS_COMPLETE, 'last_attempt_gmt' => current_time( 'mysql', true ), 'last_attempt_local' => current_time( 'mysql' ), ], [ 'action_id' => $action_id ], [ '%s' ], [ '%d' ] ); if ( empty( $updated ) ) { throw new \InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'action-scheduler' ), $action_id ) ); } } /** * Get an action's status. * * @param int $action_id Action ID. * * @return string */ public function get_status( $action_id ) { /** @var \wpdb $wpdb */ global $wpdb; $sql = "SELECT status FROM {$wpdb->actionscheduler_actions} WHERE action_id=%d"; $sql = $wpdb->prepare( $sql, $action_id ); $status = $wpdb->get_var( $sql ); if ( $status === null ) { throw new \InvalidArgumentException( __( 'Invalid action ID. No status found.', 'action-scheduler' ) ); } elseif ( empty( $status ) ) { throw new \RuntimeException( __( 'Unknown status found for action.', 'action-scheduler' ) ); } else { return $status; } } } inc/importer/lib/action-scheduler/classes/migration/BatchFetcher.php000064400000003222147600053410021635 0ustar00store = $source_store; } /** * Retrieve a list of actions. * * @param int $count The number of actions to retrieve * * @return int[] A list of action IDs */ public function fetch( $count = 10 ) { foreach ( $this->get_query_strategies( $count ) as $query ) { $action_ids = $this->store->query_actions( $query ); if ( ! empty( $action_ids ) ) { return $action_ids; } } return []; } /** * Generate a list of prioritized of action search parameters. * * @param int $count Number of actions to find. * * @return array */ private function get_query_strategies( $count ) { $now = as_get_datetime_object(); $args = [ 'date' => $now, 'per_page' => $count, 'offset' => 0, 'orderby' => 'date', 'order' => 'ASC', ]; $priorities = [ Store::STATUS_PENDING, Store::STATUS_FAILED, Store::STATUS_CANCELED, Store::STATUS_COMPLETE, Store::STATUS_RUNNING, '', // any other unanticipated status ]; foreach ( $priorities as $status ) { yield wp_parse_args( [ 'status' => $status, 'date_compare' => '<=', ], $args ); yield wp_parse_args( [ 'status' => $status, 'date_compare' => '>=', ], $args ); } } }inc/importer/lib/action-scheduler/classes/migration/DryRun_ActionMigrator.php000064400000000741147600053410023543 0ustar00 $this->get_scheduled_date_string( $action, $last_attempt_date ), 'last_attempt_local' => $this->get_scheduled_date_string_local( $action, $last_attempt_date ), ]; $wpdb->update( $wpdb->actionscheduler_actions, $data, array( 'action_id' => $action_id ), array( '%s', '%s' ), array( '%d' ) ); } return $action_id; } catch ( \Exception $e ) { throw new \RuntimeException( sprintf( __( 'Error saving action: %s', 'action-scheduler' ), $e->getMessage() ), 0 ); } } } inc/importer/lib/action-scheduler/classes/migration/Config.php000064400000006773147600053410020536 0ustar00source_store ) ) { throw new \RuntimeException( __( 'Source store must be configured before running a migration', 'action-scheduler' ) ); } return $this->source_store; } /** * Set the configured source store. * * @param ActionScheduler_Store $store Source store object. */ public function set_source_store( Store $store ) { $this->source_store = $store; } /** * Get the configured source loger. * * @return ActionScheduler_Logger */ public function get_source_logger() { if ( empty( $this->source_logger ) ) { throw new \RuntimeException( __( 'Source logger must be configured before running a migration', 'action-scheduler' ) ); } return $this->source_logger; } /** * Set the configured source logger. * * @param ActionScheduler_Logger $logger */ public function set_source_logger( Logger $logger ) { $this->source_logger = $logger; } /** * Get the configured destination store. * * @return ActionScheduler_Store */ public function get_destination_store() { if ( empty( $this->destination_store ) ) { throw new \RuntimeException( __( 'Destination store must be configured before running a migration', 'action-scheduler' ) ); } return $this->destination_store; } /** * Set the configured destination store. * * @param ActionScheduler_Store $store */ public function set_destination_store( Store $store ) { $this->destination_store = $store; } /** * Get the configured destination logger. * * @return ActionScheduler_Logger */ public function get_destination_logger() { if ( empty( $this->destination_logger ) ) { throw new \RuntimeException( __( 'Destination logger must be configured before running a migration', 'action-scheduler' ) ); } return $this->destination_logger; } /** * Set the configured destination logger. * * @param ActionScheduler_Logger $logger */ public function set_destination_logger( Logger $logger ) { $this->destination_logger = $logger; } /** * Get flag indicating whether it's a dry run. * * @return bool */ public function get_dry_run() { return $this->dry_run; } /** * Set flag indicating whether it's a dry run. * * @param bool $dry_run */ public function set_dry_run( $dry_run ) { $this->dry_run = (bool) $dry_run; } /** * Get progress bar object. * * @return ActionScheduler\WPCLI\ProgressBar */ public function get_progress_bar() { return $this->progress_bar; } /** * Set progress bar object. * * @param ActionScheduler\WPCLI\ProgressBar $progress_bar */ public function set_progress_bar( ProgressBar $progress_bar ) { $this->progress_bar = $progress_bar; } } inc/importer/lib/action-scheduler/classes/migration/LogMigrator.php000064400000002272147600053410021545 0ustar00source = $source_logger; $this->destination = $destination_Logger; } /** * Migrate an action log. * * @param int $source_action_id Source logger object. * @param int $destination_action_id Destination logger object. */ public function migrate( $source_action_id, $destination_action_id ) { $logs = $this->source->get_logs( $source_action_id ); foreach ( $logs as $log ) { if ( $log->get_action_id() == $source_action_id ) { $this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() ); } } } } inc/importer/lib/action-scheduler/classes/migration/ActionMigrator.php000064400000007065147600053410022246 0ustar00source = $source_store; $this->destination = $destination_store; $this->log_migrator = $log_migrator; } /** * Migrate an action. * * @param int $source_action_id Action ID. * * @return int 0|new action ID */ public function migrate( $source_action_id ) { try { $action = $this->source->fetch_action( $source_action_id ); $status = $this->source->get_status( $source_action_id ); } catch ( \Exception $e ) { $action = null; $status = ''; } if ( is_null( $action ) || empty( $status ) || ! $action->get_schedule()->get_date() ) { // null action or empty status means the fetch operation failed or the action didn't exist // null schedule means it's missing vital data // delete it and move on try { $this->source->delete_action( $source_action_id ); } catch ( \Exception $e ) { // nothing to do, it didn't exist in the first place } do_action( 'action_scheduler/no_action_to_migrate', $source_action_id, $this->source, $this->destination ); return 0; } try { // Make sure the last attempt date is set correctly for completed and failed actions $last_attempt_date = ( $status !== \ActionScheduler_Store::STATUS_PENDING ) ? $this->source->get_date( $source_action_id ) : null; $destination_action_id = $this->destination->save_action( $action, null, $last_attempt_date ); } catch ( \Exception $e ) { do_action( 'action_scheduler/migrate_action_failed', $source_action_id, $this->source, $this->destination ); return 0; // could not save the action in the new store } try { switch ( $status ) { case \ActionScheduler_Store::STATUS_FAILED : $this->destination->mark_failure( $destination_action_id ); break; case \ActionScheduler_Store::STATUS_CANCELED : $this->destination->cancel_action( $destination_action_id ); break; } $this->log_migrator->migrate( $source_action_id, $destination_action_id ); $this->source->delete_action( $source_action_id ); $test_action = $this->source->fetch_action( $source_action_id ); if ( ! is_a( $test_action, 'ActionScheduler_NullAction' ) ) { throw new \RuntimeException( sprintf( __( 'Unable to remove source migrated action %s', 'action-scheduler' ), $source_action_id ) ); } do_action( 'action_scheduler/migrated_action', $source_action_id, $destination_action_id, $this->source, $this->destination ); return $destination_action_id; } catch ( \Exception $e ) { // could not delete from the old store $this->source->mark_migrated( $source_action_id ); do_action( 'action_scheduler/migrate_action_incomplete', $source_action_id, $destination_action_id, $this->source, $this->destination ); do_action( 'action_scheduler/migrated_action', $source_action_id, $destination_action_id, $this->source, $this->destination ); return $destination_action_id; } } } inc/importer/lib/action-scheduler/classes/migration/Scheduler.php000064400000005542147600053410021240 0ustar00get_migration_runner(); $count = $migration_runner->run( $this->get_batch_size() ); if ( $count === 0 ) { $this->mark_complete(); } else { $this->schedule_migration( time() + $this->get_schedule_interval() ); } } /** * Mark the migration complete. */ public function mark_complete() { $this->unschedule_migration(); \ActionScheduler_DataController::mark_migration_complete(); do_action( 'action_scheduler/migration_complete' ); } /** * Get a flag indicating whether the migration is scheduled. * * @return bool Whether there is a pending action in the store to handle the migration */ public function is_migration_scheduled() { $next = as_next_scheduled_action( self::HOOK ); return ! empty( $next ); } /** * Schedule the migration. * * @param int $when Optional timestamp to run the next migration batch. Defaults to now. * * @return string The action ID */ public function schedule_migration( $when = 0 ) { $next = as_next_scheduled_action( self::HOOK ); if ( ! empty( $next ) ) { return $next; } if ( empty( $when ) ) { $when = time() + MINUTE_IN_SECONDS; } return as_schedule_single_action( $when, self::HOOK, array(), self::GROUP ); } /** * Remove the scheduled migration action. */ public function unschedule_migration() { as_unschedule_action( self::HOOK, null, self::GROUP ); } /** * Get migration batch schedule interval. * * @return int Seconds between migration runs. Defaults to 0 seconds to allow chaining migration via Async Runners. */ private function get_schedule_interval() { return (int) apply_filters( 'action_scheduler/migration_interval', 0 ); } /** * Get migration batch size. * * @return int Number of actions to migrate in each batch. Defaults to 250. */ private function get_batch_size() { return (int) apply_filters( 'action_scheduler/migration_batch_size', 250 ); } /** * Get migration runner object. * * @return Runner */ private function get_migration_runner() { $config = Controller::instance()->get_migration_config_object(); return new Runner( $config ); } } inc/importer/lib/action-scheduler/classes/migration/DryRun_LogMigrator.php000064400000000711147600053410023044 0ustar00migration_scheduler = $migration_scheduler; $this->store_classname = ''; } /** * Set the action store class name. * * @param string $class Classname of the store class. * * @return string */ public function get_store_class( $class ) { if ( \ActionScheduler_DataController::is_migration_complete() ) { return \ActionScheduler_DataController::DATASTORE_CLASS; } elseif ( \ActionScheduler_Store::DEFAULT_CLASS !== $class ) { $this->store_classname = $class; return $class; } else { return 'ActionScheduler_HybridStore'; } } /** * Set the action logger class name. * * @param string $class Classname of the logger class. * * @return string */ public function get_logger_class( $class ) { \ActionScheduler_Store::instance(); if ( $this->has_custom_datastore() ) { $this->logger_classname = $class; return $class; } else { return \ActionScheduler_DataController::LOGGER_CLASS; } } /** * Get flag indicating whether a custom datastore is in use. * * @return bool */ public function has_custom_datastore() { return (bool) $this->store_classname; } /** * Set up the background migration process. * * @return void */ public function schedule_migration() { $logging_tables = new ActionScheduler_LoggerSchema(); $store_tables = new ActionScheduler_StoreSchema(); /* * In some unusual cases, the expected tables may not have been created. In such cases * we do not schedule a migration as doing so will lead to fatal error conditions. * * In such cases the user will likely visit the Tools > Scheduled Actions screen to * investigate, and will see appropriate messaging (this step also triggers an attempt * to rebuild any missing tables). * * @see https://github.com/woocommerce/action-scheduler/issues/653 */ if ( ActionScheduler_DataController::is_migration_complete() || $this->migration_scheduler->is_migration_scheduled() || ! $store_tables->tables_exist() || ! $logging_tables->tables_exist() ) { return; } $this->migration_scheduler->schedule_migration(); } /** * Get the default migration config object * * @return ActionScheduler\Migration\Config */ public function get_migration_config_object() { static $config = null; if ( ! $config ) { $source_store = $this->store_classname ? new $this->store_classname() : new \ActionScheduler_wpPostStore(); $source_logger = $this->logger_classname ? new $this->logger_classname() : new \ActionScheduler_wpCommentLogger(); $config = new Config(); $config->set_source_store( $source_store ); $config->set_source_logger( $source_logger ); $config->set_destination_store( new \ActionScheduler_DBStoreMigrator() ); $config->set_destination_logger( new \ActionScheduler_DBLogger() ); if ( defined( 'WP_CLI' ) && WP_CLI ) { $config->set_progress_bar( new ProgressBar( '', 0 ) ); } } return apply_filters( 'action_scheduler/migration_config', $config ); } /** * Hook dashboard migration notice. */ public function hook_admin_notices() { if ( ! $this->allow_migration() || \ActionScheduler_DataController::is_migration_complete() ) { return; } add_action( 'admin_notices', array( $this, 'display_migration_notice' ), 10, 0 ); } /** * Show a dashboard notice that migration is in progress. */ public function display_migration_notice() { printf( '

    %s

    ', esc_html__( 'Action Scheduler migration in progress. The list of scheduled actions may be incomplete.', 'action-scheduler' ) ); } /** * Add store classes. Hook migration. */ private function hook() { add_filter( 'action_scheduler_store_class', array( $this, 'get_store_class' ), 100, 1 ); add_filter( 'action_scheduler_logger_class', array( $this, 'get_logger_class' ), 100, 1 ); add_action( 'init', array( $this, 'maybe_hook_migration' ) ); add_action( 'wp_loaded', array( $this, 'schedule_migration' ) ); // Action Scheduler may be displayed as a Tools screen or WooCommerce > Status administration screen add_action( 'load-tools_page_action-scheduler', array( $this, 'hook_admin_notices' ), 10, 0 ); add_action( 'load-woocommerce_page_wc-status', array( $this, 'hook_admin_notices' ), 10, 0 ); } /** * Possibly hook the migration scheduler action. * * @author Jeremy Pry */ public function maybe_hook_migration() { if ( ! $this->allow_migration() || \ActionScheduler_DataController::is_migration_complete() ) { return; } $this->migration_scheduler->hook(); } /** * Allow datastores to enable migration to AS tables. */ public function allow_migration() { if ( ! \ActionScheduler_DataController::dependencies_met() ) { return false; } if ( null === $this->migrate_custom_store ) { $this->migrate_custom_store = apply_filters( 'action_scheduler_migrate_data_store', false ); } return ( ! $this->has_custom_datastore() ) || $this->migrate_custom_store; } /** * Proceed with the migration if the dependencies have been met. */ public static function init() { if ( \ActionScheduler_DataController::dependencies_met() ) { self::instance()->hook(); } } /** * Singleton factory. */ public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new static( new Scheduler() ); } return self::$instance; } } inc/importer/lib/action-scheduler/classes/migration/Runner.php000064400000007256147600053410020577 0ustar00source_store = $config->get_source_store(); $this->destination_store = $config->get_destination_store(); $this->source_logger = $config->get_source_logger(); $this->destination_logger = $config->get_destination_logger(); $this->batch_fetcher = new BatchFetcher( $this->source_store ); if ( $config->get_dry_run() ) { $this->log_migrator = new DryRun_LogMigrator( $this->source_logger, $this->destination_logger ); $this->action_migrator = new DryRun_ActionMigrator( $this->source_store, $this->destination_store, $this->log_migrator ); } else { $this->log_migrator = new LogMigrator( $this->source_logger, $this->destination_logger ); $this->action_migrator = new ActionMigrator( $this->source_store, $this->destination_store, $this->log_migrator ); } if ( defined( 'WP_CLI' ) && WP_CLI ) { $this->progress_bar = $config->get_progress_bar(); } } /** * Run migration batch. * * @param int $batch_size Optional batch size. Default 10. * * @return int Size of batch processed. */ public function run( $batch_size = 10 ) { $batch = $this->batch_fetcher->fetch( $batch_size ); $batch_size = count( $batch ); if ( ! $batch_size ) { return 0; } if ( $this->progress_bar ) { /* translators: %d: amount of actions */ $this->progress_bar->set_message( sprintf( _n( 'Migrating %d action', 'Migrating %d actions', $batch_size, 'action-scheduler' ), number_format_i18n( $batch_size ) ) ); $this->progress_bar->set_count( $batch_size ); } $this->migrate_actions( $batch ); return $batch_size; } /** * Migration a batch of actions. * * @param array $action_ids List of action IDs to migrate. */ public function migrate_actions( array $action_ids ) { do_action( 'action_scheduler/migration_batch_starting', $action_ids ); \ActionScheduler::logger()->unhook_stored_action(); $this->destination_logger->unhook_stored_action(); foreach ( $action_ids as $source_action_id ) { $destination_action_id = $this->action_migrator->migrate( $source_action_id ); if ( $destination_action_id ) { $this->destination_logger->log( $destination_action_id, sprintf( /* translators: 1: source action ID 2: source store class 3: destination action ID 4: destination store class */ __( 'Migrated action with ID %1$d in %2$s to ID %3$d in %4$s', 'action-scheduler' ), $source_action_id, get_class( $this->source_store ), $destination_action_id, get_class( $this->destination_store ) ) ); } if ( $this->progress_bar ) { $this->progress_bar->tick(); } } if ( $this->progress_bar ) { $this->progress_bar->finish(); } \ActionScheduler::logger()->hook_stored_action(); do_action( 'action_scheduler/migration_batch_complete', $action_ids ); } /** * Initialize destination store and logger. */ public function init_destination() { $this->destination_store->init(); $this->destination_logger->init(); } } inc/importer/lib/action-scheduler/classes/schedules/ActionScheduler_SimpleSchedule.php000064400000004154147600053410025350 0ustar00__wakeup() for details. **/ private $timestamp = NULL; /** * @param DateTime $after * * @return DateTime|null */ public function calculate_next( DateTime $after ) { return null; } /** * @return bool */ public function is_recurring() { return false; } /** * Serialize schedule with data required prior to AS 3.0.0 * * Prior to Action Scheduler 3.0.0, schedules used different property names to refer * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 * aligned properties and property names for better inheritance. To guard against the * scheduled date for single actions always being seen as "now" if downgrading to * Action Scheduler < 3.0.0, we need to also store the data with the old property names * so if it's unserialized in AS < 3.0, the schedule doesn't end up with a null recurrence. * * @return array */ public function __sleep() { $sleep_params = parent::__sleep(); $this->timestamp = $this->scheduled_timestamp; return array_merge( $sleep_params, array( 'timestamp', ) ); } /** * Unserialize recurring schedules serialized/stored prior to AS 3.0.0 * * Prior to Action Scheduler 3.0.0, schedules used different property names to refer * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 * aligned properties and property names for better inheritance. To maintain backward * compatibility with schedules serialized and stored prior to 3.0, we need to correctly * map the old property names with matching visibility. */ public function __wakeup() { if ( is_null( $this->scheduled_timestamp ) && ! is_null( $this->timestamp ) ) { $this->scheduled_timestamp = $this->timestamp; unset( $this->timestamp ); } parent::__wakeup(); } } inc/importer/lib/action-scheduler/classes/schedules/ActionScheduler_CanceledSchedule.php000064400000002705147600053410025615 0ustar00__wakeup() for details. **/ private $timestamp = NULL; /** * @param DateTime $after * * @return DateTime|null */ public function calculate_next( DateTime $after ) { return null; } /** * Cancelled actions should never have a next schedule, even if get_next() * is called with $after < $this->scheduled_date. * * @param DateTime $after * @return DateTime|null */ public function get_next( DateTime $after ) { return null; } /** * @return bool */ public function is_recurring() { return false; } /** * Unserialize recurring schedules serialized/stored prior to AS 3.0.0 * * Prior to Action Scheduler 3.0.0, schedules used different property names to refer * to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 * aligned properties and property names for better inheritance. To maintain backward * compatibility with schedules serialized and stored prior to 3.0, we need to correctly * map the old property names with matching visibility. */ public function __wakeup() { if ( ! is_null( $this->timestamp ) ) { $this->scheduled_timestamp = $this->timestamp; unset( $this->timestamp ); } parent::__wakeup(); } } inc/importer/lib/action-scheduler/classes/schedules/ActionScheduler_Schedule.php000064400000000406147600053410024172 0ustar00scheduled_date = null; } /** * This schedule has no scheduled DateTime, so we need to override the parent __sleep() * @return array */ public function __sleep() { return array(); } public function __wakeup() { $this->scheduled_date = null; } } inc/importer/lib/action-scheduler/classes/schedules/ActionScheduler_IntervalSchedule.php000064400000004752147600053410025707 0ustar00__wakeup() for details. **/ private $start_timestamp = NULL; /** * Deprecated property @see $this->__wakeup() for details. **/ private $interval_in_seconds = NULL; /** * Calculate when this schedule should start after a given date & time using * the number of seconds between recurrences. * * @param DateTime $after * @return DateTime */ protected function calculate_next( DateTime $after ) { $after->modify( '+' . (int) $this->get_recurrence() . ' seconds' ); return $after; } /** * @return int */ public function interval_in_seconds() { _deprecated_function( __METHOD__, '3.0.0', '(int)ActionScheduler_Abstract_RecurringSchedule::get_recurrence()' ); return (int) $this->get_recurrence(); } /** * Serialize interval schedules with data required prior to AS 3.0.0 * * Prior to Action Scheduler 3.0.0, reccuring schedules used different property names to * refer to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 * aligned properties and property names for better inheritance. To guard against the * possibility of infinite loops if downgrading to Action Scheduler < 3.0.0, we need to * also store the data with the old property names so if it's unserialized in AS < 3.0, * the schedule doesn't end up with a null/false/0 recurrence. * * @return array */ public function __sleep() { $sleep_params = parent::__sleep(); $this->start_timestamp = $this->scheduled_timestamp; $this->interval_in_seconds = $this->recurrence; return array_merge( $sleep_params, array( 'start_timestamp', 'interval_in_seconds' ) ); } /** * Unserialize interval schedules serialized/stored prior to AS 3.0.0 * * For more background, @see ActionScheduler_Abstract_RecurringSchedule::__wakeup(). */ public function __wakeup() { if ( is_null( $this->scheduled_timestamp ) && ! is_null( $this->start_timestamp ) ) { $this->scheduled_timestamp = $this->start_timestamp; unset( $this->start_timestamp ); } if ( is_null( $this->recurrence ) && ! is_null( $this->interval_in_seconds ) ) { $this->recurrence = $this->interval_in_seconds; unset( $this->interval_in_seconds ); } parent::__wakeup(); } } inc/importer/lib/action-scheduler/classes/schedules/ActionScheduler_CronSchedule.php000064400000007201147600053410025014 0ustar00__wakeup() for details. **/ private $start_timestamp = NULL; /** * Deprecated property @see $this->__wakeup() for details. **/ private $cron = NULL; /** * Wrapper for parent constructor to accept a cron expression string and map it to a CronExpression for this * objects $recurrence property. * * @param DateTime $start The date & time to run the action at or after. If $start aligns with the CronSchedule passed via $recurrence, it will be used. If it does not align, the first matching date after it will be used. * @param CronExpression|string $recurrence The CronExpression used to calculate the schedule's next instance. * @param DateTime|null $first (Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance. */ public function __construct( DateTime $start, $recurrence, DateTime $first = null ) { if ( ! is_a( $recurrence, 'CronExpression' ) ) { $recurrence = CronExpression::factory( $recurrence ); } // For backward compatibility, we need to make sure the date is set to the first matching cron date, not whatever date is passed in. Importantly, by passing true as the 3rd param, if $start matches the cron expression, then it will be used. This was previously handled in the now deprecated next() method. $date = $recurrence->getNextRunDate( $start, 0, true ); // parent::__construct() will set this to $date by default, but that may be different to $start now. $first = empty( $first ) ? $start : $first; parent::__construct( $date, $recurrence, $first ); } /** * Calculate when an instance of this schedule would start based on a given * date & time using its the CronExpression. * * @param DateTime $after * @return DateTime */ protected function calculate_next( DateTime $after ) { return $this->recurrence->getNextRunDate( $after, 0, false ); } /** * @return string */ public function get_recurrence() { return strval( $this->recurrence ); } /** * Serialize cron schedules with data required prior to AS 3.0.0 * * Prior to Action Scheduler 3.0.0, reccuring schedules used different property names to * refer to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp * was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 * aligned properties and property names for better inheritance. To guard against the * possibility of infinite loops if downgrading to Action Scheduler < 3.0.0, we need to * also store the data with the old property names so if it's unserialized in AS < 3.0, * the schedule doesn't end up with a null recurrence. * * @return array */ public function __sleep() { $sleep_params = parent::__sleep(); $this->start_timestamp = $this->scheduled_timestamp; $this->cron = $this->recurrence; return array_merge( $sleep_params, array( 'start_timestamp', 'cron' ) ); } /** * Unserialize cron schedules serialized/stored prior to AS 3.0.0 * * For more background, @see ActionScheduler_Abstract_RecurringSchedule::__wakeup(). */ public function __wakeup() { if ( is_null( $this->scheduled_timestamp ) && ! is_null( $this->start_timestamp ) ) { $this->scheduled_timestamp = $this->start_timestamp; unset( $this->start_timestamp ); } if ( is_null( $this->recurrence ) && ! is_null( $this->cron ) ) { $this->recurrence = $this->cron; unset( $this->cron ); } parent::__wakeup(); } } inc/importer/lib/action-scheduler/classes/schema/ActionScheduler_StoreSchema.php000064400000011100147600053410024125 0ustar00tables = [ self::ACTIONS_TABLE, self::CLAIMS_TABLE, self::GROUPS_TABLE, ]; } /** * Performs additional setup work required to support this schema. */ public function init() { add_action( 'action_scheduler_before_schema_update', array( $this, 'update_schema_5_0' ), 10, 2 ); } protected function get_table_definition( $table ) { global $wpdb; $table_name = $wpdb->$table; $charset_collate = $wpdb->get_charset_collate(); $max_index_length = 191; // @see wp_get_db_schema() $default_date = self::DEFAULT_DATE; switch ( $table ) { case self::ACTIONS_TABLE: return "CREATE TABLE {$table_name} ( action_id bigint(20) unsigned NOT NULL auto_increment, hook varchar(191) NOT NULL, status varchar(20) NOT NULL, scheduled_date_gmt datetime NULL default '${default_date}', scheduled_date_local datetime NULL default '${default_date}', args varchar($max_index_length), schedule longtext, group_id bigint(20) unsigned NOT NULL default '0', attempts int(11) NOT NULL default '0', last_attempt_gmt datetime NULL default '${default_date}', last_attempt_local datetime NULL default '${default_date}', claim_id bigint(20) unsigned NOT NULL default '0', extended_args varchar(8000) DEFAULT NULL, PRIMARY KEY (action_id), KEY hook (hook($max_index_length)), KEY status (status), KEY scheduled_date_gmt (scheduled_date_gmt), KEY args (args($max_index_length)), KEY group_id (group_id), KEY last_attempt_gmt (last_attempt_gmt), KEY claim_id (claim_id), KEY `claim_id_status_scheduled_date_gmt` (`claim_id`, `status`, `scheduled_date_gmt`) ) $charset_collate"; case self::CLAIMS_TABLE: return "CREATE TABLE {$table_name} ( claim_id bigint(20) unsigned NOT NULL auto_increment, date_created_gmt datetime NULL default '${default_date}', PRIMARY KEY (claim_id), KEY date_created_gmt (date_created_gmt) ) $charset_collate"; case self::GROUPS_TABLE: return "CREATE TABLE {$table_name} ( group_id bigint(20) unsigned NOT NULL auto_increment, slug varchar(255) NOT NULL, PRIMARY KEY (group_id), KEY slug (slug($max_index_length)) ) $charset_collate"; default: return ''; } } /** * Update the actions table schema, allowing datetime fields to be NULL. * * This is needed because the NOT NULL constraint causes a conflict with some versions of MySQL * configured with sql_mode=NO_ZERO_DATE, which can for instance lead to tables not being created. * * Most other schema updates happen via ActionScheduler_Abstract_Schema::update_table(), however * that method relies on dbDelta() and this change is not possible when using that function. * * @param string $table Name of table being updated. * @param string $db_version The existing schema version of the table. */ public function update_schema_5_0( $table, $db_version ) { global $wpdb; if ( 'actionscheduler_actions' !== $table || version_compare( $db_version, '5', '>=' ) ) { return; } // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared $table_name = $wpdb->prefix . 'actionscheduler_actions'; $table_list = $wpdb->get_col( "SHOW TABLES LIKE '${table_name}'" ); $default_date = self::DEFAULT_DATE; if ( ! empty( $table_list ) ) { $query = " ALTER TABLE ${table_name} MODIFY COLUMN scheduled_date_gmt datetime NULL default '${default_date}', MODIFY COLUMN scheduled_date_local datetime NULL default '${default_date}', MODIFY COLUMN last_attempt_gmt datetime NULL default '${default_date}', MODIFY COLUMN last_attempt_local datetime NULL default '${default_date}' "; $wpdb->query( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared } // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared } } inc/importer/lib/action-scheduler/classes/schema/ActionScheduler_LoggerSchema.php000064400000005464147600053410024270 0ustar00tables = [ self::LOG_TABLE, ]; } /** * Performs additional setup work required to support this schema. */ public function init() { add_action( 'action_scheduler_before_schema_update', array( $this, 'update_schema_3_0' ), 10, 2 ); } protected function get_table_definition( $table ) { global $wpdb; $table_name = $wpdb->$table; $charset_collate = $wpdb->get_charset_collate(); switch ( $table ) { case self::LOG_TABLE: $default_date = ActionScheduler_StoreSchema::DEFAULT_DATE; return "CREATE TABLE {$table_name} ( log_id bigint(20) unsigned NOT NULL auto_increment, action_id bigint(20) unsigned NOT NULL, message text NOT NULL, log_date_gmt datetime NULL default '${default_date}', log_date_local datetime NULL default '${default_date}', PRIMARY KEY (log_id), KEY action_id (action_id), KEY log_date_gmt (log_date_gmt) ) $charset_collate"; default: return ''; } } /** * Update the logs table schema, allowing datetime fields to be NULL. * * This is needed because the NOT NULL constraint causes a conflict with some versions of MySQL * configured with sql_mode=NO_ZERO_DATE, which can for instance lead to tables not being created. * * Most other schema updates happen via ActionScheduler_Abstract_Schema::update_table(), however * that method relies on dbDelta() and this change is not possible when using that function. * * @param string $table Name of table being updated. * @param string $db_version The existing schema version of the table. */ public function update_schema_3_0( $table, $db_version ) { global $wpdb; if ( 'actionscheduler_logs' !== $table || version_compare( $db_version, '3', '>=' ) ) { return; } // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared $table_name = $wpdb->prefix . 'actionscheduler_logs'; $table_list = $wpdb->get_col( "SHOW TABLES LIKE '${table_name}'" ); $default_date = ActionScheduler_StoreSchema::DEFAULT_DATE; if ( ! empty( $table_list ) ) { $query = " ALTER TABLE ${table_name} MODIFY COLUMN log_date_gmt datetime NULL default '${default_date}', MODIFY COLUMN log_date_local datetime NULL default '${default_date}' "; $wpdb->query( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared } // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared } } inc/importer/lib/action-scheduler/classes/ActionScheduler_LogEntry.php000064400000003344147600053410022226 0ustar00comment_type * to ActionScheduler_LogEntry::__construct(), goodness knows why, and the Follow-up Emails plugin * hard-codes loading its own version of ActionScheduler_wpCommentLogger with that out-dated method, * goodness knows why, so we need to guard against that here instead of using a DateTime type declaration * for the constructor's 3rd param of $date and causing a fatal error with older versions of FUE. */ if ( null !== $date && ! is_a( $date, 'DateTime' ) ) { _doing_it_wrong( __METHOD__, 'The third parameter must be a valid DateTime instance, or null.', '2.0.0' ); $date = null; } $this->action_id = $action_id; $this->message = $message; $this->date = $date ? $date : new Datetime; } /** * Returns the date when this log entry was created * * @return Datetime */ public function get_date() { return $this->date; } public function get_action_id() { return $this->action_id; } public function get_message() { return $this->message; } } inc/importer/lib/action-scheduler/classes/ActionScheduler_WPCommentCleaner.php000064400000010470147600053410023624 0ustar00 Status administration screen add_action( 'load-tools_page_action-scheduler', array( __CLASS__, 'register_admin_notice' ) ); add_action( 'load-woocommerce_page_wc-status', array( __CLASS__, 'register_admin_notice' ) ); } /** * Determines if there are log entries in the wp comments table. * * Uses the flag set on migration completion set by @see self::maybe_schedule_cleanup(). * * @return boolean Whether there are scheduled action comments in the comments table. */ public static function has_logs() { return 'yes' === get_option( self::$has_logs_option_key ); } /** * Schedules the WP Post comment table cleanup to run in 6 months if it's not already scheduled. * Attached to the migration complete hook 'action_scheduler/migration_complete'. */ public static function maybe_schedule_cleanup() { if ( (bool) get_comments( array( 'type' => ActionScheduler_wpCommentLogger::TYPE, 'number' => 1, 'fields' => 'ids' ) ) ) { update_option( self::$has_logs_option_key, 'yes' ); if ( ! as_next_scheduled_action( self::$cleanup_hook ) ) { as_schedule_single_action( gmdate( 'U' ) + ( 6 * MONTH_IN_SECONDS ), self::$cleanup_hook ); } } } /** * Delete all action comments from the WP Comments table. */ public static function delete_all_action_comments() { global $wpdb; $wpdb->delete( $wpdb->comments, array( 'comment_type' => ActionScheduler_wpCommentLogger::TYPE, 'comment_agent' => ActionScheduler_wpCommentLogger::AGENT ) ); delete_option( self::$has_logs_option_key ); } /** * Registers admin notices about the orphaned action logs. */ public static function register_admin_notice() { add_action( 'admin_notices', array( __CLASS__, 'print_admin_notice' ) ); } /** * Prints details about the orphaned action logs and includes information on where to learn more. */ public static function print_admin_notice() { $next_cleanup_message = ''; $next_scheduled_cleanup_hook = as_next_scheduled_action( self::$cleanup_hook ); if ( $next_scheduled_cleanup_hook ) { /* translators: %s: date interval */ $next_cleanup_message = sprintf( __( 'This data will be deleted in %s.', 'action-scheduler' ), human_time_diff( gmdate( 'U' ), $next_scheduled_cleanup_hook ) ); } $notice = sprintf( /* translators: 1: next cleanup message 2: github issue URL */ __( 'Action Scheduler has migrated data to custom tables; however, orphaned log entries exist in the WordPress Comments table. %1$s Learn more »', 'action-scheduler' ), $next_cleanup_message, 'https://github.com/woocommerce/action-scheduler/issues/368' ); echo '

    ' . wp_kses_post( $notice ) . '

    '; } } inc/importer/lib/action-scheduler/classes/ActionScheduler_Compatibility.php000064400000006235147600053410023276 0ustar00 $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) { if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) { return $filtered_limit; } else { return false; } } elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) { if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) { return $wp_max_limit; } else { return false; } } return false; } /** * Attempts to raise the PHP timeout for time intensive processes. * * Only allows raising the existing limit and prevents lowering it. Wrapper for wc_set_time_limit(), when available. * * @param int The time limit in seconds. */ public static function raise_time_limit( $limit = 0 ) { if ( $limit < ini_get( 'max_execution_time' ) ) { return; } if ( function_exists( 'wc_set_time_limit' ) ) { wc_set_time_limit( $limit ); } elseif ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved @set_time_limit( $limit ); } } } inc/importer/lib/action-scheduler/classes/ActionScheduler_QueueCleaner.php000064400000012170147600053410023036 0ustar00store = $store ? $store : ActionScheduler_Store::instance(); $this->batch_size = $batch_size; } public function delete_old_actions() { $lifespan = apply_filters( 'action_scheduler_retention_period', $this->month_in_seconds ); $cutoff = as_get_datetime_object($lifespan.' seconds ago'); $statuses_to_purge = array( ActionScheduler_Store::STATUS_COMPLETE, ActionScheduler_Store::STATUS_CANCELED, ); foreach ( $statuses_to_purge as $status ) { $actions_to_delete = $this->store->query_actions( array( 'status' => $status, 'modified' => $cutoff, 'modified_compare' => '<=', 'per_page' => $this->get_batch_size(), 'orderby' => 'none', ) ); foreach ( $actions_to_delete as $action_id ) { try { $this->store->delete_action( $action_id ); } catch ( Exception $e ) { /** * Notify 3rd party code of exceptions when deleting a completed action older than the retention period * * This hook provides a way for 3rd party code to log or otherwise handle exceptions relating to their * actions. * * @since 2.0.0 * * @param int $action_id The scheduled actions ID in the data store * @param Exception $e The exception thrown when attempting to delete the action from the data store * @param int $lifespan The retention period, in seconds, for old actions * @param int $count_of_actions_to_delete The number of old actions being deleted in this batch */ do_action( 'action_scheduler_failed_old_action_deletion', $action_id, $e, $lifespan, count( $actions_to_delete ) ); } } } } /** * Unclaim pending actions that have not been run within a given time limit. * * When called by ActionScheduler_Abstract_QueueRunner::run_cleanup(), the time limit passed * as a parameter is 10x the time limit used for queue processing. * * @param int $time_limit The number of seconds to allow a queue to run before unclaiming its pending actions. Default 300 (5 minutes). */ public function reset_timeouts( $time_limit = 300 ) { $timeout = apply_filters( 'action_scheduler_timeout_period', $time_limit ); if ( $timeout < 0 ) { return; } $cutoff = as_get_datetime_object($timeout.' seconds ago'); $actions_to_reset = $this->store->query_actions( array( 'status' => ActionScheduler_Store::STATUS_PENDING, 'modified' => $cutoff, 'modified_compare' => '<=', 'claimed' => true, 'per_page' => $this->get_batch_size(), 'orderby' => 'none', ) ); foreach ( $actions_to_reset as $action_id ) { $this->store->unclaim_action( $action_id ); do_action( 'action_scheduler_reset_action', $action_id ); } } /** * Mark actions that have been running for more than a given time limit as failed, based on * the assumption some uncatachable and unloggable fatal error occurred during processing. * * When called by ActionScheduler_Abstract_QueueRunner::run_cleanup(), the time limit passed * as a parameter is 10x the time limit used for queue processing. * * @param int $time_limit The number of seconds to allow an action to run before it is considered to have failed. Default 300 (5 minutes). */ public function mark_failures( $time_limit = 300 ) { $timeout = apply_filters( 'action_scheduler_failure_period', $time_limit ); if ( $timeout < 0 ) { return; } $cutoff = as_get_datetime_object($timeout.' seconds ago'); $actions_to_reset = $this->store->query_actions( array( 'status' => ActionScheduler_Store::STATUS_RUNNING, 'modified' => $cutoff, 'modified_compare' => '<=', 'per_page' => $this->get_batch_size(), 'orderby' => 'none', ) ); foreach ( $actions_to_reset as $action_id ) { $this->store->mark_failure( $action_id ); do_action( 'action_scheduler_failed_action', $action_id, $timeout ); } } /** * Do all of the cleaning actions. * * @param int $time_limit The number of seconds to use as the timeout and failure period. Default 300 (5 minutes). * @author Jeremy Pry */ public function clean( $time_limit = 300 ) { $this->delete_old_actions(); $this->reset_timeouts( $time_limit ); $this->mark_failures( $time_limit ); } /** * Get the batch size for cleaning the queue. * * @author Jeremy Pry * @return int */ protected function get_batch_size() { /** * Filter the batch size when cleaning the queue. * * @param int $batch_size The number of actions to clean in one batch. */ return absint( apply_filters( 'action_scheduler_cleanup_batch_size', $this->batch_size ) ); } } inc/importer/lib/action-scheduler/classes/ActionScheduler_ActionFactory.php000064400000017416147600053410023235 0ustar00get_date() ); } break; default : $action_class = 'ActionScheduler_FinishedAction'; break; } $action_class = apply_filters( 'action_scheduler_stored_action_class', $action_class, $status, $hook, $args, $schedule, $group ); $action = new $action_class( $hook, $args, $schedule, $group ); /** * Allow 3rd party code to change the instantiated action for a given hook, args, schedule and group. * * @param ActionScheduler_Action $action The instantiated action. * @param string $hook The instantiated action's hook. * @param array $args The instantiated action's args. * @param ActionScheduler_Schedule $schedule The instantiated action's schedule. * @param string $group The instantiated action's group. */ return apply_filters( 'action_scheduler_stored_action_instance', $action, $hook, $args, $schedule, $group ); } /** * Enqueue an action to run one time, as soon as possible (rather a specific scheduled time). * * This method creates a new action with the NULLSchedule. This schedule maps to a MySQL datetime string of * 0000-00-00 00:00:00. This is done to create a psuedo "async action" type that is fully backward compatible. * Existing queries to claim actions claim by date, meaning actions scheduled for 0000-00-00 00:00:00 will * always be claimed prior to actions scheduled for a specific date. This makes sure that any async action is * given priority in queue processing. This has the added advantage of making sure async actions can be * claimed by both the existing WP Cron and WP CLI runners, as well as a new async request runner. * * @param string $hook The hook to trigger when this action runs * @param array $args Args to pass when the hook is triggered * @param string $group A group to put the action in * * @return int The ID of the stored action */ public function async( $hook, $args = array(), $group = '' ) { $schedule = new ActionScheduler_NullSchedule(); $action = new ActionScheduler_Action( $hook, $args, $schedule, $group ); return $this->store( $action ); } /** * @param string $hook The hook to trigger when this action runs * @param array $args Args to pass when the hook is triggered * @param int $when Unix timestamp when the action will run * @param string $group A group to put the action in * * @return int The ID of the stored action */ public function single( $hook, $args = array(), $when = null, $group = '' ) { $date = as_get_datetime_object( $when ); $schedule = new ActionScheduler_SimpleSchedule( $date ); $action = new ActionScheduler_Action( $hook, $args, $schedule, $group ); return $this->store( $action ); } /** * Create the first instance of an action recurring on a given interval. * * @param string $hook The hook to trigger when this action runs * @param array $args Args to pass when the hook is triggered * @param int $first Unix timestamp for the first run * @param int $interval Seconds between runs * @param string $group A group to put the action in * * @return int The ID of the stored action */ public function recurring( $hook, $args = array(), $first = null, $interval = null, $group = '' ) { if ( empty($interval) ) { return $this->single( $hook, $args, $first, $group ); } $date = as_get_datetime_object( $first ); $schedule = new ActionScheduler_IntervalSchedule( $date, $interval ); $action = new ActionScheduler_Action( $hook, $args, $schedule, $group ); return $this->store( $action ); } /** * Create the first instance of an action recurring on a Cron schedule. * * @param string $hook The hook to trigger when this action runs * @param array $args Args to pass when the hook is triggered * @param int $base_timestamp The first instance of the action will be scheduled * to run at a time calculated after this timestamp matching the cron * expression. This can be used to delay the first instance of the action. * @param int $schedule A cron definition string * @param string $group A group to put the action in * * @return int The ID of the stored action */ public function cron( $hook, $args = array(), $base_timestamp = null, $schedule = null, $group = '' ) { if ( empty($schedule) ) { return $this->single( $hook, $args, $base_timestamp, $group ); } $date = as_get_datetime_object( $base_timestamp ); $cron = CronExpression::factory( $schedule ); $schedule = new ActionScheduler_CronSchedule( $date, $cron ); $action = new ActionScheduler_Action( $hook, $args, $schedule, $group ); return $this->store( $action ); } /** * Create a successive instance of a recurring or cron action. * * Importantly, the action will be rescheduled to run based on the current date/time. * That means when the action is scheduled to run in the past, the next scheduled date * will be pushed forward. For example, if a recurring action set to run every hour * was scheduled to run 5 seconds ago, it will be next scheduled for 1 hour in the * future, which is 1 hour and 5 seconds from when it was last scheduled to run. * * Alternatively, if the action is scheduled to run in the future, and is run early, * likely via manual intervention, then its schedule will change based on the time now. * For example, if a recurring action set to run every day, and is run 12 hours early, * it will run again in 24 hours, not 36 hours. * * This slippage is less of an issue with Cron actions, as the specific run time can * be set for them to run, e.g. 1am each day. In those cases, and entire period would * need to be missed before there was any change is scheduled, e.g. in the case of an * action scheduled for 1am each day, the action would need to run an entire day late. * * @param ActionScheduler_Action $action The existing action. * * @return string The ID of the stored action * @throws InvalidArgumentException If $action is not a recurring action. */ public function repeat( $action ) { $schedule = $action->get_schedule(); $next = $schedule->get_next( as_get_datetime_object() ); if ( is_null( $next ) || ! $schedule->is_recurring() ) { throw new InvalidArgumentException( __( 'Invalid action - must be a recurring action.', 'action-scheduler' ) ); } $schedule_class = get_class( $schedule ); $new_schedule = new $schedule( $next, $schedule->get_recurrence(), $schedule->get_first_date() ); $new_action = new ActionScheduler_Action( $action->get_hook(), $action->get_args(), $new_schedule, $action->get_group() ); return $this->store( $new_action ); } /** * @param ActionScheduler_Action $action * * @return int The ID of the stored action */ protected function store( ActionScheduler_Action $action ) { $store = ActionScheduler_Store::instance(); return $store->save_action( $action ); } } inc/importer/lib/action-scheduler/classes/ActionScheduler_DataController.php000064400000012245147600053410023400 0ustar00=' ); return $php_support && apply_filters( 'action_scheduler_migration_dependencies_met', true ); } /** * Get a flag indicating whether the migration is complete. * * @return bool Whether the flag has been set marking the migration as complete */ public static function is_migration_complete() { return get_option( self::STATUS_FLAG ) === self::STATUS_COMPLETE; } /** * Mark the migration as complete. */ public static function mark_migration_complete() { update_option( self::STATUS_FLAG, self::STATUS_COMPLETE ); } /** * Unmark migration when a plugin is de-activated. Will not work in case of silent activation, for example in an update. * We do this to mitigate the bug of lost actions which happens if there was an AS 2.x to AS 3.x migration in the past, but that plugin is now * deactivated and the site was running on AS 2.x again. */ public static function mark_migration_incomplete() { delete_option( self::STATUS_FLAG ); } /** * Set the action store class name. * * @param string $class Classname of the store class. * * @return string */ public static function set_store_class( $class ) { return self::DATASTORE_CLASS; } /** * Set the action logger class name. * * @param string $class Classname of the logger class. * * @return string */ public static function set_logger_class( $class ) { return self::LOGGER_CLASS; } /** * Set the sleep time in seconds. * * @param integer $sleep_time The number of seconds to pause before resuming operation. */ public static function set_sleep_time( $sleep_time ) { self::$sleep_time = (int) $sleep_time; } /** * Set the tick count required for freeing memory. * * @param integer $free_ticks The number of ticks to free memory on. */ public static function set_free_ticks( $free_ticks ) { self::$free_ticks = (int) $free_ticks; } /** * Free memory if conditions are met. * * @param int $ticks Current tick count. */ public static function maybe_free_memory( $ticks ) { if ( self::$free_ticks && 0 === $ticks % self::$free_ticks ) { self::free_memory(); } } /** * Reduce memory footprint by clearing the database query and object caches. */ public static function free_memory() { if ( 0 < self::$sleep_time ) { /* translators: %d: amount of time */ \WP_CLI::warning( sprintf( _n( 'Stopped the insanity for %d second', 'Stopped the insanity for %d seconds', self::$sleep_time, 'action-scheduler' ), self::$sleep_time ) ); sleep( self::$sleep_time ); } \WP_CLI::warning( __( 'Attempting to reduce used memory...', 'action-scheduler' ) ); /** * @var $wpdb \wpdb * @var $wp_object_cache \WP_Object_Cache */ global $wpdb, $wp_object_cache; $wpdb->queries = array(); if ( ! is_a( $wp_object_cache, 'WP_Object_Cache' ) ) { return; } $wp_object_cache->group_ops = array(); $wp_object_cache->stats = array(); $wp_object_cache->memcache_debug = array(); $wp_object_cache->cache = array(); if ( is_callable( array( $wp_object_cache, '__remoteset' ) ) ) { call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important } } /** * Connect to table datastores if migration is complete. * Otherwise, proceed with the migration if the dependencies have been met. */ public static function init() { if ( self::is_migration_complete() ) { add_filter( 'action_scheduler_store_class', array( 'ActionScheduler_DataController', 'set_store_class' ), 100 ); add_filter( 'action_scheduler_logger_class', array( 'ActionScheduler_DataController', 'set_logger_class' ), 100 ); add_action( 'deactivate_plugin', array( 'ActionScheduler_DataController', 'mark_migration_incomplete' ) ); } elseif ( self::dependencies_met() ) { Controller::init(); } add_action( 'action_scheduler/progress_tick', array( 'ActionScheduler_DataController', 'maybe_free_memory' ) ); } /** * Singleton factory. */ public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new static(); } return self::$instance; } } inc/importer/lib/action-scheduler/classes/ActionScheduler_OptionLock.php000064400000003361147600053410022543 0ustar00maybe_dispatch_async_request() uses a lock to avoid * calling ActionScheduler_QueueRunner->has_maximum_concurrent_batches() every time the 'shutdown', * hook is triggered, because that method calls ActionScheduler_QueueRunner->store->get_claim_count() * to find the current number of claims in the database. * * @param string $lock_type A string to identify different lock types. * @bool True if lock value has changed, false if not or if set failed. */ public function set( $lock_type ) { return update_option( $this->get_key( $lock_type ), time() + $this->get_duration( $lock_type ) ); } /** * If a lock is set, return the timestamp it was set to expiry. * * @param string $lock_type A string to identify different lock types. * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire. */ public function get_expiration( $lock_type ) { return get_option( $this->get_key( $lock_type ) ); } /** * Get the key to use for storing the lock in the transient * * @param string $lock_type A string to identify different lock types. * @return string */ protected function get_key( $lock_type ) { return sprintf( 'action_scheduler_lock_%s', $lock_type ); } } inc/importer/lib/action-scheduler/classes/ActionScheduler_Exception.php000064400000000323147600053410022413 0ustar00id = $id; $this->action_ids = $action_ids; } public function get_id() { return $this->id; } public function get_actions() { return $this->action_ids; } } inc/importer/lib/action-scheduler/classes/ActionScheduler_NullLogEntry.php000064400000000333147600053410023054 0ustar00store = $store; } public function attach( ActionScheduler_ActionClaim $claim ) { $this->claim = $claim; add_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) ); add_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0, 1 ); add_action( 'action_scheduler_after_execute', array( $this, 'untrack_action' ), 0, 0 ); add_action( 'action_scheduler_execution_ignored', array( $this, 'untrack_action' ), 0, 0 ); add_action( 'action_scheduler_failed_execution', array( $this, 'untrack_action' ), 0, 0 ); } public function detach() { $this->claim = NULL; $this->untrack_action(); remove_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) ); remove_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0 ); remove_action( 'action_scheduler_after_execute', array( $this, 'untrack_action' ), 0 ); remove_action( 'action_scheduler_execution_ignored', array( $this, 'untrack_action' ), 0 ); remove_action( 'action_scheduler_failed_execution', array( $this, 'untrack_action' ), 0 ); } public function track_current_action( $action_id ) { $this->action_id = $action_id; } public function untrack_action() { $this->action_id = 0; } public function handle_unexpected_shutdown() { if ( $error = error_get_last() ) { if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ) ) ) { if ( !empty($this->action_id) ) { $this->store->mark_failure( $this->action_id ); do_action( 'action_scheduler_unexpected_shutdown', $this->action_id, $error ); } } $this->store->release_claim( $this->claim ); } } } inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php000064400000045733147600053410022356 0ustar00 label). * * @var array */ protected $columns = array(); /** * Actions (name => label). * * @var array */ protected $row_actions = array(); /** * The active data stores * * @var ActionScheduler_Store */ protected $store; /** * A logger to use for getting action logs to display * * @var ActionScheduler_Logger */ protected $logger; /** * A ActionScheduler_QueueRunner runner instance (or child class) * * @var ActionScheduler_QueueRunner */ protected $runner; /** * Bulk actions. The key of the array is the method name of the implementation: * * bulk_(array $ids, string $sql_in). * * See the comments in the parent class for further details * * @var array */ protected $bulk_actions = array(); /** * Flag variable to render our notifications, if any, once. * * @var bool */ protected static $did_notification = false; /** * Array of seconds for common time periods, like week or month, alongside an internationalised string representation, i.e. "Day" or "Days" * * @var array */ private static $time_periods; /** * Sets the current data store object into `store->action` and initialises the object. * * @param ActionScheduler_Store $store * @param ActionScheduler_Logger $logger * @param ActionScheduler_QueueRunner $runner */ public function __construct( ActionScheduler_Store $store, ActionScheduler_Logger $logger, ActionScheduler_QueueRunner $runner ) { $this->store = $store; $this->logger = $logger; $this->runner = $runner; $this->table_header = __( 'Scheduled Actions', 'action-scheduler' ); $this->bulk_actions = array( 'delete' => __( 'Delete', 'action-scheduler' ), ); $this->columns = array( 'hook' => __( 'Hook', 'action-scheduler' ), 'status' => __( 'Status', 'action-scheduler' ), 'args' => __( 'Arguments', 'action-scheduler' ), 'group' => __( 'Group', 'action-scheduler' ), 'recurrence' => __( 'Recurrence', 'action-scheduler' ), 'schedule' => __( 'Scheduled Date', 'action-scheduler' ), 'log_entries' => __( 'Log', 'action-scheduler' ), ); $this->sort_by = array( 'schedule', 'hook', 'group', ); $this->search_by = array( 'hook', 'args', 'claim_id', ); $request_status = $this->get_request_status(); if ( empty( $request_status ) ) { $this->sort_by[] = 'status'; } elseif ( in_array( $request_status, array( 'in-progress', 'failed' ) ) ) { $this->columns += array( 'claim_id' => __( 'Claim ID', 'action-scheduler' ) ); $this->sort_by[] = 'claim_id'; } $this->row_actions = array( 'hook' => array( 'run' => array( 'name' => __( 'Run', 'action-scheduler' ), 'desc' => __( 'Process the action now as if it were run as part of a queue', 'action-scheduler' ), ), 'cancel' => array( 'name' => __( 'Cancel', 'action-scheduler' ), 'desc' => __( 'Cancel the action now to avoid it being run in future', 'action-scheduler' ), 'class' => 'cancel trash', ), ), ); self::$time_periods = array( array( 'seconds' => YEAR_IN_SECONDS, /* translators: %s: amount of time */ 'names' => _n_noop( '%s year', '%s years', 'action-scheduler' ), ), array( 'seconds' => MONTH_IN_SECONDS, /* translators: %s: amount of time */ 'names' => _n_noop( '%s month', '%s months', 'action-scheduler' ), ), array( 'seconds' => WEEK_IN_SECONDS, /* translators: %s: amount of time */ 'names' => _n_noop( '%s week', '%s weeks', 'action-scheduler' ), ), array( 'seconds' => DAY_IN_SECONDS, /* translators: %s: amount of time */ 'names' => _n_noop( '%s day', '%s days', 'action-scheduler' ), ), array( 'seconds' => HOUR_IN_SECONDS, /* translators: %s: amount of time */ 'names' => _n_noop( '%s hour', '%s hours', 'action-scheduler' ), ), array( 'seconds' => MINUTE_IN_SECONDS, /* translators: %s: amount of time */ 'names' => _n_noop( '%s minute', '%s minutes', 'action-scheduler' ), ), array( 'seconds' => 1, /* translators: %s: amount of time */ 'names' => _n_noop( '%s second', '%s seconds', 'action-scheduler' ), ), ); parent::__construct( array( 'singular' => 'action-scheduler', 'plural' => 'action-scheduler', 'ajax' => false, ) ); } /** * Convert an interval of seconds into a two part human friendly string. * * The WordPress human_time_diff() function only calculates the time difference to one degree, meaning * even if an action is 1 day and 11 hours away, it will display "1 day". This function goes one step * further to display two degrees of accuracy. * * Inspired by the Crontrol::interval() function by Edward Dale: https://wordpress.org/plugins/wp-crontrol/ * * @param int $interval A interval in seconds. * @param int $periods_to_include Depth of time periods to include, e.g. for an interval of 70, and $periods_to_include of 2, both minutes and seconds would be included. With a value of 1, only minutes would be included. * @return string A human friendly string representation of the interval. */ private static function human_interval( $interval, $periods_to_include = 2 ) { if ( $interval <= 0 ) { return __( 'Now!', 'action-scheduler' ); } $output = ''; for ( $time_period_index = 0, $periods_included = 0, $seconds_remaining = $interval; $time_period_index < count( self::$time_periods ) && $seconds_remaining > 0 && $periods_included < $periods_to_include; $time_period_index++ ) { $periods_in_interval = floor( $seconds_remaining / self::$time_periods[ $time_period_index ]['seconds'] ); if ( $periods_in_interval > 0 ) { if ( ! empty( $output ) ) { $output .= ' '; } $output .= sprintf( _n( self::$time_periods[ $time_period_index ]['names'][0], self::$time_periods[ $time_period_index ]['names'][1], $periods_in_interval, 'action-scheduler' ), $periods_in_interval ); $seconds_remaining -= $periods_in_interval * self::$time_periods[ $time_period_index ]['seconds']; $periods_included++; } } return $output; } /** * Returns the recurrence of an action or 'Non-repeating'. The output is human readable. * * @param ActionScheduler_Action $action * * @return string */ protected function get_recurrence( $action ) { $schedule = $action->get_schedule(); if ( $schedule->is_recurring() ) { $recurrence = $schedule->get_recurrence(); if ( is_numeric( $recurrence ) ) { /* translators: %s: time interval */ return sprintf( __( 'Every %s', 'action-scheduler' ), self::human_interval( $recurrence ) ); } else { return $recurrence; } } return __( 'Non-repeating', 'action-scheduler' ); } /** * Serializes the argument of an action to render it in a human friendly format. * * @param array $row The array representation of the current row of the table * * @return string */ public function column_args( array $row ) { if ( empty( $row['args'] ) ) { return apply_filters( 'action_scheduler_list_table_column_args', '', $row ); } $row_html = '
      '; foreach ( $row['args'] as $key => $value ) { $row_html .= sprintf( '
    • %s => %s
    • ', esc_html( var_export( $key, true ) ), esc_html( var_export( $value, true ) ) ); } $row_html .= '
    '; return apply_filters( 'action_scheduler_list_table_column_args', $row_html, $row ); } /** * Prints the logs entries inline. We do so to avoid loading Javascript and other hacks to show it in a modal. * * @param array $row Action array. * @return string */ public function column_log_entries( array $row ) { $log_entries_html = '
      '; $timezone = new DateTimezone( 'UTC' ); foreach ( $row['log_entries'] as $log_entry ) { $log_entries_html .= $this->get_log_entry_html( $log_entry, $timezone ); } $log_entries_html .= '
    '; return $log_entries_html; } /** * Prints the logs entries inline. We do so to avoid loading Javascript and other hacks to show it in a modal. * * @param ActionScheduler_LogEntry $log_entry * @param DateTimezone $timezone * @return string */ protected function get_log_entry_html( ActionScheduler_LogEntry $log_entry, DateTimezone $timezone ) { $date = $log_entry->get_date(); $date->setTimezone( $timezone ); return sprintf( '
  • %s
    %s
  • ', esc_html( $date->format( 'Y-m-d H:i:s O' ) ), esc_html( $log_entry->get_message() ) ); } /** * Only display row actions for pending actions. * * @param array $row Row to render * @param string $column_name Current row * * @return string */ protected function maybe_render_actions( $row, $column_name ) { if ( 'pending' === strtolower( $row[ 'status_name' ] ) ) { return parent::maybe_render_actions( $row, $column_name ); } return ''; } /** * Renders admin notifications * * Notifications: * 1. When the maximum number of tasks are being executed simultaneously. * 2. Notifications when a task is manually executed. * 3. Tables are missing. */ public function display_admin_notices() { global $wpdb; if ( ( is_a( $this->store, 'ActionScheduler_HybridStore' ) || is_a( $this->store, 'ActionScheduler_DBStore' ) ) && apply_filters( 'action_scheduler_enable_recreate_data_store', true ) ) { $table_list = array( 'actionscheduler_actions', 'actionscheduler_logs', 'actionscheduler_groups', 'actionscheduler_claims', ); $found_tables = $wpdb->get_col( "SHOW TABLES LIKE '{$wpdb->prefix}actionscheduler%'" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared foreach ( $table_list as $table_name ) { if ( ! in_array( $wpdb->prefix . $table_name, $found_tables ) ) { $this->admin_notices[] = array( 'class' => 'error', 'message' => __( 'It appears one or more database tables were missing. Attempting to re-create the missing table(s).' , 'action-scheduler' ), ); $this->recreate_tables(); parent::display_admin_notices(); return; } } } if ( $this->runner->has_maximum_concurrent_batches() ) { $claim_count = $this->store->get_claim_count(); $this->admin_notices[] = array( 'class' => 'updated', 'message' => sprintf( /* translators: %s: amount of claims */ _n( 'Maximum simultaneous queues already in progress (%s queue). No additional queues will begin processing until the current queues are complete.', 'Maximum simultaneous queues already in progress (%s queues). No additional queues will begin processing until the current queues are complete.', $claim_count, 'action-scheduler' ), $claim_count ), ); } elseif ( $this->store->has_pending_actions_due() ) { $async_request_lock_expiration = ActionScheduler::lock()->get_expiration( 'async-request-runner' ); // No lock set or lock expired if ( false === $async_request_lock_expiration || $async_request_lock_expiration < time() ) { $in_progress_url = add_query_arg( 'status', 'in-progress', remove_query_arg( 'status' ) ); /* translators: %s: process URL */ $async_request_message = sprintf( __( 'A new queue has begun processing. View actions in-progress »', 'action-scheduler' ), esc_url( $in_progress_url ) ); } else { /* translators: %d: seconds */ $async_request_message = sprintf( __( 'The next queue will begin processing in approximately %d seconds.', 'action-scheduler' ), $async_request_lock_expiration - time() ); } $this->admin_notices[] = array( 'class' => 'notice notice-info', 'message' => $async_request_message, ); } $notification = get_transient( 'action_scheduler_admin_notice' ); if ( is_array( $notification ) ) { delete_transient( 'action_scheduler_admin_notice' ); $action = $this->store->fetch_action( $notification['action_id'] ); $action_hook_html = '' . $action->get_hook() . ''; if ( 1 == $notification['success'] ) { $class = 'updated'; switch ( $notification['row_action_type'] ) { case 'run' : /* translators: %s: action HTML */ $action_message_html = sprintf( __( 'Successfully executed action: %s', 'action-scheduler' ), $action_hook_html ); break; case 'cancel' : /* translators: %s: action HTML */ $action_message_html = sprintf( __( 'Successfully canceled action: %s', 'action-scheduler' ), $action_hook_html ); break; default : /* translators: %s: action HTML */ $action_message_html = sprintf( __( 'Successfully processed change for action: %s', 'action-scheduler' ), $action_hook_html ); break; } } else { $class = 'error'; /* translators: 1: action HTML 2: action ID 3: error message */ $action_message_html = sprintf( __( 'Could not process change for action: "%1$s" (ID: %2$d). Error: %3$s', 'action-scheduler' ), $action_hook_html, esc_html( $notification['action_id'] ), esc_html( $notification['error_message'] ) ); } $action_message_html = apply_filters( 'action_scheduler_admin_notice_html', $action_message_html, $action, $notification ); $this->admin_notices[] = array( 'class' => $class, 'message' => $action_message_html, ); } parent::display_admin_notices(); } /** * Prints the scheduled date in a human friendly format. * * @param array $row The array representation of the current row of the table * * @return string */ public function column_schedule( $row ) { return $this->get_schedule_display_string( $row['schedule'] ); } /** * Get the scheduled date in a human friendly format. * * @param ActionScheduler_Schedule $schedule * @return string */ protected function get_schedule_display_string( ActionScheduler_Schedule $schedule ) { $schedule_display_string = ''; if ( ! $schedule->get_date() ) { return '0000-00-00 00:00:00'; } $next_timestamp = $schedule->get_date()->getTimestamp(); $schedule_display_string .= $schedule->get_date()->format( 'Y-m-d H:i:s O' ); $schedule_display_string .= '
    '; if ( gmdate( 'U' ) > $next_timestamp ) { /* translators: %s: date interval */ $schedule_display_string .= sprintf( __( ' (%s ago)', 'action-scheduler' ), self::human_interval( gmdate( 'U' ) - $next_timestamp ) ); } else { /* translators: %s: date interval */ $schedule_display_string .= sprintf( __( ' (%s)', 'action-scheduler' ), self::human_interval( $next_timestamp - gmdate( 'U' ) ) ); } return $schedule_display_string; } /** * Bulk delete * * Deletes actions based on their ID. This is the handler for the bulk delete. It assumes the data * properly validated by the callee and it will delete the actions without any extra validation. * * @param array $ids * @param string $ids_sql Inherited and unused */ protected function bulk_delete( array $ids, $ids_sql ) { foreach ( $ids as $id ) { $this->store->delete_action( $id ); } } /** * Implements the logic behind running an action. ActionScheduler_Abstract_ListTable validates the request and their * parameters are valid. * * @param int $action_id */ protected function row_action_cancel( $action_id ) { $this->process_row_action( $action_id, 'cancel' ); } /** * Implements the logic behind running an action. ActionScheduler_Abstract_ListTable validates the request and their * parameters are valid. * * @param int $action_id */ protected function row_action_run( $action_id ) { $this->process_row_action( $action_id, 'run' ); } /** * Force the data store schema updates. */ protected function recreate_tables() { if ( is_a( $this->store, 'ActionScheduler_HybridStore' ) ) { $store = $this->store; } else { $store = new ActionScheduler_HybridStore(); } add_action( 'action_scheduler/created_table', array( $store, 'set_autoincrement' ), 10, 2 ); $store_schema = new ActionScheduler_StoreSchema(); $logger_schema = new ActionScheduler_LoggerSchema(); $store_schema->register_tables( true ); $logger_schema->register_tables( true ); remove_action( 'action_scheduler/created_table', array( $store, 'set_autoincrement' ), 10 ); } /** * Implements the logic behind processing an action once an action link is clicked on the list table. * * @param int $action_id * @param string $row_action_type The type of action to perform on the action. */ protected function process_row_action( $action_id, $row_action_type ) { try { switch ( $row_action_type ) { case 'run' : $this->runner->process_action( $action_id, 'Admin List Table' ); break; case 'cancel' : $this->store->cancel_action( $action_id ); break; } $success = 1; $error_message = ''; } catch ( Exception $e ) { $success = 0; $error_message = $e->getMessage(); } set_transient( 'action_scheduler_admin_notice', compact( 'action_id', 'success', 'error_message', 'row_action_type' ), 30 ); } /** * {@inheritDoc} */ public function prepare_items() { $this->prepare_column_headers(); $per_page = $this->get_items_per_page( $this->package . '_items_per_page', $this->items_per_page ); $query = array( 'per_page' => $per_page, 'offset' => $this->get_items_offset(), 'status' => $this->get_request_status(), 'orderby' => $this->get_request_orderby(), 'order' => $this->get_request_order(), 'search' => $this->get_request_search_query(), ); $this->items = array(); $total_items = $this->store->query_actions( $query, 'count' ); $status_labels = $this->store->get_status_labels(); foreach ( $this->store->query_actions( $query ) as $action_id ) { try { $action = $this->store->fetch_action( $action_id ); } catch ( Exception $e ) { continue; } if ( is_a( $action, 'ActionScheduler_NullAction' ) ) { continue; } $this->items[ $action_id ] = array( 'ID' => $action_id, 'hook' => $action->get_hook(), 'status_name' => $this->store->get_status( $action_id ), 'status' => $status_labels[ $this->store->get_status( $action_id ) ], 'args' => $action->get_args(), 'group' => $action->get_group(), 'log_entries' => $this->logger->get_logs( $action_id ), 'claim_id' => $this->store->get_claim_id( $action_id ), 'recurrence' => $this->get_recurrence( $action ), 'schedule' => $action->get_schedule(), ); } $this->set_pagination_args( array( 'total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil( $total_items / $per_page ), ) ); } /** * Prints the available statuses so the user can click to filter. */ protected function display_filter_by_status() { $this->status_counts = $this->store->action_counts(); parent::display_filter_by_status(); } /** * Get the text to display in the search box on the list table. */ protected function get_search_box_button_text() { return __( 'Search hook, args and claim ID', 'action-scheduler' ); } } inc/importer/lib/action-scheduler/classes/ActionScheduler_DateTime.php000064400000003070147600053410022153 0ustar00format( 'U' ); } /** * Set the UTC offset. * * This represents a fixed offset instead of a timezone setting. * * @param $offset */ public function setUtcOffset( $offset ) { $this->utcOffset = intval( $offset ); } /** * Returns the timezone offset. * * @return int * @link http://php.net/manual/en/datetime.getoffset.php */ public function getOffset() { return $this->utcOffset ? $this->utcOffset : parent::getOffset(); } /** * Set the TimeZone associated with the DateTime * * @param DateTimeZone $timezone * * @return static * @link http://php.net/manual/en/datetime.settimezone.php */ public function setTimezone( $timezone ) { $this->utcOffset = 0; parent::setTimezone( $timezone ); return $this; } /** * Get the timestamp with the WordPress timezone offset added or subtracted. * * @since 3.0.0 * @return int */ public function getOffsetTimestamp() { return $this->getTimestamp() + $this->getOffset(); } } inc/importer/lib/action-scheduler/classes/ActionScheduler_wcSystemStatus.php000064400000011651147600053410023505 0ustar00store = $store; } /** * Display action data, including number of actions grouped by status and the oldest & newest action in each status. * * Helpful to identify issues, like a clogged queue. */ public function render() { $action_counts = $this->store->action_counts(); $status_labels = $this->store->get_status_labels(); $oldest_and_newest = $this->get_oldest_and_newest( array_keys( $status_labels ) ); $this->get_template( $status_labels, $action_counts, $oldest_and_newest ); } /** * Get oldest and newest scheduled dates for a given set of statuses. * * @param array $status_keys Set of statuses to find oldest & newest action for. * @return array */ protected function get_oldest_and_newest( $status_keys ) { $oldest_and_newest = array(); foreach ( $status_keys as $status ) { $oldest_and_newest[ $status ] = array( 'oldest' => '–', 'newest' => '–', ); if ( 'in-progress' === $status ) { continue; } $oldest_and_newest[ $status ]['oldest'] = $this->get_action_status_date( $status, 'oldest' ); $oldest_and_newest[ $status ]['newest'] = $this->get_action_status_date( $status, 'newest' ); } return $oldest_and_newest; } /** * Get oldest or newest scheduled date for a given status. * * @param string $status Action status label/name string. * @param string $date_type Oldest or Newest. * @return DateTime */ protected function get_action_status_date( $status, $date_type = 'oldest' ) { $order = 'oldest' === $date_type ? 'ASC' : 'DESC'; $action = $this->store->query_actions( array( 'claimed' => false, 'status' => $status, 'per_page' => 1, 'order' => $order, ) ); if ( ! empty( $action ) ) { $date_object = $this->store->get_date( $action[0] ); $action_date = $date_object->format( 'Y-m-d H:i:s O' ); } else { $action_date = '–'; } return $action_date; } /** * Get oldest or newest scheduled date for a given status. * * @param array $status_labels Set of statuses to find oldest & newest action for. * @param array $action_counts Number of actions grouped by status. * @param array $oldest_and_newest Date of the oldest and newest action with each status. */ protected function get_template( $status_labels, $action_counts, $oldest_and_newest ) { $as_version = ActionScheduler_Versions::instance()->latest_version(); $as_datastore = get_class( ActionScheduler_Store::instance() ); ?> $count ) { // WC uses the 3rd column for export, so we need to display more data in that (hidden when viewed as part of the table) and add an empty 2nd column. printf( '', esc_html( $status_labels[ $status ] ), number_format_i18n( $count ), $oldest_and_newest[ $status ]['oldest'], $oldest_and_newest[ $status ]['newest'] ); } ?>

     
    %1$s %2$s, Oldest: %3$s, Newest: %4$s%3$s%4$s
    store ); } $this->async_request = $async_request; } /** * @codeCoverageIgnore */ public function init() { add_filter( 'cron_schedules', array( self::instance(), 'add_wp_cron_schedule' ) ); // Check for and remove any WP Cron hook scheduled by Action Scheduler < 3.0.0, which didn't include the $context param $next_timestamp = wp_next_scheduled( self::WP_CRON_HOOK ); if ( $next_timestamp ) { wp_unschedule_event( $next_timestamp, self::WP_CRON_HOOK ); } $cron_context = array( 'WP Cron' ); if ( ! wp_next_scheduled( self::WP_CRON_HOOK, $cron_context ) ) { $schedule = apply_filters( 'action_scheduler_run_schedule', self::WP_CRON_SCHEDULE ); wp_schedule_event( time(), $schedule, self::WP_CRON_HOOK, $cron_context ); } add_action( self::WP_CRON_HOOK, array( self::instance(), 'run' ) ); $this->hook_dispatch_async_request(); } /** * Hook check for dispatching an async request. */ public function hook_dispatch_async_request() { add_action( 'shutdown', array( $this, 'maybe_dispatch_async_request' ) ); } /** * Unhook check for dispatching an async request. */ public function unhook_dispatch_async_request() { remove_action( 'shutdown', array( $this, 'maybe_dispatch_async_request' ) ); } /** * Check if we should dispatch an async request to process actions. * * This method is attached to 'shutdown', so is called frequently. To avoid slowing down * the site, it mitigates the work performed in each request by: * 1. checking if it's in the admin context and then * 2. haven't run on the 'shutdown' hook within the lock time (60 seconds by default) * 3. haven't exceeded the number of allowed batches. * * The order of these checks is important, because they run from a check on a value: * 1. in memory - is_admin() maps to $GLOBALS or the WP_ADMIN constant * 2. in memory - transients use autoloaded options by default * 3. from a database query - has_maximum_concurrent_batches() run the query * $this->store->get_claim_count() to find the current number of claims in the DB. * * If all of these conditions are met, then we request an async runner check whether it * should dispatch a request to process pending actions. */ public function maybe_dispatch_async_request() { if ( is_admin() && ! ActionScheduler::lock()->is_locked( 'async-request-runner' ) ) { // Only start an async queue at most once every 60 seconds ActionScheduler::lock()->set( 'async-request-runner' ); $this->async_request->maybe_dispatch(); } } /** * Process actions in the queue. Attached to self::WP_CRON_HOOK i.e. 'action_scheduler_run_queue' * * The $context param of this method defaults to 'WP Cron', because prior to Action Scheduler 3.0.0 * that was the only context in which this method was run, and the self::WP_CRON_HOOK hook had no context * passed along with it. New code calling this method directly, or by triggering the self::WP_CRON_HOOK, * should set a context as the first parameter. For an example of this, refer to the code seen in * @see ActionScheduler_AsyncRequest_QueueRunner::handle() * * @param string $context Optional identifer for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' * Generally, this should be capitalised and not localised as it's a proper noun. * @return int The number of actions processed. */ public function run( $context = 'WP Cron' ) { ActionScheduler_Compatibility::raise_memory_limit(); ActionScheduler_Compatibility::raise_time_limit( $this->get_time_limit() ); do_action( 'action_scheduler_before_process_queue' ); $this->run_cleanup(); $processed_actions = 0; if ( false === $this->has_maximum_concurrent_batches() ) { $batch_size = apply_filters( 'action_scheduler_queue_runner_batch_size', 25 ); do { $processed_actions_in_batch = $this->do_batch( $batch_size, $context ); $processed_actions += $processed_actions_in_batch; } while ( $processed_actions_in_batch > 0 && ! $this->batch_limits_exceeded( $processed_actions ) ); // keep going until we run out of actions, time, or memory } do_action( 'action_scheduler_after_process_queue' ); return $processed_actions; } /** * Process a batch of actions pending in the queue. * * Actions are processed by claiming a set of pending actions then processing each one until either the batch * size is completed, or memory or time limits are reached, defined by @see $this->batch_limits_exceeded(). * * @param int $size The maximum number of actions to process in the batch. * @param string $context Optional identifer for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' * Generally, this should be capitalised and not localised as it's a proper noun. * @return int The number of actions processed. */ protected function do_batch( $size = 100, $context = '' ) { $claim = $this->store->stake_claim($size); $this->monitor->attach($claim); $processed_actions = 0; foreach ( $claim->get_actions() as $action_id ) { // bail if we lost the claim if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $claim->get_id() ) ) ) { break; } $this->process_action( $action_id, $context ); $processed_actions++; if ( $this->batch_limits_exceeded( $processed_actions ) ) { break; } } $this->store->release_claim($claim); $this->monitor->detach(); $this->clear_caches(); return $processed_actions; } /** * Running large batches can eat up memory, as WP adds data to its object cache. * * If using a persistent object store, this has the side effect of flushing that * as well, so this is disabled by default. To enable: * * add_filter( 'action_scheduler_queue_runner_flush_cache', '__return_true' ); */ protected function clear_caches() { if ( ! wp_using_ext_object_cache() || apply_filters( 'action_scheduler_queue_runner_flush_cache', false ) ) { wp_cache_flush(); } } public function add_wp_cron_schedule( $schedules ) { $schedules['every_minute'] = array( 'interval' => 60, // in seconds 'display' => __( 'Every minute', 'action-scheduler' ), ); return $schedules; } } inc/importer/lib/action-scheduler/classes/ActionScheduler_Versions.php000064400000002357147600053410022276 0ustar00versions[$version_string]) ) { return FALSE; } $this->versions[$version_string] = $initialization_callback; return TRUE; } public function get_versions() { return $this->versions; } public function latest_version() { $keys = array_keys($this->versions); if ( empty($keys) ) { return false; } uasort( $keys, 'version_compare' ); return end($keys); } public function latest_version_callback() { $latest = $this->latest_version(); if ( empty($latest) || !isset($this->versions[$latest]) ) { return '__return_null'; } return $this->versions[$latest]; } /** * @return ActionScheduler_Versions * @codeCoverageIgnore */ public static function instance() { if ( empty(self::$instance) ) { self::$instance = new self(); } return self::$instance; } /** * @codeCoverageIgnore */ public static function initialize_latest_version() { $self = self::instance(); call_user_func($self->latest_version_callback()); } } inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php000064400000012505147600053410022345 0ustar00render(); } /** * Registers action-scheduler into WooCommerce > System status. * * @param array $tabs An associative array of tab key => label. * @return array $tabs An associative array of tab key => label, including Action Scheduler's tabs */ public function register_system_status_tab( array $tabs ) { $tabs['action-scheduler'] = __( 'Scheduled Actions', 'action-scheduler' ); return $tabs; } /** * Include Action Scheduler's administration under the Tools menu. * * A menu under the Tools menu is important for backward compatibility (as that's * where it started), and also provides more convenient access than the WooCommerce * System Status page, and for sites where WooCommerce isn't active. */ public function register_menu() { $hook_suffix = add_submenu_page( 'tools.php', __( 'Scheduled Actions', 'action-scheduler' ), __( 'Scheduled Actions', 'action-scheduler' ), 'manage_options', 'action-scheduler', array( $this, 'render_admin_ui' ) ); add_action( 'load-' . $hook_suffix , array( $this, 'process_admin_ui' ) ); } /** * Triggers processing of any pending actions. */ public function process_admin_ui() { $this->get_list_table(); } /** * Renders the Admin UI */ public function render_admin_ui() { $table = $this->get_list_table(); $table->display_page(); } /** * Get the admin UI object and process any requested actions. * * @return ActionScheduler_ListTable */ protected function get_list_table() { if ( null === $this->list_table ) { $this->list_table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner() ); $this->list_table->process_actions(); } return $this->list_table; } /** * Provide more information about the screen and its data in the help tab. */ public function add_help_tabs() { $screen = get_current_screen(); if ( ! $screen || self::$screen_id != $screen->id ) { return; } $as_version = ActionScheduler_Versions::instance()->latest_version(); $screen->add_help_tab( array( 'id' => 'action_scheduler_about', 'title' => __( 'About', 'action-scheduler' ), 'content' => '

    ' . sprintf( __( 'About Action Scheduler %s', 'action-scheduler' ), $as_version ) . '

    ' . '

    ' . __( 'Action Scheduler is a scalable, traceable job queue for background processing large sets of actions. Action Scheduler works by triggering an action hook to run at some time in the future. Scheduled actions can also be scheduled to run on a recurring schedule.', 'action-scheduler' ) . '

    ', ) ); $screen->add_help_tab( array( 'id' => 'action_scheduler_columns', 'title' => __( 'Columns', 'action-scheduler' ), 'content' => '

    ' . __( 'Scheduled Action Columns', 'action-scheduler' ) . '

    ' . '
      ' . sprintf( '
    • %1$s: %2$s
    • ', __( 'Hook', 'action-scheduler' ), __( 'Name of the action hook that will be triggered.', 'action-scheduler' ) ) . sprintf( '
    • %1$s: %2$s
    • ', __( 'Status', 'action-scheduler' ), __( 'Action statuses are Pending, Complete, Canceled, Failed', 'action-scheduler' ) ) . sprintf( '
    • %1$s: %2$s
    • ', __( 'Arguments', 'action-scheduler' ), __( 'Optional data array passed to the action hook.', 'action-scheduler' ) ) . sprintf( '
    • %1$s: %2$s
    • ', __( 'Group', 'action-scheduler' ), __( 'Optional action group.', 'action-scheduler' ) ) . sprintf( '
    • %1$s: %2$s
    • ', __( 'Recurrence', 'action-scheduler' ), __( 'The action\'s schedule frequency.', 'action-scheduler' ) ) . sprintf( '
    • %1$s: %2$s
    • ', __( 'Scheduled', 'action-scheduler' ), __( 'The date/time the action is/was scheduled to run.', 'action-scheduler' ) ) . sprintf( '
    • %1$s: %2$s
    • ', __( 'Log', 'action-scheduler' ), __( 'Activity log for the action.', 'action-scheduler' ) ) . '
    ', ) ); } } inc/importer/lib/action-scheduler/classes/ActionScheduler_AsyncRequest_QueueRunner.php000064400000004255147600053410025451 0ustar00store = $store; } /** * Handle async requests * * Run a queue, and maybe dispatch another async request to run another queue * if there are still pending actions after completing a queue in this request. */ protected function handle() { do_action( 'action_scheduler_run_queue', 'Async Request' ); // run a queue in the same way as WP Cron, but declare the Async Request context $sleep_seconds = $this->get_sleep_seconds(); if ( $sleep_seconds ) { sleep( $sleep_seconds ); } $this->maybe_dispatch(); } /** * If the async request runner is needed and allowed to run, dispatch a request. */ public function maybe_dispatch() { if ( ! $this->allow() ) { return; } $this->dispatch(); ActionScheduler_QueueRunner::instance()->unhook_dispatch_async_request(); } /** * Only allow async requests when needed. * * Also allow 3rd party code to disable running actions via async requests. */ protected function allow() { if ( ! has_action( 'action_scheduler_run_queue' ) || ActionScheduler::runner()->has_maximum_concurrent_batches() || ! $this->store->has_pending_actions_due() ) { $allow = false; } else { $allow = true; } return apply_filters( 'action_scheduler_allow_async_request_runner', $allow ); } /** * Chaining async requests can crash MySQL. A brief sleep call in PHP prevents that. */ protected function get_sleep_seconds() { return apply_filters( 'action_scheduler_async_request_sleep_seconds', 5, $this ); } } inc/importer/lib/action-scheduler/deprecated/ActionScheduler_Store_Deprecated.php000064400000002040147600053410024332 0ustar00mark_failure( $action_id ); } /** * Add base hooks * * @since 2.2.6 */ protected static function hook() { _deprecated_function( __METHOD__, '3.0.0' ); } /** * Remove base hooks * * @since 2.2.6 */ protected static function unhook() { _deprecated_function( __METHOD__, '3.0.0' ); } /** * Get the site's local time. * * @deprecated 2.1.0 * @return DateTimeZone */ protected function get_local_timezone() { _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); return ActionScheduler_TimezoneHelper::get_local_timezone(); } } inc/importer/lib/action-scheduler/deprecated/ActionScheduler_Abstract_QueueRunner_Deprecated.php000064400000001523147600053410027344 0ustar00 '' - the name of the action that will be triggered * 'args' => NULL - the args array that will be passed with the action * 'date' => NULL - the scheduled date of the action. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone. * 'date_compare' => '<=' - operator for testing "date". accepted values are '!=', '>', '>=', '<', '<=', '=' * 'modified' => NULL - the date the action was last updated. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone. * 'modified_compare' => '<=' - operator for testing "modified". accepted values are '!=', '>', '>=', '<', '<=', '=' * 'group' => '' - the group the action belongs to * 'status' => '' - ActionScheduler_Store::STATUS_COMPLETE or ActionScheduler_Store::STATUS_PENDING * 'claimed' => NULL - TRUE to find claimed actions, FALSE to find unclaimed actions, a string to find a specific claim ID * 'per_page' => 5 - Number of results to return * 'offset' => 0 * 'orderby' => 'date' - accepted values are 'hook', 'group', 'modified', or 'date' * 'order' => 'ASC' * @param string $return_format OBJECT, ARRAY_A, or ids * * @deprecated 2.1.0 * * @return array */ function wc_get_scheduled_actions( $args = array(), $return_format = OBJECT ) { _deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' ); return as_get_scheduled_actions( $args, $return_format ); } inc/importer/lib/action-scheduler/deprecated/ActionScheduler_Schedule_Deprecated.php000064400000001337147600053410025002 0ustar00get_date(); $replacement_method = 'get_date()'; } else { $return_value = $this->get_next( $after ); $replacement_method = 'get_next( $after )'; } _deprecated_function( __METHOD__, '3.0.0', __CLASS__ . '::' . $replacement_method ); return $return_value; } } inc/importer/lib/action-scheduler/deprecated/ActionScheduler_AdminView_Deprecated.php000064400000012507147600053410025132 0ustar00 * @link http://en.wikipedia.org/wiki/Cron */ class CronExpression { const MINUTE = 0; const HOUR = 1; const DAY = 2; const MONTH = 3; const WEEKDAY = 4; const YEAR = 5; /** * @var array CRON expression parts */ private $cronParts; /** * @var CronExpression_FieldFactory CRON field factory */ private $fieldFactory; /** * @var array Order in which to test of cron parts */ private static $order = array(self::YEAR, self::MONTH, self::DAY, self::WEEKDAY, self::HOUR, self::MINUTE); /** * Factory method to create a new CronExpression. * * @param string $expression The CRON expression to create. There are * several special predefined values which can be used to substitute the * CRON expression: * * @yearly, @annually) - Run once a year, midnight, Jan. 1 - 0 0 1 1 * * @monthly - Run once a month, midnight, first of month - 0 0 1 * * * @weekly - Run once a week, midnight on Sun - 0 0 * * 0 * @daily - Run once a day, midnight - 0 0 * * * * @hourly - Run once an hour, first minute - 0 * * * * * *@param CronExpression_FieldFactory $fieldFactory (optional) Field factory to use * * @return CronExpression */ public static function factory($expression, CronExpression_FieldFactory $fieldFactory = null) { $mappings = array( '@yearly' => '0 0 1 1 *', '@annually' => '0 0 1 1 *', '@monthly' => '0 0 1 * *', '@weekly' => '0 0 * * 0', '@daily' => '0 0 * * *', '@hourly' => '0 * * * *' ); if (isset($mappings[$expression])) { $expression = $mappings[$expression]; } return new self($expression, $fieldFactory ? $fieldFactory : new CronExpression_FieldFactory()); } /** * Parse a CRON expression * * @param string $expression CRON expression (e.g. '8 * * * *') * @param CronExpression_FieldFactory $fieldFactory Factory to create cron fields */ public function __construct($expression, CronExpression_FieldFactory $fieldFactory) { $this->fieldFactory = $fieldFactory; $this->setExpression($expression); } /** * Set or change the CRON expression * * @param string $value CRON expression (e.g. 8 * * * *) * * @return CronExpression * @throws InvalidArgumentException if not a valid CRON expression */ public function setExpression($value) { $this->cronParts = preg_split('/\s/', $value, -1, PREG_SPLIT_NO_EMPTY); if (count($this->cronParts) < 5) { throw new InvalidArgumentException( $value . ' is not a valid CRON expression' ); } foreach ($this->cronParts as $position => $part) { $this->setPart($position, $part); } return $this; } /** * Set part of the CRON expression * * @param int $position The position of the CRON expression to set * @param string $value The value to set * * @return CronExpression * @throws InvalidArgumentException if the value is not valid for the part */ public function setPart($position, $value) { if (!$this->fieldFactory->getField($position)->validate($value)) { throw new InvalidArgumentException( 'Invalid CRON field value ' . $value . ' as position ' . $position ); } $this->cronParts[$position] = $value; return $this; } /** * Get a next run date relative to the current date or a specific date * * @param string|DateTime $currentTime (optional) Relative calculation date * @param int $nth (optional) Number of matches to skip before returning a * matching next run date. 0, the default, will return the current * date and time if the next run date falls on the current date and * time. Setting this value to 1 will skip the first match and go to * the second match. Setting this value to 2 will skip the first 2 * matches and so on. * @param bool $allowCurrentDate (optional) Set to TRUE to return the * current date if it matches the cron expression * * @return DateTime * @throws RuntimeException on too many iterations */ public function getNextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getRunDate($currentTime, $nth, false, $allowCurrentDate); } /** * Get a previous run date relative to the current date or a specific date * * @param string|DateTime $currentTime (optional) Relative calculation date * @param int $nth (optional) Number of matches to skip before returning * @param bool $allowCurrentDate (optional) Set to TRUE to return the * current date if it matches the cron expression * * @return DateTime * @throws RuntimeException on too many iterations * @see CronExpression::getNextRunDate */ public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getRunDate($currentTime, $nth, true, $allowCurrentDate); } /** * Get multiple run dates starting at the current date or a specific date * * @param int $total Set the total number of dates to calculate * @param string|DateTime $currentTime (optional) Relative calculation date * @param bool $invert (optional) Set to TRUE to retrieve previous dates * @param bool $allowCurrentDate (optional) Set to TRUE to return the * current date if it matches the cron expression * * @return array Returns an array of run dates */ public function getMultipleRunDates($total, $currentTime = 'now', $invert = false, $allowCurrentDate = false) { $matches = array(); for ($i = 0; $i < max(0, $total); $i++) { $matches[] = $this->getRunDate($currentTime, $i, $invert, $allowCurrentDate); } return $matches; } /** * Get all or part of the CRON expression * * @param string $part (optional) Specify the part to retrieve or NULL to * get the full cron schedule string. * * @return string|null Returns the CRON expression, a part of the * CRON expression, or NULL if the part was specified but not found */ public function getExpression($part = null) { if (null === $part) { return implode(' ', $this->cronParts); } elseif (array_key_exists($part, $this->cronParts)) { return $this->cronParts[$part]; } return null; } /** * Helper method to output the full expression. * * @return string Full CRON expression */ public function __toString() { return $this->getExpression(); } /** * Determine if the cron is due to run based on the current date or a * specific date. This method assumes that the current number of * seconds are irrelevant, and should be called once per minute. * * @param string|DateTime $currentTime (optional) Relative calculation date * * @return bool Returns TRUE if the cron is due to run or FALSE if not */ public function isDue($currentTime = 'now') { if ('now' === $currentTime) { $currentDate = date('Y-m-d H:i'); $currentTime = strtotime($currentDate); } elseif ($currentTime instanceof DateTime) { $currentDate = $currentTime->format('Y-m-d H:i'); $currentTime = strtotime($currentDate); } else { $currentTime = new DateTime($currentTime); $currentTime->setTime($currentTime->format('H'), $currentTime->format('i'), 0); $currentDate = $currentTime->format('Y-m-d H:i'); $currentTime = (int)($currentTime->getTimestamp()); } return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime; } /** * Get the next or previous run date of the expression relative to a date * * @param string|DateTime $currentTime (optional) Relative calculation date * @param int $nth (optional) Number of matches to skip before returning * @param bool $invert (optional) Set to TRUE to go backwards in time * @param bool $allowCurrentDate (optional) Set to TRUE to return the * current date if it matches the cron expression * * @return DateTime * @throws RuntimeException on too many iterations */ protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $allowCurrentDate = false) { if ($currentTime instanceof DateTime) { $currentDate = $currentTime; } else { $currentDate = new DateTime($currentTime ? $currentTime : 'now'); $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get())); } $currentDate->setTime($currentDate->format('H'), $currentDate->format('i'), 0); $nextRun = clone $currentDate; $nth = (int) $nth; // Set a hard limit to bail on an impossible date for ($i = 0; $i < 1000; $i++) { foreach (self::$order as $position) { $part = $this->getExpression($position); if (null === $part) { continue; } $satisfied = false; // Get the field object used to validate this part $field = $this->fieldFactory->getField($position); // Check if this is singular or a list if (strpos($part, ',') === false) { $satisfied = $field->isSatisfiedBy($nextRun, $part); } else { foreach (array_map('trim', explode(',', $part)) as $listPart) { if ($field->isSatisfiedBy($nextRun, $listPart)) { $satisfied = true; break; } } } // If the field is not satisfied, then start over if (!$satisfied) { $field->increment($nextRun, $invert); continue 2; } } // Skip this match if needed if ((!$allowCurrentDate && $nextRun == $currentDate) || --$nth > -1) { $this->fieldFactory->getField(0)->increment($nextRun, $invert); continue; } return $nextRun; } // @codeCoverageIgnoreStart throw new RuntimeException('Impossible CRON expression'); // @codeCoverageIgnoreEnd } } inc/importer/lib/action-scheduler/lib/cron-expression/CronExpression_FieldFactory.php000064400000003321147600053410025205 0ustar00 * @link http://en.wikipedia.org/wiki/Cron */ class CronExpression_FieldFactory { /** * @var array Cache of instantiated fields */ private $fields = array(); /** * Get an instance of a field object for a cron expression position * * @param int $position CRON expression position value to retrieve * * @return CronExpression_FieldInterface * @throws InvalidArgumentException if a position is not valid */ public function getField($position) { if (!isset($this->fields[$position])) { switch ($position) { case 0: $this->fields[$position] = new CronExpression_MinutesField(); break; case 1: $this->fields[$position] = new CronExpression_HoursField(); break; case 2: $this->fields[$position] = new CronExpression_DayOfMonthField(); break; case 3: $this->fields[$position] = new CronExpression_MonthField(); break; case 4: $this->fields[$position] = new CronExpression_DayOfWeekField(); break; case 5: $this->fields[$position] = new CronExpression_YearField(); break; default: throw new InvalidArgumentException( $position . ' is not a valid position' ); } } return $this->fields[$position]; } } inc/importer/lib/action-scheduler/lib/cron-expression/CronExpression_YearField.php000064400000001651147600053410024502 0ustar00 */ class CronExpression_YearField extends CronExpression_AbstractField { /** * {@inheritdoc} */ public function isSatisfiedBy(DateTime $date, $value) { return $this->isSatisfied($date->format('Y'), $value); } /** * {@inheritdoc} */ public function increment(DateTime $date, $invert = false) { if ($invert) { $date->modify('-1 year'); $date->setDate($date->format('Y'), 12, 31); $date->setTime(23, 59, 0); } else { $date->modify('+1 year'); $date->setDate($date->format('Y'), 1, 1); $date->setTime(0, 0, 0); } return $this; } /** * {@inheritdoc} */ public function validate($value) { return (bool) preg_match('/[\*,\/\-0-9]+/', $value); } } inc/importer/lib/action-scheduler/lib/cron-expression/README.md000064400000006277147600053410020354 0ustar00PHP Cron Expression Parser ========================== [![Latest Stable Version](https://poser.pugx.org/mtdowling/cron-expression/v/stable.png)](https://packagist.org/packages/mtdowling/cron-expression) [![Total Downloads](https://poser.pugx.org/mtdowling/cron-expression/downloads.png)](https://packagist.org/packages/mtdowling/cron-expression) [![Build Status](https://secure.travis-ci.org/mtdowling/cron-expression.png)](http://travis-ci.org/mtdowling/cron-expression) The PHP cron expression parser can parse a CRON expression, determine if it is due to run, calculate the next run date of the expression, and calculate the previous run date of the expression. You can calculate dates far into the future or past by skipping n number of matching dates. The parser can handle increments of ranges (e.g. */12, 2-59/3), intervals (e.g. 0-9), lists (e.g. 1,2,3), W to find the nearest weekday for a given day of the month, L to find the last day of the month, L to find the last given weekday of a month, and hash (#) to find the nth weekday of a given month. Credits ========== Created by Micheal Dowling. Ported to PHP 5.2 by Flightless, Inc. Based on version 1.0.3: https://github.com/mtdowling/cron-expression/tree/v1.0.3 Installing ========== Add the following to your project's composer.json: ```javascript { "require": { "mtdowling/cron-expression": "1.0.*" } } ``` Usage ===== ```php isDue(); echo $cron->getNextRunDate()->format('Y-m-d H:i:s'); echo $cron->getPreviousRunDate()->format('Y-m-d H:i:s'); // Works with complex expressions $cron = Cron\CronExpression::factory('3-59/15 2,6-12 */15 1 2-5'); echo $cron->getNextRunDate()->format('Y-m-d H:i:s'); // Calculate a run date two iterations into the future $cron = Cron\CronExpression::factory('@daily'); echo $cron->getNextRunDate(null, 2)->format('Y-m-d H:i:s'); // Calculate a run date relative to a specific time $cron = Cron\CronExpression::factory('@monthly'); echo $cron->getNextRunDate('2010-01-12 00:00:00')->format('Y-m-d H:i:s'); ``` CRON Expressions ================ A CRON expression is a string representing the schedule for a particular command to execute. The parts of a CRON schedule are as follows: * * * * * * - - - - - - | | | | | | | | | | | + year [optional] | | | | +----- day of week (0 - 7) (Sunday=0 or 7) | | | +---------- month (1 - 12) | | +--------------- day of month (1 - 31) | +-------------------- hour (0 - 23) +------------------------- min (0 - 59) Requirements ============ - PHP 5.3+ - PHPUnit is required to run the unit tests - Composer is required to run the unit tests CHANGELOG ========= 1.0.3 (2013-11-23) ------------------ * Only set default timezone if the given $currentTime is not a DateTime instance (#34) * Fixes issue #28 where PHP increments of ranges were failing due to PHP casting hyphens to 0 * Now supports expressions with any number of extra spaces, tabs, or newlines * Using static instead of self in `CronExpression::factory` inc/importer/lib/action-scheduler/lib/cron-expression/LICENSE000064400000002112147600053410020062 0ustar00Copyright (c) 2011 Michael Dowling and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. inc/importer/lib/action-scheduler/lib/cron-expression/CronExpression_DayOfWeekField.php000064400000007521147600053410025422 0ustar00 */ class CronExpression_DayOfWeekField extends CronExpression_AbstractField { /** * {@inheritdoc} */ public function isSatisfiedBy(DateTime $date, $value) { if ($value == '?') { return true; } // Convert text day of the week values to integers $value = str_ireplace( array('SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'), range(0, 6), $value ); $currentYear = $date->format('Y'); $currentMonth = $date->format('m'); $lastDayOfMonth = $date->format('t'); // Find out if this is the last specific weekday of the month if (strpos($value, 'L')) { $weekday = str_replace('7', '0', substr($value, 0, strpos($value, 'L'))); $tdate = clone $date; $tdate->setDate($currentYear, $currentMonth, $lastDayOfMonth); while ($tdate->format('w') != $weekday) { $tdate->setDate($currentYear, $currentMonth, --$lastDayOfMonth); } return $date->format('j') == $lastDayOfMonth; } // Handle # hash tokens if (strpos($value, '#')) { list($weekday, $nth) = explode('#', $value); // Validate the hash fields if ($weekday < 1 || $weekday > 5) { throw new InvalidArgumentException("Weekday must be a value between 1 and 5. {$weekday} given"); } if ($nth > 5) { throw new InvalidArgumentException('There are never more than 5 of a given weekday in a month'); } // The current weekday must match the targeted weekday to proceed if ($date->format('N') != $weekday) { return false; } $tdate = clone $date; $tdate->setDate($currentYear, $currentMonth, 1); $dayCount = 0; $currentDay = 1; while ($currentDay < $lastDayOfMonth + 1) { if ($tdate->format('N') == $weekday) { if (++$dayCount >= $nth) { break; } } $tdate->setDate($currentYear, $currentMonth, ++$currentDay); } return $date->format('j') == $currentDay; } // Handle day of the week values if (strpos($value, '-')) { $parts = explode('-', $value); if ($parts[0] == '7') { $parts[0] = '0'; } elseif ($parts[1] == '0') { $parts[1] = '7'; } $value = implode('-', $parts); } // Test to see which Sunday to use -- 0 == 7 == Sunday $format = in_array(7, str_split($value)) ? 'N' : 'w'; $fieldValue = $date->format($format); return $this->isSatisfied($fieldValue, $value); } /** * {@inheritdoc} */ public function increment(DateTime $date, $invert = false) { if ($invert) { $date->modify('-1 day'); $date->setTime(23, 59, 0); } else { $date->modify('+1 day'); $date->setTime(0, 0, 0); } return $this; } /** * {@inheritdoc} */ public function validate($value) { return (bool) preg_match('/[\*,\/\-0-9A-Z]+/', $value); } } inc/importer/lib/action-scheduler/lib/cron-expression/CronExpression_FieldInterface.php000064400000002162147600053410025500 0ustar00 */ interface CronExpression_FieldInterface { /** * Check if the respective value of a DateTime field satisfies a CRON exp * * @param DateTime $date DateTime object to check * @param string $value CRON expression to test against * * @return bool Returns TRUE if satisfied, FALSE otherwise */ public function isSatisfiedBy(DateTime $date, $value); /** * When a CRON expression is not satisfied, this method is used to increment * or decrement a DateTime object by the unit of the cron field * * @param DateTime $date DateTime object to change * @param bool $invert (optional) Set to TRUE to decrement * * @return CronExpression_FieldInterface */ public function increment(DateTime $date, $invert = false); /** * Validates a CRON expression for a given field * * @param string $value CRON expression value to validate * * @return bool Returns TRUE if valid, FALSE otherwise */ public function validate($value); } inc/importer/lib/action-scheduler/lib/cron-expression/CronExpression_MinutesField.php000064400000001371147600053410025225 0ustar00 */ class CronExpression_MinutesField extends CronExpression_AbstractField { /** * {@inheritdoc} */ public function isSatisfiedBy(DateTime $date, $value) { return $this->isSatisfied($date->format('i'), $value); } /** * {@inheritdoc} */ public function increment(DateTime $date, $invert = false) { if ($invert) { $date->modify('-1 minute'); } else { $date->modify('+1 minute'); } return $this; } /** * {@inheritdoc} */ public function validate($value) { return (bool) preg_match('/[\*,\/\-0-9]+/', $value); } } inc/importer/lib/action-scheduler/lib/cron-expression/CronExpression_HoursField.php000064400000002205147600053410024676 0ustar00 */ class CronExpression_HoursField extends CronExpression_AbstractField { /** * {@inheritdoc} */ public function isSatisfiedBy(DateTime $date, $value) { return $this->isSatisfied($date->format('H'), $value); } /** * {@inheritdoc} */ public function increment(DateTime $date, $invert = false) { // Change timezone to UTC temporarily. This will // allow us to go back or forwards and hour even // if DST will be changed between the hours. $timezone = $date->getTimezone(); $date->setTimezone(new DateTimeZone('UTC')); if ($invert) { $date->modify('-1 hour'); $date->setTime($date->format('H'), 59); } else { $date->modify('+1 hour'); $date->setTime($date->format('H'), 0); } $date->setTimezone($timezone); return $this; } /** * {@inheritdoc} */ public function validate($value) { return (bool) preg_match('/[\*,\/\-0-9]+/', $value); } } inc/importer/lib/action-scheduler/lib/cron-expression/CronExpression_MonthField.php000064400000002567147600053410024676 0ustar00 */ class CronExpression_MonthField extends CronExpression_AbstractField { /** * {@inheritdoc} */ public function isSatisfiedBy(DateTime $date, $value) { // Convert text month values to integers $value = str_ireplace( array( 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC' ), range(1, 12), $value ); return $this->isSatisfied($date->format('m'), $value); } /** * {@inheritdoc} */ public function increment(DateTime $date, $invert = false) { if ($invert) { // $date->modify('last day of previous month'); // remove for php 5.2 compat $date->modify('previous month'); $date->modify($date->format('Y-m-t')); $date->setTime(23, 59); } else { //$date->modify('first day of next month'); // remove for php 5.2 compat $date->modify('next month'); $date->modify($date->format('Y-m-01')); $date->setTime(0, 0); } return $this; } /** * {@inheritdoc} */ public function validate($value) { return (bool) preg_match('/[\*,\/\-0-9A-Z]+/', $value); } } inc/importer/lib/action-scheduler/lib/cron-expression/CronExpression_DayOfMonthField.php000064400000007014147600053410025611 0ustar00 */ class CronExpression_DayOfMonthField extends CronExpression_AbstractField { /** * Get the nearest day of the week for a given day in a month * * @param int $currentYear Current year * @param int $currentMonth Current month * @param int $targetDay Target day of the month * * @return DateTime Returns the nearest date */ private static function getNearestWeekday($currentYear, $currentMonth, $targetDay) { $tday = str_pad($targetDay, 2, '0', STR_PAD_LEFT); $target = new DateTime("$currentYear-$currentMonth-$tday"); $currentWeekday = (int) $target->format('N'); if ($currentWeekday < 6) { return $target; } $lastDayOfMonth = $target->format('t'); foreach (array(-1, 1, -2, 2) as $i) { $adjusted = $targetDay + $i; if ($adjusted > 0 && $adjusted <= $lastDayOfMonth) { $target->setDate($currentYear, $currentMonth, $adjusted); if ($target->format('N') < 6 && $target->format('m') == $currentMonth) { return $target; } } } } /** * {@inheritdoc} */ public function isSatisfiedBy(DateTime $date, $value) { // ? states that the field value is to be skipped if ($value == '?') { return true; } $fieldValue = $date->format('d'); // Check to see if this is the last day of the month if ($value == 'L') { return $fieldValue == $date->format('t'); } // Check to see if this is the nearest weekday to a particular value if (strpos($value, 'W')) { // Parse the target day $targetDay = substr($value, 0, strpos($value, 'W')); // Find out if the current day is the nearest day of the week return $date->format('j') == self::getNearestWeekday( $date->format('Y'), $date->format('m'), $targetDay )->format('j'); } return $this->isSatisfied($date->format('d'), $value); } /** * {@inheritdoc} */ public function increment(DateTime $date, $invert = false) { if ($invert) { $date->modify('previous day'); $date->setTime(23, 59); } else { $date->modify('next day'); $date->setTime(0, 0); } return $this; } /** * {@inheritdoc} */ public function validate($value) { return (bool) preg_match('/[\*,\/\-\?LW0-9A-Za-z]+/', $value); } } inc/importer/lib/action-scheduler/lib/cron-expression/CronExpression_AbstractField.php000064400000005020147600053410025337 0ustar00 */ abstract class CronExpression_AbstractField implements CronExpression_FieldInterface { /** * Check to see if a field is satisfied by a value * * @param string $dateValue Date value to check * @param string $value Value to test * * @return bool */ public function isSatisfied($dateValue, $value) { if ($this->isIncrementsOfRanges($value)) { return $this->isInIncrementsOfRanges($dateValue, $value); } elseif ($this->isRange($value)) { return $this->isInRange($dateValue, $value); } return $value == '*' || $dateValue == $value; } /** * Check if a value is a range * * @param string $value Value to test * * @return bool */ public function isRange($value) { return strpos($value, '-') !== false; } /** * Check if a value is an increments of ranges * * @param string $value Value to test * * @return bool */ public function isIncrementsOfRanges($value) { return strpos($value, '/') !== false; } /** * Test if a value is within a range * * @param string $dateValue Set date value * @param string $value Value to test * * @return bool */ public function isInRange($dateValue, $value) { $parts = array_map('trim', explode('-', $value, 2)); return $dateValue >= $parts[0] && $dateValue <= $parts[1]; } /** * Test if a value is within an increments of ranges (offset[-to]/step size) * * @param string $dateValue Set date value * @param string $value Value to test * * @return bool */ public function isInIncrementsOfRanges($dateValue, $value) { $parts = array_map('trim', explode('/', $value, 2)); $stepSize = isset($parts[1]) ? $parts[1] : 0; if ($parts[0] == '*' || $parts[0] === '0') { return (int) $dateValue % $stepSize == 0; } $range = explode('-', $parts[0], 2); $offset = $range[0]; $to = isset($range[1]) ? $range[1] : $dateValue; // Ensure that the date value is within the range if ($dateValue < $offset || $dateValue > $to) { return false; } for ($i = $offset; $i <= $to; $i+= $stepSize) { if ($i == $dateValue) { return true; } } return false; } } inc/importer/lib/action-scheduler/lib/WP_Async_Request.php000064400000006314147600053410017633 0ustar00identifier = $this->prefix . '_' . $this->action; add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); } /** * Set data used during the request * * @param array $data Data. * * @return $this */ public function data( $data ) { $this->data = $data; return $this; } /** * Dispatch the async request * * @return array|WP_Error */ public function dispatch() { $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); $args = $this->get_post_args(); return wp_remote_post( esc_url_raw( $url ), $args ); } /** * Get query args * * @return array */ protected function get_query_args() { if ( property_exists( $this, 'query_args' ) ) { return $this->query_args; } return array( 'action' => $this->identifier, 'nonce' => wp_create_nonce( $this->identifier ), ); } /** * Get query URL * * @return string */ protected function get_query_url() { if ( property_exists( $this, 'query_url' ) ) { return $this->query_url; } return admin_url( 'admin-ajax.php' ); } /** * Get post args * * @return array */ protected function get_post_args() { if ( property_exists( $this, 'post_args' ) ) { return $this->post_args; } return array( 'timeout' => 0.01, 'blocking' => false, 'body' => $this->data, 'cookies' => $_COOKIE, 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), ); } /** * Maybe handle * * Check for correct nonce and pass to handler. */ public function maybe_handle() { // Don't lock up other requests while processing session_write_close(); check_ajax_referer( $this->identifier, 'nonce' ); $this->handle(); wp_die(); } /** * Handle * * Override this method to perform any actions required * during the async request. */ abstract protected function handle(); } } inc/importer/lib/action-scheduler/functions.php000064400000027065147600053410015710 0ustar00async( $hook, $args, $group ); } /** * Schedule an action to run one time * * @param int $timestamp When the job will run. * @param string $hook The hook to trigger. * @param array $args Arguments to pass when the hook triggers. * @param string $group The group to assign this job to. * * @return int The action ID. */ function as_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) { if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { return 0; } return ActionScheduler::factory()->single( $hook, $args, $timestamp, $group ); } /** * Schedule a recurring action * * @param int $timestamp When the first instance of the job will run. * @param int $interval_in_seconds How long to wait between runs. * @param string $hook The hook to trigger. * @param array $args Arguments to pass when the hook triggers. * @param string $group The group to assign this job to. * * @return int The action ID. */ function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) { if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { return 0; } return ActionScheduler::factory()->recurring( $hook, $args, $timestamp, $interval_in_seconds, $group ); } /** * Schedule an action that recurs on a cron-like schedule. * * @param int $base_timestamp The first instance of the action will be scheduled * to run at a time calculated after this timestamp matching the cron * expression. This can be used to delay the first instance of the action. * @param string $schedule A cron-link schedule string * @see http://en.wikipedia.org/wiki/Cron * * * * * * * * ┬ ┬ ┬ ┬ ┬ ┬ * | | | | | | * | | | | | + year [optional] * | | | | +----- day of week (0 - 7) (Sunday=0 or 7) * | | | +---------- month (1 - 12) * | | +--------------- day of month (1 - 31) * | +-------------------- hour (0 - 23) * +------------------------- min (0 - 59) * @param string $hook The hook to trigger. * @param array $args Arguments to pass when the hook triggers. * @param string $group The group to assign this job to. * * @return int The action ID. */ function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) { if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { return 0; } return ActionScheduler::factory()->cron( $hook, $args, $timestamp, $schedule, $group ); } /** * Cancel the next occurrence of a scheduled action. * * While only the next instance of a recurring or cron action is unscheduled by this method, that will also prevent * all future instances of that recurring or cron action from being run. Recurring and cron actions are scheduled in * a sequence instead of all being scheduled at once. Each successive occurrence of a recurring action is scheduled * only after the former action is run. If the next instance is never run, because it's unscheduled by this function, * then the following instance will never be scheduled (or exist), which is effectively the same as being unscheduled * by this method also. * * @param string $hook The hook that the job will trigger. * @param array $args Args that would have been passed to the job. * @param string $group The group the job is assigned to. * * @return string|null The scheduled action ID if a scheduled action was found, or null if no matching action found. */ function as_unschedule_action( $hook, $args = array(), $group = '' ) { if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { return 0; } $params = array( 'hook' => $hook, 'status' => ActionScheduler_Store::STATUS_PENDING, 'orderby' => 'date', 'order' => 'ASC', 'group' => $group, ); if ( is_array( $args ) ) { $params['args'] = $args; } $action_id = ActionScheduler::store()->query_action( $params ); if ( $action_id ) { ActionScheduler::store()->cancel_action( $action_id ); } return $action_id; } /** * Cancel all occurrences of a scheduled action. * * @param string $hook The hook that the job will trigger. * @param array $args Args that would have been passed to the job. * @param string $group The group the job is assigned to. */ function as_unschedule_all_actions( $hook, $args = array(), $group = '' ) { if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { return; } if ( empty( $args ) ) { if ( ! empty( $hook ) && empty( $group ) ) { ActionScheduler_Store::instance()->cancel_actions_by_hook( $hook ); return; } if ( ! empty( $group ) && empty( $hook ) ) { ActionScheduler_Store::instance()->cancel_actions_by_group( $group ); return; } } do { $unscheduled_action = as_unschedule_action( $hook, $args, $group ); } while ( ! empty( $unscheduled_action ) ); } /** * Check if there is an existing action in the queue with a given hook, args and group combination. * * An action in the queue could be pending, in-progress or async. If the is pending for a time in * future, its scheduled date will be returned as a timestamp. If it is currently being run, or an * async action sitting in the queue waiting to be processed, in which case boolean true will be * returned. Or there may be no async, in-progress or pending action for this hook, in which case, * boolean false will be the return value. * * @param string $hook * @param array $args * @param string $group * * @return int|bool The timestamp for the next occurrence of a pending scheduled action, true for an async or in-progress action or false if there is no matching action. */ function as_next_scheduled_action( $hook, $args = null, $group = '' ) { if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { return false; } $params = array( 'hook' => $hook, 'orderby' => 'date', 'order' => 'ASC', 'group' => $group, ); if ( is_array( $args ) ) { $params['args'] = $args; } $params['status'] = ActionScheduler_Store::STATUS_RUNNING; $action_id = ActionScheduler::store()->query_action( $params ); if ( $action_id ) { return true; } $params['status'] = ActionScheduler_Store::STATUS_PENDING; $action_id = ActionScheduler::store()->query_action( $params ); if ( null === $action_id ) { return false; } $action = ActionScheduler::store()->fetch_action( $action_id ); $scheduled_date = $action->get_schedule()->get_date(); if ( $scheduled_date ) { return (int) $scheduled_date->format( 'U' ); } elseif ( null === $scheduled_date ) { // pending async action with NullSchedule return true; } return false; } /** * Check if there is a scheduled action in the queue but more efficiently than as_next_scheduled_action(). * * It's recommended to use this function when you need to know whether a specific action is currently scheduled * (pending or in-progress). * * @since x.x.x * * @param string $hook The hook of the action. * @param array $args Args that have been passed to the action. Null will matches any args. * @param string $group The group the job is assigned to. * * @return bool True if a matching action is pending or in-progress, false otherwise. */ function as_has_scheduled_action( $hook, $args = null, $group = '' ) { if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { return false; } $query_args = array( 'hook' => $hook, 'status' => array( ActionScheduler_Store::STATUS_RUNNING, ActionScheduler_Store::STATUS_PENDING ), 'group' => $group, 'orderby' => 'none', ); if ( null !== $args ) { $query_args['args'] = $args; } $action_id = ActionScheduler::store()->query_action( $query_args ); return $action_id !== null; } /** * Find scheduled actions * * @param array $args Possible arguments, with their default values: * 'hook' => '' - the name of the action that will be triggered * 'args' => NULL - the args array that will be passed with the action * 'date' => NULL - the scheduled date of the action. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone. * 'date_compare' => '<=' - operator for testing "date". accepted values are '!=', '>', '>=', '<', '<=', '=' * 'modified' => NULL - the date the action was last updated. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone. * 'modified_compare' => '<=' - operator for testing "modified". accepted values are '!=', '>', '>=', '<', '<=', '=' * 'group' => '' - the group the action belongs to * 'status' => '' - ActionScheduler_Store::STATUS_COMPLETE or ActionScheduler_Store::STATUS_PENDING * 'claimed' => NULL - TRUE to find claimed actions, FALSE to find unclaimed actions, a string to find a specific claim ID * 'per_page' => 5 - Number of results to return * 'offset' => 0 * 'orderby' => 'date' - accepted values are 'hook', 'group', 'modified', 'date' or 'none' * 'order' => 'ASC' * * @param string $return_format OBJECT, ARRAY_A, or ids. * * @return array */ function as_get_scheduled_actions( $args = array(), $return_format = OBJECT ) { if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { return array(); } $store = ActionScheduler::store(); foreach ( array('date', 'modified') as $key ) { if ( isset($args[$key]) ) { $args[$key] = as_get_datetime_object($args[$key]); } } $ids = $store->query_actions( $args ); if ( $return_format == 'ids' || $return_format == 'int' ) { return $ids; } $actions = array(); foreach ( $ids as $action_id ) { $actions[$action_id] = $store->fetch_action( $action_id ); } if ( $return_format == ARRAY_A ) { foreach ( $actions as $action_id => $action_object ) { $actions[$action_id] = get_object_vars($action_object); } } return $actions; } /** * Helper function to create an instance of DateTime based on a given * string and timezone. By default, will return the current date/time * in the UTC timezone. * * Needed because new DateTime() called without an explicit timezone * will create a date/time in PHP's timezone, but we need to have * assurance that a date/time uses the right timezone (which we almost * always want to be UTC), which means we need to always include the * timezone when instantiating datetimes rather than leaving it up to * the PHP default. * * @param mixed $date_string A date/time string. Valid formats are explained in http://php.net/manual/en/datetime.formats.php. * @param string $timezone A timezone identifier, like UTC or Europe/Lisbon. The list of valid identifiers is available http://php.net/manual/en/timezones.php. * * @return ActionScheduler_DateTime */ function as_get_datetime_object( $date_string = null, $timezone = 'UTC' ) { if ( is_object( $date_string ) && $date_string instanceof DateTime ) { $date = new ActionScheduler_DateTime( $date_string->format( 'Y-m-d H:i:s' ), new DateTimeZone( $timezone ) ); } elseif ( is_numeric( $date_string ) ) { $date = new ActionScheduler_DateTime( '@' . $date_string, new DateTimeZone( $timezone ) ); } else { $date = new ActionScheduler_DateTime( $date_string, new DateTimeZone( $timezone ) ); } return $date; } inc/importer/lib/action-scheduler/README.md000064400000005360147600053410014440 0ustar00# Action Scheduler - Job Queue for WordPress [![Build Status](https://travis-ci.org/woocommerce/action-scheduler.png?branch=master)](https://travis-ci.org/woocommerce/action-scheduler) [![codecov](https://codecov.io/gh/woocommerce/action-scheduler/branch/master/graph/badge.svg)](https://codecov.io/gh/woocommerce/action-scheduler) Action Scheduler is a scalable, traceable job queue for background processing large sets of actions in WordPress. It's specially designed to be distributed in WordPress plugins. Action Scheduler works by triggering an action hook to run at some time in the future. Each hook can be scheduled with unique data, to allow callbacks to perform operations on that data. The hook can also be scheduled to run on one or more occassions. Think of it like an extension to `do_action()` which adds the ability to delay and repeat a hook. ## Battle-Tested Background Processing Every month, Action Scheduler processes millions of payments for [Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/), webhooks for [WooCommerce](https://wordpress.org/plugins/woocommerce/), as well as emails and other events for a range of other plugins. It's been seen on live sites processing queues in excess of 50,000 jobs and doing resource intensive operations, like processing payments and creating orders, at a sustained rate of over 10,000 / hour without negatively impacting normal site operations. This is all on infrastructure and WordPress sites outside the control of the plugin author. If your plugin needs background processing, especially of large sets of tasks, Action Scheduler can help. ## Learn More To learn more about how to Action Scheduler works, and how to use it in your plugin, check out the docs on [ActionScheduler.org](https://actionscheduler.org). There you will find: * [Usage guide](https://actionscheduler.org/usage/): instructions on installing and using Action Scheduler * [WP CLI guide](https://actionscheduler.org/wp-cli/): instructions on running Action Scheduler at scale via WP CLI * [API Reference](https://actionscheduler.org/api/): complete reference guide for all API functions * [Administration Guide](https://actionscheduler.org/admin/): guide to managing scheduled actions via the administration screen * [Guide to Background Processing at Scale](https://actionscheduler.org/perf/): instructions for running Action Scheduler at scale via the default WP Cron queue runner ## Credits Action Scheduler is developed and maintained by [Automattic](http://automattic.com/) with significant early development completed by [Flightless](https://flightless.us/). Collaboration is cool. We'd love to work with you to improve Action Scheduler. [Pull Requests](https://github.com/woocommerce/action-scheduler/pulls) welcome. inc/importer/lib/action-scheduler/changelog.txt000064400000003150147600053410015644 0ustar00*** Changelog *** = 3.3.0 - 2021-09-15 = * Enhancement - Adds as_has_scheduled_action() to provide a performant way to test for existing actions. #645 * Fix - Improves compatibility with environments where NO_ZERO_DATE is enabled. #519 * Fix - Adds safety checks to guard against errors when our database tables cannot be created. #645 * Dev - Now supports queries that use multiple statuses. #649 * Dev - Minimum requirements for WordPress and PHP bumped (to 5.2 and 5.6 respectively). #723 = 3.2.1 - 2021-06-21 = * Fix - Add extra safety/account for different versions of AS and different loading patterns. #714 * Fix - Handle hidden columns (Tools → Scheduled Actions) | #600. = 3.2.0 - 2021-06-03 = * Fix - Add "no ordering" option to as_next_scheduled_action(). * Fix - Add secondary scheduled date checks when claiming actions (DBStore) | #634. * Fix - Add secondary scheduled date checks when claiming actions (wpPostStore) | #634. * Fix - Adds a new index to the action table, reducing the potential for deadlocks (props: @glagonikas). * Fix - Fix unit tests infrastructure and adapt tests to PHP 8. * Fix - Identify in-use data store. * Fix - Improve test_migration_is_scheduled. * Fix - PHP notice on list table. * Fix - Speed up clean up and batch selects. * Fix - Update pending dependencies. * Fix - [PHP 8.0] Only pass action arg values through to do_action_ref_array(). * Fix - [PHP 8] Set the PHP version to 7.1 in composer.json for PHP 8 compatibility. * Fix - add is_initialized() to docs. * Fix - fix file permissions. * Fix - fixes #664 by replacing __ with esc_html__. = 3.1.6 - 2020-05-12 = * Change log starts. inc/importer/lib/action-scheduler/license.txt000064400000104515147600053410015346 0ustar00 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . inc/importer/lib/action-scheduler/action-scheduler.php000064400000005044147600053410017122 0ustar00. * * @package ActionScheduler */ if ( ! function_exists( 'action_scheduler_register_3_dot_3_dot_0' ) && function_exists( 'add_action' ) ) { if ( ! class_exists( 'ActionScheduler_Versions' ) ) { require_once __DIR__ . '/classes/ActionScheduler_Versions.php'; add_action( 'plugins_loaded', array( 'ActionScheduler_Versions', 'initialize_latest_version' ), 1, 0 ); } add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_3_dot_0', 0, 0 ); /** * Registers this version of Action Scheduler. */ function action_scheduler_register_3_dot_3_dot_0() { $versions = ActionScheduler_Versions::instance(); $versions->register( '3.3.0', 'action_scheduler_initialize_3_dot_3_dot_0' ); } /** * Initializes this version of Action Scheduler. */ function action_scheduler_initialize_3_dot_3_dot_0() { // A final safety check is required even here, because historic versions of Action Scheduler // followed a different pattern (in some unusual cases, we could reach this point and the // ActionScheduler class is already defined—so we need to guard against that). if ( ! class_exists( 'ActionScheduler' ) ) { require_once __DIR__ . '/classes/abstracts/ActionScheduler.php'; ActionScheduler::init( __FILE__ ); } } // Support usage in themes - load this version if no plugin has loaded a version yet. if ( did_action( 'plugins_loaded' ) && ! doing_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler' ) ) { action_scheduler_initialize_3_dot_3_dot_0(); do_action( 'action_scheduler_pre_theme_init' ); ActionScheduler_Versions::initialize_latest_version(); } } inc/importer/lib/action-scheduler/readme.txt000064400000010474147600053410015161 0ustar00=== Action Scheduler === Contributors: Automattic, wpmuguru, claudiosanches, peterfabian1000, vedjain, jamosova, obliviousharmony, konamiman, sadowski, royho, barryhughes-1 Tags: scheduler, cron Requires at least: 5.2 Tested up to: 5.7 Stable tag: 3.3.0 License: GPLv3 Requires PHP: 5.6 Action Scheduler - Job Queue for WordPress == Description == Action Scheduler is a scalable, traceable job queue for background processing large sets of actions in WordPress. It's specially designed to be distributed in WordPress plugins. Action Scheduler works by triggering an action hook to run at some time in the future. Each hook can be scheduled with unique data, to allow callbacks to perform operations on that data. The hook can also be scheduled to run on one or more occassions. Think of it like an extension to `do_action()` which adds the ability to delay and repeat a hook. ## Battle-Tested Background Processing Every month, Action Scheduler processes millions of payments for [Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/), webhooks for [WooCommerce](https://wordpress.org/plugins/woocommerce/), as well as emails and other events for a range of other plugins. It's been seen on live sites processing queues in excess of 50,000 jobs and doing resource intensive operations, like processing payments and creating orders, at a sustained rate of over 10,000 / hour without negatively impacting normal site operations. This is all on infrastructure and WordPress sites outside the control of the plugin author. If your plugin needs background processing, especially of large sets of tasks, Action Scheduler can help. ## Learn More To learn more about how to Action Scheduler works, and how to use it in your plugin, check out the docs on [ActionScheduler.org](https://actionscheduler.org). There you will find: * [Usage guide](https://actionscheduler.org/usage/): instructions on installing and using Action Scheduler * [WP CLI guide](https://actionscheduler.org/wp-cli/): instructions on running Action Scheduler at scale via WP CLI * [API Reference](https://actionscheduler.org/api/): complete reference guide for all API functions * [Administration Guide](https://actionscheduler.org/admin/): guide to managing scheduled actions via the administration screen * [Guide to Background Processing at Scale](https://actionscheduler.org/perf/): instructions for running Action Scheduler at scale via the default WP Cron queue runner ## Credits Action Scheduler is developed and maintained by [Automattic](http://automattic.com/) with significant early development completed by [Flightless](https://flightless.us/). Collaboration is cool. We'd love to work with you to improve Action Scheduler. [Pull Requests](https://github.com/woocommerce/action-scheduler/pulls) welcome. == Changelog == = 3.3.0 - 2021-09-15 = * Enhancement - Adds as_has_scheduled_action() to provide a performant way to test for existing actions. #645 * Fix - Improves compatibility with environments where NO_ZERO_DATE is enabled. #519 * Fix - Adds safety checks to guard against errors when our database tables cannot be created. #645 * Dev - Now supports queries that use multiple statuses. #649 * Dev - Minimum requirements for WordPress and PHP bumped (to 5.2 and 5.6 respectively). #723 = 3.2.1 - 2021-06-21 = * Fix - Add extra safety/account for different versions of AS and different loading patterns. #714 * Fix - Handle hidden columns (Tools → Scheduled Actions) | #600. = 3.2.0 - 2021-06-03 = * Fix - Add "no ordering" option to as_next_scheduled_action(). * Fix - Add secondary scheduled date checks when claiming actions (DBStore) | #634. * Fix - Add secondary scheduled date checks when claiming actions (wpPostStore) | #634. * Fix - Adds a new index to the action table, reducing the potential for deadlocks (props: @glagonikas). * Fix - Fix unit tests infrastructure and adapt tests to PHP 8. * Fix - Identify in-use data store. * Fix - Improve test_migration_is_scheduled. * Fix - PHP notice on list table. * Fix - Speed up clean up and batch selects. * Fix - Update pending dependencies. * Fix - [PHP 8.0] Only pass action arg values through to do_action_ref_array(). * Fix - [PHP 8] Set the PHP version to 7.1 in composer.json for PHP 8 compatibility. * Fix - add is_initialized() to docs. * Fix - fix file permissions. * Fix - fixes #664 by replacing __ with esc_html__. inc/importer/templates/importer-scheduled.php000064400000003220147600053410015461 0ustar00 PENCI_PODCAST_IMPORTER_POST_TYPE_IMPORT, 'posts_per_page' => 299, ] ); ?>
    ID, 'pencipdc_rss_feed', true);?>
    inc/importer/templates/_form-field.php000064400000010423147600053410014050 0ustar00
    data-pencipdc-conditional-display="" > $data[ 'name' ], 'selected' => ( $data['value'] ?? '' ) ] ); ?>
    >
    />

    _form-field.php has not been called correctly, missing $data.

    inc/importer/templates/tools.php000064400000003140147600053410013023 0ustar00 [ 'title' => __( "Import Feed", 'penci-podcast' ), 'template' => 'importer-form.php' ], 'scheduled-list' => [ 'title' => __( "Scheduled Imports", 'penci-podcast' ), 'template' => 'importer-scheduled.php' ], ]; if ( isset( $_GET['post_id'] ) && $current_tab === 'edit' ) { $tabs['edit'] = [ 'title' => sprintf( __( "Edit Feed %s", 'penci-podcast' ), get_the_title( intval( $_GET['post_id'] ) ) ), 'template' => 'importer-form.php' ]; } $tabs = apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_tools_tabs', $tabs ); if ( ! isset( $tabs[ $current_tab ] ) ) { $current_tab = array_key_first( $tabs ); } ?>

    inc/importer/templates/importer-form.php000064400000004033147600053410014467 0ustar00
    $render_data ] ); ?>

    $render_data ] ); ?>
    inc/importer/functions.php000064400000015200147600053410011675 0ustar00 $unused ) { return $key; } return ''; } } if ( ! function_exists( 'pencipdc_importer_redirect' ) ) { function pencipdc_importer_redirect( $location, $status = 302 ) { wp_redirect( $location, $status, PENCI_PODCAST_IMPORTER_NAME ); exit; } } if ( ! function_exists( 'pencipdc_importer_load_template' ) ) { /** * @param $template_name * @param array $args * @param string $template_path * @param string $default_path */ function pencipdc_importer_load_template( $template_name, $args = [], $template_path = '', $default_path = '' ) { PenciPodcast\Template::load_template( $template_name, $args, $template_path, $default_path ); } } if ( ! function_exists( 'pencipdc_importer_supported_post_types' ) ) { function pencipdc_importer_supported_post_types(): array { $response = [ 'podcast' ]; if ( defined( "SSP_CPT_PODCAST" ) ) { $response[] = SSP_CPT_PODCAST; } return apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_supported_post_types', $response ); } } if ( ! function_exists( 'pencipdc_importer_default_post_type' ) ) { function pencipdc_importer_default_post_type(): string { return apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_default_post_type', ( defined( "SSP_CPT_PODCAST" ) ? SSP_CPT_PODCAST : 'post' ) ); } } if ( ! function_exists( 'pencipdc_importer_post_type_id_title_assoc' ) ) { function pencipdc_importer_post_type_id_title_assoc( string $post_type ): array { $shows = get_posts( [ 'post_type' => $post_type, 'numberposts' => 9999, ] ); $response = []; foreach ( $shows as $post ) { $response[ $post->ID ] = $post->post_title; } return $response; } } if ( ! function_exists( 'pencipdc_importer_feed_limit_reached' ) ) { function pencipdc_importer_feed_limit_reached(): bool { return count( get_posts( [ 'post_type' => PENCI_PODCAST_IMPORTER_POST_TYPE_IMPORT, 'fields' => 'ids' ] ) ) >= pencipdc_importer_feed_cron_limit(); } } if ( ! function_exists( 'pencipdc_importer_feed_cron_limit' ) ) { function pencipdc_importer_feed_cron_limit() { return apply_filters( PENCI_PODCAST_IMPORTER_ALIAS . '_feed_cron_limit', 1 ); } } if ( ! function_exists( 'podcast_importer_is_whitelisted_host' ) ) { function podcast_importer_is_whitelisted_host( $parsed_feed_host, $rss_feed_url ) { return ( ( preg_match( '/transistor.fm|anchor.fm|fireside.fm|simplecast.com|sounder.fm|spreaker.com|whooshkaa.com|omny.fm|omnycontent.com|megaphone.fm|podbean.com|buzzsprout.com/i', $parsed_feed_host ) ) || ( preg_match( '/megaphone.fm|captivate.fm|simplecast.com|sounder.fm|ausha.co|omny.fm|omnycontent.com|pinecast.com|audioboom.com|buzzsprout.com/i', $rss_feed_url ) ) ); } } if ( ! function_exists( 'pencipdc_importer_append_player_to_content' ) ) { function pencipdc_importer_append_player_to_content() { return ! function_exists( 'ssp_episodes' ) && ! function_exists( 'powerpress_get_enclosure_data' ) && ! function_exists( 'spp_sl_sppress_plugin_updater' ) && ! function_exists( 'pencipdc_themes_theme_updater' ); } } // if ( ! function_exists( 'pencipdc_importer_sanitize_feed_value' ) ) { function pencipdc_importer_sanitize_feed_value( $string ) { $content = array(); $string = trim( (string) $string ); $string = str_replace( " ", "", $string ); if ( preg_match( '/^$/is', $string, $content ) ) { $string = $content[1]; } else { $string = html_entity_decode( $string ); } $string = strip_tags( $string, [ '

    ', '

    ', '

    ', '

    ','

    ', '
    ', '

    ', '','
    ' ] ); return $string; } } if ( ! function_exists( 'pencipdc_importer_get_taxonomy_type_select_definition' ) ) { function pencipdc_importer_get_taxonomy_type_select_definition( $post_types, $hierarchical = true ): array { $hierarchical = boolval( $hierarchical ); $taxonomies_post_type_map = []; foreach ( $post_types as $post_type ) { $post_type_taxonomies = get_object_taxonomies( $post_type ); foreach ( $post_type_taxonomies as $post_type_taxonomy ) { if ( isset( $taxonomies_post_type_map[ $post_type_taxonomy ] ) ) { $taxonomies_post_type_map[ $post_type_taxonomy ][] = $post_type; continue; } $taxonomy_information = get_taxonomy( $post_type_taxonomy ); if ( boolval( $taxonomy_information->hierarchical ) !== $hierarchical ) { continue; } $taxonomies_post_type_map[ $post_type_taxonomy ] = [ $post_type ]; } } if ( empty( $taxonomies_post_type_map ) ) { return []; } $response = []; foreach ( $taxonomies_post_type_map as $taxonomy => $post_types ) { $response[ $taxonomy ] = [ 'data-post-types' => implode( ' ', $post_types ), 'label' => $taxonomy ]; } return $response; } } if ( ! function_exists( 'pencipdc_importer_get_taxonomies_select_definition' ) ) { function pencipdc_importer_get_taxonomies_select_definition( $post_types, $hierarchical = true ): array { $hierarchical = boolval( $hierarchical ); $taxonomies_post_type_map = []; foreach ( $post_types as $post_type ) { $post_type_taxonomies = get_object_taxonomies( $post_type ); foreach ( $post_type_taxonomies as $post_type_taxonomy ) { if ( isset( $taxonomies_post_type_map[ $post_type_taxonomy ] ) ) { $taxonomies_post_type_map[ $post_type_taxonomy ][] = $post_type; continue; } $taxonomy_information = get_taxonomy( $post_type_taxonomy ); if ( boolval( $taxonomy_information->hierarchical ) !== $hierarchical ) { continue; } $taxonomies_post_type_map[ $post_type_taxonomy ] = [ $post_type ]; } } if ( empty( $taxonomies_post_type_map ) ) { return []; } $response = []; foreach ( $taxonomies_post_type_map as $taxonomy => $post_types ) { $categories = get_categories( [ 'taxonomy' => $taxonomy, 'hide_empty' => false ] ); foreach ( $categories as $category ) { $response[ $category->term_id ] = [ 'data-post-types' => implode( ' ', $post_types ), 'label' => ( count( $post_types ) >= 2 ? $taxonomy . ' - ' : '' ) . $category->name ]; } } return $response; } } if ( ! function_exists( 'pencipdc_importer_utility_selected' ) ) { /** * @param $selected * @param bool $current * @param bool $echo * * @return string */ function pencipdc_importer_utility_selected( $selected, $current = true, $echo = true ) { if ( is_array( $selected ) ) { return selected( 1, in_array( $current, $selected ), $echo ); } return selected( $selected, $current, $echo ); } }inc/importer/autoload.php000064400000001116147600053410011476 0ustar00setup(); // Various Hooks & Additions. PenciPodcast\Hooks::instance()->setup(); // Post Types add_action( 'init', [ PenciPodcast\PostTypes::instance(), 'setup' ] ); // RestAPI add_action( 'rest_api_init', [ PenciPodcast\RestAPI::instance(), 'setup' ] ); // General Functionality add_action( 'plugins_loaded', [ PenciPodcast\Controller::instance(), 'setup' ] ); // Site Health add_filter( 'site_status_tests', [ PenciPodcast\SiteHealth::instance(), 'tests' ] ); // Hook for importer cron job use PenciPodcast\Helper\Scheduler as Helper_Scheduler; add_action( PENCI_PODCAST_IMPORTER_ALIAS . '_cron', 'pencipdc_importer_test_scheduler_integrity' ); if ( ! wp_next_scheduled( PENCI_PODCAST_IMPORTER_ALIAS . '_cron' ) ) { wp_schedule_event( current_time( 'timestamp' ), 'daily', PENCI_PODCAST_IMPORTER_ALIAS . '_cron' ); } function pencipdc_importer_test_scheduler_integrity() { if ( Helper_Scheduler::is_everything_scheduled() ) { return true; } else { return Helper_Scheduler::schedule_posts(); } } if ( is_admin() ) { add_action( 'admin_menu', [ PenciPodcast\AdminMenu::instance(), 'setup' ] ); add_action( 'admin_enqueue_scripts', [ PenciPodcast\AdminAssets::instance(), 'setup' ] ); } register_deactivation_hook( __FILE__, function () { $next_schedule = wp_next_scheduled( 'pencipdc_importer_cron' ); if ( false !== $next_schedule ) { wp_unschedule_event( $next_schedule, PENCI_PODCAST_IMPORTER_CRON_JOB_FREQUENCY, 'pencipdc_importer_cron' ); } $next_schedule = wp_next_scheduled( 'pencipdc_import_cron_process_queue' ); if ( false !== $next_schedule ) { wp_unschedule_event( $next_schedule, PENCI_PODCAST_IMPORTER_CRON_JOB_PROCESS_FREQUENCY, 'pencipdc_import_cron_process_queue' ); } as_unschedule_action( PENCI_PODCAST_IMPORTER_ALIAS . '_scheduler_feeds_sync' ); as_unschedule_all_actions( '', [], PENCI_PODCAST_IMPORTER_SCHEDULER_FEED_GROUP ); } );inc/queries.php000064400000007352147600053410007512 0ustar00prefix}posts AS p LEFT JOIN {$wpdb->prefix}term_relationships AS tr ON(p.ID = tr.object_id) WHERE tr.term_taxonomy_id IN({$id}) OR tr.term_taxonomy_id IN( SELECT DISTINCT(tt.term_taxonomy_id) FROM {$wpdb->prefix}term_taxonomy AS tt WHERE tt.parent IN({$id}) ) AND p.post_type = 'podcast' AND(p.post_status = 'publish')"; $category_with_series = "SELECT term_id FROM {$wpdb->prefix}term_taxonomy WHERE taxonomy = '{$tax}'"; $query = "SELECT DISTINCT(term_taxonomy_id) FROM {$wpdb->prefix}term_relationships WHERE object_id IN({$post_with_category}) AND term_taxonomy_id IN({$category_with_series})"; $query = $wpdb->get_results( $query ); $result_ids = array(); if ( ! empty( $query ) ) { foreach ( $query as $result ) { $result_ids[] = pencipdc_get_term_translate_id( $result->term_taxonomy_id ); } } $result = pencipdc_cache( $query_hash, $result_ids ); } return $result; } } if ( ! function_exists( 'pencipdc_get_podcast_author' ) ) { function pencipdc_get_podcast_author( $podcast_id ) { $episodes = pencipdc_podcast_posts( $podcast_id ); $is_empty = empty( $episodes ) ? true : false; $user = false; if ( ! $is_empty ) { $authors = array(); foreach ( $episodes as $episode_obj ) { $authors[] = $episode_obj->post_author; } if ( ! empty( $authors ) ) { $values = array_count_values( $authors ); arsort( $values ); $most_users = array_slice( array_keys( $values ), 0, 1, true ); foreach ( $most_users as $index => $users ) { $user = $users; } } } return $user; } } if ( ! function_exists( 'pencipdc_podcast_posts' ) ) { /** * @param $podcast_id * @param array $args * * @return array|false|int[]|mixed|WP_Post[] */ function pencipdc_podcast_posts( $podcast_id, $args = array() ) { $defaults = array( 'orderby' => 'rand', 'post_type' => 'podcast', 'tax_query' => array( array( 'taxonomy' => 'podcast-series', 'field' => 'term_id', 'terms' => $podcast_id, // Where term_id of selected $podcast_id. 'include_children' => false, ), ), ); $_args = wp_parse_args( $args, $defaults ); $query_hash = 'query_hash_' . md5( serialize( $_args ) ); if ( ! $episodes = pencipdc_cache( $query_hash ) ) { $episodes = pencipdc_cache( $query_hash, call_user_func( static function () use ( $_args ) { return get_posts( $_args ); } ) ); } if ( ! is_wp_error( $episodes ) ) { return $episodes; } return array(); } }inc/taxonomy-meta.php000064400000005576147600053410010645 0ustar00term_id; $t_tax = $tag->taxonomy; $penci_categories = get_option( "pencipdc_series_$t_id" ); if ( 'podcast-category' == $t_tax ) { $penci_categories = get_option( "pencipdc_category_$t_id" ); } $featured_img = isset( $penci_categories['featured_img'] ) ? $penci_categories['featured_img'] : ''; ?>

    'featured_img', 'class' => '', 'name' => 'featured_img', 'source' => $featured_img, 'button' => 'btn-single-image', 'multi' => false, 'maxsize' => apply_filters( 'penci_maxsize_upload_profile_picture', '2mb' ) ) ); ?>
    '', 'size' => '', 'num' => 5, 'author' => '', 'sub' => '', 'episode' => '', 'desc' => '', 'img_pos' => '', 'class' => '', ), $atts, 'podcast' ); ob_start(); load_template( PENCI_PODCAST_DIR . 'templates/playlist.php', true, $atts ); return ob_get_clean(); } }inc/metabox.php000064400000010332147600053410007464 0ustar00ID, 'pencipc_media_duration', true ); $media_url = get_post_meta( $post->ID, 'pencipc_media_url', true ); // Display the form, using the current value. ?>

    'pencipdc_player', 'track' => 'pencipdc_player_track', ); protected $total = 0; protected $types = array( 'audio', ); protected $type; /** * Player constructor. */ private function __construct() { add_action( 'template_redirect', array( $this, 'render_player' ) ); add_action( 'penci_action_before_the_content', array( $this, 'render_player_in_post' ), 99 ); add_shortcode( $this->shortcode['player'], array( $this, 'player_shortcode' ) ); add_shortcode( $this->shortcode['track'], array( $this, 'player_track_shortcode' ) ); add_filter( 'wp_print_styles', array( $this, 'add_single_episode_to_playlist' ) ); add_action( 'wp_ajax_get_episode_data', array( $this, 'get_episode_data_action' ) ); add_action( 'wp_ajax_nopriv_get_episode_data', array( $this, 'get_episode_data_action' ) ); add_action( 'wp_ajax_get_episode_data_by_series', array( $this, 'get_episode_data_by_series_action' ) ); add_action( 'wp_ajax_nopriv_get_episode_data_by_series', array( $this, 'get_episode_data_by_series_action' ) ); } /** * Singleton page of Player class * * @return Penci_PodCast_Player */ public static function get_instance() { if ( null === static::$instance ) { static::$instance = new static(); } return static::$instance; } /** * Callback for [pencipdc_player] shortcode * * @param array $atts * @param string $content * * @return string */ public function player_shortcode( $atts = array(), $content = '' ) { $html = ''; if ( defined( 'PENCI_SOLEDAD_VERSION' ) ) { static $instance = 0; $instance ++; wp_enqueue_script( 'pencipdc-jplayer', PENCI_PODCAST_URL . '/assets/js/jquery.jplayer.js', array( 'jquery' ), PENCI_PODCAST_VERSION, true ); wp_enqueue_script( 'pencipdc-jplayer-playlist', PENCI_PODCAST_URL . '/assets/js/pencipdc.playlist.js', array( 'jquery' ), PENCI_PODCAST_VERSION, true ); $cover_item = '
    '; $item_title_wrapper = '
    -
    '; $pencipdc_player_bar = '
    00:00
    00:00
    '; $pencipdc_playlist = '
    '; $main_control = '' . '' . '' . ''; $shuffle_btn = '' . ''; $repeat_btn = '' . ''; // Get Track $track = ''; if ( ! empty( $content ) ) { $content = wp_strip_all_tags( nl2br( do_shortcode( $content ) ) ); // Replace last comma if ( false !== ( $pos = strrpos( $content, ',' ) ) ) { $content = substr_replace( $content, '', $pos, 1 ); } $track = ''; } $html = '
    ' . $main_control . '
    ' . $cover_item . '
    ' . $item_title_wrapper . $pencipdc_player_bar . '
    ' . $shuffle_btn . $repeat_btn . '

    ' . pencipdc_translate('queue') . '

    ' . $pencipdc_playlist . '
    Update Required Flash plugin
    ' . $cover_item . '
    ' . $item_title_wrapper . '
    ' . $pencipdc_player_bar . '
    ' . $pencipdc_playlist . '
    ' . $shuffle_btn . $main_control . $repeat_btn . '
    ' . $track . '
    '; } return $html; } /** * @param array $atts * @param string $content * * @return string */ public function player_track_shortcode( $atts = array(), $content = '' ) { $atts = shortcode_atts( array( 'series' => '', 'thumbnail' => sprintf( '%s/wp-includes/images/media/%s.png', get_site_url(), 'audio' ), 'title' => '', 'href' => '', 'src' => '', ), $atts, $this->shortcode['track'] ); $data['series_name'] = sanitize_text_field( $atts['series'] ); $data['post_title'] = sanitize_text_field( $atts['title'] ); $data['post_thumbnail'] = esc_url( $atts['thumbnail'] ); $data['post_url'] = esc_url( $atts['href'] ); $data['upload'] = esc_url( $atts['src'] ); return wp_json_encode( $data ) . ','; } /** * Render Player */ public function render_player() { if ( get_theme_mod( 'pencipodcast_podcast_enable_player', true ) ) { add_action( 'wp_footer', array( $this, 'player' ) ); add_filter( 'body_class', array( $this, 'add_body_class' ) ); } } /** * @param $classes * * @return array */ public function add_body_class( $classes ) { $classes[] = 'pencipdc_global_player'; return $classes; } /** * @param $post_id */ public function render_player_in_post( $post_id ) { if ( ! $post_id ) { $post_id = get_the_ID(); } $result = $this->is_single_episode(); $lock_player = false; $player = ''; if ( class_exists( '\PenciPaywall\ContentFilter' ) ) { $paywall_truncater = \PenciPaywall\ContentFilter::instance(); if ( $paywall_truncater->check_status() ) { $paywall_truncater->show_button( true ); $lock_player = true; } } if ( ! empty( $result ) && ! $lock_player && get_theme_mod( 'pencipodcast_podcast_enable_player', true ) ) { $data = $this->get_episode_data( $post_id ); $track = "[pencipdc_player_track series='{$data['series_name']}' thumbnail='{$data['post_thumbnail']}' title='{$data['post_title']}' href='{$data['post_url']}' src='{$data['episode_upload']}' ]"; $player = do_shortcode( '[pencipdc_player]' . $track . '[/pencipdc_player]' ); } if ( ! empty( $result ) && ! $lock_player && get_theme_mod( 'pencipodcast_podcast_enable_player', true ) ) { $player = pencipdc_podcast_add_media_menu( $post_id, 'single_episode', 'plus' ); } echo $player; } /** * @return array|bool */ public function is_single_episode() { $result = false; if ( is_singular( 'podcast' ) ) { $post_id = get_the_ID(); $args = array( 'post_id' => $post_id, ); $result = $this->set_player_data( $args ); } return $result; } /** * Set Player Data * * @param array $data * * @return array */ public function set_player_data( $data ) { $multiple_data = false; $result = array(); if ( is_array( $data ) ) { if ( ! isset( $data['post_id'] ) ) { $multiple_data = true; } if ( $multiple_data ) { foreach ( $data as $key => $value ) { if ( isset( $value['post_id'] ) ) { $episode_data = $this->get_episode_data( $value['post_id'] ); if ( ! empty( $episode_data ) ) { $result[] = array( 'series_name' => $episode_data['series_name'], 'post_thumbnail' => $episode_data['post_thumbnail'], 'post_title' => $episode_data['post_title'], 'post_url' => $episode_data['post_url'], 'upload' => $episode_data['episode_upload'], 'post_type' => $episode_data['post_type'], ); } } } } else { $episode_data = $this->get_episode_data( $data['post_id'] ); if ( ! empty( $episode_data ) ) { $result = array( 'series_name' => $episode_data['series_name'], 'post_thumbnail' => $episode_data['post_thumbnail'], 'post_title' => $episode_data['post_title'], 'post_url' => $episode_data['post_url'], 'upload' => $episode_data['episode_upload'], 'post_type' => $episode_data['post_type'], ); } } } return $result; } /** * Get episode data * * @param $post_id * * @return array */ public function get_episode_data( $post_id ) { $data = array(); $upload = get_post_meta( $post_id, 'pencipc_media_url', true ); $enable = get_theme_mod( 'pencipodcast_podcast_enable_player', true ); if ( $enable && $upload ) { $series = wp_get_post_terms( $post_id, 'podcast-series' ); $series = is_wp_error( $series ) ? '' : $series; $series = is_array( $series ) ? ( ! empty( $series ) ? $series[0] : $series ) : $series; if ( has_post_thumbnail( $post_id ) ) { $image = get_the_post_thumbnail_url( $post_id, 'thumbnail' ); } else { $image = sprintf( '%s/wp-includes/images/media/%s.png', get_site_url(), 'audio' ); if ( ! empty( $series ) ) { $attribute = pencipdc_podcast_attribute( $series->term_id, array( 'fields' => array( 'image' ) ) ); if ( $attribute['image'] ) { $image = wp_get_attachment_image_url( $attribute['image'], 'post-thumbnail' ); } } } if ( ! empty( $series ) ) { $data = array( 'series_name' => $series->name, 'post_thumbnail' => $image, 'post_title' => get_the_title( $post_id ), 'post_url' => get_post_permalink( $post_id ), 'episode_upload' => $upload, 'post_type' => get_post_type( $post_id ), ); if ( class_exists( '\PenciPaywall\ContentFilter' ) ) { $paywall_truncater = \PenciPaywall\ContentFilter::instance(); if ( $paywall_truncater->check_status( $post_id ) ) { $data['episode_upload'] = ''; } } } } return $data; } /** * Player Template */ public function player() { load_template( PENCI_PODCAST_DIR . '/templates/player.php' ); } /** * add single to playlist */ public function add_single_episode_to_playlist() { $result = $this->is_single_episode(); if ( ! empty( $result ) ) { wp_localize_script( 'penci-podcast', 'single_podcast_data', $result ); } } /** * ajax get podcast data * * @return mixed */ public function get_episode_data_action() { if ( isset( $_POST['post_id'] ) ) { $post_id = (int) sanitize_text_field( $_POST['post_id'] ); $args = array( 'post_id' => $post_id, ); $result = $this->set_player_data( $args ); if ( ! empty( $result ) ) { wp_send_json( $result ); } } wp_send_json( false ); die(); } /** * ajax get podcast data by series * * @return mixed */ public function get_episode_data_by_series_action() { if ( isset( $_POST['post_id'] ) ) { $data = array(); $post_id = (int) sanitize_text_field( $_POST['post_id'] ); $podcast = get_posts( array( 'post_type' => 'podcast', 'numberposts' => - 1, 'tax_query' => array( array( 'taxonomy' => 'podcast-series', 'field' => 'term_id', 'terms' => $post_id, ), ), ) ); if ( $podcast ) { foreach ( $podcast as $key => $value ) { $data[] = array( 'post_id' => $value->ID, ); } $result = $this->set_player_data( $data ); if ( ! empty( $result ) ) { wp_send_json( $result ); } } } wp_send_json( false ); die(); } } inc/widget.php000064400000016416147600053410007321 0ustar00 'penci_podcast_widget', 'description' => esc_html__( 'A widget that displays an podcast series content', 'soledad' ) ); /* Widget control settings. */ $control_ops = array( 'id_base' => 'penci_podcast_widget' ); $prefix = '.Soledad'; if ( function_exists( 'penci_get_theme_name' ) ) { $prefix = penci_get_theme_name( '.Soledad', true ); } /* Create the widget. */ global $wp_version; if ( 4.3 > $wp_version ) { $this->WP_Widget( 'penci_podcast_widget', $prefix . ' '.esc_html__( 'Podcast', 'soledad' ), $widget_ops, $control_ops ); } else { parent::__construct( 'penci_podcast_widget', $prefix . ' '.esc_html__( 'Podcast', 'soledad' ), $widget_ops, $control_ops ); } } /** * How to display the widget on the screen. */ function widget( $args, $instance ) { extract( $args ); /* Our variables from the widget settings. */ $title = isset( $instance['title'] ) ? $instance['title'] : ''; $title = apply_filters( 'widget_title', $title ); $podcast_series = isset( $instance['podcast_series'] ) ? $instance['podcast_series'] : ''; $desc = isset( $instance['desc'] ) ? $instance['desc'] : ''; $size = isset( $instance['size'] ) ? $instance['size'] : ''; $sub = isset( $instance['sub'] ) ? $instance['sub'] : ''; $author = isset( $instance['author'] ) ? $instance['author'] : ''; $episode = isset( $instance['episode'] ) ? $instance['episode'] : ''; $img_pos = isset( $instance['img_pos'] ) ? $instance['img_pos'] : ''; /* Before widget (defined by themes). */ echo ent2ncr( $before_widget ); /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) { echo( $before_title . $title . $after_title ); } echo do_shortcode( '[podcast desc="' . $desc . '" size="' . $size . '" sub="' . $sub . '" author="' . $author . '" episode="' . $episode . '" img_pos="' . $img_pos . '" id="' . $podcast_series . '"]' ); /* After widget (defined by themes). */ echo ent2ncr( $after_widget ); } /** * Update the widget settings. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $data_instance = $this->soledad_widget_defaults(); foreach ( $data_instance as $data => $value ) { $instance[ $data ] = ! empty( $new_instance[ $data ] ) ? $new_instance[ $data ] : ''; } return $instance; } public function soledad_widget_defaults() { $defaults = array( 'title' => 'Podcast Series', 'podcast_series' => '', 'size' => '', 'author' => '', 'sub' => '', 'episode' => '', 'desc' => '', 'img_pos' => '', ); return $defaults; } function form( $instance ) { /* Set up some default widget settings. */ $defaults = $this->soledad_widget_defaults(); $instance = wp_parse_args( (array) $instance, $defaults ); $instance_title = $instance['title'] ? str_replace( '"', '"', $instance['title'] ) : ''; $series_list = get_terms( [ 'taxonomy' => 'podcast-series', 'hide_empty' => false, ] ); ?>

    />

    />

    />

    />

    inc/helper.php000064400000033301147600053410007305 0ustar00'; $main_button_text = $is_subscribe ? pencipdc_translate( 'subscribe' ) : pencipdc_translate( 'play' ); $attribute = "class=\"pencipdc_media_option {$type}\" data-id=\"{$id}\""; $wide_button = '' . $main_button_icon . '' . $main_button_text . ''; $subscribe_button = ''; if ( ! $is_subscribe ) { $subscribe_button = '
  • ' . pencipdc_translate( 'subscribe' ) . '
  • '; } $content = $wide_button . '' . '' . '' . ''; if ( ! get_theme_mod( 'pencipodcast_podcast_global_player', true ) ) { $can_render = false; } break; case 'episode': case 'episode_overlay': case 'episode_overlay_more': case 'episode_block': case 'episode play_btn': case 'single_episode': $can_render = true; $play = ' '; if ( 'single_episode' !== $type ) { $more_button = '' . '' . '' . ''; } else { $more_button = ' '; } if ( 'episode_block' === $type ) { $play = '' . '' . '' . '' . pencipdc_translate( 'play' ) . '' . ''; } if ( 'single_episode' === $type ) { $play = '' . '' . '' . '' . pencipdc_translate( 'play' ) . '' . pencipdc_podcast_get_duration( $id, true, false, 'span' ) . ''; } if ( 'episode play_btn' === $type ) { $more_button = ''; } $content = $play . $more_button; $attribute = "class=\"pencipdc_media_option {$type}\" data-id=\"{$id}\""; if ( 'episode_overlay' === $type || 'episode_overlay_more' === $type ) { $content = 'episode_overlay' === $type ? $play : $more_button; $attribute_class = 'episode_overlay' === $type ? 'overlay' : ''; $type = 'episode'; $attribute = "class=\"pencipdc_media_option {$type} {$attribute_class}\" data-id=\"{$id}\""; } if ( ! get_theme_mod( 'pencipodcast_podcast_enable_player', true ) ) { $can_render = false; } break; } if ( $can_render ) { $output .= '
    ' . $content . '
    '; } return $output; } } if ( ! function_exists( 'pencipdc_podcast_attribute' ) ) { /** * Get most user podcast series * * @param array|int $podcast_id * @param array $args * * @return array */ function pencipdc_podcast_attribute( $podcast_id, $args = array() ) { $result = array(); $defaults = array( 'fields' => array( 'author' ), ); $_args = wp_parse_args( $args, $defaults ); foreach ( $_args['fields'] as $field ) { switch ( $field ) { case 'author': $episodes = pencipdc_podcast_posts( $podcast_id ); $is_empty = empty( $episodes ) ? true : false; $user = false; if ( ! $is_empty ) { $authors = array(); foreach ( $episodes as $episode_obj ) { $authors[] = $episode_obj->post_author; } if ( ! empty( $authors ) ) { $values = array_count_values( $authors ); arsort( $values ); $most_users = array_slice( array_keys( $values ), 0, 1, true ); foreach ( $most_users as $index => $users ) { $user = $users; } } } $result[ $field ] = $user; break; case 'category': $query_hash = 'query_hash_' . md5( serialize( 'category_podcast_' . $podcast_id ) ); if ( ! $category = pencipdc_podcast_cache( $query_hash ) ) { $episodes = pencipdc_podcast_posts( $podcast_id ); $is_empty = empty( $episodes ) ? true : false; $category = false; if ( ! $is_empty ) { $categories = array(); $temp_categories = array(); foreach ( $episodes as $episode_obj ) { $cat = get_the_category( $episode_obj->ID ); if ( ! empty( $cat ) ) { $categories[] = $cat[0]->term_id; $temp_categories[ $cat[0]->term_id ] = $cat[0]; } } if ( ! empty( $categories ) ) { $values = array_count_values( $categories ); arsort( $values ); $most_cat = array_slice( array_keys( $values ), 0, 1, true ); foreach ( $most_cat as $index => $categories ) { $category = $temp_categories[ $categories ]; } } } $category = pencipdc_podcast_cache( $query_hash, $category ); } $result[ $field ] = $category; break; case 'image': $result[ $field ] = pencipdc_get_series_image_id( $podcast_id ); break; case 'count_series': if ( is_array( $podcast_id ) ) { $result[ $field ] = empty( $podcast_id ) ? 0 : count( $podcast_id ); } elseif ( is_int( $podcast_id ) ) { $episode_count = pencipdc_get_series( array( 'term_taxonomy_id' => $podcast_id ) ); $episode_count = is_array( $episode_count ) && ! empty( $episode_count ) ? $episode_count[0]->count : 0; $result[ $field ] = $episode_count; } break; } } return $result; } } if ( ! function_exists( 'pencipdc_podcast_feed_link' ) ) { /** * @param bool $term_id * @param bool $taxonomy * * @return false|string|void */ function pencipdc_podcast_feed_link( $term_id = false, $taxonomy = false ) { $custom_feed_link = get_theme_mod( 'custom_feed_url' ); if ( $custom_feed_link ) { return esc_attr( $custom_feed_link ); } if ( false === $term_id || false === $taxonomy ) { if ( is_archive() ) { global $wp_query; $taxonomy = $wp_query->get_queried_object(); return get_term_feed_link( $taxonomy->term_id, $taxonomy->taxonomy ); } return ''; } return get_term_feed_link( $term_id, $taxonomy ); } } if ( ! function_exists( 'pencipdc_podcast_cache' ) ) { /** * Podcast Cache * * @param $query_hash * @param bool $value * * @return bool|false|mixed */ function pencipdc_podcast_cache( $query_hash, $value = false ) { if ( ! $value ) { return wp_cache_get( $query_hash, 'penci-podcast' ); } wp_cache_set( $query_hash, $value, 'penci-podcast' ); return $value; } } if ( ! function_exists( 'pencipdc_get_series' ) ) { function pencipdc_get_series( $args = '' ) { $defaults = array( 'taxonomy' => 'podcast-series' ); $args = wp_parse_args( $args, $defaults ); $query_hash = 'query_hash_' . md5( serialize( $args ) ); if ( ! $podcast = pencipdc_podcast_cache( $query_hash ) ) { $podcast = pencipdc_podcast_cache( $query_hash, call_user_func( static function () use ( $args ) { return get_terms( $args ); } ) ); } if ( empty( $podcast ) ) { return array(); } /** * Filters the array of term objects returned for the 'post_tag' taxonomy. * * @param WP_Term[]|int $tags Array of 'post_tag' term objects, or a count thereof. * @param array $args An array of arguments. @see get_terms() * * @since 7.5.0 */ $podcast = apply_filters( 'pencipdc_get_series', $podcast, $args ); return $podcast; } } function pencipdc_get_series_image_id( $id ) { $image = get_option( "pencipdc_series_$id" ); $image_id = ''; if ( isset( $image['featured_img'] ) && $image['featured_img'] ) { $image_id = $image['featured_img'][0]; } return $image_id; } function pencipdc_get_category_image_id( $id ) { $image = get_option( "pencipdc_category_$id" ); $image_id = ''; if ( isset( $image['featured_img'] ) && $image['featured_img'] ) { $image_id = $image['featured_img'][0]; } return $image_id; } if ( ! function_exists( 'pencipdc_podcast_get_duration' ) ) { /** * Get podcast Length * * @param $post_id * * @return string */ function pencipdc_podcast_get_duration( $post_id, $human_readable = false, $icon = false, $wrapper = 'div' ) { $output = ''; $duration = get_post_meta( $post_id, 'pencipc_media_duration', true ); if ( $duration ) { $output .= "<$wrapper class='pencipdc_episode_length'>"; if ( $human_readable ) { $duration_divided = explode( ':', $duration ); $count_duration = count( $duration_divided ); $h = '00'; $m = '00'; $s = '00'; if ( $count_duration <= 3 && $count_duration > 0 ) { switch ( $count_duration ) { case 3: list( $h, $m, $s ) = $duration_divided; break; case 2: $h = '00'; list( $m, $s ) = $duration_divided; break; case 1: $h = '00'; $m = '00'; list( $s ) = $duration_divided; break; } } else { if ( $count_duration > 0 ) { $s = end( $duration_divided ); $m = prev( $duration_divided ); $h = prev( $duration_divided ); } } $h = is_int( (int) $h ) ? ltrim( $h, '0' ) : '0'; $m = is_int( (int) $m ) ? ltrim( $m, '0' ) : '0'; $s = is_int( (int) $s ) ? ltrim( $s, '0' ) : '0'; $time_h = ( $h && $h !== '00' && ! empty( $h ) ? "$h " . pencipdc_translate( 'min' ) . ' ' : '' ); $time_m = ( $m && $m !== '00' && ! empty( $m ) ? "$m " : '0 ' ) . pencipdc_translate( 'min' ); $time_s = ''; if ( (int) $h < 1 && (int) $m < 2 ) { if ( (int) $m > 0 ) { $time_m .= ' '; } else { $time_m = ''; } $time_s = ( $s && $s !== '00' && ! empty( $s ) ? "$s " : '0 ' ) . pencipdc_translate( 'sec' ); } $time = $time_h . $time_m . $time_s; $icon = $icon ? " " : ''; $output .= $icon . $time; } else { $output .= normalize_duration( $duration ); } $output .= ""; } return $output; } } if ( ! function_exists( 'normalize_duration' ) ) { /** * @param $duration * * @return false|string */ function normalize_duration( $duration ) { $string = '00:00:00'; for ( $i = ( strlen( $string ) - 4 ); $i > 0; $i -- ) { $comparator = substr( $string, 0, $i ); if ( 0 === strpos( $duration, $comparator ) ) { break; } } return substr( $duration, $i ); } } function pencipdc_translate( $text = '' ) { $options = [ 'previous' => __( 'Previous', 'penci_podcast' ), 'play' => __( 'Play', 'penci_podcast' ), 'pause' => __( 'Pause', 'penci_podcast' ), 'next' => __( 'Next', 'penci_podcast' ), 'shuffle' => __( 'Shuffle', 'penci_podcast' ), 'repeat' => __( 'Repeat', 'penci_podcast' ), 'toggle_play' => __( 'Toggle Player', 'penci_podcast' ), 'toggle_playlist' => __( 'Toggle PlayList', 'penci_podcast' ), 'queue' => __( 'Queue', 'penci_podcast' ), 'mute' => __( 'Mute', 'penci_podcast' ), 'unmute' => __( 'Unmute', 'penci_podcast' ), 'volume' => __( 'Volume', 'penci_podcast' ), 'subscribe' => __( 'Subscribe', 'penci_podcast' ), 'add_to_queue' => __( 'Add to Queue', 'penci_podcast' ), 'wrong' => __( 'There\'s something wrong', 'penci_podcast' ), 'min' => __( 'min', 'penci_podcast' ), 'sec' => __( 'sec', 'penci_podcast' ), ]; if ( $text && isset( $options[ $text ] ) ) { $text_option = 'pencipdc_translate_' . $text; return get_theme_mod( $text_option ) ? get_theme_mod( $text_option ) : $options[ $text ]; } else { return $options; } }inc/init.php000064400000017753147600053410007006 0ustar00 pencipdc_translate( 'add_to_queue' ), 'failed' => pencipdc_translate( 'wrong' ), ); $option['player_option'] = sanitize_title( get_bloginfo( 'name' ) ) . '-penci-player'; $option['ajax_url'] = esc_url( admin_url( 'admin-ajax.php' ) ); return $option; } public function register_assets() { wp_enqueue_style( 'penci-podcast', plugin_dir_url( __DIR__ ) . 'assets/style.css', '', PENCI_PODCAST_VERSION ); wp_enqueue_script( 'penci-podcast', plugin_dir_url( __DIR__ ) . 'assets/js/plugin.js', [ 'jquery' ], PENCI_PODCAST_VERSION, true ); wp_localize_script( 'penci-podcast', 'pencipodcast', $this->localize_script() ); } public function elementor_widget( $widgets_manager ) { if ( class_exists('PenciSoledadElementor\Base\Base_Widget') ) { require_once( plugin_dir_path( __DIR__ ) . 'builder/elementor/podcast_listing.php' ); require_once( plugin_dir_path( __DIR__ ) . 'builder/elementor/podcast_series.php' ); require_once( plugin_dir_path( __DIR__ ) . 'builder/elementor/podcast_categories.php' ); $widgets_manager->register( new \PenciPodcastElementor() ); $widgets_manager->register( new \PenciPodcastSeriesElementor() ); $widgets_manager->register( new \PenciPodcastCategoriesElementor() ); } } public function podcast_template( $template ) { if ( is_tax( [ 'podcast-category', 'podcast-tag' ] ) ) { $template = PENCI_PODCAST_DIR . '/templates/archive-podcast.php'; } if ( is_tax( 'podcast-series' ) ) { $template = PENCI_PODCAST_DIR . '/templates/archive-series.php'; } return $template; } public function register_podcast_post_type() { $labels = array( 'name' => _x( 'Podcast', 'post type general name', 'penci-podcast' ), 'singular_name' => _x( 'Podcast', 'post type singular name', 'penci-podcast' ), 'add_new' => __( 'Add New', 'penci-podcast' ), 'add_new_item' => __( 'Add New Podcast', 'penci-podcast' ), 'edit_item' => __( 'Edit Podcast', 'penci-podcast' ), 'new_item' => __( 'New Podcast', 'penci-podcast' ), 'all_items' => __( 'All Podcasts', 'penci-podcast' ), 'view_item' => __( 'View Podcast', 'penci-podcast' ), 'search_items' => __( 'Search Podcast', 'penci-podcast' ), 'not_found' => __( 'No podcast found', 'penci-podcast' ), 'not_found_in_trash' => __( 'No podcast found in Trash', 'penci-podcast' ), 'parent_item_colon' => '', 'menu_name' => _x( 'Podcast', 'post type general name', 'penci-podcast' ), ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_icon' => 'dashicons-playlist-audio', 'query_var' => 'podcast', 'rewrite' => array( 'slug' => 'podcast' ), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt' ) ); register_post_type( 'podcast', $args ); } public function register_podcast_category() { $labels = array( 'name' => _x( 'Categories', 'taxonomy general name', 'penci-podcast' ), 'singular_name' => _x( 'Category', 'taxonomy singular name', 'penci-podcast' ), 'search_items' => __( 'Search Podcast Categories', 'penci-podcast' ), 'all_items' => __( 'All Podcast Categories', 'penci-podcast' ), 'parent_item' => __( 'Parent Podcast Category', 'penci-podcast' ), 'parent_item_colon' => __( 'Parent Podcast Category:', 'penci-podcast' ), 'edit_item' => __( 'Edit Podcast Category', 'penci-podcast' ), 'update_item' => __( 'Update Podcast Category', 'penci-podcast' ), 'add_new_item' => __( 'Add New Podcast Category', 'penci-podcast' ), 'new_item_name' => __( 'New Podcast Category Name', 'penci-podcast' ), 'menu_name' => __( 'Categories', 'penci-podcast' ) ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'show_in_rest' => true, 'rewrite' => array( 'slug' => 'podcast-category' ) ); register_taxonomy( 'podcast-category', array( 'podcast' ), $args ); } public function register_podcast_series() { $labels = array( 'name' => _x( 'Podcast Series', 'taxonomy general name', 'penci-podcast' ), 'singular_name' => _x( 'Podcast Series', 'taxonomy singular name', 'penci-podcast' ), 'search_items' => __( 'Search Podcast Series', 'penci-podcast' ), 'all_items' => __( 'All Podcast Series', 'penci-podcast' ), 'parent_item' => __( 'Parent Podcast Series', 'penci-podcast' ), 'parent_item_colon' => __( 'Parent Podcast Series:', 'penci-podcast' ), 'edit_item' => __( 'Edit Podcast Series', 'penci-podcast' ), 'update_item' => __( 'Update Podcast Series', 'penci-podcast' ), 'add_new_item' => __( 'Add New Podcast Series', 'penci-podcast' ), 'new_item_name' => __( 'New Podcast Series Name', 'penci-podcast' ), 'menu_name' => __( 'Series', 'penci-podcast' ) ); $args = array( 'hierarchical' => false, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'show_in_rest' => true, 'rewrite' => array( 'slug' => 'podcast-series' ) ); register_taxonomy( 'podcast-series', array( 'podcast' ), $args ); } public function custom_css() { $out = ''; $custom_css = [ 'pencipodcast_player_trackbgcolor' => '.pencipdc_progress_bar__seek, .pencipdc_volume_bar{background-color: {{VALUE}}}', 'pencipodcast_player_bgcolor' => '.pencipdc_mobile_player_wrapper,.pencipdc_player_control__playlist,.pencipdc_player_inner{background-color: {{VALUE}}}', 'pencipodcast_player_textcolor' => '.pencipdc_player_bar__current_time, .pencipdc_player_bar__duration,.pencipdc_dock_player .pencipdc_player_control a,.pencipdc_mobile_player_wrapper a,.pencipdc_player_control__close_player,.pencipdc_control_bar_toggle_player .pencipdc_player_control__toggle_player{color: {{VALUE}}}.pencipdc_podcast{--pcheading-cl:{{VALUE}}}', 'pencipodcast_player_boderscolor' => '.pencipdc_player_control__playlist .pencipdc_block_heading,.pencipdc_control_bar_left .pencipdc_player_control__play .fa,.pencipdc_player_control .pencipdc_player_control__pause .fa, .pencipdc_player_control .pencipdc_player_control__play .fa{border-color: {{VALUE}}}', 'pencipodcast_player_activecolor' => '.pencipdc_progress_bar__play, .pencipdc_volume_bar__value{background-color: {{VALUE}}}.pencipdc_podcast{--pcaccent-cl:{{VALUE}}}', ]; foreach ( $custom_css as $mod => $selector ) { $value = get_theme_mod( $mod ); if ( $value ) { $out .= str_replace( '{{VALUE}}', $value, $selector ); } } echo $out; } } PenciPostcast::instance();languages/en.po000064400000122573147600053410007466 0ustar00msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2023-09-07 21:09+0700\n" "PO-Revision-Date: 2023-09-07 21:09+0700\n" "Last-Translator: \n" "Language-Team: \n" "Language: en\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 3.2.2\n" "X-Poedit-Basepath: .\n" "X-Poedit-KeywordsList: _e;__;esc__;esc_html__\n" "X-Poedit-SearchPath-0: .\n" #: builder/elementor/podcast_categories.php:14 msgid "Penci Podcast - Categories" msgstr "" #: builder/elementor/podcast_categories.php:40 #: builder/elementor/podcast_listing.php:40 #: builder/elementor/podcast_series.php:40 msgid "General" msgstr "" #: builder/elementor/podcast_categories.php:45 #: builder/elementor/podcast_listing.php:53 #: inc/importer/app/Helper/FeedForm.php:106 inc/init.php:131 msgid "Categories" msgstr "" #: builder/elementor/podcast_categories.php:57 #: builder/elementor/podcast_listing.php:75 #: builder/elementor/podcast_series.php:65 msgid "Layout" msgstr "" #: builder/elementor/podcast_categories.php:63 #: builder/elementor/podcast_listing.php:81 #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:139 msgid "Columns" msgstr "" #: builder/elementor/podcast_categories.php:67 #: builder/elementor/podcast_categories.php:82 #: builder/elementor/podcast_categories.php:95 #: builder/elementor/podcast_listing.php:85 #: builder/elementor/podcast_listing.php:99 #: builder/elementor/podcast_listing.php:113 msgid "2 Columns" msgstr "" #: builder/elementor/podcast_categories.php:68 #: builder/elementor/podcast_categories.php:83 #: builder/elementor/podcast_categories.php:96 #: builder/elementor/podcast_listing.php:86 #: builder/elementor/podcast_listing.php:100 #: builder/elementor/podcast_listing.php:114 msgid "3 Columns" msgstr "" #: builder/elementor/podcast_categories.php:69 #: builder/elementor/podcast_listing.php:87 #: builder/elementor/podcast_listing.php:101 msgid "4 Columns" msgstr "" #: builder/elementor/podcast_categories.php:70 #: builder/elementor/podcast_listing.php:88 msgid "5 Columns" msgstr "" #: builder/elementor/podcast_categories.php:77 #: builder/elementor/podcast_listing.php:95 msgid "Tablet Columns" msgstr "" #: builder/elementor/podcast_categories.php:81 #: builder/elementor/podcast_categories.php:94 msgid "1 Columns" msgstr "" #: builder/elementor/podcast_categories.php:90 #: builder/elementor/podcast_listing.php:108 msgid "Mobile Columns" msgstr "" #: builder/elementor/podcast_categories.php:103 #: builder/elementor/podcast_listing.php:121 msgid "Items Gap" msgstr "" #: builder/elementor/podcast_categories.php:114 #: builder/elementor/podcast_listing.php:144 #: builder/elementor/podcast_series.php:83 msgid "Featured Image Size" msgstr "" #: builder/elementor/podcast_categories.php:122 #: builder/elementor/podcast_listing.php:162 #: builder/elementor/podcast_series.php:91 msgid "Featured Image Ratio" msgstr "" #: builder/elementor/podcast_categories.php:131 msgid "Items Boder Radius" msgstr "" #: builder/elementor/podcast_categories.php:140 #: builder/elementor/podcast_listing.php:180 #: builder/elementor/podcast_series.php:119 msgid "Podcast Meta" msgstr "" #: builder/elementor/podcast_categories.php:146 #: builder/elementor/podcast_listing.php:194 #: builder/elementor/podcast_series.php:133 msgid "Show Episode Count" msgstr "" #: builder/elementor/podcast_categories.php:154 #: builder/elementor/podcast_listing.php:202 #: builder/elementor/podcast_series.php:141 msgid "Show Description" msgstr "" #: builder/elementor/podcast_categories.php:165 msgid "Content Style" msgstr "" #: builder/elementor/podcast_categories.php:171 #: builder/elementor/podcast_listing.php:227 #: builder/elementor/podcast_series.php:166 #: inc/importer/templates/importer-scheduled.php:15 msgid "Title" msgstr "" #: builder/elementor/podcast_categories.php:179 #: builder/elementor/podcast_listing.php:235 #: builder/elementor/podcast_series.php:174 msgid "Title Typography" msgstr "" #: builder/elementor/podcast_categories.php:186 #: builder/elementor/podcast_listing.php:242 #: builder/elementor/podcast_series.php:181 msgid "Title Color" msgstr "" #: builder/elementor/podcast_categories.php:195 #: builder/elementor/podcast_listing.php:259 #: builder/elementor/podcast_series.php:221 msgid "Meta" msgstr "" #: builder/elementor/podcast_categories.php:204 #: builder/elementor/podcast_listing.php:267 #: builder/elementor/podcast_series.php:229 #: builder/elementor/podcast_series.php:296 msgid "Meta Typography" msgstr "" #: builder/elementor/podcast_categories.php:212 #: builder/elementor/podcast_listing.php:274 #: builder/elementor/podcast_series.php:236 #: builder/elementor/podcast_series.php:303 msgid "Meta Color" msgstr "" #: builder/elementor/podcast_categories.php:222 #: builder/elementor/podcast_listing.php:299 #: builder/elementor/podcast_series.php:261 msgid "Description" msgstr "" #: builder/elementor/podcast_categories.php:231 #: builder/elementor/podcast_listing.php:307 #: builder/elementor/podcast_series.php:270 msgid "Description Typography" msgstr "" #: builder/elementor/podcast_categories.php:239 #: builder/elementor/podcast_listing.php:314 #: builder/elementor/podcast_series.php:278 msgid "Description Color" msgstr "" #: builder/elementor/podcast_categories.php:249 msgid "Overlay" msgstr "" #: builder/elementor/podcast_categories.php:256 msgid "Overlay Background Color" msgstr "" #: builder/elementor/podcast_categories.php:264 msgid "Hover Overlay Background Color" msgstr "" #: builder/elementor/podcast_categories.php:328 #: builder/elementor/podcast_listing.php:548 #: builder/elementor/podcast_series.php:585 msgid "Default" msgstr "" #: builder/elementor/podcast_categories.php:340 #: builder/elementor/podcast_listing.php:560 #: builder/elementor/podcast_series.php:597 msgid "Full" msgstr "" #: builder/elementor/podcast_listing.php:14 msgid "Penci Podcast - Listing" msgstr "" #: builder/elementor/podcast_listing.php:46 #: builder/elementor/podcast_series.php:46 msgid "Number of Posts" msgstr "" #: builder/elementor/podcast_listing.php:63 #: builder/elementor/podcast_series.php:53 #: inc/importer/app/Helper/FeedForm.php:117 inc/init.php:159 msgid "Series" msgstr "" #: builder/elementor/podcast_listing.php:112 msgid "1 Column" msgstr "" #: builder/elementor/podcast_listing.php:132 #: builder/elementor/podcast_series.php:71 msgid "Image Position" msgstr "" #: builder/elementor/podcast_listing.php:136 #: builder/elementor/podcast_series.php:75 msgid "Top" msgstr "" #: builder/elementor/podcast_listing.php:137 #: builder/elementor/podcast_series.php:76 msgid "Left" msgstr "" #: builder/elementor/podcast_listing.php:152 #: builder/elementor/podcast_series.php:100 msgid "Featured Image Width" msgstr "" #: builder/elementor/podcast_listing.php:171 #: builder/elementor/podcast_series.php:110 msgid "Featured Boder Radius" msgstr "" #: builder/elementor/podcast_listing.php:186 #: builder/elementor/podcast_series.php:125 msgid "Show Author" msgstr "" #: builder/elementor/podcast_listing.php:210 msgid "Show Media Options" msgstr "" #: builder/elementor/podcast_listing.php:221 #: builder/elementor/podcast_series.php:160 msgid "Podcast Style" msgstr "" #: builder/elementor/podcast_listing.php:250 msgid "Title Hover Color" msgstr "" #: builder/elementor/podcast_listing.php:282 #: builder/elementor/podcast_series.php:244 #: builder/elementor/podcast_series.php:311 msgid "Meta Link Color" msgstr "" #: builder/elementor/podcast_listing.php:290 #: builder/elementor/podcast_series.php:252 #: builder/elementor/podcast_series.php:319 msgid "Meta Link Hover Color" msgstr "" #: builder/elementor/podcast_listing.php:323 #: builder/elementor/podcast_series.php:399 msgid "Play Button" msgstr "" #: builder/elementor/podcast_listing.php:331 #: builder/elementor/podcast_listing.php:395 #: builder/elementor/podcast_series.php:337 #: builder/elementor/podcast_series.php:407 #: builder/elementor/podcast_series.php:471 msgid "Buttons Typography" msgstr "" #: builder/elementor/podcast_listing.php:338 #: builder/elementor/podcast_listing.php:402 #: builder/elementor/podcast_series.php:345 #: builder/elementor/podcast_series.php:414 #: builder/elementor/podcast_series.php:478 msgid "Button Color" msgstr "" #: builder/elementor/podcast_listing.php:346 #: builder/elementor/podcast_listing.php:410 #: builder/elementor/podcast_series.php:354 #: builder/elementor/podcast_series.php:422 #: builder/elementor/podcast_series.php:486 msgid "Button Hover Color" msgstr "" #: builder/elementor/podcast_listing.php:354 #: builder/elementor/podcast_listing.php:418 #: builder/elementor/podcast_series.php:362 #: builder/elementor/podcast_series.php:430 #: builder/elementor/podcast_series.php:494 msgid "Button Background Color" msgstr "" #: builder/elementor/podcast_listing.php:362 #: builder/elementor/podcast_listing.php:426 #: builder/elementor/podcast_series.php:371 #: builder/elementor/podcast_series.php:438 #: builder/elementor/podcast_series.php:502 msgid "Button Background Hover Color" msgstr "" #: builder/elementor/podcast_listing.php:370 #: builder/elementor/podcast_listing.php:434 #: builder/elementor/podcast_series.php:380 #: builder/elementor/podcast_series.php:446 #: builder/elementor/podcast_series.php:510 msgid "Button Border Color" msgstr "" #: builder/elementor/podcast_listing.php:378 #: builder/elementor/podcast_listing.php:442 #: builder/elementor/podcast_series.php:389 #: builder/elementor/podcast_series.php:454 #: builder/elementor/podcast_series.php:518 msgid "Button Border Hover Color" msgstr "" #: builder/elementor/podcast_listing.php:387 #: builder/elementor/podcast_series.php:463 msgid "More Button" msgstr "" #: builder/elementor/podcast_series.php:14 msgid "Penci Podcast - Series" msgstr "" #: builder/elementor/podcast_series.php:149 #: customizer/penci_podcast_category_section.php:100 #: customizer/penci_podcast_series_section.php:43 msgid "Show Subscribe Button" msgstr "" #: builder/elementor/podcast_series.php:189 msgid "Listing Title" msgstr "" #: builder/elementor/podcast_series.php:197 msgid "Listing Title Typography" msgstr "" #: builder/elementor/podcast_series.php:204 msgid "Listing Title Color" msgstr "" #: builder/elementor/podcast_series.php:212 msgid "Listing Title Hover Color" msgstr "" #: builder/elementor/podcast_series.php:288 msgid "Item Meta" msgstr "" #: builder/elementor/podcast_series.php:328 msgid "Subscribe Button" msgstr "" #: builder/elementor/podcast_series.php:527 msgid "Borders" msgstr "" #: builder/elementor/podcast_series.php:534 msgid "General Border Color" msgstr "" #: builder/elementor/podcast_series.php:542 msgid "Listing Spacing" msgstr "" #: customizer/panel.php:23 inc/widget.php:39 inc/widget.php:41 #: penci-podcast.php:38 msgid "Podcast" msgstr "" #: customizer/panel.php:29 penci-podcast.php:41 msgid "General Settings" msgstr "" #: customizer/panel.php:30 penci-podcast.php:42 msgid "Categories Layout" msgstr "" #: customizer/panel.php:31 penci-podcast.php:43 msgid "Series Layout" msgstr "" #: customizer/panel.php:32 penci-podcast.php:44 msgid "Colors" msgstr "" #: customizer/panel.php:33 penci-podcast.php:45 msgid "Text Translation" msgstr "" #: customizer/penci_podcast_category_section.php:7 msgid "Template & Layout Settings" msgstr "" #: customizer/penci_podcast_category_section.php:15 msgid "Featured Image Position" msgstr "" #: customizer/penci_podcast_category_section.php:27 msgid "Podcast Template" msgstr "" #: customizer/penci_podcast_category_section.php:28 msgid "Choose your single podcast template." msgstr "" #: customizer/penci_podcast_category_section.php:42 msgid "Podcast Layout" msgstr "" #: customizer/penci_podcast_category_section.php:43 msgid "Choose your single podcast layout" msgstr "" #: customizer/penci_podcast_category_section.php:56 #: customizer/penci_podcast_series_section.php:8 msgid "Podcast Elements" msgstr "" #: customizer/penci_podcast_category_section.php:64 #: customizer/penci_podcast_series_section.php:16 msgid "Show Featured Image" msgstr "" #: customizer/penci_podcast_category_section.php:65 #: customizer/penci_podcast_series_section.php:17 msgid "Show featured image single podcast." msgstr "" #: customizer/penci_podcast_category_section.php:73 #: customizer/penci_podcast_series_section.php:25 msgid "Show Podcast Author" msgstr "" #: customizer/penci_podcast_category_section.php:74 #: customizer/penci_podcast_series_section.php:26 msgid "Show podcast author on podcast meta container." msgstr "" #: customizer/penci_podcast_category_section.php:82 #: customizer/penci_podcast_series_section.php:34 msgid "Show Episode Counter" msgstr "" #: customizer/penci_podcast_category_section.php:83 #: customizer/penci_podcast_series_section.php:35 msgid "Show or hide episode counter" msgstr "" #: customizer/penci_podcast_category_section.php:91 msgid "Show Podcast Meta Option" msgstr "" #: customizer/penci_podcast_category_section.php:92 msgid "Show Podcast meta option on podcast aside." msgstr "" #: customizer/penci_podcast_category_section.php:108 #: customizer/penci_podcast_series_section.php:51 msgid "Enable Post Excerpt" msgstr "" #: customizer/penci_podcast_category_section.php:109 #: customizer/penci_podcast_series_section.php:52 msgid "Show post excerpt on this block." msgstr "" #: customizer/penci_podcast_category_section.php:117 msgid "Excerpt Length" msgstr "" #: customizer/penci_podcast_category_section.php:118 msgid "Set the word length of excerpt on post." msgstr "" #: customizer/penci_podcast_category_section.php:131 msgid "Excerpt Ellipsis" msgstr "" #: customizer/penci_podcast_category_section.php:132 msgid "Define excerpt ellipsis" msgstr "" #: customizer/penci_podcast_colors_section.php:8 msgid "Player Background Color" msgstr "" #: customizer/penci_podcast_colors_section.php:15 msgid "Player Text Color" msgstr "" #: customizer/penci_podcast_colors_section.php:22 msgid "Player Text Active Color" msgstr "" #: customizer/penci_podcast_colors_section.php:29 msgid "Player Borders Color" msgstr "" #: customizer/penci_podcast_colors_section.php:36 msgid "Audio Tracking Background Color" msgstr "" #: customizer/penci_podcast_general_section.php:8 msgid "General Setting" msgstr "" #: customizer/penci_podcast_general_section.php:16 msgid "Enable Podcast Player" msgstr "" #: customizer/penci_podcast_general_section.php:17 msgid "Enable this feature will show podcast player." msgstr "" #: customizer/penci_podcast_general_section.php:25 msgid "Enable Global Player" msgstr "" #: customizer/penci_podcast_general_section.php:26 msgid "Enable this feature will show podcast player globaly." msgstr "" #: inc/helper.php:415 msgid "Previous" msgstr "" #: inc/helper.php:416 msgid "Play" msgstr "" #: inc/helper.php:417 msgid "Pause" msgstr "" #: inc/helper.php:418 msgid "Next" msgstr "" #: inc/helper.php:419 msgid "Shuffle" msgstr "" #: inc/helper.php:420 msgid "Repeat" msgstr "" #: inc/helper.php:421 msgid "Toggle Player" msgstr "" #: inc/helper.php:422 msgid "Toggle PlayList" msgstr "" #: inc/helper.php:423 msgid "Queue" msgstr "" #: inc/helper.php:424 msgid "Mute" msgstr "" #: inc/helper.php:425 msgid "Unmute" msgstr "" #: inc/helper.php:426 msgid "Volume" msgstr "" #: inc/helper.php:427 templates/playlist.php:56 msgid "Subscribe" msgstr "" #: inc/helper.php:428 msgid "Add to Queue" msgstr "" #: inc/helper.php:429 msgid "There's something wrong" msgstr "" #: inc/helper.php:430 msgid "min" msgstr "" #: inc/helper.php:431 msgid "sec" msgstr "" #: inc/importer/app/AdminAssets.php:42 #, php-format msgid "Processed %s episodes out of %s" msgstr "" #: inc/importer/app/AdminAssets.php:43 #, php-format msgid "Success! Re-synced %s previously imported episodes." msgstr "" #: inc/importer/app/AdminAssets.php:44 #, php-format msgid "" "Success! Re-synced %s previously imported episodes, and skipped %s based on " "rules." msgstr "" #: inc/importer/app/AdminAssets.php:45 #, php-format msgid "Skipped %s episode imports, based on rules." msgstr "" #: inc/importer/app/AdminAssets.php:46 msgid "No new episodes imported - all episodes already existing in WordPress!" msgstr "" #: inc/importer/app/AdminAssets.php:47 msgid "" "If you have existing draft, private or trashed posts with the same title as " "your episodes, delete those and run the importer again." msgstr "" #: inc/importer/app/AdminAssets.php:48 msgid "Error! Your feed does not contain any episodes." msgstr "" #: inc/importer/app/AdminAssets.php:49 #, php-format msgid "Success! Imported %s out of %s episodes" msgstr "" #: inc/importer/app/AdminAssets.php:50 #, php-format msgid "%s previously imported episodes re-synced" msgstr "" #: inc/importer/app/Helper/FeedForm.php:64 msgid "Podcast Feed URL" msgstr "" #: inc/importer/app/Helper/FeedForm.php:82 msgid "Podcast Status" msgstr "" #: inc/importer/app/Helper/FeedForm.php:86 msgid "Publish" msgstr "" #: inc/importer/app/Helper/FeedForm.php:87 msgid "Save as Draft" msgstr "" #: inc/importer/app/Helper/FeedForm.php:96 msgid "Podcast Author" msgstr "" #: inc/importer/app/Helper/FeedForm.php:130 msgid "Ongoing Import (Enable to continuously import future episodes)" msgstr "" #: inc/importer/app/Helper/FeedForm.php:145 msgid "Import Episode Featured Images" msgstr "" #: inc/importer/app/Helper/FeedForm.php:157 msgid "" "Use an embed audio player instead of the default Penci Podcast Player " "(depending on your podcast host)" msgstr "" #: inc/importer/app/Helper/FeedForm.php:169 msgid "Date Limit" msgstr "" #: inc/importer/app/Helper/FeedForm.php:172 msgid "01-01-2019" msgstr "" #: inc/importer/app/Helper/FeedForm.php:173 msgid "Optional: only import episodes after a certain date." msgstr "" #: inc/importer/app/Helper/FeedForm.php:181 msgid "Imported Content Tag" msgstr "" #: inc/importer/app/Helper/FeedForm.php:196 msgid "Truncate Post Content" msgstr "" #: inc/importer/app/Helper/FeedForm.php:199 msgid "" "Optional: Will trim the post content when imported to the character amount " "below." msgstr "" #: inc/importer/app/Helper/FeedForm.php:200 msgid "Leave empty to skip trimming, set to 0 to skip content import." msgstr "" #: inc/importer/app/Helper/FeedForm.php:208 msgid "Append episode number to post title" msgstr "" #: inc/importer/app/Helper/FeedForm.php:220 msgid "Append custom text to post title" msgstr "" #: inc/importer/app/Helper/FeedForm.php:223 msgid "Ex: My Podcast" msgstr "" #: inc/importer/app/Helper/FeedForm.php:224 #, php-format msgid "Optional: Add %s to display the show name." msgstr "" #: inc/importer/app/PostTypes.php:27 msgid "Podcast Imports" msgstr "" #: inc/importer/app/PostTypes.php:28 msgid "Podcast Import" msgstr "" #: inc/importer/app/RestAPI/ACL.php:33 #, php-format msgid "You are not allowed to %s." msgstr "" #: inc/importer/app/RestAPI/Response.php:46 msgid "Updated settings." msgstr "" #: inc/importer/app/RestAPI/Response.php:68 msgid "Saved podcast feed for continuous import." msgstr "" #: inc/importer/app/RestAPI/Response.php:73 msgid "" "This podcast is already scheduled for import. Delete the previous schedule " "to create a new one." msgstr "" #: inc/importer/app/SiteHealth.php:26 #, php-format msgid "%s - Scheduled Imports" msgstr "" #: inc/importer/app/SiteHealth.php:35 #, php-format msgid "%s runs the imports using the action scheduler." msgstr "" #: inc/importer/app/SiteHealth.php:41 #, php-format msgid "%s - All Actions Scheduled." msgstr "" #: inc/importer/app/SiteHealth.php:44 inc/importer/app/SiteHealth.php:53 msgid "Performance" msgstr "" #: inc/importer/app/SiteHealth.php:50 #, php-format msgid "%s - Missing Actions in schedule." msgstr "" #: inc/importer/app/SiteHealth.php:59 msgid "Reset Schedules" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ActionFactory.php:161 msgid "Invalid action - must be a recurring action." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:60 #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:75 #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:76 #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:89 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:19 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:30 msgid "Scheduled Actions" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:127 msgid "About" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:129 #, php-format msgid "About Action Scheduler %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:131 msgid "" "Action Scheduler is a scalable, traceable job queue for background " "processing large sets of actions. Action Scheduler works by triggering an " "action hook to run at some time in the future. Scheduled actions can also be " "scheduled to run on a recurring schedule." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:141 msgid "Scheduled Action Columns" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:143 #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:96 msgid "Hook" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:143 msgid "Name of the action hook that will be triggered." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:144 #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:97 msgid "Status" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:144 msgid "Action statuses are Pending, Complete, Canceled, Failed" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:145 #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:98 msgid "Arguments" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:145 msgid "Optional data array passed to the action hook." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:146 #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:99 msgid "Group" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:146 msgid "Optional action group." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:147 #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:100 msgid "Recurrence" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:147 msgid "The action's schedule frequency." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:148 msgid "Scheduled" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:148 msgid "The date/time the action is/was scheduled to run." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:149 #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:102 msgid "Log" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_AdminView.php:149 msgid "Activity log for the action." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_DataController.php:137 msgid "Attempting to reduce used memory..." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_InvalidActionException.php:21 #, php-format msgid "Action [%1$s] has an invalid schedule: %2$s" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_InvalidActionException.php:40 #, php-format msgid "" "Action [%1$s] has invalid arguments. It cannot be JSON decoded to an array. " "$args = %2$s" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:92 msgid "Delete" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:101 msgid "Scheduled Date" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:122 msgid "Claim ID" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:129 msgid "Run" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:130 msgid "Process the action now as if it were run as part of a queue" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:133 msgid "Cancel" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:134 msgid "Cancel the action now to avoid it being run in future" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:201 msgid "Now!" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:237 #, php-format msgid "Every %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:243 msgid "Non-repeating" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:341 msgid "" "It appears one or more database tables were missing. Attempting to re-create " "the missing table(s)." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:374 #, php-format msgid "" "A new queue has begun processing. View actions in-progress " "»" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:377 #, php-format msgid "The next queue will begin processing in approximately %d seconds." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:398 #, php-format msgid "Successfully executed action: %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:402 #, php-format msgid "Successfully canceled action: %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:406 #, php-format msgid "Successfully processed change for action: %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:412 #, php-format msgid "Could not process change for action: \"%1$s\" (ID: %2$d). Error: %3$s" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:458 #, php-format msgid " (%s ago)" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:461 #, php-format msgid " (%s)" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_ListTable.php:610 msgid "Search hook, args and claim ID" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_QueueRunner.php:192 msgid "Every minute" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_WPCommentCleaner.php:103 #, php-format msgid "This data will be deleted in %s." msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_WPCommentCleaner.php:108 #, php-format msgid "" "Action Scheduler has migrated data to custom tables; however, orphaned log " "entries exist in the WordPress Comments table. %1$s Learn " "more »" msgstr "" #: inc/importer/lib/action-scheduler/classes/ActionScheduler_wcSystemStatus.php:102 msgid "This section shows details of Action Scheduler." msgstr "" #: inc/importer/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php:33 #: inc/importer/lib/action-scheduler/classes/WP_CLI/ProgressBar.php:47 #, php-format msgid "The %s class can only be run within WP CLI." msgstr "" #: inc/importer/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php:59 msgid "" "There are too many concurrent batches, but the run is forced to continue." msgstr "" #: inc/importer/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php:61 msgid "There are too many concurrent batches." msgstr "" #: inc/importer/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php:113 msgid "The claim has been lost. Aborting current batch." msgstr "" #: inc/importer/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php:138 #, php-format msgid "Started processing action %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php:155 #, php-format msgid "Completed processing action %1$s with hook: %2$s" msgstr "" #: inc/importer/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php:170 #, php-format msgid "Error processing action %1$s: %2$s" msgstr "" #: inc/importer/lib/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php:136 #, php-format msgid "There was an error running the action scheduler: %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler.php:195 #, php-format msgid "%s() was called before the Action Scheduler data store was initialized" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_ListTable.php:467 msgid "Filter" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_ListTable.php:567 #, php-format msgid "Search results for \"%s\"" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Abstract_ListTable.php:672 msgid "Search" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:72 msgid "action created" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:76 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBLogger.php:138 msgid "action canceled" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:82 #, php-format msgid "action started via %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:84 msgid "action started" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:92 #, php-format msgid "action complete via %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:94 msgid "action complete" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:102 #, php-format msgid "action failed via %1$s: %2$s" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:105 #, php-format msgid "action failed: %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:112 #, php-format msgid "action timed out after %s seconds" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:118 #, php-format msgid "unexpected shutdown: PHP Fatal error %1$s in %2$s on line %3$s" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:123 msgid "action reset" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:129 #, php-format msgid "action ignored via %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:131 msgid "action ignored" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:146 #, php-format msgid "There was a failure fetching this action: %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:148 msgid "There was a failure fetching this action" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Logger.php:156 #, php-format msgid "There was a failure scheduling the next instance of this action: %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Store.php:301 #, php-format msgid "" "ActionScheduler_Action::$args too long. To ensure the args column can be " "indexed, action args should not be more than %d characters when encoded as " "JSON." msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Store.php:377 msgid "Complete" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Store.php:378 msgid "Pending" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Store.php:379 msgid "In-progress" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Store.php:380 msgid "Failed" msgstr "" #: inc/importer/lib/action-scheduler/classes/abstracts/ActionScheduler_Store.php:381 msgid "Canceled" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:78 msgid "Database error." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:86 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:35 #: inc/importer/lib/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php:44 #, php-format msgid "Error saving action: %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:243 msgid "Invalid value for select or count parameter. Cannot query actions." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:444 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:535 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:567 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:777 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:819 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:421 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:432 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:459 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:752 #, php-format msgid "Unidentified action %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:651 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:593 #, php-format msgid "The group \"%s\" does not exist." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:665 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:573 msgid "Unable to claim actions. Database error." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:838 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:719 msgid "Invalid action ID. No status found." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:840 msgid "Unknown status found for action." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:72 msgid "Unable to save action." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:238 msgid "Invalid schedule. Cannot save action." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:668 #, php-format msgid "Unable to unlock claim %s. Database error." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:683 #, php-format msgid "Unable to unlock claim on action %s. Database error." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:695 #, php-format msgid "Unable to mark failure on action %s. Database error." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php:819 #, php-format msgid "" "%s Support for strings longer than this will be removed in a future version." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:20 msgid "Scheduled actions are hooks triggered on a cetain date and time." msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:31 msgid "Scheduled Action" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:33 msgid "Add" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:34 msgid "Add New Scheduled Action" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:35 msgid "Edit" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:36 msgid "Edit Scheduled Action" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:37 msgid "New Scheduled Action" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:38 #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:39 msgid "View Action" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:40 msgid "Search Scheduled Actions" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:41 msgid "No actions found" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php:42 msgid "No actions found in trash" msgstr "" #: inc/importer/lib/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php:14 msgid "Action Group" msgstr "" #: inc/importer/lib/action-scheduler/classes/migration/ActionMigrator.php:95 #, php-format msgid "Unable to remove source migrated action %s" msgstr "" #: inc/importer/lib/action-scheduler/classes/migration/Config.php:52 msgid "Source store must be configured before running a migration" msgstr "" #: inc/importer/lib/action-scheduler/classes/migration/Config.php:74 msgid "Source logger must be configured before running a migration" msgstr "" #: inc/importer/lib/action-scheduler/classes/migration/Config.php:96 msgid "Destination store must be configured before running a migration" msgstr "" #: inc/importer/lib/action-scheduler/classes/migration/Config.php:118 msgid "Destination logger must be configured before running a migration" msgstr "" #: inc/importer/lib/action-scheduler/classes/migration/Controller.php:162 msgid "" "Action Scheduler migration in progress. The list of scheduled actions may be " "incomplete." msgstr "" #: inc/importer/lib/action-scheduler/classes/migration/Runner.php:107 #, php-format msgid "Migrated action with ID %1$d in %2$s to ID %3$d in %4$s" msgstr "" #: inc/importer/templates/_form-field.php:63 msgid "Set Image" msgstr "" #: inc/importer/templates/_form-field.php:65 msgid "Remove Image" msgstr "" #: inc/importer/templates/importer-form.php:24 msgid "Advanced Options" msgstr "" #: inc/importer/templates/importer-form.php:38 msgid "Update" msgstr "" #: inc/importer/templates/importer-form.php:40 msgid "Import" msgstr "" #: inc/importer/templates/importer-scheduled.php:9 msgid "Scheduled imports are set for sync once every hour by default." msgstr "" #: inc/importer/templates/importer-scheduled.php:16 msgid "Feed Link" msgstr "" #: inc/importer/templates/importer-scheduled.php:28 msgid "Edit Import" msgstr "" #: inc/importer/templates/importer-scheduled.php:31 msgid "Delete Import" msgstr "" #: inc/importer/templates/tools.php:5 msgid "Import Feed" msgstr "" #: inc/importer/templates/tools.php:9 msgid "Scheduled Imports" msgstr "" #: inc/importer/templates/tools.php:16 #, php-format msgid "Edit Feed %s" msgstr "" #: inc/importer/templates/tools.php:31 msgid "Import a Podcast" msgstr "" #: inc/init.php:87 msgid "Add New" msgstr "" #: inc/init.php:88 msgid "Add New Podcast" msgstr "" #: inc/init.php:89 msgid "Edit Podcast" msgstr "" #: inc/init.php:90 msgid "New Podcast" msgstr "" #: inc/init.php:91 msgid "All Podcasts" msgstr "" #: inc/init.php:92 msgid "View Podcast" msgstr "" #: inc/init.php:93 msgid "Search Podcast" msgstr "" #: inc/init.php:94 msgid "No podcast found" msgstr "" #: inc/init.php:95 msgid "No podcast found in Trash" msgstr "" #: inc/init.php:123 msgid "Search Podcast Categories" msgstr "" #: inc/init.php:124 msgid "All Podcast Categories" msgstr "" #: inc/init.php:125 msgid "Parent Podcast Category" msgstr "" #: inc/init.php:126 msgid "Parent Podcast Category:" msgstr "" #: inc/init.php:127 msgid "Edit Podcast Category" msgstr "" #: inc/init.php:128 msgid "Update Podcast Category" msgstr "" #: inc/init.php:129 msgid "Add New Podcast Category" msgstr "" #: inc/init.php:130 msgid "New Podcast Category Name" msgstr "" #: inc/init.php:151 msgid "Search Podcast Series" msgstr "" #: inc/init.php:152 msgid "All Podcast Series" msgstr "" #: inc/init.php:153 msgid "Parent Podcast Series" msgstr "" #: inc/init.php:154 msgid "Parent Podcast Series:" msgstr "" #: inc/init.php:155 msgid "Edit Podcast Series" msgstr "" #: inc/init.php:156 msgid "Update Podcast Series" msgstr "" #: inc/init.php:157 msgid "Add New Podcast Series" msgstr "" #: inc/init.php:158 msgid "New Podcast Series Name" msgstr "" #: inc/metabox.php:21 msgid "Penci Podcast" msgstr "" #: inc/metabox.php:99 msgid "Media Duration" msgstr "" #: inc/metabox.php:100 msgid "Human-read time value, ex. mm:ss." msgstr "" #: inc/metabox.php:113 msgid "Media URL" msgstr "" #: inc/metabox.php:114 msgid "Fill this option with the media url." msgstr "" #: inc/taxonomy-meta.php:29 msgid "Upload Image" msgstr "" #: inc/widget.php:25 msgid "A widget that displays an podcast series content" msgstr "" #: templates/archive-podcast.php:103 templates/archive-podcast.php:110 #: templates/archive-podcast.php:117 templates/archive-podcast.php:122 #, php-format msgid "

    %s

    " msgstr "" languages/en.mo000064400000000641147600053410007452 0ustar00Þ•$,8g9Project-Id-Version: PO-Revision-Date: 2023-09-07 21:09+0700 Last-Translator: Language-Team: Language: en MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=2; plural=(n != 1); X-Generator: Poedit 3.2.2 X-Poedit-Basepath: . X-Poedit-KeywordsList: _e;__;esc__;esc_html__ X-Poedit-SearchPath-0: . templates/loop/item-style.php000064400000004540147600053410012323 0ustar00name; $total = sprintf( _n( '%s Episode', '%s Episodes', $term->count ), number_format_i18n( $term->count ) ); $thumbnail_load = 'penci-thumb'; if ( get_theme_mod( 'penci_grid_nocrop_list' ) ): $thumbnail_load = 'penci-masonry-thumb'; endif; ?>

    description && get_theme_mod( 'pencipodcast_single_enable_post_excerpt', true ) ): ?>

    description, get_theme_mod( 'pencipodcast_single_excerpt_length', 20 ) ); ?>

    templates/loop/item-series.php000064400000007371147600053410012462 0ustar00
  • templates/loop/item-list.php000064400000004100147600053410012126 0ustar00
  • '; echo penci_get_post_views( get_the_ID() ); echo ' ' . penci_get_setting( 'penci_trans_countviews' ); echo ''; } ?>
  • templates/archive-series.php000064400000015234147600053410012171 0ustar00 ', '
    ', false ); } if ( function_exists( 'rank_math_get_breadcrumbs' ) ) { $rm_breadcrumb = rank_math_get_breadcrumbs( [ 'wrap_before' => '
    ', ] ); } if ( $rm_breadcrumb ) { echo $rm_breadcrumb; } elseif ( $yoast_breadcrumb ) { echo $yoast_breadcrumb; } else { ?>
    '; echo penci_get_setting( 'penci_trans_archives' ); echo ''; ?>
    ', '
    ', false ); } if ( function_exists( 'rank_math_get_breadcrumbs' ) ) { $rm_breadcrumb = rank_math_get_breadcrumbs( [ 'wrap_before' => '
    ', ] ); } if ( $rm_breadcrumb ) { echo $rm_breadcrumb; } elseif ( $yoast_breadcrumb ) { echo $yoast_breadcrumb; } else { ?>
    '; echo penci_get_setting( 'penci_trans_archives' ); echo ''; ?>
    '; echo '
      '; while ( have_posts() ) : the_post(); load_template( PENCI_PODCAST_DIR . 'templates/loop/item-series.php', false ); endwhile; echo '
    '; echo '
    '; penci_soledad_archive_pag_style( $layout_this ); ?>
    templates/player.php000064400000001176147600053410010554 0ustar00
    templates/playlist.php000064400000006442147600053410011122 0ustar00 'podcast', 'posts_per_page' => $args['num'], 'tax_query' => [ [ 'taxonomy' => 'podcast-series', 'terms' => $id, ] ] ] ); $img_class = isset( $args['img_pos'] ) && $args['img_pos'] ? 'img-' . $args['img_pos'] : 'img-left'; $img_size = isset( $args['size'] ) && $args['size'] ? $args['size'] : 'penci-thumb'; ?>

    name ); ?>

    found_posts ), number_format_i18n( $episode_items->found_posts ) ); ?>
    description ): ?>
    description ); ?>
      have_posts() ) : while ( $episode_items->have_posts() ) : $episode_items->the_post(); load_template( PENCI_PODCAST_DIR . 'templates/loop/item-list.php', false ); endwhile;endif; ?>
    templates/archive-podcast.php000064400000015412147600053410012332 0ustar00'; if ( get_theme_mod( 'penci_archive_descalign' ) ) { $archive_desc_align = ' pcdesc-' . get_theme_mod( 'penci_archive_descalign' ); $archive_des_open = '
    '; } if ( ! isset( $layout_this ) || empty( $layout_this ) ): $layout_this = 'standard'; endif; $class_layout = ''; if ( $layout_this == 'classic' ): $class_layout = ' classic-layout'; endif; ?> ', '
    ', false ); } if ( function_exists( 'rank_math_get_breadcrumbs' ) ) { $rm_breadcrumb = rank_math_get_breadcrumbs( [ 'wrap_before' => '
    ', ] ); } if ( $rm_breadcrumb ) { echo $rm_breadcrumb; } elseif ( $yoast_breadcrumb ) { echo $yoast_breadcrumb; } else { ?>
    '; echo penci_get_setting( 'penci_trans_archives' ); echo ''; ?>
    ', '
    ', false ); } if ( function_exists( 'rank_math_get_breadcrumbs' ) ) { $rm_breadcrumb = rank_math_get_breadcrumbs( [ 'wrap_before' => '
    ', ] ); } if ( $rm_breadcrumb ) { echo $rm_breadcrumb; } elseif ( $yoast_breadcrumb ) { echo $yoast_breadcrumb; } else { ?>
    '; echo penci_get_setting( 'penci_trans_archives' ); echo ''; ?>
    '; echo penci_get_setting( 'penci_trans_daily_archives' ); echo ' '; endif; printf( wp_kses( __( '

    %s

    ', 'soledad' ), penci_allow_html() ), get_the_date() ); elseif ( is_month() ) : if ( penci_get_setting( 'penci_trans_monthly_archives' ) ): echo ''; echo penci_get_setting( 'penci_trans_monthly_archives' ); echo ' '; endif; printf( wp_kses( __( '

    %s

    ', 'soledad' ), penci_allow_html() ), get_the_date( _x( 'F Y', 'monthly archives date format', 'soledad' ) ) ); elseif ( is_year() ) : if ( penci_get_setting( 'penci_trans_yearly_archives' ) ): echo ''; echo penci_get_setting( 'penci_trans_yearly_archives' ); echo ' '; endif; printf( wp_kses( __( '

    %s

    ', 'soledad' ), penci_allow_html() ), get_the_date( _x( 'Y', 'yearly archives date format', 'soledad' ) ) ); elseif ( is_author() ) : echo ''; echo penci_get_setting( 'penci_trans_author' ); echo ' '; printf( wp_kses( __( '

    %s

    ', 'soledad' ), penci_allow_html() ), get_userdata( get_query_var( 'author' ) )->display_name ); elseif ( is_tax() ) : the_archive_title( '

    ', '

    ' ); else : echo '

    '; echo penci_get_setting( 'penci_trans_archives' ); echo '

    '; endif; ?>
    ' ); } ?> taxonomy; $thumb = get_theme_mod( 'pencipodcast_items_position', 'top' ); $col = get_theme_mod( 'pencipodcast_items_col', 2 ); ?>
    ' ); } ?>
    penci-podcast.php000064400000004722147600053410010013 0ustar00 30, 'path' => plugin_dir_path( __FILE__ ) . '/customizer/', 'panel' => array( 'title' => esc_html__( 'Podcast', 'soledad' ), 'icon' => 'fas fa-podcast', ), 'penci_podcast_general_section' => array( 'title' => esc_html__( 'General Settings', 'soledad' ) ), 'penci_podcast_category_section' => array( 'title' => esc_html__( 'Categories Layout', 'soledad' ) ), 'penci_podcast_series_section' => array( 'title' => esc_html__( 'Series Layout', 'soledad' ) ), 'penci_podcast_colors_section' => array( 'title' => esc_html__( 'Colors', 'soledad' ) ), 'penci_podcast_translate_section' => array( 'title' => esc_html__( 'Text Translation', 'soledad' ) ), ); return $options; } ); require_once 'inc/importer/importer.php'; require_once 'inc/init.php'; require_once 'inc/queries.php'; require_once 'inc/helper.php'; require_once 'inc/player.php'; require_once 'inc/metabox.php'; require_once 'inc/shortcodes.php'; require_once 'inc/taxonomy-meta.php'; require_once 'inc/widget.php'; Penci_PodCast_Player::get_instance(); PenciPodCast_Shortcode::get_instance();