From f91eb91363dd964a5464e341c79257b848dc20e4 Mon Sep 17 00:00:00 2001 From: Woo Date: Wed, 12 Jun 2024 10:15:47 +0000 Subject: [PATCH] Updates to 6.0.25 --- admin/assets/build/index.asset.php | 2 +- admin/assets/build/index.js | 2 +- admin/assets/js/min/variables.min.js | 2 +- admin/assets/js/min/variables.min.js.map | 2 +- admin/assets/js/variables.js | 21 +- admin/assets/src/workflow-tab-handler.js | 29 +- admin/coupons-list.php | 103 +++--- admin/list-table.php | 241 +++++++------- admin/workflow-list.php | 102 +++--- automatewoo.php | 6 +- changelog.txt | 16 + includes/Actions.php | 1 + .../Actions/Campaign_Monitor_Abstract.php | 22 +- .../Campaign_Monitor_Add_Subscriber.php | 35 +- .../Campaign_Monitor_Remove_Subscriber.php | 67 ++-- includes/Actions/Customer_Add_Tags.php | 38 ++- includes/Actions/Customer_Change_Role.php | 58 +++- includes/Actions/Customer_Remove_Tags.php | 22 +- .../Actions/Memberships_Change_Status.php | 123 +++++++ includes/Actions/Order_Add_Note.php | 32 +- includes/Actions/Order_Change_Status.php | 37 ++- includes/Actions/Order_Resend_Email.php | 78 +++-- includes/Actions/Order_Trigger_Action.php | 48 ++- .../Order_Update_Customer_Shipping_Note.php | 40 ++- includes/Actions/Order_Update_Meta.php | 47 ++- includes/Actions/Subscription_Add_Coupon.php | 19 +- .../Actions/Subscription_Change_Status.php | 47 ++- .../Subscription_Edit_Coupon_Abstract.php | 35 +- .../Actions/Subscription_Send_Invoice.php | 27 +- includes/Actions/Subscription_Update_Meta.php | 19 +- includes/Communication_Page.php | 58 ++-- includes/DataTypes/Subscription.php | 18 +- .../Subscription_Status_Changed.php | 33 +- includes/Fields/Coupon.php | 13 + .../Fields/Searchable_Select_Abstract.php | 3 +- includes/Fields/Select.php | 2 +- includes/Fields/Subscription_Products.php | 51 +-- includes/Fields/Subscription_Status.php | 9 +- includes/Fields/User_Role.php | 26 +- includes/Fields_Helper.php | 29 -- includes/Integrations/ActiveCampaign.php | 5 +- includes/Integrations/Campaign_Monitor.php | 44 +-- includes/Mailer_Abstract.php | 24 ++ ...n_Failed_Automatic_Payment_Retry_Count.php | 17 +- includes/Rules/SubscriptionPaymentCount.php | 18 +- includes/Rules/Subscription_Items.php | 8 +- includes/Rules/Subscription_Status.php | 21 +- includes/Triggers/Subscription_Before_End.php | 24 +- .../Subscription_Payment_Complete.php | 42 ++- .../Triggers/Subscription_Payment_Failed.php | 43 ++- includes/Triggers/Subscription_Trial_End.php | 30 +- includes/Usage_Tracking/Initializer.php | 3 +- .../Variables/Abstract_Generate_Coupon.php | 4 +- .../Subscription_Billing_Address.php | 19 +- includes/Variables/Subscription_End_Date.php | 19 +- includes/Variables/Subscription_ID.php | 18 +- includes/Variables/Subscription_Items.php | 38 ++- .../Subscription_Last_Payment_Date.php | 19 +- includes/Variables/Subscription_Meta.php | 15 +- .../Subscription_Next_Payment_Date.php | 19 +- .../Variables/Subscription_Payment_Method.php | 20 +- .../Subscription_Shipping_Address.php | 19 +- .../Variables/Subscription_Start_Date.php | 19 +- includes/Variables/Subscription_Status.php | 18 +- .../Variables/Subscription_Trial_End_Date.php | 19 +- .../Variables/Subscription_View_Order_Url.php | 20 +- includes/Workflow_Email.php | 5 + languages/automatewoo.pot | 306 ++++++++++-------- vendor/autoload.php | 2 +- vendor/composer/ClassLoader.php | 96 +++--- vendor/composer/InstalledVersions.php | 17 +- vendor/composer/autoload_classmap.php | 1 + vendor/composer/autoload_real.php | 8 +- vendor/composer/autoload_static.php | 9 +- vendor/composer/installed.php | 12 +- 75 files changed, 1586 insertions(+), 978 deletions(-) create mode 100644 includes/Actions/Memberships_Change_Status.php diff --git a/admin/assets/build/index.asset.php b/admin/assets/build/index.asset.php index d79750c..24886f3 100644 --- a/admin/assets/build/index.asset.php +++ b/admin/assets/build/index.asset.php @@ -1 +1 @@ - array('lodash', 'wc-components', 'wc-tracks', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-data-controls', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill', 'wp-url'), 'version' => '33766721a6b446ffb216'); + array('lodash', 'wc-components', 'wc-tracks', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-data-controls', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill', 'wp-url'), 'version' => 'c5c76919fe63962a9475'); diff --git a/admin/assets/build/index.js b/admin/assets/build/index.js index 4031e33..e0076ed 100644 --- a/admin/assets/build/index.js +++ b/admin/assets/build/index.js @@ -18,4 +18,4 @@ // translators: %(itemCount)d: number of matching items, %(dataType)s: type of item, %(workflow)s: workflow title (0,s.__)('Adding %(itemCount)d matching %(dataType)s to the queue for the "%(workflow)s" workflow. If you leave this page the process will stop.',"automatewoo"),{workflow:n.title,dataType:o.primaryDataTypePluralName,itemCount:m})),(0,f.createElement)(_,{progress:u.progress}),(0,f.createElement)("div",{className:"automatewoo-workflow-runner-buttons"},(0,f.createElement)(h.Button,{isSecondary:!0,onClick:a},(0,s.__)("Cancel","automatewoo"))))}()))};qe.propTypes={workflow:b.PropTypes.shape({id:b.PropTypes.number.isRequired,title:b.PropTypes.string.isRequired}).isRequired,workflowQuickFilterData:b.PropTypes.shape({primaryDataTypePluralName:b.PropTypes.string.isRequired}).isRequired,items:b.PropTypes.object.isRequired,onStepCancel:b.PropTypes.func.isRequired};var Ce=qe,je=function(e){var t=e.query,r=p((0,f.useState)({}),2),n=r[0],o=r[1],a=p((0,f.useState)(!1),2),i=a[0],u=a[1],c=p((0,f.useState)({}),2),m=c[0],b=c[1],v=p((0,f.useState)("select"),2),h=v[0],E=v[1],g=p((0,f.useState)(!1),2),_=g[0],k=g[1],R=p((0,f.useState)(!0),2),O=R[0],T=R[1],S=function(){var e=l(w().mark((function e(){var t,r,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return k(!0),(0,y.recordEvent)("aw_manual_workflow_runner_select_workflow",{conversion_tracking_enabled:n.is_conversion_tracking_enabled,tracking_enabled:n.is_tracking_enabled,title:n.title,type:n.type,trigger_name:n.trigger.name}),e.prev=2,e.next=5,re(n.id);case 5:t=e.sent,r=t.possibleResultCounts,o=t.primaryDataType,u({possibleResultCounts:r,primaryDataType:o,primaryDataTypePluralName:C(o)}),E("find"),k(!1),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(2),A((0,s.__)("Error loading the workflow data.","automatewoo"),e.t0);case 16:case"end":return e.stop()}}),e,null,[[2,13]])})));return function(){return e.apply(this,arguments)}}();(0,f.useEffect)((function(){var e=function(){var e=l(w().mark((function e(){var r,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(T(!0),0===(r=void 0!==t.workflowId?parseInt(t.workflowId,10):0)){e.next=14;break}return e.prev=3,e.next=6,F(r);case 6:(n=e.sent).title||(n.title=(0,s.__)("(no title)","automatewoo")),o(n),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(3),A((0,s.__)("The workflow couldn't be loaded from the URL.","automatewoo"),e.t0);case 14:T(!1);case 15:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(){return e.apply(this,arguments)}}();e()}),[t.workflowId]);var P=function(e){(0,y.recordEvent)("aw_manual_run_workflow_button_clicked",{items_count:Object.keys(e).length}),E("queue"),b(e)},q=function(){(0,y.recordEvent)("aw_manual_find_matching_cancel_button_clicked",{}),E("select")},C=function(e){var t={order:(0,s.__)("orders","automatewoo"),subscription:(0,s.__)("subscriptions","automatewoo")};return t.hasOwnProperty(e)?t[e]:(0,s.__)("items","automatewoo")},j=[{key:"select",label:(0,s.__)("Select","automatewoo"),content:(0,f.createElement)(J,{onStepComplete:S,isPreFillingWorkflow:O,workflow:n,setWorkflow:o})},{key:"find",label:(0,s.__)("Find","automatewoo"),content:function(){if("find"===h&&n&&i){var e=(t=i.possibleResultCounts,r=0,t.forEach((function(e){r+=e.count})),r);return(0,f.createElement)(Re,{workflow:n,workflowQuickFilterData:i,possibleResultsCount:e,onStepComplete:P,onStepCancel:q})}var t,r;return""}()},{key:"queue",label:(0,s.__)("Queue","automatewoo"),content:n&&i&&(0,f.createElement)(Ce,{workflow:n,workflowQuickFilterData:i,items:m,onStepCancel:function(){(0,y.recordEvent)("aw_manual_queue_items_cancel_button_clicked",{}),E("select"),b({})}})}];return(0,f.createElement)(d.Stepper,{steps:j,currentStep:h,className:"automatewoo-manual-workflow-runner-stepper",isPending:_})},Ne=function(e){var t=e.onSelect,r=e.tabs,n=e.initialTabName,o=e.children;return(0,f.createElement)("div",{className:"automatewoo-page-tabs-component"},(0,f.createElement)(h.TabPanel,{initialTabName:n,onSelect:t,tabs:r},o))};Ne.propTypes={children:v().func.isRequired,onSelect:v().func.isRequired,tabs:v().array.isRequired,initialTabName:v().string.isRequired};var De=Ne,Ie=window.wp.dataControls,xe="automatewoo/presets",We=function(e,t){return e.requesting[t]||!1},Ae=function(e,t){return e.errors[t]||!1},Fe=function(e){return e.presets},Me=function(e){return e.didCreateWorkflow},Le={SET_IS_REQUESTING:"SET_IS_REQUESTING",SET_ERROR:"SET_ERROR"};function Ue(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Qe(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:nt(nt({},et),{},{presets:[],didCreateWorkflow:!1}),t=arguments.length>1?arguments[1]:void 0,r=t.type,n=t.presets;switch(r){case Ge.UPDATE_PRESETS:e=nt(nt(nt({},e),ot(e,"getPresets")),{},{presets:n});break;case Ge.CREATED_WORKFLOW:e=nt(nt(nt({},e),ot(e,"createWorkflow")),{},{didCreateWorkflow:!0})}return tt(e,t)},actions:t,controls:Ie.controls,selectors:e,resolvers:n});var at=function(e){var t=e.children,r=e.number;return(0,f.createElement)(f.Fragment,null,0===r?"":(0,f.createElement)(h.CardDivider,null),(0,f.createElement)(h.CardBody,null,t))};at.propTypes={children:v().element.isRequired,number:v().number.isRequired};var it=at,st=function(e){var t=e.title,r=e.description,n=e.button;return(0,f.createElement)("div",{className:"automatewoo-presets-list-item"},(0,f.createElement)("div",{className:"automatewoo-presets-list-item__left"},(0,f.createElement)("h4",{className:"automatewoo-presets-list-item__title"},t),(0,f.createElement)("p",{className:"automatewoo-presets-list-item__description"},r)),(0,f.createElement)("div",{className:"automatewoo-presets-list-item__actions"},n))};st.propTypes={title:v().string.isRequired,description:v().string.isRequired,button:v().element.isRequired};var ut=st,ct=function(e,t){(0,y.recordEvent)("aw_preset_list_button_clicked",{action:e,preset_name:t})},lt=function(e){var t=e.name,r=e.title,n=e.description,o=e.link,a=(0,f.createElement)(h.Button,{href:o,isSecondary:!0,target:"_blank",onClick:function(){ct("view_guide",t)}},(0,s.__)("Learn more","automatewoo"));return(0,f.createElement)(ut,{title:r,description:n,button:a})};lt.propTypes={name:v().string.isRequired,title:v().string.isRequired,description:v().string.isRequired,link:v().string.isRequired};var pt=lt,ft=function(e){var t=e.name,r=e.title,n=e.description,o=e.createWorkflow,a=e.createWorkflowIsRequesting,i=(0,f.createElement)(h.Button,{isPrimary:!0,onClick:function(){o(t),ct("create_workflow",t)},disabled:a},(0,s.__)("Create workflow","automatewoo"));return(0,f.createElement)(ut,{description:n,title:r,button:i})};ft.propTypes={name:v().string.isRequired,title:v().string.isRequired,description:v().string.isRequired,createWorkflow:v().func.isRequired,createWorkflowIsRequesting:v().bool.isRequired};var mt=ft,wt=function(e){var t=e.presets,r=e.createWorkflow,n=e.createWorkflowIsRequesting;return(0,f.createElement)(f.Fragment,null,t.map((function(e,t){return(0,f.createElement)(it,{key:t,number:t},"guide"===e.type?(0,f.createElement)(pt,e):(0,f.createElement)(mt,K({},e,{createWorkflow:r,createWorkflowIsRequesting:n})))})))};wt.propTypes={presets:v().array.isRequired,createWorkflow:v().func.isRequired,createWorkflowIsRequesting:v().bool.isRequired};var dt,yt=wt,bt=function(){return(0,f.createElement)("div",{className:"automatewoo-presets-list-item automatewoo-presets-list-item--placeholder","aria-hidden":!0},(0,f.createElement)("div",{className:"automatewoo-presets-list-item__left"},(0,f.createElement)(V,{className:"automatewoo-presets-list-item__title"}),(0,f.createElement)(V,{className:"automatewoo-presets-list-item__description"})),(0,f.createElement)("div",{className:"automatewoo-presets-list-item__actions"},(0,f.createElement)(V,{className:"automatewoo-presets-list-item__button"})))},vt=function(){return i(Array(5).keys()).map((function(e){return(0,f.createElement)(it,{key:e,number:e},(0,f.createElement)(bt,null))}))},ht=function(e){var t=e.message,r=void 0===t?null:t;return(0,f.createElement)(h.CardBody,null,(0,f.createElement)(d.EmptyContent,{title:(0,s.__)("There was an error loading presets. Please try again.","automatewoo"),message:r,actionLabel:(0,s.__)("Reload","automatewoo"),actionURL:null,actionCallback:function(){return window.location.reload()}}))},Et=function(){var e,t=(0,S.useSelect)((function(e){var t=e(xe);return{getPresetsError:t.getError("getPresets"),getPresetsIsRequesting:t.isRequesting("getPresets"),presets:t.getPresets(),createWorkflowIsRequesting:t.isRequesting("createWorkflow"),didCreateWorkflow:t.didCreateWorkflow()}}),[]),r=t.presets,n=t.getPresetsError,o=t.getPresetsIsRequesting,a=t.createWorkflowIsRequesting,i=t.didCreateWorkflow,u=(0,S.useDispatch)(xe).createWorkflow,c=(0,S.useDispatch)("core/notices").createNotice,p=function(){var e=l(w().mark((function e(t){var r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,u(t);case 3:r=e.sent,window.location.href=W(r,"preset"),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),c("error",(0,s.__)("Error: The workflow couldn't be created."));case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(_x){return e.apply(this,arguments)}}();if(n){var m=n.message?(0,s.sprintf)( // translators: %s: The error message. -(0,s.__)("Error: %s","automatewoo"),n.message):null;e=(0,f.createElement)(ht,{message:m})}else e=o?(0,f.createElement)(vt,null):(0,f.createElement)(yt,{presets:r,createWorkflow:p,createWorkflowIsRequesting:a||i});return(0,f.createElement)(h.Card,{size:"medium",className:"automatewoo-presets-list-card"},e)};/edit.php.+post_type=aw_workflow/.test(window.location.href)&&document.addEventListener("DOMContentLoaded",(function(){var e,t,r,n,o,a,i,u,c,l,p;e="workflows",t=[{name:"workflows",title:(0,s.__)("My workflows","automatewoo")},{name:"presets",title:(0,s.__)("Browse presets","automatewoo")}],n=function(t){var r=[document.querySelector("#wpbody-content .subsubsub"),document.querySelector("#wpbody-content #posts-filter")],n=t===e?"block":"none";r.forEach((function(e){e.style.display=n}))},o=function(e){r=e,window.location.hash=e,n(e),c(e)},a=function(e){if(l(),"presets"===e.name)return(0,f.createElement)(Et,null)},i=function(){return window.location.hash.substr(1)},u=function(i){t.find((function(e){return e.name===i}))||(i=r||e),r=i,(0,f.render)((0,f.createElement)(De,{tabs:t,onSelect:o,initialTabName:i},a),p),c(i),n(i)},c=function(e){(0,y.recordEvent)("aw_workflow_tab_view",{tab:e})},l=function(){var e=document.querySelector(".automatewoo-welcome-notice");e&&("presets"===i()?e.style.display="none":e.style.display="block")},p=function(){var e=document.createElement("div");e.setAttribute("id","automatewoo-workflow-tabs-root");var t=document.querySelector("#wpbody-content .wrap > h2.screen-reader-text");return t.parentNode.insertBefore(e,t),e}(),window.addEventListener("hashchange",(function(){var e=i();e!==r&&((0,f.unmountComponentAtNode)(p),u(e))}),!1),u(i())}),!1),r(867),dt=window.jQuery,document.querySelector(".notice[data-automatewoo-dismissible-notice]")&&dt(".notice[data-automatewoo-dismissible-notice]").each((function(){var e=dt(this).data("automatewoo-dismissible-notice").replace("-","_");(0,y.recordEvent)("aw_notice_viewed",{notice_identifier:e}),dt(this).on("click","a[data-automatewoo-link-type]",(function(){return(0,y.queueRecordEvent)("aw_notice_link_clicked",{notice_identifier:e,link_type:dt(this).data("automatewoo-link-type")}),!0})),dt(this).on("click","button.notice-dismiss",(function(){return(0,y.recordEvent)("aw_notice_dismissed",{notice_identifier:e}),!0}))})),(0,u.addFilter)("woocommerce_admin_pages_list","automatewoo",(function(e){return[].concat(i(e),[{breadcrumbs:[(0,s.__)("AutomateWoo","automatewoo"),(0,s.__)("Workflows","automatewoo"),(0,s.__)("Manual Runner","automatewoo")],title:(0,s.__)("AutomateWoo Manual Workflow Runner","automatewoo"),container:je,path:"/automatewoo/manual-workflow-runner",wpOpenMenu:"toplevel_page_automatewoo"}])}))}()}(); \ No newline at end of file +(0,s.__)("Error: %s","automatewoo"),n.message):null;e=(0,f.createElement)(ht,{message:m})}else e=o?(0,f.createElement)(vt,null):(0,f.createElement)(yt,{presets:r,createWorkflow:p,createWorkflowIsRequesting:a||i});return(0,f.createElement)(h.Card,{size:"medium",className:"automatewoo-presets-list-card"},e)};/edit.php.+post_type=aw_workflow/.test(window.location.href)&&document.addEventListener("DOMContentLoaded",(function(){var e,t,r,n,o,a,i,u,c,l,p,m;e="workflows",t=[{name:"workflows",title:(0,s.__)("My workflows","automatewoo")},{name:"presets",title:(0,s.__)("Browse presets","automatewoo")}],o=function(t){var r=[document.querySelector("#wpbody-content .subsubsub"),document.querySelector("#wpbody-content #posts-filter")],n=t===e?"block":"none";r.forEach((function(e){e.style.display=n}))},a=function(e){r=e,window.location.hash=e,o(e),l(e)},i=function(e){if(p(),"presets"===e.name)return(0,f.createElement)(Et,null)},u=function(){return window.location.hash.substr(1)},c=function(s){t.find((function(e){return e.name===s}))||(s=r||e),r=s;var u=(0,f.createElement)(De,{tabs:t,onSelect:a,initialTabName:s},i);void 0!==f.createRoot?(n=(0,f.createRoot)(m)).render(u):(0,f.render)(u,m),l(s),o(s)},l=function(e){(0,y.recordEvent)("aw_workflow_tab_view",{tab:e})},p=function(){var e=document.querySelector(".automatewoo-welcome-notice");e&&("presets"===u()?e.style.display="none":e.style.display="block")},m=function(){var e=document.createElement("div");e.setAttribute("id","automatewoo-workflow-tabs-root");var t=document.querySelector("#wpbody-content .wrap > h2.screen-reader-text");return t.parentNode.insertBefore(e,t),e}(),window.addEventListener("hashchange",(function(){var e=u();e!==r&&(void 0!==f.createRoot?n&&(n.unmount(),n=null):(0,f.unmountComponentAtNode)(m),c(e))}),!1),c(u())}),!1),r(867),dt=window.jQuery,document.querySelector(".notice[data-automatewoo-dismissible-notice]")&&dt(".notice[data-automatewoo-dismissible-notice]").each((function(){var e=dt(this).data("automatewoo-dismissible-notice").replace("-","_");(0,y.recordEvent)("aw_notice_viewed",{notice_identifier:e}),dt(this).on("click","a[data-automatewoo-link-type]",(function(){return(0,y.queueRecordEvent)("aw_notice_link_clicked",{notice_identifier:e,link_type:dt(this).data("automatewoo-link-type")}),!0})),dt(this).on("click","button.notice-dismiss",(function(){return(0,y.recordEvent)("aw_notice_dismissed",{notice_identifier:e}),!0}))})),(0,u.addFilter)("woocommerce_admin_pages_list","automatewoo",(function(e){return[].concat(i(e),[{breadcrumbs:[(0,s.__)("AutomateWoo","automatewoo"),(0,s.__)("Workflows","automatewoo"),(0,s.__)("Manual Runner","automatewoo")],title:(0,s.__)("AutomateWoo Manual Workflow Runner","automatewoo"),container:je,path:"/automatewoo/manual-workflow-runner",wpOpenMenu:"toplevel_page_automatewoo"}])}))}()}(); \ No newline at end of file diff --git a/admin/assets/js/min/variables.min.js b/admin/assets/js/min/variables.min.js index 5046b32..ddca4cc 100644 --- a/admin/assets/js/min/variables.min.js +++ b/admin/assets/js/min/variables.min.js @@ -1,2 +1,2 @@ -var __webpack_exports__={};jQuery((function(a){AutomateWoo.Variables={$meta_box:a("#aw_variables_box"),init(){this.init_clipboard(),a(document.body).on("change keyup",".aw-workflow-variable-parameter",this.update_preview_field),a(document.body).on("keypress","input.aw-workflow-variable-parameter",this.restrict_parameter_chars),this.$meta_box.on("click",".aw-workflow-variable",this.open_modal)},init_clipboard(){new ClipboardJS(".aw-clipboard-btn",{text(){return a("#aw_workflow_variable_preview_field").text()}}).on("success",(function(){a(".aw-clipboard-btn").html("Copied!"),setTimeout((function(){AutomateWoo.Modal.close()}),500)}))},open_modal(){AutomateWoo.Modal.open(),AutomateWoo.Modal.loading();const e={action:"aw_modal_variable_info",variable:a(this).text()};a.post(ajaxurl,e,(function(a){AutomateWoo.Modal.contents(a),AutomateWoo.Variables.update_preview_field()}))},update_preview_field(){const e=a("#aw_workflow_variable_preview_field"),t=e.data("variable"),o=[];a(".aw-workflow-variable-parameter").each((function(){const e=a(this).parents(".aw-workflow-variables-parameter-row:first");if(e.data("parameter-show")){const t=e.data("parameter-show").split("="),o=a('.aw-workflow-variable-parameter[name="'+t[0]+'"]');if(!o.length||o.val()!==t[1])return void e.hide();e.show()}const t={name:a(this).attr("name"),required:e.data("is-required"),value:a(this).val()};o.push(t)}));const r=AutomateWoo.Variables.generate_variable_string(t,o);e.text(r)},generate_variable_string(e,t){let o="{{ "+e;if(t.length){const e=[];a.each(t,(function(a,t){t.value?e.push(t.name+": '"+t.value+"'"):t.required&&e.push(t.name+": '...'")})),e.length>0&&(o+=" | ",o+=e.join(", "))}return o+" }}"},restrict_parameter_chars(e){if(-1!==a.inArray(e.which,[39,123,124,125]))return!1}},AutomateWoo.Variables.init()})); +var __webpack_exports__={};jQuery((function(a){AutomateWoo.Variables={$meta_box:a("#aw_variables_box"),init(){this.init_clipboard(),a(document.body).on("change keyup",".aw-workflow-variable-parameter",this.update_preview_field),a(document.body).on("keypress","input.aw-workflow-variable-parameter",this.restrict_parameter_chars),this.$meta_box.on("click",".aw-workflow-variable",this.open_modal)},init_clipboard(){new ClipboardJS(".aw-clipboard-btn",{text(){let e=a("#aw_workflow_variable_preview_field").text();return a(".aw-workflow-variable-parameter").each((function(t,r){if(a(r).prop("required")&&!a(r).get(0).checkValidity())return a(r).get(0).reportValidity(),e=!1,!1})),e}}).on("success",(function(){a(".aw-clipboard-btn").html("Copied!"),setTimeout((function(){AutomateWoo.Modal.close()}),500)}))},open_modal(){AutomateWoo.Modal.open(),AutomateWoo.Modal.loading();const e={action:"aw_modal_variable_info",variable:a(this).text()};a.post(ajaxurl,e,(function(a){AutomateWoo.Modal.contents(a),AutomateWoo.Variables.update_preview_field()}))},update_preview_field(){const e=a("#aw_workflow_variable_preview_field"),t=e.data("variable"),r=[];a(".aw-workflow-variable-parameter").each((function(){const e=a(this).parents(".aw-workflow-variables-parameter-row:first");if(e.data("parameter-show")){const t=e.data("parameter-show").split("="),r=a('.aw-workflow-variable-parameter[name="'+t[0]+'"]');if(!r.length||r.val()!==t[1])return void e.hide();e.show()}const t={name:a(this).attr("name"),required:e.data("is-required"),value:a(this).val()};r.push(t)}));const o=AutomateWoo.Variables.generate_variable_string(t,r);e.text(o)},generate_variable_string(e,t){let r="{{ "+e;if(t.length){const e=[];a.each(t,(function(a,t){t.value?e.push(t.name+": '"+t.value+"'"):t.required&&e.push(t.name+": '...'")})),e.length>0&&(r+=" | ",r+=e.join(", "))}return r+" }}"},restrict_parameter_chars(e){if(-1!==a.inArray(e.which,[39,123,124,125]))return!1}},AutomateWoo.Variables.init()})); //# sourceMappingURL=variables.min.js.map \ No newline at end of file diff --git a/admin/assets/js/min/variables.min.js.map b/admin/assets/js/min/variables.min.js.map index 72b8eb0..5c2b801 100644 --- a/admin/assets/js/min/variables.min.js.map +++ b/admin/assets/js/min/variables.min.js.map @@ -1 +1 @@ -{"version":3,"file":"variables.min.js","mappings":"2BAOAA,QAAQ,SAAWC,GAClBC,YAAYC,UAAY,CACvBC,UAAWH,EAAG,qBAEdI,OACCC,KAAKC,iBAELN,EAAGO,SAASC,MAAOC,GAClB,eACA,kCACAJ,KAAKK,sBAENV,EAAGO,SAASC,MAAOC,GAClB,WACA,uCACAJ,KAAKM,0BAGNN,KAAKF,UAAUM,GACd,QACA,wBACAJ,KAAKO,WAEP,EAIAN,iBACmB,IAAIO,YAAa,oBAAqB,CACvDC,OACC,OAAOd,EAAG,uCAAwCc,MACnD,IAGSL,GAAI,WAAW,WACxBT,EAAG,qBAAsBe,KAAM,WAE/BC,YAAY,WACXf,YAAYgB,MAAMC,OACnB,GAAG,IACJ,GACD,EAEAN,aACCX,YAAYgB,MAAME,OAClBlB,YAAYgB,MAAMG,UAElB,MAAMC,EAAW,CAChBC,OAAQ,yBACRC,SAAUvB,EAAGK,MAAOS,QAGrBd,EAAEwB,KAAMC,QAASJ,GAAU,SAAWK,GACrCzB,YAAYgB,MAAMU,SAAUD,GAC5BzB,YAAYC,UAAUQ,sBACvB,GACD,EAKAA,uBACC,MAAMkB,EAAgB5B,EAAG,uCACnBuB,EAAWK,EAAcC,KAAM,YAC/BC,EAAa,GAEnB9B,EAAG,mCAAoC+B,MAAM,WAC5C,MAAMC,EAAYhC,EAAGK,MAAO4B,QAC3B,8CAID,GAAKD,EAAUH,KAAM,kBAAqB,CACzC,MAAMK,EAAYF,EAChBH,KAAM,kBACNM,MAAO,KAEHC,EAAkBpC,EACvB,yCACCkC,EAAW,GACX,MAGF,IACCE,EAAgBC,QAChBD,EAAgBE,QAAUJ,EAAW,GAKrC,YADAF,EAAUO,OAFVP,EAAUQ,MAKZ,CAEA,MAAMC,EAAQ,CACbC,KAAM1C,EAAGK,MAAOsC,KAAM,QACtBC,SAAUZ,EAAUH,KAAM,eAC1BgB,MAAO7C,EAAGK,MAAOiC,OAGlBR,EAAWgB,KAAML,EAClB,IAEA,MAAMM,EAAS9C,YAAYC,UAAU8C,yBACpCzB,EACAO,GAGDF,EAAcd,KAAMiC,EACrB,EAOAC,yBAA0BzB,EAAUO,GACnC,IAAIiB,EAAS,MAAQxB,EAErB,GAAKO,EAAWO,OAAS,CACxB,MAAMY,EAAa,GAEnBjD,EAAE+B,KAAMD,GAAY,SAAWoB,EAAGT,GAC5BA,EAAMI,MACVI,EAAWH,KACVL,EAAMC,KAAO,MAAQD,EAAMI,MAAQ,KAEzBJ,EAAMG,UACjBK,EAAWH,KAAML,EAAMC,KAAO,UAEhC,IAEKO,EAAWZ,OAAS,IACxBU,GAAU,MACVA,GAAUE,EAAWE,KAAM,MAE7B,CAEA,OAAOJ,EAAS,KACjB,EAKApC,yBAA0ByC,GAGzB,IAA+C,IAA1CpD,EAAEqD,QAASD,EAAME,MAFH,CAAE,GAAI,IAAK,IAAK,MAEgB,OAAO,CAC3D,GAGDrD,YAAYC,UAAUE,MACvB","sources":["webpack://automatewoo/./admin/assets/js/variables.js"],"sourcesContent":["// Register eslint ignored glabals - to be revisited.\n// https://github.com/woocommerce/automatewoo/issues/1212\n/* global AutomateWoo, ClipboardJS, ajaxurl */\n/**\n * AutomateWoo Variables\n */\n\njQuery( function ( $ ) {\n\tAutomateWoo.Variables = {\n\t\t$meta_box: $( '#aw_variables_box' ),\n\n\t\tinit() {\n\t\t\tthis.init_clipboard();\n\n\t\t\t$( document.body ).on(\n\t\t\t\t'change keyup',\n\t\t\t\t'.aw-workflow-variable-parameter',\n\t\t\t\tthis.update_preview_field\n\t\t\t);\n\t\t\t$( document.body ).on(\n\t\t\t\t'keypress',\n\t\t\t\t'input.aw-workflow-variable-parameter',\n\t\t\t\tthis.restrict_parameter_chars\n\t\t\t);\n\n\t\t\tthis.$meta_box.on(\n\t\t\t\t'click',\n\t\t\t\t'.aw-workflow-variable',\n\t\t\t\tthis.open_modal\n\t\t\t);\n\t\t},\n\n\t\t/**\n\t\t */\n\t\tinit_clipboard() {\n\t\t\tconst clipboard = new ClipboardJS( '.aw-clipboard-btn', {\n\t\t\t\ttext() {\n\t\t\t\t\treturn $( '#aw_workflow_variable_preview_field' ).text();\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tclipboard.on( 'success', function () {\n\t\t\t\t$( '.aw-clipboard-btn' ).html( 'Copied!' );\n\n\t\t\t\tsetTimeout( function () {\n\t\t\t\t\tAutomateWoo.Modal.close();\n\t\t\t\t}, 500 );\n\t\t\t} );\n\t\t},\n\n\t\topen_modal() {\n\t\t\tAutomateWoo.Modal.open();\n\t\t\tAutomateWoo.Modal.loading();\n\n\t\t\tconst ajaxData = {\n\t\t\t\taction: 'aw_modal_variable_info',\n\t\t\t\tvariable: $( this ).text(),\n\t\t\t};\n\n\t\t\t$.post( ajaxurl, ajaxData, function ( response ) {\n\t\t\t\tAutomateWoo.Modal.contents( response );\n\t\t\t\tAutomateWoo.Variables.update_preview_field();\n\t\t\t} );\n\t\t},\n\n\t\t/**\n\t\t * Updates the variable preview text field\n\t\t */\n\t\tupdate_preview_field() {\n\t\t\tconst $previewField = $( '#aw_workflow_variable_preview_field' );\n\t\t\tconst variable = $previewField.data( 'variable' );\n\t\t\tconst parameters = [];\n\n\t\t\t$( '.aw-workflow-variable-parameter' ).each( function () {\n\t\t\t\tconst $paramRow = $( this ).parents(\n\t\t\t\t\t'.aw-workflow-variables-parameter-row:first'\n\t\t\t\t);\n\n\t\t\t\t// Check 'show' logic\n\t\t\t\tif ( $paramRow.data( 'parameter-show' ) ) {\n\t\t\t\t\tconst showLogic = $paramRow\n\t\t\t\t\t\t.data( 'parameter-show' )\n\t\t\t\t\t\t.split( '=' );\n\n\t\t\t\t\tconst $conditionField = $(\n\t\t\t\t\t\t'.aw-workflow-variable-parameter[name=\"' +\n\t\t\t\t\t\t\tshowLogic[ 0 ] +\n\t\t\t\t\t\t\t'\"]'\n\t\t\t\t\t);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t$conditionField.length &&\n\t\t\t\t\t\t$conditionField.val() === showLogic[ 1 ]\n\t\t\t\t\t) {\n\t\t\t\t\t\t$paramRow.show();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$paramRow.hide();\n\t\t\t\t\t\treturn; // don't add parameter to preview\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst param = {\n\t\t\t\t\tname: $( this ).attr( 'name' ),\n\t\t\t\t\trequired: $paramRow.data( 'is-required' ),\n\t\t\t\t\tvalue: $( this ).val(),\n\t\t\t\t};\n\n\t\t\t\tparameters.push( param );\n\t\t\t} );\n\n\t\t\tconst string = AutomateWoo.Variables.generate_variable_string(\n\t\t\t\tvariable,\n\t\t\t\tparameters\n\t\t\t);\n\n\t\t\t$previewField.text( string );\n\t\t},\n\n\t\t/**\n\t\t *\n\t\t * @param {string} variable\n\t\t * @param {Array} parameters\n\t\t */\n\t\tgenerate_variable_string( variable, parameters ) {\n\t\t\tlet string = '{{ ' + variable;\n\n\t\t\tif ( parameters.length ) {\n\t\t\t\tconst paramParts = [];\n\n\t\t\t\t$.each( parameters, function ( i, param ) {\n\t\t\t\t\tif ( param.value ) {\n\t\t\t\t\t\tparamParts.push(\n\t\t\t\t\t\t\tparam.name + \": '\" + param.value + \"'\"\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if ( param.required ) {\n\t\t\t\t\t\tparamParts.push( param.name + \": '...'\" );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\tif ( paramParts.length > 0 ) {\n\t\t\t\t\tstring += ' | ';\n\t\t\t\t\tstring += paramParts.join( ', ' );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn string + ' }}';\n\t\t},\n\n\t\t/**\n\t\t * @param {Event} event jQuery `keypress` event, with `which` property.\n\t\t */\n\t\trestrict_parameter_chars( event ) {\n\t\t\tconst restricted = [ 39, 123, 124, 125 ];\n\n\t\t\tif ( $.inArray( event.which, restricted ) !== -1 ) return false;\n\t\t},\n\t};\n\n\tAutomateWoo.Variables.init();\n} );\n"],"names":["jQuery","$","AutomateWoo","Variables","$meta_box","init","this","init_clipboard","document","body","on","update_preview_field","restrict_parameter_chars","open_modal","ClipboardJS","text","html","setTimeout","Modal","close","open","loading","ajaxData","action","variable","post","ajaxurl","response","contents","$previewField","data","parameters","each","$paramRow","parents","showLogic","split","$conditionField","length","val","hide","show","param","name","attr","required","value","push","string","generate_variable_string","paramParts","i","join","event","inArray","which"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"variables.min.js","mappings":"2BAOAA,QAAQ,SAAWC,GAClBC,YAAYC,UAAY,CACvBC,UAAWH,EAAG,qBAEdI,OACCC,KAAKC,iBAELN,EAAGO,SAASC,MAAOC,GAClB,eACA,kCACAJ,KAAKK,sBAENV,EAAGO,SAASC,MAAOC,GAClB,WACA,uCACAJ,KAAKM,0BAGNN,KAAKF,UAAUM,GACd,QACA,wBACAJ,KAAKO,WAEP,EAIAN,iBACmB,IAAIO,YAAa,oBAAqB,CACvDC,OACC,IAAIA,EAAOd,EACV,uCACCc,OAiBF,OAfAd,EAAG,mCAAoCe,MAAM,SAC5CC,EACAC,GAEA,GACCjB,EAAGiB,GAAQC,KAAM,cACflB,EAAGiB,GAAQE,IAAK,GAAIC,gBAKtB,OAHApB,EAAGiB,GAAQE,IAAK,GAAIE,iBACpBP,GAAO,GAEA,CAET,IAEOA,CACR,IAGSL,GAAI,WAAW,WACxBT,EAAG,qBAAsBsB,KAAM,WAE/BC,YAAY,WACXtB,YAAYuB,MAAMC,OACnB,GAAG,IACJ,GACD,EAEAb,aACCX,YAAYuB,MAAME,OAClBzB,YAAYuB,MAAMG,UAElB,MAAMC,EAAW,CAChBC,OAAQ,yBACRC,SAAU9B,EAAGK,MAAOS,QAGrBd,EAAE+B,KAAMC,QAASJ,GAAU,SAAWK,GACrChC,YAAYuB,MAAMU,SAAUD,GAC5BhC,YAAYC,UAAUQ,sBACvB,GACD,EAKAA,uBACC,MAAMyB,EAAgBnC,EAAG,uCACnB8B,EAAWK,EAAcC,KAAM,YAC/BC,EAAa,GAEnBrC,EAAG,mCAAoCe,MAAM,WAC5C,MAAMuB,EAAYtC,EAAGK,MAAOkC,QAC3B,8CAID,GAAKD,EAAUF,KAAM,kBAAqB,CACzC,MAAMI,EAAYF,EAChBF,KAAM,kBACNK,MAAO,KAEHC,EAAkB1C,EACvB,yCACCwC,EAAW,GACX,MAGF,IACCE,EAAgBC,QAChBD,EAAgBE,QAAUJ,EAAW,GAKrC,YADAF,EAAUO,OAFVP,EAAUQ,MAKZ,CAEA,MAAMC,EAAQ,CACbC,KAAMhD,EAAGK,MAAO4C,KAAM,QACtBC,SAAUZ,EAAUF,KAAM,eAC1Be,MAAOnD,EAAGK,MAAOuC,OAGlBP,EAAWe,KAAML,EAClB,IAEA,MAAMM,EAASpD,YAAYC,UAAUoD,yBACpCxB,EACAO,GAGDF,EAAcrB,KAAMuC,EACrB,EAOAC,yBAA0BxB,EAAUO,GACnC,IAAIgB,EAAS,MAAQvB,EAErB,GAAKO,EAAWM,OAAS,CACxB,MAAMY,EAAa,GAEnBvD,EAAEe,KAAMsB,GAAY,SAAWrB,EAAG+B,GAC5BA,EAAMI,MACVI,EAAWH,KACVL,EAAMC,KAAO,MAAQD,EAAMI,MAAQ,KAEzBJ,EAAMG,UACjBK,EAAWH,KAAML,EAAMC,KAAO,UAEhC,IAEKO,EAAWZ,OAAS,IACxBU,GAAU,MACVA,GAAUE,EAAWC,KAAM,MAE7B,CAEA,OAAOH,EAAS,KACjB,EAKA1C,yBAA0B8C,GAGzB,IAA+C,IAA1CzD,EAAE0D,QAASD,EAAME,MAFH,CAAE,GAAI,IAAK,IAAK,MAEgB,OAAO,CAC3D,GAGD1D,YAAYC,UAAUE,MACvB","sources":["webpack://automatewoo/./admin/assets/js/variables.js"],"sourcesContent":["// Register eslint ignored glabals - to be revisited.\n// https://github.com/woocommerce/automatewoo/issues/1212\n/* global AutomateWoo, ClipboardJS, ajaxurl */\n/**\n * AutomateWoo Variables\n */\n\njQuery( function ( $ ) {\n\tAutomateWoo.Variables = {\n\t\t$meta_box: $( '#aw_variables_box' ),\n\n\t\tinit() {\n\t\t\tthis.init_clipboard();\n\n\t\t\t$( document.body ).on(\n\t\t\t\t'change keyup',\n\t\t\t\t'.aw-workflow-variable-parameter',\n\t\t\t\tthis.update_preview_field\n\t\t\t);\n\t\t\t$( document.body ).on(\n\t\t\t\t'keypress',\n\t\t\t\t'input.aw-workflow-variable-parameter',\n\t\t\t\tthis.restrict_parameter_chars\n\t\t\t);\n\n\t\t\tthis.$meta_box.on(\n\t\t\t\t'click',\n\t\t\t\t'.aw-workflow-variable',\n\t\t\t\tthis.open_modal\n\t\t\t);\n\t\t},\n\n\t\t/**\n\t\t */\n\t\tinit_clipboard() {\n\t\t\tconst clipboard = new ClipboardJS( '.aw-clipboard-btn', {\n\t\t\t\ttext() {\n\t\t\t\t\tlet text = $(\n\t\t\t\t\t\t'#aw_workflow_variable_preview_field'\n\t\t\t\t\t).text();\n\n\t\t\t\t\t$( '.aw-workflow-variable-parameter' ).each( function (\n\t\t\t\t\t\ti,\n\t\t\t\t\t\tfield\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t$( field ).prop( 'required' ) &&\n\t\t\t\t\t\t\t! $( field ).get( 0 ).checkValidity()\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t$( field ).get( 0 ).reportValidity();\n\t\t\t\t\t\t\ttext = false;\n\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn text;\n\t\t\t\t},\n\t\t\t} );\n\n\t\t\tclipboard.on( 'success', function () {\n\t\t\t\t$( '.aw-clipboard-btn' ).html( 'Copied!' );\n\n\t\t\t\tsetTimeout( function () {\n\t\t\t\t\tAutomateWoo.Modal.close();\n\t\t\t\t}, 500 );\n\t\t\t} );\n\t\t},\n\n\t\topen_modal() {\n\t\t\tAutomateWoo.Modal.open();\n\t\t\tAutomateWoo.Modal.loading();\n\n\t\t\tconst ajaxData = {\n\t\t\t\taction: 'aw_modal_variable_info',\n\t\t\t\tvariable: $( this ).text(),\n\t\t\t};\n\n\t\t\t$.post( ajaxurl, ajaxData, function ( response ) {\n\t\t\t\tAutomateWoo.Modal.contents( response );\n\t\t\t\tAutomateWoo.Variables.update_preview_field();\n\t\t\t} );\n\t\t},\n\n\t\t/**\n\t\t * Updates the variable preview text field\n\t\t */\n\t\tupdate_preview_field() {\n\t\t\tconst $previewField = $( '#aw_workflow_variable_preview_field' );\n\t\t\tconst variable = $previewField.data( 'variable' );\n\t\t\tconst parameters = [];\n\n\t\t\t$( '.aw-workflow-variable-parameter' ).each( function () {\n\t\t\t\tconst $paramRow = $( this ).parents(\n\t\t\t\t\t'.aw-workflow-variables-parameter-row:first'\n\t\t\t\t);\n\n\t\t\t\t// Check 'show' logic\n\t\t\t\tif ( $paramRow.data( 'parameter-show' ) ) {\n\t\t\t\t\tconst showLogic = $paramRow\n\t\t\t\t\t\t.data( 'parameter-show' )\n\t\t\t\t\t\t.split( '=' );\n\n\t\t\t\t\tconst $conditionField = $(\n\t\t\t\t\t\t'.aw-workflow-variable-parameter[name=\"' +\n\t\t\t\t\t\t\tshowLogic[ 0 ] +\n\t\t\t\t\t\t\t'\"]'\n\t\t\t\t\t);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t$conditionField.length &&\n\t\t\t\t\t\t$conditionField.val() === showLogic[ 1 ]\n\t\t\t\t\t) {\n\t\t\t\t\t\t$paramRow.show();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$paramRow.hide();\n\t\t\t\t\t\treturn; // don't add parameter to preview\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst param = {\n\t\t\t\t\tname: $( this ).attr( 'name' ),\n\t\t\t\t\trequired: $paramRow.data( 'is-required' ),\n\t\t\t\t\tvalue: $( this ).val(),\n\t\t\t\t};\n\n\t\t\t\tparameters.push( param );\n\t\t\t} );\n\n\t\t\tconst string = AutomateWoo.Variables.generate_variable_string(\n\t\t\t\tvariable,\n\t\t\t\tparameters\n\t\t\t);\n\n\t\t\t$previewField.text( string );\n\t\t},\n\n\t\t/**\n\t\t *\n\t\t * @param {string} variable\n\t\t * @param {Array} parameters\n\t\t */\n\t\tgenerate_variable_string( variable, parameters ) {\n\t\t\tlet string = '{{ ' + variable;\n\n\t\t\tif ( parameters.length ) {\n\t\t\t\tconst paramParts = [];\n\n\t\t\t\t$.each( parameters, function ( i, param ) {\n\t\t\t\t\tif ( param.value ) {\n\t\t\t\t\t\tparamParts.push(\n\t\t\t\t\t\t\tparam.name + \": '\" + param.value + \"'\"\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if ( param.required ) {\n\t\t\t\t\t\tparamParts.push( param.name + \": '...'\" );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\tif ( paramParts.length > 0 ) {\n\t\t\t\t\tstring += ' | ';\n\t\t\t\t\tstring += paramParts.join( ', ' );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn string + ' }}';\n\t\t},\n\n\t\t/**\n\t\t * @param {Event} event jQuery `keypress` event, with `which` property.\n\t\t */\n\t\trestrict_parameter_chars( event ) {\n\t\t\tconst restricted = [ 39, 123, 124, 125 ];\n\n\t\t\tif ( $.inArray( event.which, restricted ) !== -1 ) return false;\n\t\t},\n\t};\n\n\tAutomateWoo.Variables.init();\n} );\n"],"names":["jQuery","$","AutomateWoo","Variables","$meta_box","init","this","init_clipboard","document","body","on","update_preview_field","restrict_parameter_chars","open_modal","ClipboardJS","text","each","i","field","prop","get","checkValidity","reportValidity","html","setTimeout","Modal","close","open","loading","ajaxData","action","variable","post","ajaxurl","response","contents","$previewField","data","parameters","$paramRow","parents","showLogic","split","$conditionField","length","val","hide","show","param","name","attr","required","value","push","string","generate_variable_string","paramParts","join","event","inArray","which"],"sourceRoot":""} \ No newline at end of file diff --git a/admin/assets/js/variables.js b/admin/assets/js/variables.js index 7b462a6..b192ae2 100644 --- a/admin/assets/js/variables.js +++ b/admin/assets/js/variables.js @@ -35,7 +35,26 @@ jQuery( function ( $ ) { init_clipboard() { const clipboard = new ClipboardJS( '.aw-clipboard-btn', { text() { - return $( '#aw_workflow_variable_preview_field' ).text(); + let text = $( + '#aw_workflow_variable_preview_field' + ).text(); + + $( '.aw-workflow-variable-parameter' ).each( function ( + i, + field + ) { + if ( + $( field ).prop( 'required' ) && + ! $( field ).get( 0 ).checkValidity() + ) { + $( field ).get( 0 ).reportValidity(); + text = false; + + return false; + } + } ); + + return text; }, } ); diff --git a/admin/assets/src/workflow-tab-handler.js b/admin/assets/src/workflow-tab-handler.js index 0bd100d..3182364 100644 --- a/admin/assets/src/workflow-tab-handler.js +++ b/admin/assets/src/workflow-tab-handler.js @@ -1,9 +1,9 @@ /** * External dependencies */ -import { render, unmountComponentAtNode } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { recordEvent } from '@woocommerce/tracks'; +import { createRoot, render, unmountComponentAtNode } from '@wordpress/element'; // eslint-disable-line import/named /** * Internal dependencies @@ -67,17 +67,25 @@ const loadTabHandler = ( defaultTabName, tabs ) => { currentTab = tabName; - render( + const pageTabs = ( { getTabContent } - , - tabsRootEl + ); + if ( typeof createRoot !== 'undefined' ) { + // compatibility-code "WP >= 6.2" -- React >= 18 + reactTabsRoot = createRoot( tabsRootEl ); + reactTabsRoot.render( pageTabs ); + } else { + // compatibility-code "WP < 6.2" -- React < 18 + render( pageTabs, tabsRootEl ); + } + recordTracksTabViewEvent( tabName ); hackyUpdateAllWorkflowsTabVisibility( tabName ); }; @@ -95,7 +103,17 @@ const loadTabHandler = ( defaultTabName, tabs ) => { } // Hack: Unmount and rerender tabs because we can't programmatically change the current tab - unmountComponentAtNode( tabsRootEl ); + if ( typeof createRoot !== 'undefined' ) { + // compatibility-code "WP >= 6.2" -- React >= 18 + if ( reactTabsRoot ) { + reactTabsRoot.unmount(); + reactTabsRoot = null; + } + } else { + // compatibility-code "WP < 6.2" -- React < 18 + unmountComponentAtNode( tabsRootEl ); + } + renderPageTabs( tabName ); }; @@ -120,6 +138,7 @@ const loadTabHandler = ( defaultTabName, tabs ) => { // Init let currentTab; + let reactTabsRoot; const tabsRootEl = insertTabsRootDomElement(); window.addEventListener( 'hashchange', handleHashChange, false ); renderPageTabs( getHash() ); diff --git a/admin/coupons-list.php b/admin/coupons-list.php index f46cfc6..9c5cda9 100644 --- a/admin/coupons-list.php +++ b/admin/coupons-list.php @@ -1,32 +1,44 @@ 'shop_coupon', - 'filter_automatewoo' => '1' - ], admin_url( 'edit.php' ) ); + $url = add_query_arg( + [ + 'post_type' => 'shop_coupon', + 'filter_automatewoo' => '1', + ], + admin_url( 'edit.php' ) + ); $trash = aw_array_extract( $views, 'trash' ); - $count = number_format_i18n( $this->get_count() ); + $count = number_format_i18n( $this->get_count() ); $views['automatewoo'] = '' . __( 'AutomateWoo', 'automatewoo' ) . ' (' . $count . ')'; if ( $trash ) { @@ -38,19 +50,22 @@ function filter_views( $views ) { /** - * @param $counts - * @param $type - * @return mixed + * Alters WP Post Counts + * + * @param stdClass $counts An object containing the current post_type’s post counts by status. + * @param string $type Post type. + * + * @return stdClass Filtered post counts. */ - function filter_counts( $counts, $type ) { + public function filter_counts( $counts, $type ) { if ( $type !== 'shop_coupon' ) { return $counts; } if ( ! isset( $counts->automatewoo ) ) { - $count = $this->get_count(); - $counts->publish -= $count; + $count = $this->get_count(); + $counts->publish -= $count; $counts->automatewoo = $count; } @@ -59,30 +74,38 @@ function filter_counts( $counts, $type ) { /** - * @return int + * Get the post count + * + * @return int The post count */ - function get_count() { - $coupons = get_posts([ - 'post_type' => 'shop_coupon', - 'fields' => 'ids', - 'posts_per_page' => -1, - 'meta_query' => [ - [ - 'key' => '_is_aw_coupon', - 'value' => '1' - ] + public function get_count() { + $coupons = get_posts( + [ + 'post_type' => 'shop_coupon', + 'fields' => 'ids', + 'posts_per_page' => -1, + 'meta_query' => [ + [ + 'key' => '_is_aw_coupon', + 'value' => '1', + ], + ], ] - ]); + ); return count( $coupons ); } /** - * @param $query WP_Query + * Alter the results on pre gets posts. After the query variable object is created, but before the actual query is run. + * + * @param WP_Query $query The WP_Query instance (passed by reference). */ - function modify_results( $query ) { + public function modify_results( $query ) { - if ( ! $query->is_main_query() ) return; + if ( ! $query->is_main_query() ) { + return; + } if ( ! isset( $query->query_vars['meta_query'] ) ) { $query->query_vars['meta_query'] = []; @@ -90,16 +113,14 @@ function modify_results( $query ) { if ( aw_request( 'filter_automatewoo' ) ) { $query->query_vars['meta_query'][] = [ - 'key' => '_is_aw_coupon', - 'value' => '1' + 'key' => '_is_aw_coupon', + 'value' => '1', ]; - } - elseif ( aw_request( 'post_status' ) == 'publish' ) { + } elseif ( aw_request( 'post_status' ) === 'publish' ) { $query->query_vars['meta_query'][] = [ - 'key' => '_is_aw_coupon', - 'compare' => 'NOT EXISTS' + 'key' => '_is_aw_coupon', + 'compare' => 'NOT EXISTS', ]; } } - } diff --git a/admin/list-table.php b/admin/list-table.php index c2b94d0..fe95e36 100644 --- a/admin/list-table.php +++ b/admin/list-table.php @@ -1,9 +1,10 @@ search_button_text = __( 'Search', 'automatewoo' ); - wp_enqueue_script('automatewoo-modal'); + public function __construct( $args ) { + $this->search_button_text = __( 'Search', 'automatewoo' ); + wp_enqueue_script( 'automatewoo-modal' ); parent::__construct( $args ); } @@ -53,7 +54,7 @@ function __construct( $args ) { /** * Output the report */ - function output_report() { + public function output_report() { $this->prepare_items(); echo '
'; $this->display(); @@ -61,44 +62,32 @@ function output_report() { } - /** - * @deprecated use Format::email() - * @param $email - * @return string - */ - function format_email( $email ) { - wc_deprecated_function( __METHOD__, '5.2.0', 'Format::email' ); - - return Format::email( $email ); - } - /** * @param \WP_User $user * @return string */ - function format_user( $user ) { + public function format_user( $user ) { if ( $user ) { - $name = esc_attr( sprintf( _x( '%1$s %2$s', 'full name', 'automatewoo' ), $user->first_name, $user->last_name ) ); + /* translators: 1: User First name, 2: User Last name */ + $name = esc_attr( sprintf( _x( '%1$s %2$s', 'full name', 'automatewoo' ), $user->first_name, $user->last_name ) ); $email = esc_attr( $user->user_email ); return "$name $email "; - } - else { + } else { return $this->format_blank(); } } /** - * @param $email - * @return string + * @param string $email The email + * @return string */ - function format_guest( $email ) { + public function format_guest( $email ) { if ( $email ) { return esc_attr( __( '[Guest]', 'automatewoo' ) ) . ' ' . Format::email( $email ); - } - else { - return $this->format_blank(); + } else { + return $this->format_blank(); } } @@ -112,30 +101,33 @@ protected function get_table_classes() { /** - * @param $date - * @param bool $is_gmt - * @return string + * @param DateTime $date + * @param bool $is_gmt + * phpcs:ignore Squiz.Commenting.FunctionComment.InvalidNoReturn + * @return string Return is void but the view is returned as string via "include" statement. */ - function format_date( $date, $is_gmt = true ) { - Admin::get_view('hoverable-date', [ - 'date' => $date, - 'shorten_month' => true, - 'is_gmt' => $is_gmt, - ]); + public function format_date( $date, $is_gmt = true ) { + Admin::get_view( + 'hoverable-date', + [ + 'date' => $date, + 'shorten_month' => true, + 'is_gmt' => $is_gmt, + ] + ); } /** - * @param $workflow Workflow|false - * @return string + * @param Workflow|false $workflow + * @return string */ - function format_workflow_title( $workflow ) { + public function format_workflow_title( $workflow ) { if ( ! $workflow || ! $workflow->exists ) { - return $this->format_blank(); - } - else { - $return = '' . $workflow->get_title() . ''; + return $this->format_blank(); + } else { + $return = '' . $workflow->get_title() . ''; if ( Language::is_multilingual() ) { $return .= ' [' . $workflow->get_language() . ']'; @@ -143,84 +135,101 @@ function format_workflow_title( $workflow ) { return $return; } - } /** * @return string */ - function format_blank() { + public function format_blank() { return '-'; } - + /** + * Renders the filters + * + * @param string $which + */ protected function extra_tablenav( $which ) { - if ( $which !== 'top' ) { - return; - } + if ( $which !== 'top' ) { + return; + } - ?> - -
+ ?> + +
filters(); ?> -
- - + + '; - Admin::get_hidden_form_inputs_from_query([ 'page', 'section', 'tab' ] ); - wp_nonce_field( $this->nonce_action, '_wpnonce', false ); - } + /** + * Renders the opening of the form + */ + public function output_form_open() { + echo '
'; + Admin::get_hidden_form_inputs_from_query( [ 'page', 'section', 'tab' ] ); + wp_nonce_field( $this->nonce_action, '_wpnonce', false ); + } - function output_form_close() { - echo '
'; - } + /** + * Renders the closing of the form + */ + public function output_form_close() { + echo ''; + } /** * Display the table plus the form elements */ - function display() { + public function display() { $this->views(); $this->output_form_open(); if ( $this->enable_search ) { - $this->output_search(); - } + $this->output_search(); + } $this->output_table(); $this->output_form_close(); } - function output_search() { - $this->search_box( $this->search_button_text, $this->search_input_id ); - } + /** + * Displays the search box + */ + public function output_search() { + $this->search_box( $this->search_button_text, $this->search_input_id ); + } /** * Output the table only */ - function output_table() { - parent::display(); - } + public function output_table() { + parent::display(); + } - function output_workflow_filter() { + /** + * Displays the workflow filter + */ + public function output_workflow_filter() { - $workflow_id = ''; + $workflow_id = ''; $workflow_name = ''; + // This function just gets a Workflow ID from the URL and displays some HTML in the UI so no need to check nonce necessarily. + // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! empty( $_GET['_workflow'] ) ) { - $workflow_id = absint( $_GET['_workflow'] ); + // phpcs:ignore WordPress.Security.NonceVerification.Recommended + $workflow_id = absint( $_GET['_workflow'] ); $workflow_name = get_the_title( $workflow_id ); } @@ -229,13 +238,13 @@ function output_workflow_filter() { @@ -244,9 +253,12 @@ function output_workflow_filter() { } - function output_customer_filter() { + /** + * Displays the customer filter. + */ + public function output_customer_filter() { $customer_string = ''; - $customer = Customer_Factory::get( aw_request('filter_customer' ) ); + $customer = Customer_Factory::get( aw_request( 'filter_customer' ) ); if ( $customer ) { $customer_string = esc_html( $customer->get_full_name() ) . ' (' . esc_html( $customer->get_email() ) . ')'; @@ -261,7 +273,10 @@ function output_customer_filter() { data-action="aw_json_search_customers" data-allow_clear="true" > - get_id() . '"' . selected( true, true, false ) . '>' . wp_kses_post( $customer_string ) . ''; } ?> + get_id() ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $customer_string ) . ''; } + ?> _args['plural'] ); - } ?> -
- - has_items() ): ?> - get_bulk_actions() ): ?> -
- bulk_actions( $which ); ?> -
- - extra_tablenav( $which ); - $this->pagination( $which ); - ?> - -
-
+
+ + has_items() ) : ?> + get_bulk_actions() ) : ?> +
+ bulk_actions( $which ); ?> +
+ + extra_tablenav( $which ); + $this->pagination( $which ); + ?> + +
+
statuses(); } - /** - * @param $columns - * @return array + * Alters the columns displayed in the Posts list table. + * + * @param string[] $columns An associative array of column headings. + * @return string[] Altered column headings. */ - function columns( $columns ) { + public function columns( $columns ) { unset( $columns['date'] ); unset( $columns['stats'] ); unset( $columns['likes'] ); - $columns['timing'] = __( 'Timing', 'automatewoo' ); - $columns['times_run'] = __( 'Run Count', 'automatewoo' ); - $columns['queued'] = __( 'Queue Count', 'automatewoo' ); + $columns['timing'] = __( 'Timing', 'automatewoo' ); + $columns['times_run'] = __( 'Run Count', 'automatewoo' ); + $columns['queued'] = __( 'Queue Count', 'automatewoo' ); $columns['aw_status_toggle'] = ''; return $columns; } - /** - * @param $column - * @param $post_id + * Alters a custom column in the Posts list table. + * + * @param string $column The name of the column to display. + * @param int $post_id The current post ID. */ - function column_data( $column, $post_id ) { + public function column_data( $column, $post_id ) { $workflow = Factory::get( $post_id ); - if ( ! $workflow ) + if ( ! $workflow ) { return; + } switch ( $column ) { case 'timing': - echo $this->get_timing_text( $workflow ); + echo esc_attr( $this->get_timing_text( $workflow ) ); break; case 'times_run': - if ( $count = $workflow->get_times_run() ) { - echo '' . $count . ''; - } - else { + $count = $workflow->get_times_run(); + if ( $count ) { + echo '' . esc_attr( $count ) . ''; + } else { echo '-'; } break; case 'queued': - if ( $count = $workflow->get_current_queue_count() ) { - echo '' . $count . ''; - } - else { + $count = $workflow->get_current_queue_count(); + if ( $count ) { + echo '' . esc_attr( $count ) . ''; + } else { echo '-'; } break; @@ -109,44 +113,49 @@ function column_data( $column, $post_id ) { /** * Tweak workflow statuses */ - function statuses() { + public function statuses() { global $wp_post_statuses; - // rename published + /* translators: %s: the count of published workflows */ $wp_post_statuses['publish']->label_count = _n_noop( 'Active (%s)', 'Active (%s)', 'automatewoo' ); - - $trash = $wp_post_statuses['trash']; - unset( $wp_post_statuses['trash'] ); - $wp_post_statuses['trash'] = $trash; } /** - * @param $actions - * @return mixed + * Alters the items in the bulk actions menu of the list table. + * + * @param array $actions An array of the available bulk actions. + * + * @return array The altered bulk actions. */ - function bulk_actions( $actions ) { - unset($actions['edit']); + public function bulk_actions( $actions ) { + unset( $actions['edit'] ); return $actions; } - /** - * @param $actions - * @return mixed + * Alters the array of row action links on the Posts list table. + * + * @param string[] $actions An array of row action links. Defaults are + * 'Edit', 'Quick Edit', 'Restore', 'Trash', + * 'Delete Permanently', 'Preview', and 'View'. + * + * @return string[] The altered array of row action links. */ - function row_actions( $actions ) { - unset($actions['inline hide-if-no-js']); + public function row_actions( $actions ) { + unset( $actions['inline hide-if-no-js'] ); return $actions; } /** - * @param Workflow $workflow - * @return string + * Get the timing description string for a workflow. + * + * @param Workflow $workflow The workflow to get the timing description string. + * @return string The timing description string. */ - function get_timing_text( $workflow ) { + public function get_timing_text( $workflow ) { try { return ( new TimingDescriptionGenerator( $workflow ) )->generate(); } catch ( \Exception $e ) { @@ -220,5 +229,4 @@ public function filter_views( $views ) { return $views; } - } diff --git a/automatewoo.php b/automatewoo.php index 5801ba8..1ee1848 100644 --- a/automatewoo.php +++ b/automatewoo.php @@ -3,7 +3,7 @@ * Plugin Name: AutomateWoo * Plugin URI: https://automatewoo.com * Description: Powerful marketing automation for your WooCommerce store. - * Version: 6.0.24 + * Version: 6.0.25 * Author: WooCommerce * Author URI: https://woo.com * License: GPLv3 @@ -13,7 +13,7 @@ * Tested up to: 6.5 * Requires Plugins: woocommerce * WC requires at least: 6.7 - * WC tested up to: 8.9 + * WC tested up to: 9.0 * Woo: 4652610:f6f1f8a56a16a3715b30b21fb557e78f * * This program is free software: you can redistribute it and/or modify @@ -37,7 +37,7 @@ defined( 'ABSPATH' ) || exit; define( 'AUTOMATEWOO_SLUG', 'automatewoo' ); -define( 'AUTOMATEWOO_VERSION', '6.0.24' ); // WRCS: DEFINED_VERSION. +define( 'AUTOMATEWOO_VERSION', '6.0.25' ); // WRCS: DEFINED_VERSION. define( 'AUTOMATEWOO_FILE', __FILE__ ); define( 'AUTOMATEWOO_PATH', __DIR__ ); define( 'AUTOMATEWOO_MIN_PHP_VER', '7.4.0' ); diff --git a/changelog.txt b/changelog.txt index 165448e..ac53c61 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,21 @@ *** AutomateWoo Changelog *** +2024-06-11 - version 6.0.25 +* Add - Action to manage WooCommerce Membership statuses. +* Add - Support for one-click unsubscribe links in non-transactional emails. +* Dev - PHPCS for Campaign Monitor files. +* Dev - PHPCS for Order Actions files. +* Dev - PHPCS for WooCommerce Subscriptions related files. +* Dev - PHPCS for list-table, workflow-list and coupons-list. +* Dev - PHPCS for: Actions/Customer_Add_Tags, Actions/Customer_Remove_Tags and Actions/Customer_Change_Role. +* Fix - Input validation on variable modal fields. +* Fix - Security issues. +* Fix - The coupon code formatting to avoid the related Actions or Variables not working correctly. +* Fix - WC_Site_Tracking throwing a fatal error. +* Tweak - Add more logs when Active Campaign doesn't find the Contact Tag. +* Tweak - Compatible with the React 18 used since WordPress 6.2. +* Tweak - WC 9.0 compatibility. + 2024-05-21 - version 6.0.24 * Fix - The usage of the `automatewoo/workflows/presets` filter. * Tweak - Add Order data to the Booking DataLayer. diff --git a/includes/Actions.php b/includes/Actions.php index f246907..6e39e6e 100644 --- a/includes/Actions.php +++ b/includes/Actions.php @@ -72,6 +72,7 @@ static function load_includes() { if ( Integrations::is_memberships_enabled() ) { $includes[ 'memberships_change_plan' ] = 'AutomateWoo\Action_Memberships_Change_Plan'; $includes[ 'memberships_delete_user_membership' ] = 'AutomateWoo\Action_Memberships_Delete_User_Membership'; + $includes[ 'memberships_change_status' ] = 'AutomateWoo\Action_Memberships_Change_Status'; } if ( Options::mailchimp_enabled() ) { diff --git a/includes/Actions/Campaign_Monitor_Abstract.php b/includes/Actions/Campaign_Monitor_Abstract.php index 75b40d7..d28aeca 100644 --- a/includes/Actions/Campaign_Monitor_Abstract.php +++ b/includes/Actions/Campaign_Monitor_Abstract.php @@ -1,16 +1,22 @@ group = __( 'Campaign Monitor', 'automatewoo' ); } @@ -18,7 +24,7 @@ function load_admin_details() { /** * @return Fields\Text */ - function get_subscriber_email_field() { + public function get_subscriber_email_field() { $email = ( new Fields\Text() ) ->set_name( 'email' ) ->set_title( __( 'Subscriber email', 'automatewoo' ) ) @@ -32,7 +38,7 @@ function get_subscriber_email_field() { /** * @return Fields\Text */ - function get_subscriber_name_field() { + public function get_subscriber_name_field() { $email = ( new Fields\Text() ) ->set_name( 'name' ) ->set_title( __( 'Subscriber name', 'automatewoo' ) ) @@ -44,7 +50,7 @@ function get_subscriber_name_field() { /** * @return Fields\Select */ - function get_list_field() { + public function get_list_field() { $list = new Fields\Select(); $list->set_name( 'list' ); $list->set_title( __( 'List', 'automatewoo' ) ); @@ -57,13 +63,11 @@ function get_list_field() { /** * @return Fields\Checkbox */ - function get_resubscribe_field() { + public function get_resubscribe_field() { $field = new Fields\Checkbox(); $field->set_name( 'resubscribe' ); $field->set_title( __( 'Resubscribe', 'automatewoo' ) ); $field->set_description( __( 'If checked the user will be subscribed even if they have already unsubscribed from one of your lists. Use with caution.', 'automatewoo' ) ); return $field; } - - } diff --git a/includes/Actions/Campaign_Monitor_Add_Subscriber.php b/includes/Actions/Campaign_Monitor_Add_Subscriber.php index 5e5c29f..f0434cc 100644 --- a/includes/Actions/Campaign_Monitor_Add_Subscriber.php +++ b/includes/Actions/Campaign_Monitor_Add_Subscriber.php @@ -1,34 +1,44 @@ title = __( 'Add Subscriber to List', 'automatewoo' ); parent::load_admin_details(); } - function load_fields() { + /** + * Method to load the action's fields. + */ + public function load_fields() { $this->add_field( $this->get_subscriber_email_field() ); $this->add_field( $this->get_subscriber_name_field() ); $this->add_field( $this->get_list_field() ); $this->add_field( $this->get_resubscribe_field() ); } - - function run() { - $email = Clean::email( $this->get_option( 'email', true ) ); - $name = $this->get_option( 'name', true ); - $list = $this->get_option( 'list' ); + /** + * Run the action. + */ + public function run() { + $email = Clean::email( $this->get_option( 'email', true ) ); + $name = $this->get_option( 'name', true ); + $list = $this->get_option( 'list' ); $resubscribe = $this->get_option( 'resubscribe' ); if ( ! $email || ! $list ) { @@ -39,11 +49,10 @@ function run() { $data = [ 'EmailAddress' => $email, - 'Name' => $name, - 'Resubscribe' => $resubscribe, + 'Name' => $name, + 'Resubscribe' => $resubscribe, ]; $api->request( 'POST', "/subscribers/$list.json", $data ); } - } diff --git a/includes/Actions/Campaign_Monitor_Remove_Subscriber.php b/includes/Actions/Campaign_Monitor_Remove_Subscriber.php index 8ffa0f2..800da49 100644 --- a/includes/Actions/Campaign_Monitor_Remove_Subscriber.php +++ b/includes/Actions/Campaign_Monitor_Remove_Subscriber.php @@ -1,43 +1,54 @@ title = __( 'Remove Subscriber From List', 'automatewoo' ); parent::load_admin_details(); } - - function load_fields() { + /** + * Method to load the action's fields. + */ + public function load_fields() { $type = new Fields\Select( false ); - $type->set_name('type'); + $type->set_name( 'type' ); $type->set_title( __( 'Type', 'automatewoo' ) ); $type->set_required(); $type->set_description( __( "If delete is selected the subscriber's email will not be added to the suppression list.", 'automatewoo' ) ); - $type->set_options([ - 'unsubscribe' => __( 'Unsubscribe', 'automatewoo' ), - 'delete' => __( 'Delete', 'automatewoo' ) - ]); + $type->set_options( + [ + 'unsubscribe' => __( 'Unsubscribe', 'automatewoo' ), + 'delete' => __( 'Delete', 'automatewoo' ), + ] + ); $this->add_field( $this->get_subscriber_email_field() ); $this->add_field( $this->get_list_field() ); $this->add_field( $type ); } - - function run() { - $email = Clean::email( $this->get_option('email', true ) ); - $list = $this->get_option('list' ); - $type = $this->get_option('type' ); + /** + * Run the action. + */ + public function run() { + $email = Clean::email( $this->get_option( 'email', true ) ); + $list = $this->get_option( 'list' ); + $type = $this->get_option( 'type' ); if ( ! $email || ! $list ) { return; @@ -46,15 +57,21 @@ function run() { $api = Integrations::campaign_monitor(); if ( $type === 'delete' ) { - $api->request( 'DELETE', "/subscribers/$list.json", [ - 'email' => $email - ] ); - } - else { - $api->request( 'POST', "/subscribers/$list/unsubscribe.json", [ - 'EmailAddress' => $email, - ] ); + $api->request( + 'DELETE', + "/subscribers/$list.json", + [ + 'email' => $email, + ] + ); + } else { + $api->request( + 'POST', + "/subscribers/$list/unsubscribe.json", + [ + 'EmailAddress' => $email, + ] + ); } } - } diff --git a/includes/Actions/Customer_Add_Tags.php b/includes/Actions/Customer_Add_Tags.php index 03c26e3..e2f247f 100644 --- a/includes/Actions/Customer_Add_Tags.php +++ b/includes/Actions/Customer_Add_Tags.php @@ -1,32 +1,47 @@ title = __( 'Add Tags', 'automatewoo' ); - $this->group = __( 'Customer', 'automatewoo' ); + /** + * Method to set the action's admin props. + */ + public function load_admin_details() { + $this->title = __( 'Add Tags', 'automatewoo' ); + $this->group = __( 'Customer', 'automatewoo' ); $this->description = __( 'Please note that tags are not supported on guest customers.', 'automatewoo' ); } - - function load_fields() { + /** + * Method to load the action's fields. + */ + public function load_fields() { $this->add_field( new Fields\User_Tags() ); } - - function run() { - if ( ! $customer = $this->workflow->data_layer()->get_customer() ) { + /** + * Run the action. + * + * @throws \Exception When an error occurs. + */ + public function run() { + $customer = $this->workflow->data_layer()->get_customer(); + if ( ! $customer ) { return; } @@ -38,5 +53,4 @@ function run() { wp_add_object_terms( $customer->get_user_id(), $tags, 'user_tag' ); } - } diff --git a/includes/Actions/Customer_Change_Role.php b/includes/Actions/Customer_Change_Role.php index 2d7c73e..71b2bde 100644 --- a/includes/Actions/Customer_Change_Role.php +++ b/includes/Actions/Customer_Change_Role.php @@ -1,43 +1,73 @@ title = __( 'Change Role', 'automatewoo' ); - $this->group = __( 'Customer', 'automatewoo' ); + /** + * Method to set the action's admin props. + */ + public function load_admin_details() { + $this->title = __( 'Change Role', 'automatewoo' ); + $this->group = __( 'Customer', 'automatewoo' ); $this->description = __( 'Please note that if the customer is a guest this action will do nothing.', 'automatewoo' ); } - - function load_fields() { - $user_type = new Fields\User_Role( false ); + /** + * Method to load the action's fields. + */ + public function load_fields() { + $user_type = new Fields\User_Role( false, $this->allow_all_roles() ); $user_type->set_required(); - $this->add_field($user_type); + $this->add_field( $user_type ); } - - function run() { - if ( ! $customer = $this->workflow->data_layer()->get_customer() ) { + /** + * Run the action. + * + * @throws \Exception When an error occurs. + */ + public function run() { + $customer = $this->workflow->data_layer()->get_customer(); + if ( ! $customer ) { return; } $role = $this->get_option( 'user_type' ); + $user = $customer->get_user(); - if ( $role && $user = $customer->get_user() ) { + if ( ! $this->allow_all_roles() && ( in_array( $role, User_Role::PROTECTED_ROLES, true ) || in_array( $customer->get_role(), User_Role::PROTECTED_ROLES, true ) ) ) { + return; + } + + if ( $role && $user ) { $user->set_role( $role ); } } + /** + * Check if roles in User_Role::PROTECTED_ROLES should be shown as well. + * + * @return bool + */ + private function allow_all_roles() { + return (bool) apply_filters( 'automatewoo/change_role/allow_all_roles', false ); + } } diff --git a/includes/Actions/Customer_Remove_Tags.php b/includes/Actions/Customer_Remove_Tags.php index 7cdb917..08fb21b 100644 --- a/includes/Actions/Customer_Remove_Tags.php +++ b/includes/Actions/Customer_Remove_Tags.php @@ -1,23 +1,32 @@ title = __( 'Remove Tags', 'automatewoo' ); } - - function run() { - if ( ! $customer = $this->workflow->data_layer()->get_customer() ) { + /** + * Run the action. + * + * @throws \Exception When an error occurs. + */ + public function run() { + $customer = $this->workflow->data_layer()->get_customer(); + if ( ! $customer ) { return; } @@ -29,5 +38,4 @@ function run() { wp_remove_object_terms( $customer->get_user_id(), $tags, 'user_tag' ); } - } diff --git a/includes/Actions/Memberships_Change_Status.php b/includes/Actions/Memberships_Change_Status.php new file mode 100644 index 0000000..9266d40 --- /dev/null +++ b/includes/Actions/Memberships_Change_Status.php @@ -0,0 +1,123 @@ +title = __( "Update the status of a user's current membership plan", 'automatewoo' ); + $this->description = __( 'Changes the status of a users membership. The action will only run if a membership already exists for the user.', 'automatewoo' ); + } + + /** + * Setup fields used by the Action + * + * @return void + */ + public function load_fields() { + $statuses = Memberships_Helper::get_membership_statuses(); + $plans = Memberships_Helper::get_membership_plans(); + + $plan = new Fields\Select(); + $plan->set_options( $plans ); + $plan->set_name( 'plan' ); + $plan->set_title( __( 'Membership Plan', 'automatewoo' ) ); + $plan->set_required(); + + $from_status = new Fields\Select(); + $from_status->set_options( $statuses ); + $from_status->set_name( 'from_status' ); + $from_status->set_title( __( 'Current Status', 'automatewoo' ) ); + $from_status->set_placeholder( __( '[None]', 'automatewoo' ) ); + $from_status->set_description( __( 'Leave this blank to set the new status regardless of the existing status.', 'automatewoo' ) ); + + $to_status = new Fields\Select(); + $to_status->set_options( $statuses ); + $to_status->set_name( 'to_status' ); + $to_status->set_title( __( 'New Status', 'automatewoo' ) ); + $to_status->set_required(); + + $note = new Fields\Text_Area(); + $note->set_name( 'note' ); + $note->set_title( __( 'Note', 'automatewoo' ) ); + $note->set_variable_validation(); + + $this->add_field( $plan ); + $this->add_field( $from_status ); + $this->add_field( $to_status ); + $this->add_field( $note ); + } + + /** + * Run the Action to update an existing membership status + * + * @return void + */ + public function run() { + $customer = $this->workflow->data_layer()->get_customer(); + $plan = absint( $this->get_option( 'plan' ) ); + $current_status = $this->get_option( 'from_status' ); + $new_status = $this->get_option( 'to_status' ); + $note = $this->get_option( 'note' ); + + if ( $current_status === $new_status ) { + $this->workflow->log_action_note( $this, __( 'No change made to membership because the current status is the same as the new status.', 'automatewoo' ) ); + return; + } + + $membership = $this->get_membership( $customer->get_user_id(), $plan ); + + if ( ! $membership ) { + $this->workflow->log_action_note( $this, __( 'Could not find an active membership for the customer.', 'automatewoo' ) ); + return; + } + + if ( $current_status && $current_status !== $membership->get_status() ) { + $this->workflow->log_action_note( $this, __( "Membership status doesn't match value specified in Action settings.", 'automatewoo' ) ); + return; + } + + $this->set_status_transition_note( $note ); + + $membership->update_status( $new_status ); + } + + /** + * Get a Membership for a specific user and plan + * + * @param int $customer_id ID of the customer to get the membership plan for + * @param string $plan Slug for the membership plan to retreive + * + * @return \WC_Memberships_User_Membership|\WC_Memberships_Integration_Subscriptions_User_Membership|null The User Membership or null if not found + */ + public function get_membership( $customer_id, $plan ) { + return wc_memberships_get_user_membership( $customer_id, $plan ); + } + + /** + * Prepend the membership status transition note with a user supplied note + * + * @param string $note The note to prepend to the membership status transition note + * + * @return void + */ + public function set_status_transition_note( $note ) { + wc_memberships()->get_user_memberships_instance()->set_membership_status_transition_note( $note ); + } +} diff --git a/includes/Actions/Order_Add_Note.php b/includes/Actions/Order_Add_Note.php index a8e4b51..ac7f6bd 100644 --- a/includes/Actions/Order_Add_Note.php +++ b/includes/Actions/Order_Add_Note.php @@ -1,9 +1,10 @@ title = __( 'Add Note', 'automatewoo' ); $this->group = __( 'Order', 'automatewoo' ); } - - function load_fields() { + /** + * Method to load the action's fields. + */ + public function load_fields() { $type = new Fields\Order_Note_Type(); $type->set_required(); @@ -34,7 +44,7 @@ function load_fields() { $author->set_required( false ); $note = new Fields\Text_Area(); - $note->set_name('note' ); + $note->set_name( 'note' ); $note->set_title( __( 'Note', 'automatewoo' ) ); $note->set_variable_validation(); $note->set_required(); @@ -44,8 +54,12 @@ function load_fields() { $this->add_field( $note ); } - - function run() { + /** + * Run the action. + * + * @throws \Exception When an error occurs. + */ + public function run() { $note_type = $this->get_option( 'note_type' ); $author = $this->get_option( 'note_author' ); $note = $this->get_option( 'note', true ); diff --git a/includes/Actions/Order_Change_Status.php b/includes/Actions/Order_Change_Status.php index c1f106a..ed92514 100644 --- a/includes/Actions/Order_Change_Status.php +++ b/includes/Actions/Order_Change_Status.php @@ -1,9 +1,10 @@ title = __( 'Change Status', 'automatewoo' ); $this->group = __( 'Order', 'automatewoo' ); } - - function load_fields() { + /** + * Method to load the action's fields. + */ + public function load_fields() { $order_status = new Fields\Order_Status( false ); $order_status->set_description( __( 'Order status will be changed to this.', 'automatewoo' ) ); $order_status->set_required(); - $this->add_field($order_status); + $this->add_field( $order_status ); } - - function run() { - $order = $this->workflow->data_layer()->get_order(); + /** + * Run the action. + * + * @throws \Exception When an error occurs. + */ + public function run() { + $order = $this->workflow->data_layer()->get_order(); $status = $this->get_option( 'order_status' ); if ( ! $status || ! $order ) { return; } + // translators: The workflow ID $note = sprintf( __( 'AutomateWoo workflow #%s.', 'automatewoo' ), $this->workflow->get_id() ); $order->update_status( $status, $note ); } - } diff --git a/includes/Actions/Order_Resend_Email.php b/includes/Actions/Order_Resend_Email.php index 63699a3..5653523 100644 --- a/includes/Actions/Order_Resend_Email.php +++ b/includes/Actions/Order_Resend_Email.php @@ -1,9 +1,10 @@ title = __( 'Resend Order Email', 'automatewoo' ); - $this->group = __( 'Order', 'automatewoo' ); + /** + * Method to set the action's admin props. + * + * Admin props include: title, group and description. + */ + public function load_admin_details() { + $this->title = __( 'Resend Order Email', 'automatewoo' ); + $this->group = __( 'Order', 'automatewoo' ); $this->description = __( 'Please note that email tracking is not currently supported on this action.', 'automatewoo' ); } - function load_fields() { + /** + * Method to load the action's fields. + */ + public function load_fields() { - $options = []; - $mailer = WC()->mailer(); + $options = []; + $mailer = WC()->mailer(); $available_emails = [ 'new_order', 'cancelled_order', @@ -35,36 +49,41 @@ function load_fields() { 'customer_invoice', 'customer_refunded_order', ]; - $mails = $mailer->get_emails(); /** @var \WC_Email[] $mails */ + $mails = $mailer->get_emails(); /** @var \WC_Email[] $mails */ - if ( $mails ) foreach ( $mails as $mail ) { - if ( in_array( $mail->id, $available_emails ) ) { - $title = $mail->get_title(); + if ( $mails ) { + foreach ( $mails as $mail ) { + if ( in_array( $mail->id, $available_emails, true ) ) { + $title = $mail->get_title(); - if ( ! $mail->is_customer_email() ) { - $title .= ' - ' . __( 'Admin', 'automatewoo' ); - } - else { - $title .= ' - ' . __( 'Customer', 'automatewoo' ); - } + if ( ! $mail->is_customer_email() ) { + $title .= ' - ' . __( 'Admin', 'automatewoo' ); + } else { + $title .= ' - ' . __( 'Customer', 'automatewoo' ); + } - $options[$mail->id] = $title; + $options[ $mail->id ] = $title; + } } } - $email = new Fields\Select(true); + $email = new Fields\Select( true ); $email->set_name( 'email' ); - $email->set_title( __('Email', 'automatewoo') ); + $email->set_title( __( 'Email', 'automatewoo' ) ); $email->set_required(); $email->set_options( $options ); - $this->add_field($email); + $this->add_field( $email ); } - - function run() { + /** + * Run the action. + * + * @throws \Exception When an error occurs. + */ + public function run() { $email_type = $this->get_option( 'email' ); - $order = $this->workflow->data_layer()->get_order(); + $order = $this->workflow->data_layer()->get_order(); if ( ! $email_type || ! $order ) { return; @@ -79,13 +98,14 @@ function run() { // Load mailer $mailer = WC()->mailer(); - if ( ! $mails = $mailer->get_emails() ) { + $mails = $mailer->get_emails(); + if ( ! $mails ) { return; } foreach ( $mails as $mail ) { - if ( $mail->id != $email_type ) { + if ( $mail->id !== $email_type ) { continue; } @@ -93,8 +113,8 @@ function run() { do_action( 'woocommerce_after_resend_order_email', $order, $email_type ); - $order->add_order_note( sprintf( __( '%s email notification sent by AutomateWoo workflow #%d', 'automatewoo' ), $mail->title, $this->workflow->get_id() ) ); + // translators: %1$s Mail title, %2$d The Workflow ID + $order->add_order_note( sprintf( __( '%1$s email notification sent by AutomateWoo workflow #%2$d', 'automatewoo' ), $mail->title, $this->workflow->get_id() ) ); } } - } diff --git a/includes/Actions/Order_Trigger_Action.php b/includes/Actions/Order_Trigger_Action.php index fd28757..5a9d33e 100644 --- a/includes/Actions/Order_Trigger_Action.php +++ b/includes/Actions/Order_Trigger_Action.php @@ -1,11 +1,12 @@ title = __( 'Trigger Order Action', 'automatewoo' ); - $this->group = __( 'Order', 'automatewoo' ); - $this->description = __( 'Not to be confused with AutomateWoo actions this action can trigger a WooCommerce order action. They can normally be found in the in the top right of of the order edit view.', 'automatewoo'); + /** + * Method to set the action's admin props. + * + * Admin props include: title, group and description. + */ + public function load_admin_details() { + $this->title = __( 'Trigger Order Action', 'automatewoo' ); + $this->group = __( 'Order', 'automatewoo' ); + $this->description = __( 'Not to be confused with AutomateWoo actions this action can trigger a WooCommerce order action. They can normally be found in the in the top right of of the order edit view.', 'automatewoo' ); } - - function load_fields() { + /** + * Method to load the action's fields. + */ + public function load_fields() { $action = new Fields\Select(); $action->set_name( 'order_action' ); @@ -31,7 +43,7 @@ function load_fields() { $action->set_required(); $action->set_options( $this->get_order_actions() ); - $this->add_field($action); + $this->add_field( $action ); } /** @@ -57,7 +69,7 @@ protected function get_order_actions() { $actions = (array) apply_filters( 'woocommerce_order_actions', [ - 'regenerate_download_permissions' => __( 'Generate download permissions', 'automatewoo' ) + 'regenerate_download_permissions' => __( 'Generate download permissions', 'automatewoo' ), ], null ); @@ -69,20 +81,24 @@ protected function get_order_actions() { } - function run() { + /** + * Run the action. + * + * @throws \Exception When an error occurs. + */ + public function run() { $order_action_name = $this->get_option( 'order_action' ); - $order = $this->workflow->data_layer()->get_order(); + $order = $this->workflow->data_layer()->get_order(); if ( ! $order_action_name || ! $order ) { return; } - if ( $order_action_name == 'regenerate_download_permissions' ) { + if ( $order_action_name === 'regenerate_download_permissions' ) { $data_store = \WC_Data_Store::load( 'customer-download' ); $data_store->delete_by_order_id( $order->get_id() ); wc_downloadable_product_permissions( $order->get_id(), true ); - } - else { + } else { do_action( 'woocommerce_order_action_' . sanitize_title( $order_action_name ), $order ); } } diff --git a/includes/Actions/Order_Update_Customer_Shipping_Note.php b/includes/Actions/Order_Update_Customer_Shipping_Note.php index 74799a8..e3a7b25 100644 --- a/includes/Actions/Order_Update_Customer_Shipping_Note.php +++ b/includes/Actions/Order_Update_Customer_Shipping_Note.php @@ -1,28 +1,38 @@ title = __( 'Update Customer Provided Note', 'automatewoo' ); $this->group = __( 'Order', 'automatewoo' ); } /** - * @return mixed + * Method to load the action's fields. */ - function load_fields() { + public function load_fields() { $note = ( new Fields\Text_Area() ) ->set_name( 'note' ) @@ -40,25 +50,29 @@ function load_fields() { $this->add_field( $append_checkbox ); } + /** + * Run the action. + * + * @throws \Exception When an error occurs. + */ + public function run() { + $order = $this->workflow->data_layer()->get_order(); - function run() { - if ( ! $order = $this->workflow->data_layer()->get_order() ) { + if ( ! $order ) { return; } - $note = $this->get_option( 'note', true ); + $note = $this->get_option( 'note', true ); $append = $this->get_option( 'append' ); if ( $append ) { $existing_note = $order->get_customer_note(); - $new_note = $existing_note ? $existing_note . ' | ' . $note : $note; - } - else { + $new_note = $existing_note ? $existing_note . ' | ' . $note : $note; + } else { $new_note = $note; } $order->set_customer_note( $new_note ); $order->save(); } - } diff --git a/includes/Actions/Order_Update_Meta.php b/includes/Actions/Order_Update_Meta.php index e01a51a..aff55ec 100644 --- a/includes/Actions/Order_Update_Meta.php +++ b/includes/Actions/Order_Update_Meta.php @@ -1,45 +1,62 @@ title = __( 'Update Custom Field', 'automatewoo' ); $this->group = __( 'Order', 'automatewoo' ); $this->description = __( 'This action can add or update an order\'s custom field.', 'automatewoo' ); } - - function load_fields() { + /** + * Method to load the action's fields. + */ + public function load_fields() { $meta_key = ( new Fields\Text() ) - ->set_name('meta_key') - ->set_title(__('Key', 'automatewoo')) + ->set_name( 'meta_key' ) + ->set_title( __( 'Key', 'automatewoo' ) ) ->set_variable_validation() ->set_required(); $meta_value = ( new Fields\Text() ) ->set_name( 'meta_value' ) - ->set_title( __('Value', 'automatewoo') ) + ->set_title( __( 'Value', 'automatewoo' ) ) ->set_variable_validation(); - $this->add_field($meta_key); - $this->add_field($meta_value); + $this->add_field( $meta_key ); + $this->add_field( $meta_value ); } + /** + * Run the action. + * + * @throws \Exception When an error occurs. + */ + public function run() { + $order = $this->workflow->data_layer()->get_order(); - function run() { - - if ( ! $order = $this->workflow->data_layer()->get_order() ) { + if ( ! $order ) { return; } @@ -51,7 +68,5 @@ function run() { $order->update_meta_data( $meta_key, $meta_value ); $order->save(); } - } - } diff --git a/includes/Actions/Subscription_Add_Coupon.php b/includes/Actions/Subscription_Add_Coupon.php index be8c52c..156068c 100644 --- a/includes/Actions/Subscription_Add_Coupon.php +++ b/includes/Actions/Subscription_Add_Coupon.php @@ -14,6 +14,13 @@ */ class Action_Subscription_Add_Coupon extends Action_Subscription_Edit_Coupon_Abstract { + /** + * Class constructor + */ + public function __construct() { + // Only recurring coupons can be added to subscriptions. + $this->set_recurring_coupon_only( true ); + } /** * Explain to store admin what this action does via a unique title and description. @@ -58,16 +65,4 @@ protected function get_note( $coupon ) { /* translators: %1$s: workflow title, %2$s coupon code, %3$d workflow ID */ return sprintf( __( '%1$s workflow run: added coupon %2$s to subscription. (Workflow ID: %3$d)', 'automatewoo' ), $this->workflow->get_title(), $coupon->get_code(), $this->workflow->get_id() ); } - - /** - * Add a recurring coupon selection field for this action - */ - protected function add_coupon_select_field() { - $coupon_select = new Fields\Coupon(); - $coupon_select->set_required(); - $coupon_select->set_name( 'coupon' ); - $coupon_select->set_title( __( 'Coupon', 'automatewoo' ) ); - $coupon_select->set_recurring_only( true ); - $this->add_field( $coupon_select ); - } } diff --git a/includes/Actions/Subscription_Change_Status.php b/includes/Actions/Subscription_Change_Status.php index 8d164e2..76680ed 100644 --- a/includes/Actions/Subscription_Change_Status.php +++ b/includes/Actions/Subscription_Change_Status.php @@ -1,9 +1,10 @@ title = __( 'Change Status', 'automatewoo' ); $this->group = __( 'Subscription', 'automatewoo' ); } - - function load_fields() { + /** + * Method to load the action's fields. + */ + public function load_fields() { $status = new Fields\Subscription_Status( false ); $status->set_name( 'status' ); $status->set_required(); - $this->add_field($status); + $this->add_field( $status ); } - - function run() { + /** + * Run the action. + */ + public function run() { $subscription = $this->workflow->data_layer()->get_subscription(); - $status = $this->get_option( 'status' ); + $status = $this->get_option( 'status' ); - if ( ! $status || ! $subscription ) + if ( ! $status || ! $subscription ) { return; - - $subscription->update_status( $status, sprintf( - __( 'Subscription status changed by AutomateWoo Workflow #%s.', 'automatewoo' ), - $this->workflow->get_id() - )); + } + + $subscription->update_status( + $status, + sprintf( + // translators: The Workflow ID + __( 'Subscription status changed by AutomateWoo Workflow #%s.', 'automatewoo' ), + $this->workflow->get_id() + ) + ); } - } diff --git a/includes/Actions/Subscription_Edit_Coupon_Abstract.php b/includes/Actions/Subscription_Edit_Coupon_Abstract.php index 4959fad..14e5eef 100644 --- a/includes/Actions/Subscription_Edit_Coupon_Abstract.php +++ b/includes/Actions/Subscription_Edit_Coupon_Abstract.php @@ -16,6 +16,21 @@ */ abstract class Action_Subscription_Edit_Coupon_Abstract extends AbstractEditItem { + /** + * Whether the Coupon field only queries recurring codes. + * + * @var bool + */ + private $recurring_code_only = false; + + /** + * Sets whether the Coupon field only queries recurring codes. + * + * @param bool $recurring_code_only + */ + protected function set_recurring_coupon_only( bool $recurring_code_only ) { + $this->recurring_code_only = $recurring_code_only; + } /** * Add a coupon selection field to the action's admin UI for store owners to choose what @@ -38,25 +53,19 @@ protected function get_object_for_edit() { return new \WC_Coupon( $this->get_option( 'coupon' ) ); } - /** - * Add a coupon selection field for this action + * Add a coupon selection field for this action. */ protected function add_coupon_select_field() { - $coupon_select = new Fields\Select(); + $coupon_select = new Fields\Coupon(); $coupon_select->set_required(); $coupon_select->set_name( 'coupon' ); $coupon_select->set_title( __( 'Coupon', 'automatewoo' ) ); - $coupon_select->set_options( $this->get_coupons_list() ); - $this->add_field( $coupon_select ); - } - /** - * Get the codes of all non-AutomateWoo coupons. - * - * @return array Coupon codes (as both key and value of array) - */ - protected function get_coupons_list() { - return Fields_Helper::get_coupons_list(); + if ( $this->recurring_code_only ) { + $coupon_select->set_recurring_only( true ); + } + + $this->add_field( $coupon_select ); } } diff --git a/includes/Actions/Subscription_Send_Invoice.php b/includes/Actions/Subscription_Send_Invoice.php index e4d34ad..844ae2f 100644 --- a/includes/Actions/Subscription_Send_Invoice.php +++ b/includes/Actions/Subscription_Send_Invoice.php @@ -1,9 +1,10 @@ title = __( 'Send Invoice', 'automatewoo' ); + /** + * Method to set the action's admin props. + * + * Admin props include: title, group and description. + */ + public function load_admin_details() { + $this->title = __( 'Send Invoice', 'automatewoo' ); $this->description = __( 'Email the invoice to the subscription customer.', 'automatewoo' ); - $this->group = __( 'Subscription', 'automatewoo' ); + $this->group = __( 'Subscription', 'automatewoo' ); } - - function run() { - if ( ! $subscription = $this->workflow->data_layer()->get_subscription() ) { + /** + * Run the action. + */ + public function run() { + $subscription = $this->workflow->data_layer()->get_subscription(); + if ( ! $subscription ) { return; } @@ -34,5 +44,4 @@ function run() { do_action( 'woocommerce_after_resend_order_email', $subscription, 'customer_invoice' ); } - } diff --git a/includes/Actions/Subscription_Update_Meta.php b/includes/Actions/Subscription_Update_Meta.php index 62e77d8..5a9782a 100644 --- a/includes/Actions/Subscription_Update_Meta.php +++ b/includes/Actions/Subscription_Update_Meta.php @@ -1,5 +1,4 @@ title = __( 'Update Custom Field', 'automatewoo' ); $this->group = __( 'Subscription', 'automatewoo' ); $this->description = __( 'This action can add or update a subscription\'s custom field. Please note that it should not be used to update internal fields like the subscription schedule.', 'automatewoo' ); } - function run() { - if ( ! $subscription = $this->workflow->data_layer()->get_subscription() ) { + /** + * Run the action. + */ + public function run() { + $subscription = $this->workflow->data_layer()->get_subscription(); + if ( ! $subscription ) { return; } @@ -34,7 +43,5 @@ function run() { $subscription->update_meta_data( $meta_key, $meta_value ); $subscription->save(); } - } - } diff --git a/includes/Communication_Page.php b/includes/Communication_Page.php index bbd2cf4..79124d2 100644 --- a/includes/Communication_Page.php +++ b/includes/Communication_Page.php @@ -1,30 +1,39 @@ opt_out(); + wc_add_notice( __( "Saved successfully! You won't receive marketing communications from us.", 'automatewoo' ) ); + } + + aw_get_template( 'communication-preferences/communication-form.php', $data ); } } - - static function output_signup_form() { + /** + * Get the contents of the communication preferences signup form + * + * @return string + */ + public static function output_signup_form() { wp_enqueue_style( 'automatewoo-communication-page' ); ob_start(); - aw_get_template('communication-preferences/signup-form.php' ); + aw_get_template( 'communication-preferences/signup-form.php' ); return ob_get_clean(); } - } diff --git a/includes/DataTypes/Subscription.php b/includes/DataTypes/Subscription.php index 80a960c..0974a0d 100644 --- a/includes/DataTypes/Subscription.php +++ b/includes/DataTypes/Subscription.php @@ -1,5 +1,4 @@ get_id(); } /** - * @param $compressed_item - * @param $compressed_data_layer + * @param string|int $compressed_item + * @param array|false $compressed_data_layer * @return WC_Subscription|false */ - function decompress( $compressed_item, $compressed_data_layer ) { + public function decompress( $compressed_item, $compressed_data_layer ) { $id = Clean::id( $compressed_item ); if ( ! Integrations::is_subscriptions_active() || ! $id ) { @@ -75,5 +76,4 @@ public function get_singular_name() { public function get_plural_name() { return __( 'Subscriptions', 'automatewoo' ); } - } diff --git a/includes/Event_Helpers/Subscription_Status_Changed.php b/includes/Event_Helpers/Subscription_Status_Changed.php index d1558af..7990aaf 100644 --- a/includes/Event_Helpers/Subscription_Status_Changed.php +++ b/includes/Event_Helpers/Subscription_Status_Changed.php @@ -1,5 +1,4 @@ get_id(), $new_status, $old_status ); } - } diff --git a/includes/Fields/Coupon.php b/includes/Fields/Coupon.php index a8e1ed1..f847213 100644 --- a/includes/Fields/Coupon.php +++ b/includes/Fields/Coupon.php @@ -69,4 +69,17 @@ public function set_recurring_only( bool $recurring ) { public function get_recurring_only() { return $this->recurring_only; } + + /** + * Sanitizes the value of the field. + * + * @since 6.0.25 + * + * @param string $value + * + * @return string + */ + public function sanitize_value( $value ) { + return wc_format_coupon_code( $value ); + } } diff --git a/includes/Fields/Searchable_Select_Abstract.php b/includes/Fields/Searchable_Select_Abstract.php index 7c4bf41..bea7fee 100644 --- a/includes/Fields/Searchable_Select_Abstract.php +++ b/includes/Fields/Searchable_Select_Abstract.php @@ -75,7 +75,8 @@ public function render( $values ) { data-name="get_name() ); ?>" data-allow_clear="true" data-placeholder="" - data-action="get_search_ajax_action() ); ?>"> + data-action="get_search_ajax_action() ); ?>" + get_required() ? 'required' : '' ); ?>> $option_value ) { echo ''; diff --git a/includes/Fields/Select.php b/includes/Fields/Select.php index fafbe41..f2420ff 100644 --- a/includes/Fields/Select.php +++ b/includes/Fields/Select.php @@ -101,7 +101,7 @@ function has_dynamic_options() { */ function render( $value = false ) { - $value = Clean::recursive( $value ); + $value = $this->sanitize_value( $value ); if ( $this->has_dynamic_options() ) { $this->add_data_attr( 'automatewoo-dynamic-select' ); diff --git a/includes/Fields/Subscription_Products.php b/includes/Fields/Subscription_Products.php index 98a6119..114ddb4 100644 --- a/includes/Fields/Subscription_Products.php +++ b/includes/Fields/Subscription_Products.php @@ -1,11 +1,12 @@ set_title( __( 'Subscription products', 'automatewoo' ) ); @@ -28,30 +33,32 @@ function __construct() { $options = []; - $query = new \WP_Query([ - 'post_type' => 'product', - 'posts_per_page' => -1, - 'no_found_rows' => true, - 'tax_query' => [ - [ - 'taxonomy' => 'product_type', - 'field' => 'slug', - 'terms' => [ - 'subscription', - 'variable-subscription' + $query = new \WP_Query( + [ + 'post_type' => 'product', + 'posts_per_page' => -1, + 'no_found_rows' => true, + 'tax_query' => [ + [ + 'taxonomy' => 'product_type', + 'field' => 'slug', + 'terms' => [ + 'subscription', + 'variable-subscription', + ], ], ], - ], - ]); + ] + ); foreach ( $query->posts as $subscription_post ) { $product = wc_get_product( $subscription_post ); $options[ $product->get_id() ] = $product->get_formatted_name(); - if ( $product->is_type('variable-subscription') ) { + if ( $product->is_type( 'variable-subscription' ) ) { foreach ( $product->get_children() as $variation_id ) { - $variation = wc_get_product( $variation_id ); + $variation = wc_get_product( $variation_id ); $options[ $variation_id ] = $variation->get_formatted_name(); } } @@ -70,13 +77,11 @@ function __construct() { * * @return array|string */ - function sanitize_value( $value ) { + public function sanitize_value( $value ) { if ( $this->multiple ) { return Clean::ids( $value ); - } - else{ + } else { return Clean::id( $value ); } } - } diff --git a/includes/Fields/Subscription_Status.php b/includes/Fields/Subscription_Status.php index 20a1e8a..9230928 100644 --- a/includes/Fields/Subscription_Status.php +++ b/includes/Fields/Subscription_Status.php @@ -1,23 +1,25 @@ set_title( __( 'Subscription status', 'automatewoo' ) ); @@ -28,5 +30,4 @@ function __construct( $allow_all = true ) { $this->set_options( Subscription_Workflow_Helper::get_subscription_statuses() ); } - } diff --git a/includes/Fields/User_Role.php b/includes/Fields/User_Role.php index 6206136..4b1e18d 100644 --- a/includes/Fields/User_Role.php +++ b/includes/Fields/User_Role.php @@ -1,35 +1,41 @@ set_title( __( 'User role', 'automatewoo' ) ); - if ( $allow_all ) { - $this->set_placeholder('[Any]'); + if ( $allow_any ) { + $this->set_placeholder( '[Any]' ); } global $wp_roles; - foreach( $wp_roles->roles as $key => $role ) { - $this->options[$key] = $role['name']; + foreach ( $wp_roles->roles as $key => $role ) { + if ( $allow_all_roles || ! in_array( $key, self::PROTECTED_ROLES, true ) ) { + $this->options[ $key ] = $role['name']; + } } } - } diff --git a/includes/Fields_Helper.php b/includes/Fields_Helper.php index 9afdd41..aa02865 100644 --- a/includes/Fields_Helper.php +++ b/includes/Fields_Helper.php @@ -46,35 +46,6 @@ static function get_product_tags_list() { return $list; } - - /** - * @since 3.3.2 - * @return array - */ - static function get_coupons_list() { - $list = []; - - $query = new \WP_Query([ - 'post_type' => 'shop_coupon', - 'posts_per_page' => -1, - 'no_found_rows' => true, - 'meta_query' => [ - [ - 'key' => '_is_aw_coupon', - 'compare' => 'NOT EXISTS' - ] - ] - ]); - - foreach ( $query->posts as $coupon ) { - $code = wc_format_coupon_code( $coupon->post_title ); - $list[ $code ] = $code; - } - - return $list; - } - - /** * @return array */ diff --git a/includes/Integrations/ActiveCampaign.php b/includes/Integrations/ActiveCampaign.php index 1532493..35ce3f3 100644 --- a/includes/Integrations/ActiveCampaign.php +++ b/includes/Integrations/ActiveCampaign.php @@ -397,8 +397,9 @@ public function get_tag_id( $tag, $create_missing_tag = false, $retry_on_error = $this->active_tags = []; return $this->get_tag_id( $tag, $create_missing_tag, false ); } - - $this->log( esc_html__( 'Unexpected response when attempting to create a tag', 'automatewoo' ) ); + // phpcs:disable WordPress.PHP.DevelopmentFunctions + $this->log( 'Unexpected response when attempting to create a tag. Response: ' . print_r( $response, true ) . 'Tags: ' . print_r( $this->active_tags, true ) ); + // phpcs:enable return false; } diff --git a/includes/Integrations/Campaign_Monitor.php b/includes/Integrations/Campaign_Monitor.php index 1173103..5d29e05 100644 --- a/includes/Integrations/Campaign_Monitor.php +++ b/includes/Integrations/Campaign_Monitor.php @@ -1,9 +1,10 @@ api_key = $api_key; + public function __construct( $api_key, $client_id = false ) { + $this->api_key = $api_key; $this->client_id = $client_id; } @@ -54,21 +55,21 @@ public function is_enabled(): bool { /** * Automatically logs errors * - * @param $method - * @param $endpoint - * @param $args + * @param string $method + * @param string $endpoint + * @param array $args * * @return Remote_Request */ - function request( $method, $endpoint, $args = [] ) { + public function request( $method, $endpoint, $args = [] ) { $request_args = [ - 'headers' => [ + 'headers' => [ 'Authorization' => 'Basic ' . base64_encode( $this->api_key . ':x' ), - 'Accept' => 'application/json' + 'Accept' => 'application/json', ], - 'timeout' => 10, - 'method' => $method, - 'sslverify' => false + 'timeout' => 10, + 'method' => $method, + 'sslverify' => false, ]; $url = $this->api_root . $endpoint; @@ -97,24 +98,25 @@ function request( $method, $endpoint, $args = [] ) { /** * @return array */ - function get_lists() { + public function get_lists() { if ( ! $this->client_id ) { return []; } - if ( $cache = Cache::get_transient( 'campaign_monitor_lists' ) ) { + $cache = Cache::get_transient( 'campaign_monitor_lists' ); + if ( $cache ) { return $cache; } $request = $this->request( 'GET', "/clients/{$this->client_id}/lists.json" ); - $lists = $request->get_body(); - $clean = []; + $lists = $request->get_body(); + $clean = []; if ( ! $request->is_successful() ) { return []; } - foreach( $lists as $list ) { + foreach ( $lists as $list ) { $clean[ $list['ListID'] ] = $list['Name']; } @@ -127,9 +129,7 @@ function get_lists() { /** * Clear cached data */ - function clear_cache_data() { + public function clear_cache_data() { Cache::delete_transient( 'campaign_monitor_lists' ); } - - } diff --git a/includes/Mailer_Abstract.php b/includes/Mailer_Abstract.php index fca1dca..241c3c3 100644 --- a/includes/Mailer_Abstract.php +++ b/includes/Mailer_Abstract.php @@ -65,6 +65,14 @@ abstract class Mailer_Abstract { */ public $email_type = 'html'; + /** + * URL to set as the List-Unsubscribe header to support one click + * unsubscribe. Header will not be included if value is false. + * + * @var string|bool + */ + public $one_click_unsubscribe = false; + /** * Returns email body, can be HTML or plain text. * @@ -102,6 +110,17 @@ public function set_subject( $subject ) { $this->subject = $subject; } + /** + * Set the URL for the one click unsubscribe header + * + * @param string $url The URL where a POST request will be received to unsubscribe an email address + * + * @return void + */ + public function set_one_click_unsubscribe( $url ) { + $this->one_click_unsubscribe = $url; + } + /** * Get email sender email address. * @@ -192,6 +211,11 @@ public function send() { $headers[] = 'Reply-To: ' . $this->reply_to; } + if ( $this->one_click_unsubscribe ) { + $headers[] = 'List-Unsubscribe-Post: List-Unsubscribe=One-Click'; + $headers[] = "List-Unsubscribe: <$this->one_click_unsubscribe>"; + } + $subject = wp_specialchars_decode( $this->subject, ENT_QUOTES ); $sent = wp_mail( $this->email, diff --git a/includes/Rules/Order_Subscription_Failed_Automatic_Payment_Retry_Count.php b/includes/Rules/Order_Subscription_Failed_Automatic_Payment_Retry_Count.php index 7cc2bea..194d96f 100644 --- a/includes/Rules/Order_Subscription_Failed_Automatic_Payment_Retry_Count.php +++ b/includes/Rules/Order_Subscription_Failed_Automatic_Payment_Retry_Count.php @@ -1,5 +1,4 @@ title = __( 'Order - Subscription Failed Automatic Payment Retry Count', 'automatewoo' ); } /** - * @param $order \WC_Order - * @param $compare - * @param $value + * @param \WC_Order $order + * @param string $compare + * @param mixed $value * @return bool */ - function validate( $order, $compare, $value ) { + public function validate( $order, $compare, $value ) { $failed_retries = \WCS_Retry_Manager::store()->get_retries( [ 'status' => 'failed', @@ -37,5 +41,4 @@ function validate( $order, $compare, $value ) { return $this->validate_number( count( $failed_retries ), $compare, $value ); } - } diff --git a/includes/Rules/SubscriptionPaymentCount.php b/includes/Rules/SubscriptionPaymentCount.php index 73ee6d1..66bb11f 100644 --- a/includes/Rules/SubscriptionPaymentCount.php +++ b/includes/Rules/SubscriptionPaymentCount.php @@ -1,5 +1,4 @@ title = __( 'Subscription - Payment Count', 'automatewoo' ); } /** * @param WC_Subscription $subscription - * @param $compare - * @param $value + * @param string $compare + * @param mixed $value * @return bool */ - function validate( $subscription, $compare, $value ) { + public function validate( $subscription, $compare, $value ) { // Method changed in WCS 2.6 $payment_count = is_callable( [ $subscription, 'get_payment_count' ] ) ? $subscription->get_payment_count() : $subscription->get_completed_payment_count(); return $this->validate_number( $payment_count, $compare, $value ); } - } diff --git a/includes/Rules/Subscription_Items.php b/includes/Rules/Subscription_Items.php index 1072a67..55fbce6 100644 --- a/includes/Rules/Subscription_Items.php +++ b/includes/Rules/Subscription_Items.php @@ -1,5 +1,4 @@ title = __( 'Subscription - Items', 'automatewoo' ); } - } diff --git a/includes/Rules/Subscription_Status.php b/includes/Rules/Subscription_Status.php index d70352f..5f7ea66 100644 --- a/includes/Rules/Subscription_Status.php +++ b/includes/Rules/Subscription_Status.php @@ -1,5 +1,4 @@ title = __( 'Subscription - Status', 'automatewoo' ); } - function load_select_choices() { + /** + * @return array + */ + public function load_select_choices() { return Subscription_Workflow_Helper::get_subscription_statuses(); } /** - * @param $subscription \WC_Subscription - * @param $compare - * @param $value + * @param \WC_Subscription $subscription + * @param string $compare + * @param array|string $value * @return bool */ - function validate( $subscription, $compare, $value ) { + public function validate( $subscription, $compare, $value ) { return $this->validate_select( 'wc-' . $subscription->get_status(), $compare, $value ); } @@ -58,5 +64,4 @@ function validate( $subscription, $compare, $value ) { public function get_quick_filter_clause( $compare_type, $value ) { return $this->generate_array_quick_filter_clause( 'status', $compare_type, $value ); } - } diff --git a/includes/Triggers/Subscription_Before_End.php b/includes/Triggers/Subscription_Before_End.php index f0cedca..90ea350 100644 --- a/includes/Triggers/Subscription_Before_End.php +++ b/includes/Triggers/Subscription_Before_End.php @@ -1,28 +1,35 @@ title = __( 'Subscription Before End', 'automatewoo' ); + /** + * Method to set the action's admin props. + * + * Admin props include: title, group and description. + */ + public function load_admin_details() { + $this->title = __( 'Subscription Before End', 'automatewoo' ); $this->description = __( "This trigger runs once per day for any subscriptions that are due to expire/end on the workflow's target date. For example, if set to run 7 days before end, it would look for subscriptions that are due to end on the date exactly 7 days from now.", 'automatewoo' ); $this->description .= ' ' . $this->get_description_text_workflow_not_immediate(); - $this->group = Subscription_Workflow_Helper::get_group_name(); + $this->group = Subscription_Workflow_Helper::get_group_name(); } - - function load_fields() { + /** + * Load fields. + */ + public function load_fields() { $days_before = ( new Fields\Positive_Number() ) ->set_name( 'days_before' ) @@ -78,5 +85,4 @@ public function validate_before_queued_event( $workflow ) { return true; } - } diff --git a/includes/Triggers/Subscription_Payment_Complete.php b/includes/Triggers/Subscription_Payment_Complete.php index 2f3c4a9..0e0d688 100644 --- a/includes/Triggers/Subscription_Payment_Complete.php +++ b/includes/Triggers/Subscription_Payment_Complete.php @@ -1,9 +1,10 @@ title = __( 'Subscription Renewal Payment Complete', 'automatewoo' ); $this->group = Subscription_Workflow_Helper::get_group_name(); } - - function load_fields() { + /** + * Registers any fields used on for a trigger + */ + public function load_fields() { $this->add_field( Subscription_Workflow_Helper::get_products_field() ); $this->add_field( Subscription_Workflow_Helper::get_active_subscriptions_only_field() ); } - function register_hooks() { + /** + * Register the hooks for when this trigger should run + */ + public function register_hooks() { add_action( 'automatewoo/subscription/renewal_payment_complete_async', [ $this, 'handle_payment_complete' ], 10, 2 ); } @@ -47,19 +55,21 @@ function register_hooks() { * @param int $subscription_id * @param int $order_id */ - function handle_payment_complete( $subscription_id, $order_id ) { + public function handle_payment_complete( $subscription_id, $order_id ) { $subscription = wcs_get_subscription( $subscription_id ); - $order = wc_get_order( $order_id ); + $order = wc_get_order( $order_id ); if ( ! $subscription || ! $order ) { return; } - $this->maybe_run([ - 'subscription' => $subscription, - 'order' => $order, - 'customer' => Customer_Factory::get_by_user_id( $subscription->get_user_id() ) - ]); + $this->maybe_run( + [ + 'subscription' => $subscription, + 'order' => $order, + 'customer' => Customer_Factory::get_by_user_id( $subscription->get_user_id() ), + ] + ); } @@ -67,7 +77,7 @@ function handle_payment_complete( $subscription_id, $order_id ) { * @param Workflow $workflow * @return bool */ - function validate_workflow( $workflow ) { + public function validate_workflow( $workflow ) { $subscription = $workflow->data_layer()->get_subscription(); @@ -87,7 +97,7 @@ function validate_workflow( $workflow ) { * @param Workflow $workflow * @return bool */ - function validate_before_queued_event( $workflow ) { + public function validate_before_queued_event( $workflow ) { $subscription = $workflow->data_layer()->get_subscription(); if ( ! $subscription ) { diff --git a/includes/Triggers/Subscription_Payment_Failed.php b/includes/Triggers/Subscription_Payment_Failed.php index 64dc2e1..a69de9e 100644 --- a/includes/Triggers/Subscription_Payment_Failed.php +++ b/includes/Triggers/Subscription_Payment_Failed.php @@ -1,9 +1,10 @@ title = __( 'Subscription Renewal Payment Failed', 'automatewoo' ); $this->group = Subscription_Workflow_Helper::get_group_name(); } - - function load_fields() { + /** + * Registers any fields used on for a trigger + */ + public function load_fields() { $this->add_field( Subscription_Workflow_Helper::get_products_field() ); } - function register_hooks() { + /** + * Register the hooks for when the trigger should run + */ + public function register_hooks() { add_action( 'automatewoo/subscription/renewal_payment_failed_async', [ $this, 'handle_payment_failed' ], 10, 2 ); } @@ -46,27 +54,29 @@ function register_hooks() { * @param int $subscription_id * @param int $order_id */ - function handle_payment_failed( $subscription_id, $order_id ) { + public function handle_payment_failed( $subscription_id, $order_id ) { $subscription = wcs_get_subscription( $subscription_id ); - $order = wc_get_order( $order_id ); + $order = wc_get_order( $order_id ); if ( ! $subscription || ! $order ) { return; } - $this->maybe_run([ - 'subscription' => $subscription, - 'order' => $order, - 'customer' => Customer_Factory::get_by_user_id( $subscription->get_user_id() ) - ]); + $this->maybe_run( + [ + 'subscription' => $subscription, + 'order' => $order, + 'customer' => Customer_Factory::get_by_user_id( $subscription->get_user_id() ), + ] + ); } /** - * @param $workflow Workflow + * @param Workflow $workflow * @return bool */ - function validate_workflow( $workflow ) { + public function validate_workflow( $workflow ) { $subscription = $workflow->data_layer()->get_subscription(); @@ -80,5 +90,4 @@ function validate_workflow( $workflow ) { return true; } - } diff --git a/includes/Triggers/Subscription_Trial_End.php b/includes/Triggers/Subscription_Trial_End.php index 820b5c4..f3509f7 100644 --- a/includes/Triggers/Subscription_Trial_End.php +++ b/includes/Triggers/Subscription_Trial_End.php @@ -1,9 +1,10 @@ title = __( 'Subscription Trial End', 'automatewoo' ); $this->group = Subscription_Workflow_Helper::get_group_name(); } - - function load_fields() { + /** + * Registers any fields used on for a trigger + */ + public function load_fields() { $this->add_field( Subscription_Workflow_Helper::get_products_field() ); } - - function register_hooks() { + /** + * Register the hooks for when this trigger should run + */ + public function register_hooks() { add_action( 'woocommerce_scheduled_subscription_trial_end', [ $this, 'handle_trial_end' ], 20, 1 ); } @@ -39,16 +46,16 @@ function register_hooks() { * * @param int $subscription_id */ - function handle_trial_end( $subscription_id ) { + public function handle_trial_end( $subscription_id ) { Subscription_Workflow_Helper::trigger_for_subscription( $this, $subscription_id ); } /** - * @param $workflow Workflow + * @param Workflow $workflow * @return bool */ - function validate_workflow( $workflow ) { + public function validate_workflow( $workflow ) { $subscription = $workflow->data_layer()->get_subscription(); if ( ! $subscription ) { @@ -61,5 +68,4 @@ function validate_workflow( $workflow ) { return true; } - } diff --git a/includes/Usage_Tracking/Initializer.php b/includes/Usage_Tracking/Initializer.php index 3f03423..a3f05bc 100644 --- a/includes/Usage_Tracking/Initializer.php +++ b/includes/Usage_Tracking/Initializer.php @@ -3,7 +3,6 @@ namespace AutomateWoo\Usage_Tracking; use AutomateWoo\Exceptions\InvalidClass; -use WC_Site_Tracking; /** * Static Helper Class for tracks. @@ -27,7 +26,7 @@ class Initializer { * general store data, referred to as the "Tracker". Here we initialize both types of data. */ public static function init() { - if ( ! ( apply_filters( 'automatewoo/usage_tracking/enabled', true ) && WC_Site_Tracking::is_tracking_enabled() ) ) { + if ( ! apply_filters( 'automatewoo/usage_tracking/enabled', true ) || 'yes' !== get_option( 'woocommerce_allow_tracking', 'no' ) ) { return; } diff --git a/includes/Variables/Abstract_Generate_Coupon.php b/includes/Variables/Abstract_Generate_Coupon.php index d95e78a..2e72450 100644 --- a/includes/Variables/Abstract_Generate_Coupon.php +++ b/includes/Variables/Abstract_Generate_Coupon.php @@ -29,7 +29,6 @@ public function load_admin_details() { $this->add_parameter_text_field( 'expires', __( 'Number of days the coupon will be valid for. If left blank then the expiry set for the template coupon will be used.', 'automatewoo' ) ); $this->add_parameter_text_field( 'prefix', __( "The prefix for the coupon code, defaults to 'aw-'. To remove the prefix set this field to a single space character.", 'automatewoo' ), false, 'aw-' ); - $this->add_parameter_text_field( 'prefix', __( "The prefix for the coupon code, defaults to 'aw-'. To remove the prefix set this field to a single space character.", 'automatewoo' ), false, 'aw-' ); $this->add_parameter_text_field( 'limit', __( "The number of times the generated coupon can be used. Set to '0' for unlimited.", 'automatewoo' ), false, '1' ); } @@ -49,7 +48,8 @@ public function generate_coupon( $email, $parameters, $workflow ) { } $coupon_generator = new Coupon_Generator(); - $coupon_generator->set_template_coupon_code( $parameters['template'] ); + $template = html_entity_decode( $parameters['template'] ); + $coupon_generator->set_template_coupon_code( $template ); if ( ! $coupon_generator->get_template_coupon_id() ) { return false; diff --git a/includes/Variables/Subscription_Billing_Address.php b/includes/Variables/Subscription_Billing_Address.php index ace03e7..4e57fbb 100644 --- a/includes/Variables/Subscription_Billing_Address.php +++ b/includes/Variables/Subscription_Billing_Address.php @@ -1,27 +1,30 @@ description = __( "Displays the formatted billing address for the subscription.", 'automatewoo'); + /** + * Method to set description and other admin props + */ + public function load_admin_details() { + $this->description = __( 'Displays the formatted billing address for the subscription.', 'automatewoo' ); } /** - * @param $subscription \WC_Subscription - * @param $parameters array + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { return $subscription->get_formatted_billing_address(); } } diff --git a/includes/Variables/Subscription_End_Date.php b/includes/Variables/Subscription_End_Date.php index 7fb3b21..4e84f9b 100644 --- a/includes/Variables/Subscription_End_Date.php +++ b/includes/Variables/Subscription_End_Date.php @@ -1,29 +1,32 @@ description = __( "Displays the subscription end date in your website's timezone.", 'automatewoo'); + $this->description = __( "Displays the subscription end date in your website's timezone.", 'automatewoo' ); $this->description .= ' ' . $this->_desc_format_tip; } /** - * @param $subscription \WC_Subscription - * @param $parameters + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { return $this->format_datetime( $subscription->get_date( 'end', 'site' ), $parameters ); } } diff --git a/includes/Variables/Subscription_ID.php b/includes/Variables/Subscription_ID.php index 340fd83..6ad9a97 100644 --- a/includes/Variables/Subscription_ID.php +++ b/includes/Variables/Subscription_ID.php @@ -1,9 +1,10 @@ description = __( "Displays the ID of the subscription.", 'automatewoo'); + /** + * Method to set description and other admin props + */ + public function load_admin_details() { + $this->description = __( 'Displays the ID of the subscription.', 'automatewoo' ); } /** - * @param $subscription \WC_Subscription - * @param $parameters + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { return $subscription->get_id(); } } diff --git a/includes/Variables/Subscription_Items.php b/includes/Variables/Subscription_Items.php index 99bbdd6..e3946e3 100644 --- a/includes/Variables/Subscription_Items.php +++ b/includes/Variables/Subscription_Items.php @@ -1,48 +1,54 @@ description = __( "Displays a product listing of items in a subscription.", 'automatewoo'); + $this->description = __( 'Displays a product listing of items in a subscription.', 'automatewoo' ); } /** - * @param $subscription \WC_Subscription - * @param $parameters array - * @param $workflow + * @param \WC_Subscription $subscription + * @param array $parameters + * @param Workflow $workflow * @return string */ - function get_value( $subscription, $parameters, $workflow ) { + public function get_value( $subscription, $parameters, $workflow ) { $template = isset( $parameters['template'] ) ? $parameters['template'] : false; - $items = $subscription->get_items(); + $items = $subscription->get_items(); $products = []; foreach ( $items as $item ) { $products[] = $item->get_product(); } - $args = array_merge( $this->get_default_product_template_args( $workflow, $parameters ), [ - 'products' => $products, - 'subscription' => $subscription, - 'order' => $subscription - ]); + $args = array_merge( + $this->get_default_product_template_args( $workflow, $parameters ), + [ + 'products' => $products, + 'subscription' => $subscription, + 'order' => $subscription, + ] + ); return $this->get_product_display_html( $template, $args ); } - } diff --git a/includes/Variables/Subscription_Last_Payment_Date.php b/includes/Variables/Subscription_Last_Payment_Date.php index b369bf1..0cdcb73 100644 --- a/includes/Variables/Subscription_Last_Payment_Date.php +++ b/includes/Variables/Subscription_Last_Payment_Date.php @@ -1,29 +1,32 @@ description = __( "Displays the date of the most recent payment for the subscription.", 'automatewoo' ); + $this->description = __( 'Displays the date of the most recent payment for the subscription.', 'automatewoo' ); $this->description .= ' ' . $this->_desc_format_tip; } /** - * @param $subscription \WC_Subscription - * @param $parameters + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { return $this->format_datetime( $subscription->get_date( 'last_payment', 'site' ), $parameters ); } } diff --git a/includes/Variables/Subscription_Meta.php b/includes/Variables/Subscription_Meta.php index 9699539..abeae26 100644 --- a/includes/Variables/Subscription_Meta.php +++ b/includes/Variables/Subscription_Meta.php @@ -1,19 +1,22 @@ description = __( "Displays a subscription's custom field.", 'automatewoo'); + $this->description = __( "Displays a subscription's custom field.", 'automatewoo' ); } @@ -23,7 +26,7 @@ function load_admin_details() { * * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { if ( $parameters['key'] ) { return (string) $subscription->get_meta( $parameters['key'] ); } diff --git a/includes/Variables/Subscription_Next_Payment_Date.php b/includes/Variables/Subscription_Next_Payment_Date.php index d251d19..a125207 100644 --- a/includes/Variables/Subscription_Next_Payment_Date.php +++ b/includes/Variables/Subscription_Next_Payment_Date.php @@ -1,29 +1,32 @@ description = __( "Displays the subscription next payment date in your website timezone.", 'automatewoo' ); + $this->description = __( 'Displays the subscription next payment date in your website timezone.', 'automatewoo' ); $this->description .= ' ' . $this->_desc_format_tip; } /** - * @param $subscription \WC_Subscription - * @param $parameters + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { return $this->format_datetime( $subscription->get_date( 'next_payment', 'site' ), $parameters ); } } diff --git a/includes/Variables/Subscription_Payment_Method.php b/includes/Variables/Subscription_Payment_Method.php index 516990d..57ff5ef 100644 --- a/includes/Variables/Subscription_Payment_Method.php +++ b/includes/Variables/Subscription_Payment_Method.php @@ -1,28 +1,30 @@ description = __( "Displays the payment method of the subscription.", 'automatewoo'); + /** + * Method to set description and other admin props + */ + public function load_admin_details() { + $this->description = __( 'Displays the payment method of the subscription.', 'automatewoo' ); } /** - * @param $subscription \WC_Subscription - * @param $parameters + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { return $subscription->get_payment_method_to_display(); } } - diff --git a/includes/Variables/Subscription_Shipping_Address.php b/includes/Variables/Subscription_Shipping_Address.php index acf9a4b..f22a4f2 100644 --- a/includes/Variables/Subscription_Shipping_Address.php +++ b/includes/Variables/Subscription_Shipping_Address.php @@ -1,27 +1,30 @@ description = __( "Displays the formatted shipping address for the subscription.", 'automatewoo'); + /** + * Method to set description and other admin props + */ + public function load_admin_details() { + $this->description = __( 'Displays the formatted shipping address for the subscription.', 'automatewoo' ); } /** - * @param $subscription \WC_Subscription - * @param $parameters array + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { return $subscription->get_formatted_shipping_address(); } } diff --git a/includes/Variables/Subscription_Start_Date.php b/includes/Variables/Subscription_Start_Date.php index 796932d..852a276 100644 --- a/includes/Variables/Subscription_Start_Date.php +++ b/includes/Variables/Subscription_Start_Date.php @@ -1,29 +1,32 @@ description = __( "Displays the subscription start date in your website's timezone.", 'automatewoo' ); + $this->description = __( "Displays the subscription start date in your website's timezone.", 'automatewoo' ); $this->description .= ' ' . $this->_desc_format_tip; } /** - * @param $subscription \WC_Subscription - * @param $parameters + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { $start_date = $subscription->get_date_created(); if ( Integrations::is_subscriptions_active( '2.4' ) ) { diff --git a/includes/Variables/Subscription_Status.php b/includes/Variables/Subscription_Status.php index ba60436..d0c2dfa 100644 --- a/includes/Variables/Subscription_Status.php +++ b/includes/Variables/Subscription_Status.php @@ -1,9 +1,10 @@ description = __( "Displays the formatted status of the subscription.", 'automatewoo'); + /** + * Method to set description and other admin props + */ + public function load_admin_details() { + $this->description = __( 'Displays the formatted status of the subscription.', 'automatewoo' ); } /** - * @param $subscription \WC_Subscription - * @param $parameters + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { return $subscription->get_status(); } } diff --git a/includes/Variables/Subscription_Trial_End_Date.php b/includes/Variables/Subscription_Trial_End_Date.php index 11f2120..49a2aa5 100644 --- a/includes/Variables/Subscription_Trial_End_Date.php +++ b/includes/Variables/Subscription_Trial_End_Date.php @@ -1,29 +1,32 @@ description = __( "Displays the subscription trial end date in your website's timezone.", 'automatewoo' ); + $this->description = __( "Displays the subscription trial end date in your website's timezone.", 'automatewoo' ); $this->description .= ' ' . $this->_desc_format_tip; } /** - * @param $subscription \WC_Subscription - * @param $parameters + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { return $this->format_datetime( $subscription->get_date( 'trial_end' ), $parameters, true ); } } diff --git a/includes/Variables/Subscription_View_Order_Url.php b/includes/Variables/Subscription_View_Order_Url.php index 8008db8..1edcc84 100644 --- a/includes/Variables/Subscription_View_Order_Url.php +++ b/includes/Variables/Subscription_View_Order_Url.php @@ -1,30 +1,32 @@ description = __( "Displays a URL to the subscription page in the My Account area.", 'automatewoo'); + /** + * Method to set description and other admin props + */ + public function load_admin_details() { + $this->description = __( 'Displays a URL to the subscription page in the My Account area.', 'automatewoo' ); } /** - * @param $subscription \WC_Subscription - * @param $parameters + * @param \WC_Subscription $subscription + * @param array $parameters * @return string */ - function get_value( $subscription, $parameters ) { + public function get_value( $subscription, $parameters ) { return ( new Login_Redirect() )->get_login_redirect_url( $subscription->get_view_order_url() ); } - } diff --git a/includes/Workflow_Email.php b/includes/Workflow_Email.php index 11fe351..1e8e065 100644 --- a/includes/Workflow_Email.php +++ b/includes/Workflow_Email.php @@ -388,6 +388,11 @@ function send() { return new \WP_Error( 'email_unsubscribed', __( "The recipient is not opted-in to this workflow.", 'automatewoo' ) ); } + if ( ! $this->workflow->is_transactional() ) { + $mailer->set_one_click_unsubscribe( Frontend::get_communication_page_permalink( $customer, 'unsubscribe' ) ); + } + + \AW_Mailer_API::setup( $mailer, $this->workflow ); $sent = $mailer->send(); diff --git a/languages/automatewoo.pot b/languages/automatewoo.pot index 3b6264d..ef0bd35 100644 --- a/languages/automatewoo.pot +++ b/languages/automatewoo.pot @@ -2,14 +2,14 @@ # This file is distributed under the GPLv3. msgid "" msgstr "" -"Project-Id-Version: AutomateWoo 6.0.24\n" +"Project-Id-Version: AutomateWoo 6.0.25\n" "Report-Msgid-Bugs-To: https://woo.com/my-account/contact-support/\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-05-21T10:40:42+00:00\n" +"POT-Creation-Date: 2024-06-11T22:04:09+02:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.7.1\n" "X-Domain: automatewoo\n" @@ -20,7 +20,7 @@ msgstr "" #: admin/admin.php:149 #: admin/admin.php:161 #: admin/admin.php:825 -#: admin/coupons-list.php:30 +#: admin/coupons-list.php:42 #: admin/WCAdminConnectPages.php:74 #: automatewoo.php:131 #: includes/Actions/Change_Workflow_Status.php:18 @@ -667,12 +667,12 @@ msgstr "" #: admin/data-layer-formatter.php:34 #: admin/reports/conversions-list.php:139 -#: includes/Actions/Order_Add_Note.php:19 -#: includes/Actions/Order_Change_Status.php:19 -#: includes/Actions/Order_Resend_Email.php:19 -#: includes/Actions/Order_Trigger_Action.php:21 -#: includes/Actions/Order_Update_Customer_Shipping_Note.php:18 -#: includes/Actions/Order_Update_Meta.php:18 +#: includes/Actions/Order_Add_Note.php:27 +#: includes/Actions/Order_Change_Status.php:30 +#: includes/Actions/Order_Resend_Email.php:30 +#: includes/Actions/Order_Trigger_Action.php:31 +#: includes/Actions/Order_Update_Customer_Shipping_Note.php:28 +#: includes/Actions/Order_Update_Meta.php:28 #: includes/DataTypes/Order.php:68 #: includes/Privacy_Exporters.php:330 msgid "Order" @@ -684,10 +684,10 @@ msgstr "" #: admin/reports/logs.php:110 #: admin/reports/opt-ins.php:71 #: admin/reports/queue.php:135 -#: includes/Actions/Customer_Add_Tags.php:18 -#: includes/Actions/Customer_Change_Role.php:18 +#: includes/Actions/Customer_Add_Tags.php:26 +#: includes/Actions/Customer_Change_Role.php:28 #: includes/Actions/Customer_Update_Meta.php:18 -#: includes/Actions/Order_Resend_Email.php:48 +#: includes/Actions/Order_Resend_Email.php:62 #: includes/Actions/Points_Rewards_Edit_Points_Abstract.php:30 #: includes/DataTypes/Customer.php:83 #: admin/assets/build/analytics.js:3 @@ -730,10 +730,10 @@ msgstr "" #: includes/Actions/Subscriptions/RecalculateTaxes.php:34 #: includes/Actions/Subscriptions/RegenerateDownloadPermissions.php:32 #: includes/Actions/Subscription_Add_Note.php:29 -#: includes/Actions/Subscription_Change_Status.php:19 -#: includes/Actions/Subscription_Send_Invoice.php:20 -#: includes/Actions/Subscription_Update_Meta.php:19 -#: includes/DataTypes/Subscription.php:65 +#: includes/Actions/Subscription_Change_Status.php:26 +#: includes/Actions/Subscription_Send_Invoice.php:27 +#: includes/Actions/Subscription_Update_Meta.php:24 +#: includes/DataTypes/Subscription.php:66 #: includes/Privacy_Exporters.php:362 msgid "Subscription" msgstr "" @@ -775,16 +775,17 @@ msgid "%1$s – %2$s" msgstr "" #: admin/json-search.php:172 -#: admin/list-table.php:98 +#: admin/list-table.php:88 #: includes/Format.php:299 msgid "[Guest]" msgstr "" -#: admin/list-table.php:47 +#: admin/list-table.php:48 msgid "Search" msgstr "" -#: admin/list-table.php:82 +#. translators: 1: User First name, 2: User Last name +#: admin/list-table.php:73 #: includes/Customer.php:362 #: includes/Data_Layer.php:440 #: includes/Guest.php:200 @@ -793,16 +794,16 @@ msgctxt "full name" msgid "%1$s %2$s" msgstr "" -#: admin/list-table.php:169 +#: admin/list-table.php:164 msgid "Filter" msgstr "" -#: admin/list-table.php:232 +#: admin/list-table.php:241 #: admin/reports/abstract-graph.php:89 msgid "Search for a workflow…" msgstr "" -#: admin/list-table.php:260 +#: admin/list-table.php:272 msgid "Search for a customer…" msgstr "" @@ -889,7 +890,7 @@ msgstr "" #: admin/reports/logs.php:168 #: admin/reports/queue.php:195 #: admin/views/action.php:32 -#: includes/Actions/Campaign_Monitor_Remove_Subscriber.php:28 +#: includes/Actions/Campaign_Monitor_Remove_Subscriber.php:36 msgid "Delete" msgstr "" @@ -1026,7 +1027,7 @@ msgstr "" #: admin/reports/guests.php:42 #: admin/views/page-guest-details.php:44 -#: includes/Actions/Order_Resend_Email.php:57 +#: includes/Actions/Order_Resend_Email.php:72 #: includes/Actions/Send_Email_Abstract.php:34 #: includes/Fields/EmailAddressWithName.php:48 msgid "Email" @@ -1183,7 +1184,7 @@ msgid "Shorten all SMS links" msgstr "" #: admin/settings-tabs/campaign-monitor.php:19 -#: includes/Actions/Campaign_Monitor_Abstract.php:14 +#: includes/Actions/Campaign_Monitor_Abstract.php:20 msgid "Campaign Monitor" msgstr "" @@ -1665,7 +1666,7 @@ msgid "Move to Trash" msgstr "" #: admin/views/meta-box-save.php:117 -#: admin/workflow-list.php:92 +#: admin/workflow-list.php:96 msgid "Run" msgstr "" @@ -1721,7 +1722,7 @@ msgstr "" #: admin/views/meta-box-timing.php:111 #: admin/workflow-edit.php:276 -#: admin/workflow-list.php:43 +#: admin/workflow-list.php:45 msgid "Timing" msgstr "" @@ -2058,25 +2059,26 @@ msgstr "" msgid "Options" msgstr "" -#: admin/workflow-list.php:44 +#: admin/workflow-list.php:46 msgid "Run Count" msgstr "" -#: admin/workflow-list.php:45 +#: admin/workflow-list.php:47 msgid "Queue Count" msgstr "" -#: admin/workflow-list.php:100 +#: admin/workflow-list.php:104 msgid "Toggle Status" msgstr "" -#: admin/workflow-list.php:117 +#. translators: %s: the count of published workflows +#: admin/workflow-list.php:121 msgid "Active (%s)" msgid_plural "Active (%s)" msgstr[0] "" msgstr[1] "" -#: admin/workflow-list.php:212 +#: admin/workflow-list.php:221 #: includes/Triggers/AbstractManual.php:21 #: includes/Workflows.php:48 msgid "Manual" @@ -2125,7 +2127,7 @@ msgid "Contact email" msgstr "" #: includes/Actions/Active_Campaign_Abstract.php:36 -#: includes/Actions/Campaign_Monitor_Abstract.php:25 +#: includes/Actions/Campaign_Monitor_Abstract.php:31 msgid "You can use variables such as {{ customer.email }} here." msgstr "" @@ -2222,7 +2224,7 @@ msgstr "" #: includes/Actions/Active_Campaign_Update_Contact_Field.php:43 #: includes/Actions/Customer_Update_Meta.php:33 -#: includes/Actions/Order_Update_Meta.php:32 +#: includes/Actions/Order_Update_Meta.php:44 #: includes/Actions/Update_Product_Meta.php:32 msgid "Value" msgstr "" @@ -2255,45 +2257,45 @@ msgstr "" msgid "List name" msgstr "" -#: includes/Actions/Campaign_Monitor_Abstract.php:24 +#: includes/Actions/Campaign_Monitor_Abstract.php:30 msgid "Subscriber email" msgstr "" -#: includes/Actions/Campaign_Monitor_Abstract.php:38 +#: includes/Actions/Campaign_Monitor_Abstract.php:44 msgid "Subscriber name" msgstr "" -#: includes/Actions/Campaign_Monitor_Abstract.php:50 +#: includes/Actions/Campaign_Monitor_Abstract.php:56 #: includes/Traits/MailServiceAction.php:27 msgid "List" msgstr "" -#: includes/Actions/Campaign_Monitor_Abstract.php:63 +#: includes/Actions/Campaign_Monitor_Abstract.php:69 #: includes/Subscription_Workflow_Helper.php:235 msgid "Resubscribe" msgstr "" -#: includes/Actions/Campaign_Monitor_Abstract.php:64 +#: includes/Actions/Campaign_Monitor_Abstract.php:70 msgid "If checked the user will be subscribed even if they have already unsubscribed from one of your lists. Use with caution." msgstr "" -#: includes/Actions/Campaign_Monitor_Add_Subscriber.php:15 +#: includes/Actions/Campaign_Monitor_Add_Subscriber.php:20 msgid "Add Subscriber to List" msgstr "" -#: includes/Actions/Campaign_Monitor_Remove_Subscriber.php:15 +#: includes/Actions/Campaign_Monitor_Remove_Subscriber.php:20 msgid "Remove Subscriber From List" msgstr "" -#: includes/Actions/Campaign_Monitor_Remove_Subscriber.php:23 +#: includes/Actions/Campaign_Monitor_Remove_Subscriber.php:30 msgid "Type" msgstr "" -#: includes/Actions/Campaign_Monitor_Remove_Subscriber.php:25 +#: includes/Actions/Campaign_Monitor_Remove_Subscriber.php:32 msgid "If delete is selected the subscriber's email will not be added to the suppression list." msgstr "" -#: includes/Actions/Campaign_Monitor_Remove_Subscriber.php:27 +#: includes/Actions/Campaign_Monitor_Remove_Subscriber.php:35 #: includes/Workflow_Email.php:310 msgid "Unsubscribe" msgstr "" @@ -2322,29 +2324,29 @@ msgstr "" msgid "Customer email" msgstr "" -#: includes/Actions/Customer_Add_Tags.php:17 +#: includes/Actions/Customer_Add_Tags.php:25 msgid "Add Tags" msgstr "" -#: includes/Actions/Customer_Add_Tags.php:19 +#: includes/Actions/Customer_Add_Tags.php:27 msgid "Please note that tags are not supported on guest customers." msgstr "" -#: includes/Actions/Customer_Change_Role.php:17 +#: includes/Actions/Customer_Change_Role.php:27 msgid "Change Role" msgstr "" -#: includes/Actions/Customer_Change_Role.php:19 +#: includes/Actions/Customer_Change_Role.php:29 msgid "Please note that if the customer is a guest this action will do nothing." msgstr "" -#: includes/Actions/Customer_Remove_Tags.php:15 +#: includes/Actions/Customer_Remove_Tags.php:19 msgid "Remove Tags" msgstr "" #: includes/Actions/Customer_Update_Meta.php:17 -#: includes/Actions/Order_Update_Meta.php:17 -#: includes/Actions/Subscription_Update_Meta.php:18 +#: includes/Actions/Order_Update_Meta.php:27 +#: includes/Actions/Subscription_Update_Meta.php:23 #: includes/Actions/Update_Product_Meta.php:17 msgid "Update Custom Field" msgstr "" @@ -2354,7 +2356,7 @@ msgid "This action can add or update a customer's custom field. If the customer msgstr "" #: includes/Actions/Customer_Update_Meta.php:27 -#: includes/Actions/Order_Update_Meta.php:26 +#: includes/Actions/Order_Update_Meta.php:38 #: includes/Actions/Update_Product_Meta.php:26 msgid "Key" msgstr "" @@ -2479,6 +2481,7 @@ msgid "Existing plan" msgstr "" #: includes/Actions/Memberships_Change_Plan.php:32 +#: includes/Actions/Memberships_Change_Status.php:47 msgid "[None]" msgstr "" @@ -2514,6 +2517,48 @@ msgstr "" msgid "Membership plan changed from %s to %s by AutomateWoo workflow:#%s" msgstr "" +#: includes/Actions/Memberships_Change_Status.php:24 +msgid "Update the status of a user's current membership plan" +msgstr "" + +#: includes/Actions/Memberships_Change_Status.php:25 +msgid "Changes the status of a users membership. The action will only run if a membership already exists for the user." +msgstr "" + +#: includes/Actions/Memberships_Change_Status.php:40 +msgid "Membership Plan" +msgstr "" + +#: includes/Actions/Memberships_Change_Status.php:46 +msgid "Current Status" +msgstr "" + +#: includes/Actions/Memberships_Change_Status.php:48 +msgid "Leave this blank to set the new status regardless of the existing status." +msgstr "" + +#: includes/Actions/Memberships_Change_Status.php:53 +msgid "New Status" +msgstr "" + +#: includes/Actions/Memberships_Change_Status.php:58 +#: includes/Actions/Order_Add_Note.php:48 +#: includes/Actions/Order_Update_Customer_Shipping_Note.php:39 +msgid "Note" +msgstr "" + +#: includes/Actions/Memberships_Change_Status.php:80 +msgid "No change made to membership because the current status is the same as the new status." +msgstr "" + +#: includes/Actions/Memberships_Change_Status.php:87 +msgid "Could not find an active membership for the customer." +msgstr "" + +#: includes/Actions/Memberships_Change_Status.php:92 +msgid "Membership status doesn't match value specified in Action settings." +msgstr "" + #: includes/Actions/Memberships_Delete_User_Membership.php:19 msgid "Delete Membership For User" msgstr "" @@ -2534,34 +2579,30 @@ msgstr "" msgid "Failed deleting membership #%s" msgstr "" -#: includes/Actions/Order_Add_Note.php:18 +#: includes/Actions/Order_Add_Note.php:26 #: includes/Actions/Subscription_Add_Note.php:28 msgid "Add Note" msgstr "" -#: includes/Actions/Order_Add_Note.php:29 +#: includes/Actions/Order_Add_Note.php:39 msgid "Note author" msgstr "" -#: includes/Actions/Order_Add_Note.php:32 +#: includes/Actions/Order_Add_Note.php:42 msgid "Author of the Note. If not set, will default to 'WooCommerce'" msgstr "" -#: includes/Actions/Order_Add_Note.php:38 -#: includes/Actions/Order_Update_Customer_Shipping_Note.php:29 -msgid "Note" -msgstr "" - -#: includes/Actions/Order_Change_Status.php:18 -#: includes/Actions/Subscription_Change_Status.php:18 +#: includes/Actions/Order_Change_Status.php:29 +#: includes/Actions/Subscription_Change_Status.php:25 msgid "Change Status" msgstr "" -#: includes/Actions/Order_Change_Status.php:25 +#: includes/Actions/Order_Change_Status.php:38 msgid "Order status will be changed to this." msgstr "" -#: includes/Actions/Order_Change_Status.php:40 +#. translators: The workflow ID +#: includes/Actions/Order_Change_Status.php:58 msgid "AutomateWoo workflow #%s." msgstr "" @@ -2573,51 +2614,52 @@ msgstr "" msgid "This action can add or update an order item's custom field." msgstr "" -#: includes/Actions/Order_Resend_Email.php:18 +#: includes/Actions/Order_Resend_Email.php:29 msgid "Resend Order Email" msgstr "" -#: includes/Actions/Order_Resend_Email.php:20 +#: includes/Actions/Order_Resend_Email.php:31 msgid "Please note that email tracking is not currently supported on this action." msgstr "" -#: includes/Actions/Order_Resend_Email.php:45 +#: includes/Actions/Order_Resend_Email.php:60 msgid "Admin" msgstr "" -#: includes/Actions/Order_Resend_Email.php:96 -msgid "%s email notification sent by AutomateWoo workflow #%d" +#. translators: %1$s Mail title, %2$d The Workflow ID +#: includes/Actions/Order_Resend_Email.php:117 +msgid "%1$s email notification sent by AutomateWoo workflow #%2$d" msgstr "" -#: includes/Actions/Order_Trigger_Action.php:20 +#: includes/Actions/Order_Trigger_Action.php:30 msgid "Trigger Order Action" msgstr "" -#: includes/Actions/Order_Trigger_Action.php:22 +#: includes/Actions/Order_Trigger_Action.php:32 msgid "Not to be confused with AutomateWoo actions this action can trigger a WooCommerce order action. They can normally be found in the in the top right of of the order edit view." msgstr "" -#: includes/Actions/Order_Trigger_Action.php:30 +#: includes/Actions/Order_Trigger_Action.php:42 msgid "Order action" msgstr "" -#: includes/Actions/Order_Trigger_Action.php:60 +#: includes/Actions/Order_Trigger_Action.php:72 msgid "Generate download permissions" msgstr "" -#: includes/Actions/Order_Update_Customer_Shipping_Note.php:17 +#: includes/Actions/Order_Update_Customer_Shipping_Note.php:27 msgid "Update Customer Provided Note" msgstr "" -#: includes/Actions/Order_Update_Customer_Shipping_Note.php:35 +#: includes/Actions/Order_Update_Customer_Shipping_Note.php:45 msgid "Append to existing note?" msgstr "" -#: includes/Actions/Order_Update_Customer_Shipping_Note.php:36 +#: includes/Actions/Order_Update_Customer_Shipping_Note.php:46 msgid "If checked and there is an existing customer shipping note for this order the note on this action will added to the field after a pipe (|). If unchecked any existing note will be replaced." msgstr "" -#: includes/Actions/Order_Update_Meta.php:19 +#: includes/Actions/Order_Update_Meta.php:29 msgid "This action can add or update an order's custom field." msgstr "" @@ -3039,24 +3081,19 @@ msgstr "" msgid "%1$s workflow run: updated trial end date to %2$s. (Workflow ID: %3$d)" msgstr "" -#: includes/Actions/Subscription_Add_Coupon.php:23 +#: includes/Actions/Subscription_Add_Coupon.php:30 msgid "Add Coupon" msgstr "" -#: includes/Actions/Subscription_Add_Coupon.php:24 +#: includes/Actions/Subscription_Add_Coupon.php:31 msgid "Add a coupon to discount future payments for a subscription. The coupon will be added using the discount amount set on the coupon. This action can be used for bulk editing subscriptions, or to change the coupons provided to a subscriber at different stages of their subscription's lifecycle. The same coupon code will only be added once to a subscription. Only recurring coupon types can be added." msgstr "" #. translators: %1$s: workflow title, %2$s coupon code, %3$d workflow ID -#: includes/Actions/Subscription_Add_Coupon.php:59 +#: includes/Actions/Subscription_Add_Coupon.php:66 msgid "%1$s workflow run: added coupon %2$s to subscription. (Workflow ID: %3$d)" msgstr "" -#: includes/Actions/Subscription_Add_Coupon.php:69 -#: includes/Actions/Subscription_Edit_Coupon_Abstract.php:49 -msgid "Coupon" -msgstr "" - #: includes/Actions/Subscription_Add_Product.php:48 msgid "Add Product" msgstr "" @@ -3070,10 +3107,15 @@ msgstr "" msgid "%1$s workflow run: added %2$s to subscription. (Product ID: %3$d; Workflow ID: %4$d)" msgstr "" -#: includes/Actions/Subscription_Change_Status.php:42 +#. translators: The Workflow ID +#: includes/Actions/Subscription_Change_Status.php:57 msgid "Subscription status changed by AutomateWoo Workflow #%s." msgstr "" +#: includes/Actions/Subscription_Edit_Coupon_Abstract.php:63 +msgid "Coupon" +msgstr "" + #: includes/Actions/Subscription_Edit_Product_Abstract.php:106 msgid "Custom Product Name" msgstr "" @@ -3116,15 +3158,15 @@ msgstr "" msgid "%1$s workflow run: removed all line items for %2$s. (Product ID: %3$d; Workflow ID: %4$d)" msgstr "" -#: includes/Actions/Subscription_Send_Invoice.php:18 +#: includes/Actions/Subscription_Send_Invoice.php:25 msgid "Send Invoice" msgstr "" -#: includes/Actions/Subscription_Send_Invoice.php:19 +#: includes/Actions/Subscription_Send_Invoice.php:26 msgid "Email the invoice to the subscription customer." msgstr "" -#: includes/Actions/Subscription_Update_Meta.php:20 +#: includes/Actions/Subscription_Update_Meta.php:25 msgid "This action can add or update a subscription's custom field. Please note that it should not be used to update internal fields like the subscription schedule." msgstr "" @@ -3233,6 +3275,11 @@ msgstr "" msgid "Communication" msgstr "" +#: includes/Communication_Page.php:64 +#: includes/Frontend_Form_Handler.php:89 +msgid "Saved successfully! You won't receive marketing communications from us." +msgstr "" + #: includes/Coupon_Generator.php:46 msgid "Generated by AutomateWoo" msgstr "" @@ -3331,7 +3378,7 @@ msgstr "" msgid "Teachers" msgstr "" -#: includes/DataTypes/Subscription.php:76 +#: includes/DataTypes/Subscription.php:77 #: includes/Subscription_Workflow_Helper.php:22 #: includes/Triggers/Utilities/SubscriptionGroup.php:18 msgid "Subscriptions" @@ -3398,8 +3445,8 @@ msgstr "" #: includes/Fields/BookingStatus.php:24 #: includes/Fields/Order_Status.php:24 -#: includes/Fields/Subscription_Products.php:27 -#: includes/Fields/Subscription_Status.php:26 +#: includes/Fields/Subscription_Products.php:32 +#: includes/Fields/Subscription_Status.php:28 #: includes/Subscription_Workflow_Helper.php:252 msgid "[Any]" msgstr "" @@ -3486,12 +3533,12 @@ msgstr "" msgid "(Quiz not found)" msgstr "" -#: includes/Fields/Subscription_Products.php:26 +#: includes/Fields/Subscription_Products.php:31 #: includes/Subscription_Workflow_Helper.php:33 msgid "Subscription products" msgstr "" -#: includes/Fields/Subscription_Status.php:23 +#: includes/Fields/Subscription_Status.php:25 msgid "Subscription status" msgstr "" @@ -3525,7 +3572,7 @@ msgctxt "time field" msgid "MM" msgstr "" -#: includes/Fields/User_Role.php:22 +#: includes/Fields/User_Role.php:27 msgid "User role" msgstr "" @@ -3602,10 +3649,6 @@ msgstr "" msgid "Thanks! Your signup was successful." msgstr "" -#: includes/Frontend_Form_Handler.php:89 -msgid "Saved successfully! You won't receive marketing communications from us." -msgstr "" - #. translators: 1: Deprecated class name, 2: Version number, 3: Replacement class name. #: includes/helpers.php:763 msgid "%1$s is deprecated since version %2$s! Use %3$s instead." @@ -3654,10 +3697,6 @@ msgstr "" msgid "Unexpected response when trying to retrieve all custom fields" msgstr "" -#: includes/Integrations/ActiveCampaign.php:401 -msgid "Unexpected response when attempting to create a tag" -msgstr "" - #: includes/Jobs/JobException.php:34 msgid "Job item not found." msgstr "" @@ -3679,28 +3718,28 @@ msgstr "" msgid "This log was created from manual workflow re-run." msgstr "" -#: includes/Mailer_Abstract.php:138 +#: includes/Mailer_Abstract.php:157 msgid "Email address is blank." msgstr "" -#: includes/Mailer_Abstract.php:142 +#: includes/Mailer_Abstract.php:161 msgid "Email address is not valid." msgstr "" -#: includes/Mailer_Abstract.php:146 +#: includes/Mailer_Abstract.php:165 msgid "Email address appears to be anonymized." msgstr "" -#: includes/Mailer_Abstract.php:158 +#: includes/Mailer_Abstract.php:177 msgid "Email address is blacklisted." msgstr "" #. translators: PHP Mailer error message. -#: includes/Mailer_Abstract.php:214 +#: includes/Mailer_Abstract.php:238 msgid "PHP Mailer - %s" msgstr "" -#: includes/Mailer_Abstract.php:217 +#: includes/Mailer_Abstract.php:241 msgid "The wp_mail() function returned false." msgstr "" @@ -5040,7 +5079,7 @@ msgstr "" msgid "Order - Status" msgstr "" -#: includes/Rules/Order_Subscription_Failed_Automatic_Payment_Retry_Count.php:19 +#: includes/Rules/Order_Subscription_Failed_Automatic_Payment_Retry_Count.php:23 msgid "Order - Subscription Failed Automatic Payment Retry Count" msgstr "" @@ -5198,7 +5237,7 @@ msgstr "" msgid "Shop - Current Date/Time" msgstr "" -#: includes/Rules/SubscriptionPaymentCount.php:21 +#: includes/Rules/SubscriptionPaymentCount.php:26 msgid "Subscription - Payment Count" msgstr "" @@ -5230,7 +5269,7 @@ msgstr "" msgid "Subscription - Has Payment Method" msgstr "" -#: includes/Rules/Subscription_Items.php:18 +#: includes/Rules/Subscription_Items.php:21 msgid "Subscription - Items" msgstr "" @@ -5262,7 +5301,7 @@ msgstr "" msgid "Workflow - Run Count For Subscription" msgstr "" -#: includes/Rules/Subscription_Status.php:27 +#: includes/Rules/Subscription_Status.php:30 msgid "Subscription - Status" msgstr "" @@ -5993,15 +6032,15 @@ msgstr "" msgid "Manual - Subscriptions" msgstr "" -#: includes/Triggers/Subscription_Before_End.php:17 +#: includes/Triggers/Subscription_Before_End.php:22 msgid "Subscription Before End" msgstr "" -#: includes/Triggers/Subscription_Before_End.php:18 +#: includes/Triggers/Subscription_Before_End.php:23 msgid "This trigger runs once per day for any subscriptions that are due to expire/end on the workflow's target date. For example, if set to run 7 days before end, it would look for subscriptions that are due to end on the date exactly 7 days from now." msgstr "" -#: includes/Triggers/Subscription_Before_End.php:29 +#: includes/Triggers/Subscription_Before_End.php:36 msgid "Days before end" msgstr "" @@ -6065,11 +6104,11 @@ msgstr "" msgid "This trigger fires after the status of any subscription order changes. The trigger can be set to run on specific order status changes and for specific order types." msgstr "" -#: includes/Triggers/Subscription_Payment_Complete.php:30 +#: includes/Triggers/Subscription_Payment_Complete.php:33 msgid "Subscription Renewal Payment Complete" msgstr "" -#: includes/Triggers/Subscription_Payment_Failed.php:30 +#: includes/Triggers/Subscription_Payment_Failed.php:33 msgid "Subscription Renewal Payment Failed" msgstr "" @@ -6097,7 +6136,7 @@ msgstr "" msgid "This trigger runs for every line item of a subscription when the status changes. Using this trigger allows access to the product data of the subscription line item." msgstr "" -#: includes/Triggers/Subscription_Trial_End.php:23 +#: includes/Triggers/Subscription_Trial_End.php:26 msgid "Subscription Trial End" msgstr "" @@ -6333,11 +6372,10 @@ msgid "Number of days the coupon will be valid for. If left blank then the expir msgstr "" #: includes/Variables/Abstract_Generate_Coupon.php:31 -#: includes/Variables/Abstract_Generate_Coupon.php:32 msgid "The prefix for the coupon code, defaults to 'aw-'. To remove the prefix set this field to a single space character." msgstr "" -#: includes/Variables/Abstract_Generate_Coupon.php:33 +#: includes/Variables/Abstract_Generate_Coupon.php:32 msgid "The number of times the generated coupon can be used. Set to '0' for unlimited." msgstr "" @@ -7190,7 +7228,7 @@ msgstr "" msgid "Displays the admin URL of the subscription." msgstr "" -#: includes/Variables/Subscription_Billing_Address.php:15 +#: includes/Variables/Subscription_Billing_Address.php:18 msgid "Displays the formatted billing address for the subscription." msgstr "" @@ -7202,15 +7240,15 @@ msgstr "" msgid "Displays the early renewal URL for the subscription." msgstr "" -#: includes/Variables/Subscription_End_Date.php:16 +#: includes/Variables/Subscription_End_Date.php:19 msgid "Displays the subscription end date in your website's timezone." msgstr "" -#: includes/Variables/Subscription_ID.php:15 +#: includes/Variables/Subscription_ID.php:19 msgid "Displays the ID of the subscription." msgstr "" -#: includes/Variables/Subscription_Items.php:19 +#: includes/Variables/Subscription_Items.php:23 msgid "Displays a product listing of items in a subscription." msgstr "" @@ -7230,15 +7268,15 @@ msgstr "" msgid "Can be used to display the quantity of a product line item on a subscription." msgstr "" -#: includes/Variables/Subscription_Last_Payment_Date.php:16 +#: includes/Variables/Subscription_Last_Payment_Date.php:19 msgid "Displays the date of the most recent payment for the subscription." msgstr "" -#: includes/Variables/Subscription_Meta.php:16 +#: includes/Variables/Subscription_Meta.php:19 msgid "Displays a subscription's custom field." msgstr "" -#: includes/Variables/Subscription_Next_Payment_Date.php:16 +#: includes/Variables/Subscription_Next_Payment_Date.php:19 msgid "Displays the subscription next payment date in your website timezone." msgstr "" @@ -7246,7 +7284,7 @@ msgstr "" msgid "Displays the subscription payment count." msgstr "" -#: includes/Variables/Subscription_Payment_Method.php:15 +#: includes/Variables/Subscription_Payment_Method.php:18 msgid "Displays the payment method of the subscription." msgstr "" @@ -7254,15 +7292,15 @@ msgstr "" msgid "Displays the subscription retry payment date in your website timezone." msgstr "" -#: includes/Variables/Subscription_Shipping_Address.php:15 +#: includes/Variables/Subscription_Shipping_Address.php:18 msgid "Displays the formatted shipping address for the subscription." msgstr "" -#: includes/Variables/Subscription_Start_Date.php:16 +#: includes/Variables/Subscription_Start_Date.php:19 msgid "Displays the subscription start date in your website's timezone." msgstr "" -#: includes/Variables/Subscription_Status.php:15 +#: includes/Variables/Subscription_Status.php:19 msgid "Displays the formatted status of the subscription." msgstr "" @@ -7270,11 +7308,11 @@ msgstr "" msgid "Displays the subscription's recurring total." msgstr "" -#: includes/Variables/Subscription_Trial_End_Date.php:16 +#: includes/Variables/Subscription_Trial_End_Date.php:19 msgid "Displays the subscription trial end date in your website's timezone." msgstr "" -#: includes/Variables/Subscription_View_Order_Url.php:17 +#: includes/Variables/Subscription_View_Order_Url.php:20 msgid "Displays a URL to the subscription page in the My Account area." msgstr "" diff --git a/vendor/autoload.php b/vendor/autoload.php index f588bd8..0a62002 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit501aaec42a52b6b5999b0388f6df3351::getLoader(); +return ComposerAutoloaderInitcd76d69e344355b0d078ee38c544eff0::getLoader(); diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index a72151c..7824d8f 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -45,35 +45,34 @@ class ClassLoader /** @var \Closure(string):void */ private static $includeFile; - /** @var ?string */ + /** @var string|null */ private $vendorDir; // PSR-4 /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixLengthsPsr4 = array(); /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixDirsPsr4 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr4 = array(); // PSR-0 /** - * @var array[] - * @psalm-var array> + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> */ private $prefixesPsr0 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr0 = array(); @@ -81,8 +80,7 @@ class ClassLoader private $useIncludePath = false; /** - * @var string[] - * @psalm-var array + * @var array */ private $classMap = array(); @@ -90,21 +88,20 @@ class ClassLoader private $classMapAuthoritative = false; /** - * @var bool[] - * @psalm-var array + * @var array */ private $missingClasses = array(); - /** @var ?string */ + /** @var string|null */ private $apcuPrefix; /** - * @var self[] + * @var array */ private static $registeredLoaders = array(); /** - * @param ?string $vendorDir + * @param string|null $vendorDir */ public function __construct($vendorDir = null) { @@ -113,7 +110,7 @@ public function __construct($vendorDir = null) } /** - * @return string[] + * @return array> */ public function getPrefixes() { @@ -125,8 +122,7 @@ public function getPrefixes() } /** - * @return array[] - * @psalm-return array> + * @return array> */ public function getPrefixesPsr4() { @@ -134,8 +130,7 @@ public function getPrefixesPsr4() } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirs() { @@ -143,8 +138,7 @@ public function getFallbackDirs() } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirsPsr4() { @@ -152,8 +146,7 @@ public function getFallbackDirsPsr4() } /** - * @return string[] Array of classname => path - * @psalm-return array + * @return array Array of classname => path */ public function getClassMap() { @@ -161,8 +154,7 @@ public function getClassMap() } /** - * @param string[] $classMap Class to filename map - * @psalm-param array $classMap + * @param array $classMap Class to filename map * * @return void */ @@ -179,24 +171,25 @@ public function addClassMap(array $classMap) * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories * * @return void */ public function add($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, - (array) $paths + $paths ); } @@ -205,19 +198,19 @@ public function add($prefix, $paths, $prepend = false) $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; + $this->prefixesPsr0[$first][$prefix] = $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], - (array) $paths + $paths ); } } @@ -226,9 +219,9 @@ public function add($prefix, $paths, $prepend = false) * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException * @@ -236,17 +229,18 @@ public function add($prefix, $paths, $prepend = false) */ public function addPsr4($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, - (array) $paths + $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { @@ -256,18 +250,18 @@ public function addPsr4($prefix, $paths, $prepend = false) throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; + $this->prefixDirsPsr4[$prefix] = $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - (array) $paths + $paths ); } } @@ -276,8 +270,8 @@ public function addPsr4($prefix, $paths, $prepend = false) * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories * * @return void */ @@ -294,8 +288,8 @@ public function set($prefix, $paths) * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -481,9 +475,9 @@ public function findFile($class) } /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. + * Returns the currently registered loaders keyed by their corresponding vendor directories. * - * @return self[] + * @return array */ public static function getRegisteredLoaders() { diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index c6b54af..51e734a 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -98,7 +98,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; } } @@ -119,7 +119,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) */ public static function satisfies(VersionParser $parser, $packageName, $constraint) { - $constraint = $parser->parseConstraints($constraint); + $constraint = $parser->parseConstraints((string) $constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); @@ -328,7 +328,9 @@ private static function getInstalled() if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { self::$installed = $installed[count($installed) - 1]; } @@ -340,12 +342,17 @@ private static function getInstalled() // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; } else { self::$installed = array(); } } - $installed[] = self::$installed; + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } return $installed; } diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 3347463..0879b75 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -49,6 +49,7 @@ 'AutomateWoo\\Action_Mailpoet_Unsubscribe' => $baseDir . '/includes/Actions/Mailpoet_Unsubscribe.php', 'AutomateWoo\\Action_Memberships_Abstract' => $baseDir . '/includes/Actions/Memberships_Abstract.php', 'AutomateWoo\\Action_Memberships_Change_Plan' => $baseDir . '/includes/Actions/Memberships_Change_Plan.php', + 'AutomateWoo\\Action_Memberships_Change_Status' => $baseDir . '/includes/Actions/Memberships_Change_Status.php', 'AutomateWoo\\Action_Memberships_Delete_User_Membership' => $baseDir . '/includes/Actions/Memberships_Delete_User_Membership.php', 'AutomateWoo\\Action_Order_Add_Note' => $baseDir . '/includes/Actions/Order_Add_Note.php', 'AutomateWoo\\Action_Order_Change_Status' => $baseDir . '/includes/Actions/Order_Change_Status.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 6581b4f..6edc6ad 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit501aaec42a52b6b5999b0388f6df3351 +class ComposerAutoloaderInitcd76d69e344355b0d078ee38c544eff0 { private static $loader; @@ -24,12 +24,12 @@ public static function getLoader() require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInit501aaec42a52b6b5999b0388f6df3351', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitcd76d69e344355b0d078ee38c544eff0', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit501aaec42a52b6b5999b0388f6df3351', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitcd76d69e344355b0d078ee38c544eff0', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit501aaec42a52b6b5999b0388f6df3351::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitcd76d69e344355b0d078ee38c544eff0::getInitializer($loader)); $loader->register(true); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 7a3ecf9..c6c76d0 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit501aaec42a52b6b5999b0388f6df3351 +class ComposerStaticInitcd76d69e344355b0d078ee38c544eff0 { public static $prefixLengthsPsr4 = array ( 'A' => @@ -69,6 +69,7 @@ class ComposerStaticInit501aaec42a52b6b5999b0388f6df3351 'AutomateWoo\\Action_Mailpoet_Unsubscribe' => __DIR__ . '/../..' . '/includes/Actions/Mailpoet_Unsubscribe.php', 'AutomateWoo\\Action_Memberships_Abstract' => __DIR__ . '/../..' . '/includes/Actions/Memberships_Abstract.php', 'AutomateWoo\\Action_Memberships_Change_Plan' => __DIR__ . '/../..' . '/includes/Actions/Memberships_Change_Plan.php', + 'AutomateWoo\\Action_Memberships_Change_Status' => __DIR__ . '/../..' . '/includes/Actions/Memberships_Change_Status.php', 'AutomateWoo\\Action_Memberships_Delete_User_Membership' => __DIR__ . '/../..' . '/includes/Actions/Memberships_Delete_User_Membership.php', 'AutomateWoo\\Action_Order_Add_Note' => __DIR__ . '/../..' . '/includes/Actions/Order_Add_Note.php', 'AutomateWoo\\Action_Order_Change_Status' => __DIR__ . '/../..' . '/includes/Actions/Order_Change_Status.php', @@ -994,9 +995,9 @@ class ComposerStaticInit501aaec42a52b6b5999b0388f6df3351 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit501aaec42a52b6b5999b0388f6df3351::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit501aaec42a52b6b5999b0388f6df3351::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit501aaec42a52b6b5999b0388f6df3351::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitcd76d69e344355b0d078ee38c544eff0::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitcd76d69e344355b0d078ee38c544eff0::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitcd76d69e344355b0d078ee38c544eff0::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 4bcf6bb..b3985bd 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,9 +1,9 @@ array( 'name' => 'woocommerce/automatewoo', - 'pretty_version' => 'dev-release/6.0.24', - 'version' => 'dev-release/6.0.24', - 'reference' => '8fded7348531a3347334ea4f1e9f6519bb65bc32', + 'pretty_version' => 'dev-release/6.0.25', + 'version' => 'dev-release/6.0.25', + 'reference' => 'bf5b981c5d6cbe0a05c9287bdeb842b95f4b64f1', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -11,9 +11,9 @@ ), 'versions' => array( 'woocommerce/automatewoo' => array( - 'pretty_version' => 'dev-release/6.0.24', - 'version' => 'dev-release/6.0.24', - 'reference' => '8fded7348531a3347334ea4f1e9f6519bb65bc32', + 'pretty_version' => 'dev-release/6.0.25', + 'version' => 'dev-release/6.0.25', + 'reference' => 'bf5b981c5d6cbe0a05c9287bdeb842b95f4b64f1', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),