Version Description
Download this release
Release Info
Developer | constantcontact |
Plugin | Creative Mail – Easier WordPress & WooCommerce Email Marketing |
Version | 1.4.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.9 to 1.4.0
- CHANGELOG.md +4 -0
- README.md +2 -1
- assets/js/block/submit.js +1 -0
- assets/js/block/subscribe.asset.php +1 -0
- assets/js/block/subscribe.css +4 -0
- assets/js/block/subscribe.js +1 -0
- assets/js/subscribe/submit.js +38 -0
- composer.json +1 -0
- creative-mail-plugin.php +33 -3
- readme.txt +2 -1
- src/CreativeMail.php +9 -0
- src/blocks/LoadBlock.php +33 -0
- src/blocks/subscribe/block.json +68 -0
- src/blocks/subscribe/edit.js +365 -0
- src/blocks/subscribe/editor.scss +7 -0
- src/blocks/subscribe/index.js +27 -0
- src/blocks/subscribe/save.js +160 -0
- src/blocks/subscribe/style.scss +47 -0
- src/clients/CreativeMailClient.php +14 -0
- src/helpers/EncryptionHelper.php +1 -0
- src/managers/ApiManager.php +35 -2
- src/managers/FormManager.php +90 -0
- src/managers/IntegrationManager.php +12 -0
- src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php +3 -1
- src/modules/contacts/Handlers/CreativeMailPluginHandler.php +69 -0
- src/modules/contacts/Handlers/ElementorPluginHandler.php +1 -1
- src/modules/contacts/Handlers/WooCommercePluginHandler.php +5 -3
- src/modules/contacts/Managers/ContactsSyncManager.php +5 -5
- src/modules/contacts/models/ContactModel.php +13 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_classmap.php +3 -0
- vendor/composer/autoload_psr4.php +1 -0
- vendor/composer/autoload_real.php +4 -4
- vendor/composer/autoload_static.php +13 -5
CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
Changelog
|
2 |
=========
|
3 |
|
|
|
|
|
|
|
|
|
4 |
#### 1.3.9 - May 26 2021
|
5 |
- Include notice when you have enabled a password protection plugin.
|
6 |
|
1 |
Changelog
|
2 |
=========
|
3 |
|
4 |
+
|
5 |
+
#### 1.4.0 - June 15 2021
|
6 |
+
- Added gutenberg contact form block CreativeMail
|
7 |
+
|
8 |
#### 1.3.9 - May 26 2021
|
9 |
- Include notice when you have enabled a password protection plugin.
|
10 |
|
README.md
CHANGED
@@ -3,7 +3,7 @@ Contributors: Constant Contact
|
|
3 |
Tags: email, marketing, newsletter, subscribe, contact form, constant contact, crm, automations, ecommerce, promotion, offers, retargeting
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 5.7
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
Requires PHP: 5.6
|
@@ -90,6 +90,7 @@ Creative Mail by Constant Contact [Privacy Notice](https://www.endurance.com/pri
|
|
90 |
6. Enhance your brand with logomaker
|
91 |
|
92 |
== Changelog ==
|
|
|
93 |
* 1.3.9 - Include notice when you have enabled a password protection plugin.
|
94 |
* 1.3.8 - Fixes an issue with WooCommerce recommendations.
|
95 |
* 1.3.7 - Fixes an issue specific to PHP 7.4
|
3 |
Tags: email, marketing, newsletter, subscribe, contact form, constant contact, crm, automations, ecommerce, promotion, offers, retargeting
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 5.7
|
6 |
+
Stable tag: 1.4.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
Requires PHP: 5.6
|
90 |
6. Enhance your brand with logomaker
|
91 |
|
92 |
== Changelog ==
|
93 |
+
* 1.4.0 - Added gutenberg contact form block CreativeMail
|
94 |
* 1.3.9 - Include notice when you have enabled a password protection plugin.
|
95 |
* 1.3.8 - Fixes an issue with WooCommerce recommendations.
|
96 |
* 1.3.7 - Fixes an issue specific to PHP 7.4
|
assets/js/block/submit.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t){function n(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,l=function(){};return{s:l,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:l}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}!function(){var e,t=n(document.getElementsByClassName("cm-contact-form"));try{for(t.s();!(e=t.n()).done;){e.value.onsubmit=function(e){var t,n,r,o,l,i,a,u;e.preventDefault();var s=e.target,c=null===(t=s.getElementsByClassName("firstName")[0])||void 0===t?void 0:t.value,f=null===(n=s.getElementsByClassName("lastName")[0])||void 0===n?void 0:n.value,d=null===(r=s.getElementsByClassName("email")[0])||void 0===r?void 0:r.value,m=null===(o=s.getElementsByClassName("telephone")[0])||void 0===o?void 0:o.value,v=null===(l=s.getElementsByClassName("consent_check")[0])||void 0===l?void 0:l.checked,y=(null===(i=s.getElementsByClassName("list_id")[0])||void 0===i?void 0:i.value)||null;jQuery.post(null===(a=ce4wp_form_submit_data)||void 0===a?void 0:a.url,{action:"ce4wp_form_submission",nonce:null===(u=ce4wp_form_submit_data)||void 0===u?void 0:u.nonce,first_name:c,last_name:f,email:d,telephone:m,consent:v,list_id:y}).done((function(){s.style.visibility="hidden",s.parentElement.getElementsByClassName("onSubmission")[0].style.display="block"}))}}}catch(e){t.e(e)}finally{t.f()}}()}]);
|
assets/js/block/subscribe.asset.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '3e53aedd2b98369b19de93a5627cad33');
|
assets/js/block/subscribe.css
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
.wp-block-ce4wp-subscribe{max-width:840px;margin:0 auto}.wp-block-ce4wp-subscribe .title{margin-bottom:0}.wp-block-ce4wp-subscribe .subTitle{margin-top:0;font-size:0.8em}.wp-block-ce4wp-subscribe .disclaimer{margin-top:5px;font-size:0.8em}.wp-block-ce4wp-subscribe .disclaimer .disclaimer-label{margin-left:10px}.wp-block-ce4wp-subscribe .inputBlock{width:100%;margin-bottom:10px}.wp-block-ce4wp-subscribe .inputBlock input{width:100%}.wp-block-ce4wp-subscribe .inputBlock label{display:inline-block}.wp-block-ce4wp-subscribe .submit-button{margin-top:10px;display:block}.wp-block-ce4wp-subscribe .required-text{display:inline-block;margin:0;padding:0;margin-left:0.3em}.wp-block-ce4wp-subscribe .onSubmission{height:0;max-width:840px;margin:0 auto}.ce4wp-link{cursor:pointer}
|
2 |
+
|
3 |
+
.no-flex{display:block}.sub-header{margin-bottom:1em}
|
4 |
+
|
assets/js/block/subscribe.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){var t={};function a(n){if(t[n])return t[n].exports;var l=t[n]={i:n,l:!1,exports:{}};return e[n].call(l.exports,l,l.exports,a),l.l=!0,l.exports}a.m=e,a.c=t,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)a.d(n,l,function(t){return e[t]}.bind(null,l));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=16)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.components},function(e,t){e.exports=window.wp.blockEditor},function(e,t){e.exports=window.wp.i18n},function(e,t,a){var n=a(13),l=a(14),c=a(6),r=a(15);e.exports=function(e,t){return n(e)||l(e,t)||c(e,t)||r()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,a){var n=a(5);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?n(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=window.wp.blocks},function(e,t){e.exports=function(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,a){var n=a(10),l=a(11),c=a(6),r=a(12);e.exports=function(e){return n(e)||l(e)||c(e)||r()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,a){var n=a(5);e.exports=function(e){if(Array.isArray(e))return n(e)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){var a=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=a){var n,l,c=[],r=!0,o=!1;try{for(a=a.call(e);!(r=(n=a.next()).done)&&(c.push(n.value),!t||c.length!==t);r=!0);}catch(e){o=!0,l=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw l}}return c}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,a){"use strict";a.r(t);var n=a(7),l=a(8),c=a.n(l),r=a(9),o=a.n(r),s=a(4),i=a.n(s),u=a(0),m=a(3),b=a(2),p=a(1);function d(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function f(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?d(Object(a),!0).forEach((function(t){c()(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):d(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}var O="notshow",j="optional",y="required";Object(n.registerBlockType)("ce4wp/subscribe",{edit:function(e){var t=this,a=e.attributes,n=e.setAttributes,l=e.className,c=e.clientId;a.blockId||n({blockId:c});var r=function(){var e=React.useState([]),t=i()(e,2),a=t[0],n=t[1],l=React.useState(!1),c=i()(l,2),r=c[0],o=c[1],s=React.useState(!1),u=i()(s,2),m=u[0],b=u[1];return React.useEffect((function(){var e,t;r||m||(o(!0),jQuery.post(null===(e=ce4wp_form_submit_data)||void 0===e?void 0:e.url,{action:"ce4wp_get_all_custom_lists",nonce:null===(t=ce4wp_form_submit_data)||void 0===t?void 0:t.listNonce}).done((function(e){o(!1),b(!0),null!=(null==e?void 0:e.data)&&null!=e.data.length&&n(e.data.map((function(e){return{label:e.name,value:e.id}})))})))}),[r,m,a]),{customLists:a,loading:r,hasLoaded:m}}().customLists;return Object(u.createElement)("div",{className:"wp-block-ce4wp-subscribe ".concat(l||"")},Object(u.createElement)(b.BlockControls,{key:"setting"},Object(u.createElement)(b.InspectorControls,{key:"setting"},Object(u.createElement)(p.Panel,{header:"Settings"},Object(u.createElement)(p.PanelBody,{title:"Contact Segmentation",initialOpen:!0},Object(u.createElement)(p.PanelRow,{className:"no-flex"},Object(u.createElement)("fieldset",null,Object(u.createElement)("i",{className:"subTitle sub-header"},Object(m.__)("Automatically assign a new contact to a list when they subscribe","ce4wp"),Object(u.createElement)("br",null),Object(u.createElement)(p.ExternalLink,{onClick:function(){return ce4wpNavigateToDashboard(t,"fbcd9606-288a-4d82-be7c-449eaf5a3792",{source:"ce4wp_form_menu"},ce4wpDashboardStartCallback,ce4wpDashboardFinishCallback)}},Object(u.createElement)("span",{id:"ce4wp-manage-lists","data-link_reference":"836b20fc-9ff1-41b2-912b-a8646caf05a4"},Object(m.__)("Manage your lists","ce4wp")))),Object(u.createElement)("br",null),Object(u.createElement)("br",null),Object(u.createElement)(p.SelectControl,{label:"list",value:a.customList,options:[{label:Object(m.__)("Don't assign to a list","cewp4"),value:""}].concat(o()(r)),onChange:function(e){return n({customList:e})}})))),Object(u.createElement)(p.PanelBody,{title:"On submission",initialOpen:!0},Object(u.createElement)(p.PanelRow,null,Object(u.createElement)("fieldset",null,Object(u.createElement)(p.TextareaControl,{label:"Message text",value:a.onSubmission,onChange:function(e){return n({onSubmission:e})}})))),Object(u.createElement)(p.PanelBody,{title:"Disclaimer settings",initialOpen:!0},Object(u.createElement)(p.PanelRow,{className:"no-flex"},Object(u.createElement)("fieldset",null,Object(u.createElement)(p.SelectControl,{label:"Permission to mail",value:a.emailPermission,options:[{label:"message",value:"message"},{label:"checkbox",value:"checkbox"}],onChange:function(e){return n(f(f({},a),{},{emailPermission:e}))}})))),Object(u.createElement)(p.PanelBody,{title:"Field settings",initialOpen:!0},Object(u.createElement)(p.PanelRow,{className:"no-flex"},Object(u.createElement)("fieldset",null,Object(u.createElement)(p.SelectControl,{label:"First name field",value:a.displayFirstName,options:[{label:"Do not show",value:O},{label:"Optional",value:j},{label:"Required",value:y}],onChange:function(e){return n({displayFirstName:e})}}))),Object(u.createElement)(p.PanelRow,{className:"no-flex"},Object(u.createElement)("fieldset",null,Object(u.createElement)(p.SelectControl,{label:"Last name field",value:a.displayLastName,options:[{label:"Do not show",value:O},{label:"Optional",value:j},{label:"Required",value:y}],onChange:function(e){return n({displayLastName:e})}}))),Object(u.createElement)(p.PanelRow,{className:"no-flex"},Object(u.createElement)("fieldset",null,Object(u.createElement)(p.SelectControl,{label:"Telephone field",value:a.displayTelephone,options:[{label:"Do not show",value:O},{label:"Optional",value:j},{label:"Required",value:y}],onChange:function(e){return n({displayTelephone:e})}}))))))),Object(u.createElement)("form",{name:"contact-form"},Object(u.createElement)(b.RichText,{tagName:"h2",onChange:function(e){n({title:e})},value:a.title}),Object(u.createElement)(b.RichText,{tagName:"p",className:"subTitle",onChange:function(e){n({subTitle:e})},value:a.subTitle}),a.displayFirstName!==O&&Object(u.createElement)("div",{className:"inputBlock"},Object(u.createElement)(b.RichText,{tagName:"label",className:"firstNameLabel",onChange:function(e){n({firstNameLabel:e})},value:a.firstNameLabel}),a.displayFirstName===y&&Object(u.createElement)("p",{className:"required-text subTitle",style:{color:"#ee0000"}},"*"),Object(u.createElement)("input",{name:"first_name",type:"text"})),a.displayLastName!==O&&Object(u.createElement)("div",{className:"inputBlock"},Object(u.createElement)(b.RichText,{tagName:"label",className:"lastNameLabel",onChange:function(e){n({lastNameLabel:e})},value:a.lastNameLabel}),a.displayLastName===y&&Object(u.createElement)("p",{className:"required-text subTitle",style:{color:"#ee0000"}},"*"),Object(u.createElement)("input",{name:"last_name",type:"text"})),a.displayTelephone!==O&&Object(u.createElement)("div",{class:"inputBlock"},Object(u.createElement)(b.RichText,{tagName:"label",className:"lastNameLabel",onChange:function(e){n({telephoneLabel:e})},value:a.telephoneLabel}),a.displayTelephone===y&&Object(u.createElement)("p",{className:"required-text subTitle",style:{color:"#ee0000"}},"*"),Object(u.createElement)("input",{name:"telephone",type:"text"})),Object(u.createElement)("div",{className:"inputBlock"},Object(u.createElement)(b.RichText,{tagName:"label",className:"emailLabel",onChange:function(e){n({emailLabel:e})},value:a.emailLabel}),Object(u.createElement)("p",{className:"required-text subTitle",style:{color:"#ee0000"}},"*"),Object(u.createElement)("input",{className:"textwidget",name:"email",type:"text"})),"message"==a.emailPermission&&Object(u.createElement)("span",{className:"disclaimer"},Object(m.__)("By submitting your information, you are granting us permission to email you. You may unsubscribe at any time.","cewp4")),"checkbox"==a.emailPermission&&Object(u.createElement)("div",null,Object(u.createElement)("input",{type:"checkbox",name:"consent_check_".concat(c),id:"consent_check_".concat(c)}),Object(u.createElement)("label",{htmlFor:"consent_check_".concat(c),className:"disclaimer"},Object(m.__)("Can we send you an email from time to time?","cewp4"))),Object(u.createElement)("br",null),Object(u.createElement)("button",{className:"wp-block-button__link submit-button",type:"button"},Object(m.__)("Subscribe","cewp4"))))},save:function(e){var t=e.attributes,a=e.className;return Object(u.createElement)("div",{className:"wp-block-ce4wp-subscribe ".concat(a||"")},Object(u.createElement)("div",{className:"onSubmission",style:{display:"none"}},Object(u.createElement)(b.RichText.Content,{className:"title",tagName:"h2",value:t.title}),Object(u.createElement)("p",{className:"subTitle"},Object(m.__)(t.onSubmission,"cewp4"))),Object(u.createElement)("form",{className:"cm-contact-form",name:"contact-form"},Object(u.createElement)("input",{className:"list_id",name:"list_id",type:"hidden",value:t.customList}),Object(u.createElement)(b.RichText.Content,{className:"title",tagName:"h2",value:t.title})," ",Object(u.createElement)(b.RichText.Content,{className:"subTitle",tagName:"p",value:t.subTitle}),t.displayFirstName!==O&&Object(u.createElement)("div",{className:"inputBlock"},Object(u.createElement)(b.RichText.Content,{tagName:"label",value:t.firstNameLabel}),t.displayFirstName===y&&Object(u.createElement)("span",{className:"wp-caption-text required-text",style:{color:"#ee0000"}},"*"),Object(u.createElement)("input",{className:"firstName",name:"first_name",type:"text",required:t.displayFirstName===y})),t.displayLastName!==O&&Object(u.createElement)("div",{className:"inputBlock"},Object(u.createElement)(b.RichText.Content,{tagName:"label",value:t.lastNameLabel}),t.displayLastName===y&&Object(u.createElement)("span",{className:"wp-caption-text required-text",style:{color:"#ee0000"}},"*"),Object(u.createElement)("input",{className:"lastName",name:"last_name",type:"text",required:t.displayFirstName===y})),t.displayTelephone!==O&&Object(u.createElement)("div",{className:"inputBlock"},Object(u.createElement)(b.RichText.Content,{tagName:"label",value:t.telephoneLabel}),t.displayTelephone===y&&Object(u.createElement)("span",{className:"wp-caption-text required-text",style:{color:"#ee0000"}},"*"),Object(u.createElement)("input",{className:"telephone",name:"telephone",type:"tel",pattern:"[+]?[0-9\\(\\)\\s+-]{5,20}",oninvalid:"setCustomValidity('".concat(Object(m.__)("Please enter a valid phone number","cewp4"),"')"),oninput:"setCustomValidity('')",required:t.displayFirstName===y})),Object(u.createElement)("div",{className:"inputBlock"},Object(u.createElement)(b.RichText.Content,{tagName:"label",value:t.emailLabel}),Object(u.createElement)("span",{className:"wp-caption-text required-text",style:{color:"#ee0000"}},"*"),Object(u.createElement)("input",{className:"email",name:"email",type:"email",oninvalid:"setCustomValidity('".concat(Object(m.__)("Please enter a valid email address","cewp4"),"')"),oninput:"setCustomValidity('')",required:!0})),"message"==t.emailPermission&&Object(u.createElement)("span",{className:"disclaimer"},Object(u.createElement)("input",{className:"consent_check",name:"consent",type:"hidden",checked:!0}),Object(m.__)("By submitting your information, you are granting us permission to email you. You may unsubscribe at any time.","cewp4")),"checkbox"==t.emailPermission&&Object(u.createElement)("span",null,Object(u.createElement)("input",{className:"consent_check",name:"consent_check_".concat(t.blockId),id:"consent_check_".concat(t.blockId),type:"checkbox"}),Object(u.createElement)("label",{htmlFor:"consent_check_".concat(t.blockId),className:"disclaimer"},Object(m.__)("Can we send you an email from time to time?","cewp4"))),Object(u.createElement)("button",{className:"wp-block-button__link submit-button",type:"submit"},Object(m.__)("Subscribe","cewp4"))))},supports:{alignWide:!1}})}]);
|
assets/js/subscribe/submit.js
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// phpcs:disable
|
2 |
+
/**
|
3 |
+
* addOnSubmit.
|
4 |
+
* Adds the submit function to subscribe contact forms
|
5 |
+
* @package CreativeMail
|
6 |
+
*/
|
7 |
+
(function addOnSubmit() {
|
8 |
+
let submitButtons = document.getElementsByClassName("cm-contact-form");
|
9 |
+
for (let element of submitButtons) {
|
10 |
+
element.onsubmit = (e) => {
|
11 |
+
e.preventDefault();
|
12 |
+
let formElement = e.target;
|
13 |
+
let firstName = formElement.getElementsByClassName("firstName")[0]?.value;
|
14 |
+
let lastName = formElement.getElementsByClassName("lastName")[0]?.value;
|
15 |
+
let email = formElement.getElementsByClassName("email")[0]?.value;
|
16 |
+
let telephone = formElement.getElementsByClassName("telephone")[0]?.value;
|
17 |
+
let consent = formElement.getElementsByClassName("consent_check")[0]?.checked;
|
18 |
+
let listId = formElement.getElementsByClassName("list_id")[0]?.value || null;
|
19 |
+
jQuery.post(ce4wp_form_submit_data?.url, {
|
20 |
+
action: "ce4wp_form_submission",
|
21 |
+
nonce: ce4wp_form_submit_data?.nonce,
|
22 |
+
first_name: firstName,
|
23 |
+
last_name: lastName,
|
24 |
+
email: email,
|
25 |
+
telephone: telephone,
|
26 |
+
consent: consent,
|
27 |
+
list_id: listId
|
28 |
+
}).done(function() {
|
29 |
+
formElement.style.visibility = "hidden";
|
30 |
+
let parentElement = formElement.parentElement;
|
31 |
+
let onSubmission = parentElement.getElementsByClassName(
|
32 |
+
"onSubmission"
|
33 |
+
)[0];
|
34 |
+
onSubmission.style.display = "block";
|
35 |
+
});
|
36 |
+
};
|
37 |
+
}
|
38 |
+
})();
|
composer.json
CHANGED
@@ -19,6 +19,7 @@
|
|
19 |
"CreativeMail\\Modules\\": "src/modules/",
|
20 |
"CreativeMail\\Constants\\": "src/constants/",
|
21 |
"CreativeMail\\Integrations\\": "src/integrations/",
|
|
|
22 |
"CreativeMail\\": "src/"
|
23 |
}
|
24 |
},
|
19 |
"CreativeMail\\Modules\\": "src/modules/",
|
20 |
"CreativeMail\\Constants\\": "src/constants/",
|
21 |
"CreativeMail\\Integrations\\": "src/integrations/",
|
22 |
+
"CreativeMail\\Blocks\\": "src/blocks/",
|
23 |
"CreativeMail\\": "src/"
|
24 |
}
|
25 |
},
|
creative-mail-plugin.php
CHANGED
@@ -9,12 +9,13 @@
|
|
9 |
* Plugin URI: https://wordpress.org/plugins/creative-mail-by-constant-contact/
|
10 |
* Description: Free email marketing designed specifically for WordPress, Jetpack and WooCommerce. Send newsletters, promotions, updates and transactional e-commerce emails. Simple and easy, powered by Constant Contact’s rock solid reliability.
|
11 |
* Author: Constant Contact
|
12 |
-
* Version: 1.
|
13 |
* Author URI: https://www.constantcontact.com
|
14 |
* WC requires at least: 3.0.0
|
15 |
* WC tested up to: 5.1.0
|
16 |
*/
|
17 |
use CreativeMail\CreativeMail;
|
|
|
18 |
function _load_ce4wp_plugin()
|
19 |
{
|
20 |
global $creativemail;
|
@@ -26,7 +27,7 @@ function _load_ce4wp_plugin()
|
|
26 |
define('CE4WP_PLUGIN_DIR', __DIR__ . '/');
|
27 |
define('CE4WP_PLUGIN_URL', plugin_dir_url(__FILE__) . '/');
|
28 |
define('CE4WP_PLUGIN_FILE', __FILE__);
|
29 |
-
define('CE4WP_PLUGIN_VERSION', '1.
|
30 |
define('CE4WP_INSTANCE_UUID_KEY', 'ce4wp_instance_uuid');
|
31 |
define('CE4WP_INSTANCE_HANDSHAKE_TOKEN', 'ce4wp_handshake_token');
|
32 |
define('CE4WP_INSTANCE_HANDSHAKE_EXPIRATION', 'ce4wp_handshake_expiration');
|
@@ -43,7 +44,7 @@ function _load_ce4wp_plugin()
|
|
43 |
define('CE4WP_APP_GATEWAY_URL', 'https://app-gateway.creativemail.com/');
|
44 |
define('CE4WP_APP_URL', 'https://app.creativemail.com/');
|
45 |
define('CE4WP_ENVIRONMENT', 'PRODUCTION');
|
46 |
-
define('CE4WP_BUILD_NUMBER', '
|
47 |
define('CE4WP_RAYGUN_PHP_KEY', 'Z85xL3mkgnW13Ri9DajGUg');
|
48 |
define('CE4WP_BATCH_SIZE', 500);
|
49 |
define('CE4WP_WC_API_KEY_ID', 'ce4wp_woocommerce_api_key_id');
|
@@ -59,6 +60,11 @@ function _load_ce4wp_plugin()
|
|
59 |
$creativemail = CreativeMail::get_instance();
|
60 |
$creativemail->add_hooks();
|
61 |
|
|
|
|
|
|
|
|
|
|
|
62 |
return true;
|
63 |
}
|
64 |
|
@@ -83,3 +89,27 @@ function ce4wp_activate()
|
|
83 |
add_action('plugins_loaded', '_load_ce4wp_plugin', 10);
|
84 |
register_activation_hook(__FILE__, 'ce4wp_activate');
|
85 |
register_deactivation_hook(__FILE__, 'ce4wp_deactivate');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
* Plugin URI: https://wordpress.org/plugins/creative-mail-by-constant-contact/
|
10 |
* Description: Free email marketing designed specifically for WordPress, Jetpack and WooCommerce. Send newsletters, promotions, updates and transactional e-commerce emails. Simple and easy, powered by Constant Contact’s rock solid reliability.
|
11 |
* Author: Constant Contact
|
12 |
+
* Version: 1.4.0
|
13 |
* Author URI: https://www.constantcontact.com
|
14 |
* WC requires at least: 3.0.0
|
15 |
* WC tested up to: 5.1.0
|
16 |
*/
|
17 |
use CreativeMail\CreativeMail;
|
18 |
+
use CreativeMail\Blocks\LoadBlock;
|
19 |
function _load_ce4wp_plugin()
|
20 |
{
|
21 |
global $creativemail;
|
27 |
define('CE4WP_PLUGIN_DIR', __DIR__ . '/');
|
28 |
define('CE4WP_PLUGIN_URL', plugin_dir_url(__FILE__) . '/');
|
29 |
define('CE4WP_PLUGIN_FILE', __FILE__);
|
30 |
+
define('CE4WP_PLUGIN_VERSION', '1.4.0');
|
31 |
define('CE4WP_INSTANCE_UUID_KEY', 'ce4wp_instance_uuid');
|
32 |
define('CE4WP_INSTANCE_HANDSHAKE_TOKEN', 'ce4wp_handshake_token');
|
33 |
define('CE4WP_INSTANCE_HANDSHAKE_EXPIRATION', 'ce4wp_handshake_expiration');
|
44 |
define('CE4WP_APP_GATEWAY_URL', 'https://app-gateway.creativemail.com/');
|
45 |
define('CE4WP_APP_URL', 'https://app.creativemail.com/');
|
46 |
define('CE4WP_ENVIRONMENT', 'PRODUCTION');
|
47 |
+
define('CE4WP_BUILD_NUMBER', '1272');
|
48 |
define('CE4WP_RAYGUN_PHP_KEY', 'Z85xL3mkgnW13Ri9DajGUg');
|
49 |
define('CE4WP_BATCH_SIZE', 500);
|
50 |
define('CE4WP_WC_API_KEY_ID', 'ce4wp_woocommerce_api_key_id');
|
60 |
$creativemail = CreativeMail::get_instance();
|
61 |
$creativemail->add_hooks();
|
62 |
|
63 |
+
if (version_compare($GLOBALS['wp_version'], '5.5', '>=')) {
|
64 |
+
$loadBlock = LoadBlock::get_instance();
|
65 |
+
$loadBlock->add_hooks();
|
66 |
+
}
|
67 |
+
|
68 |
return true;
|
69 |
}
|
70 |
|
89 |
add_action('plugins_loaded', '_load_ce4wp_plugin', 10);
|
90 |
register_activation_hook(__FILE__, 'ce4wp_activate');
|
91 |
register_deactivation_hook(__FILE__, 'ce4wp_deactivate');
|
92 |
+
|
93 |
+
// Add on submit to subscribe buttons
|
94 |
+
add_action('init', 'wpse_add_front_end_on_submit');
|
95 |
+
function wpse_add_front_end_on_submit()
|
96 |
+
{
|
97 |
+
wp_enqueue_script(
|
98 |
+
'ce4wp_form_submit',
|
99 |
+
plugins_url('assets/js/block/submit.js', __FILE__),
|
100 |
+
array('jquery'),
|
101 |
+
filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/block/submit.js' ),
|
102 |
+
true
|
103 |
+
);
|
104 |
+
|
105 |
+
wp_localize_script(
|
106 |
+
'ce4wp_form_submit',
|
107 |
+
'ce4wp_form_submit_data',
|
108 |
+
[
|
109 |
+
'siteUrl' => get_site_url(),
|
110 |
+
'url' => admin_url('admin-ajax.php'),
|
111 |
+
'nonce' => wp_create_nonce( 'ce4wp_form_submission'),
|
112 |
+
'listNonce' => wp_create_nonce( 'ce4wp_get_lists' )
|
113 |
+
]
|
114 |
+
);
|
115 |
+
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: Constant Contact
|
|
3 |
Tags: email, marketing, newsletter, subscribe, contact form, constant contact, crm, automations, ecommerce, promotion, offers, retargeting
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 5.7
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
Requires PHP: 5.6
|
@@ -95,6 +95,7 @@ Creative Mail by Constant Contact [Privacy Notice](https://www.endurance.com/pri
|
|
95 |
6. Enhance your brand with logomaker
|
96 |
|
97 |
== Changelog ==
|
|
|
98 |
* 1.3.9 - Include notice when you have enabled a password protection plugin.
|
99 |
* 1.3.8 - Fixes an issue with WooCommerce recommendations.
|
100 |
* 1.3.7 - Fixes an issue specific to PHP 7.4
|
3 |
Tags: email, marketing, newsletter, subscribe, contact form, constant contact, crm, automations, ecommerce, promotion, offers, retargeting
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 5.7
|
6 |
+
Stable tag: 1.4.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
Requires PHP: 5.6
|
95 |
6. Enhance your brand with logomaker
|
96 |
|
97 |
== Changelog ==
|
98 |
+
* 1.4.0 - Added gutenberg contact form block CreativeMail
|
99 |
* 1.3.9 - Include notice when you have enabled a password protection plugin.
|
100 |
* 1.3.8 - Fixes an issue with WooCommerce recommendations.
|
101 |
* 1.3.7 - Fixes an issue specific to PHP 7.4
|
src/CreativeMail.php
CHANGED
@@ -6,6 +6,7 @@ namespace CreativeMail;
|
|
6 |
use CreativeMail\Managers\AdminManager;
|
7 |
use CreativeMail\Managers\ApiManager;
|
8 |
use CreativeMail\Managers\CheckoutManager;
|
|
|
9 |
use CreativeMail\Managers\DatabaseManager;
|
10 |
use CreativeMail\Managers\EmailManager;
|
11 |
use CreativeMail\Managers\InstanceManager;
|
@@ -24,6 +25,7 @@ class CreativeMail
|
|
24 |
private $database_manager;
|
25 |
private $checkout_manager;
|
26 |
private $contacts_sync_manager;
|
|
|
27 |
|
28 |
public function __construct()
|
29 |
{
|
@@ -38,6 +40,7 @@ class CreativeMail
|
|
38 |
$this->email_manager = new EmailManager();
|
39 |
$this->checkout_manager = new CheckoutManager();
|
40 |
$this->contacts_sync_manager = new ContactsSyncManager();
|
|
|
41 |
}
|
42 |
|
43 |
public function add_hooks()
|
@@ -57,6 +60,7 @@ class CreativeMail
|
|
57 |
$this->integration_manager->add_hooks();
|
58 |
$this->instance_manager->add_hooks();
|
59 |
$this->email_manager->add_hooks();
|
|
|
60 |
|
61 |
// check if abandoned cart email is managed by creative mail
|
62 |
$enabled = $this->email_manager->is_email_managed('cart_abandoned_ce4wp');
|
@@ -101,6 +105,11 @@ class CreativeMail
|
|
101 |
return $this->contacts_sync_manager;
|
102 |
}
|
103 |
|
|
|
|
|
|
|
|
|
|
|
104 |
public function is_active()
|
105 |
{
|
106 |
return in_array(plugin_basename(CE4WP_PLUGIN_FILE), apply_filters('active_plugins', get_option('active_plugins')));
|
6 |
use CreativeMail\Managers\AdminManager;
|
7 |
use CreativeMail\Managers\ApiManager;
|
8 |
use CreativeMail\Managers\CheckoutManager;
|
9 |
+
use CreativeMail\Managers\FormManager;
|
10 |
use CreativeMail\Managers\DatabaseManager;
|
11 |
use CreativeMail\Managers\EmailManager;
|
12 |
use CreativeMail\Managers\InstanceManager;
|
25 |
private $database_manager;
|
26 |
private $checkout_manager;
|
27 |
private $contacts_sync_manager;
|
28 |
+
private $form_manager;
|
29 |
|
30 |
public function __construct()
|
31 |
{
|
40 |
$this->email_manager = new EmailManager();
|
41 |
$this->checkout_manager = new CheckoutManager();
|
42 |
$this->contacts_sync_manager = new ContactsSyncManager();
|
43 |
+
$this->form_manager = new FormManager();
|
44 |
}
|
45 |
|
46 |
public function add_hooks()
|
60 |
$this->integration_manager->add_hooks();
|
61 |
$this->instance_manager->add_hooks();
|
62 |
$this->email_manager->add_hooks();
|
63 |
+
$this->form_manager->add_hooks();
|
64 |
|
65 |
// check if abandoned cart email is managed by creative mail
|
66 |
$enabled = $this->email_manager->is_email_managed('cart_abandoned_ce4wp');
|
105 |
return $this->contacts_sync_manager;
|
106 |
}
|
107 |
|
108 |
+
public function get_form_manager()
|
109 |
+
{
|
110 |
+
return $this->form_manager;
|
111 |
+
}
|
112 |
+
|
113 |
public function is_active()
|
114 |
{
|
115 |
return in_array(plugin_basename(CE4WP_PLUGIN_FILE), apply_filters('active_plugins', get_option('active_plugins')));
|
src/blocks/LoadBlock.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class MyPlugin_Blocks
|
5 |
+
*/
|
6 |
+
namespace CreativeMail\Blocks;
|
7 |
+
class LoadBlock {
|
8 |
+
private static $instance;
|
9 |
+
public function __construct() {
|
10 |
+
}
|
11 |
+
public function add_hooks() {
|
12 |
+
add_action( 'init', array($this, 'create_blocks') );
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Registers the block using the metadata loaded from the `block.json` file.
|
17 |
+
* Behind the scenes, it registers also all assets so they can be enqueued
|
18 |
+
* through the block editor in the corresponding context
|
19 |
+
*/
|
20 |
+
function create_blocks() {
|
21 |
+
register_block_type_from_metadata(__DIR__ . '/subscribe' );
|
22 |
+
}
|
23 |
+
|
24 |
+
public static function get_instance()
|
25 |
+
{
|
26 |
+
|
27 |
+
if (self::$instance === null) {
|
28 |
+
self::$instance = new LoadBlock();
|
29 |
+
}
|
30 |
+
|
31 |
+
return self::$instance;
|
32 |
+
}
|
33 |
+
}
|
src/blocks/subscribe/block.json
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"attributes": {
|
3 |
+
"blockId": {
|
4 |
+
"type": "string"
|
5 |
+
},
|
6 |
+
"title": {
|
7 |
+
"type": "string",
|
8 |
+
"default": "Subscribe"
|
9 |
+
},
|
10 |
+
"subTitle": {
|
11 |
+
"type": "string",
|
12 |
+
"default": "Sign up for our newsletter and stay up to date"
|
13 |
+
},
|
14 |
+
"firstNameLabel": {
|
15 |
+
"type": "string",
|
16 |
+
"default": "First name"
|
17 |
+
},
|
18 |
+
"lastNameLabel": {
|
19 |
+
"type": "string",
|
20 |
+
"default": "Last name"
|
21 |
+
},
|
22 |
+
"emailLabel": {
|
23 |
+
"type": "string",
|
24 |
+
"default": "Email"
|
25 |
+
},
|
26 |
+
"telephoneLabel": {
|
27 |
+
"type": "string",
|
28 |
+
"default": "Telephone"
|
29 |
+
},
|
30 |
+
"emailPermission": {
|
31 |
+
"type": "string",
|
32 |
+
"default": "checkbox"
|
33 |
+
},
|
34 |
+
"displayTelephone": {
|
35 |
+
"type": "string",
|
36 |
+
"default": "notshow"
|
37 |
+
},
|
38 |
+
"displayFirstName": {
|
39 |
+
"type": "string",
|
40 |
+
"default": "optional"
|
41 |
+
},
|
42 |
+
"displayLastName": {
|
43 |
+
"type": "string",
|
44 |
+
"default": "optional"
|
45 |
+
},
|
46 |
+
"onSubmission": {
|
47 |
+
"type": "string",
|
48 |
+
"selector": "div",
|
49 |
+
"default": "Thank you for subscribing!"
|
50 |
+
},
|
51 |
+
"customList": {
|
52 |
+
"type": "string",
|
53 |
+
"default": null
|
54 |
+
}
|
55 |
+
},
|
56 |
+
"name": "ce4wp/subscribe",
|
57 |
+
"title": "Creative Mail",
|
58 |
+
"category": "widgets",
|
59 |
+
"icon": "email",
|
60 |
+
"description": "Let your contact subscribe to a mailing list for creative mail.",
|
61 |
+
"supports": {
|
62 |
+
"html": false
|
63 |
+
},
|
64 |
+
"textdomain": "subscribe",
|
65 |
+
"editorScript": "file:../../../assets/js/block/subscribe.js",
|
66 |
+
"editorStyle": "file:../../../assets/js/block/subscribe.css",
|
67 |
+
"style": "file:../../../assets/js/block/subscribe.css"
|
68 |
+
}
|
src/blocks/subscribe/edit.js
ADDED
@@ -0,0 +1,365 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { __ } from "@wordpress/i18n";
|
2 |
+
import {
|
3 |
+
BlockControls,
|
4 |
+
InspectorControls,
|
5 |
+
RichText,
|
6 |
+
} from "@wordpress/block-editor";
|
7 |
+
import {
|
8 |
+
SelectControl,
|
9 |
+
TextareaControl,
|
10 |
+
Panel,
|
11 |
+
PanelBody,
|
12 |
+
PanelRow,
|
13 |
+
ExternalLink
|
14 |
+
} from "@wordpress/components";
|
15 |
+
|
16 |
+
import "./editor.scss";
|
17 |
+
|
18 |
+
export const FIELD_SETTING = {
|
19 |
+
NOTSHOW: "notshow",
|
20 |
+
OPTIONAL: "optional",
|
21 |
+
REQUIRED: "required",
|
22 |
+
};
|
23 |
+
|
24 |
+
const useCustomLists = () => {
|
25 |
+
const [customLists, setCustomLists] = React.useState([]);
|
26 |
+
const [loading, setLoading] = React.useState(false);
|
27 |
+
const [hasLoaded, setHasLoaded] = React.useState(false);
|
28 |
+
|
29 |
+
React.useEffect(() => {
|
30 |
+
if (loading || hasLoaded) return;
|
31 |
+
setLoading(true);
|
32 |
+
jQuery
|
33 |
+
.post(ce4wp_form_submit_data?.url, {
|
34 |
+
action: "ce4wp_get_all_custom_lists",
|
35 |
+
nonce: ce4wp_form_submit_data?.listNonce,
|
36 |
+
})
|
37 |
+
.done((response) => {
|
38 |
+
setLoading(false);
|
39 |
+
setHasLoaded(true);
|
40 |
+
if (response?.data != null && response.data.length != undefined) {
|
41 |
+
setCustomLists(response.data.map((list) => ({
|
42 |
+
label: list.name,
|
43 |
+
value: list.id,
|
44 |
+
})))
|
45 |
+
}
|
46 |
+
});
|
47 |
+
}, [loading, hasLoaded, customLists]);
|
48 |
+
|
49 |
+
return {
|
50 |
+
customLists,
|
51 |
+
loading,
|
52 |
+
hasLoaded,
|
53 |
+
};
|
54 |
+
};
|
55 |
+
|
56 |
+
export default function Edit({
|
57 |
+
attributes,
|
58 |
+
setAttributes,
|
59 |
+
className,
|
60 |
+
clientId,
|
61 |
+
}) {
|
62 |
+
const { blockId } = attributes;
|
63 |
+
if (!blockId) {
|
64 |
+
setAttributes({ blockId: clientId });
|
65 |
+
}
|
66 |
+
const { customLists } = useCustomLists()
|
67 |
+
|
68 |
+
return (
|
69 |
+
<div className={`wp-block-ce4wp-subscribe ${className ? className : ''}`}>
|
70 |
+
<BlockControls key="setting">
|
71 |
+
<InspectorControls key="setting">
|
72 |
+
<Panel header="Settings">
|
73 |
+
<PanelBody title="Contact Segmentation" initialOpen={true}>
|
74 |
+
<PanelRow className="no-flex">
|
75 |
+
<fieldset>
|
76 |
+
<i className="subTitle sub-header">
|
77 |
+
{__(
|
78 |
+
"Automatically assign a new contact to a list when they subscribe",
|
79 |
+
"ce4wp"
|
80 |
+
)}
|
81 |
+
<br />
|
82 |
+
<ExternalLink
|
83 |
+
onClick={() =>
|
84 |
+
ce4wpNavigateToDashboard(
|
85 |
+
this,
|
86 |
+
"fbcd9606-288a-4d82-be7c-449eaf5a3792",
|
87 |
+
{ source: "ce4wp_form_menu" },
|
88 |
+
ce4wpDashboardStartCallback,
|
89 |
+
ce4wpDashboardFinishCallback
|
90 |
+
)
|
91 |
+
}
|
92 |
+
>
|
93 |
+
<span
|
94 |
+
id="ce4wp-manage-lists"
|
95 |
+
data-link_reference="836b20fc-9ff1-41b2-912b-a8646caf05a4"
|
96 |
+
>
|
97 |
+
{__("Manage your lists", "ce4wp")}
|
98 |
+
</span>
|
99 |
+
</ExternalLink>
|
100 |
+
</i>
|
101 |
+
<br />
|
102 |
+
<br />
|
103 |
+
<SelectControl
|
104 |
+
label="list"
|
105 |
+
value={attributes.customList}
|
106 |
+
options={[
|
107 |
+
{
|
108 |
+
label: __("Don't assign to a list", "cewp4"),
|
109 |
+
value: "",
|
110 |
+
},
|
111 |
+
...customLists,
|
112 |
+
]}
|
113 |
+
onChange={(customList) =>
|
114 |
+
setAttributes({
|
115 |
+
customList,
|
116 |
+
})
|
117 |
+
}
|
118 |
+
/>
|
119 |
+
</fieldset>
|
120 |
+
</PanelRow>
|
121 |
+
</PanelBody>
|
122 |
+
<PanelBody title="On submission" initialOpen={true}>
|
123 |
+
<PanelRow>
|
124 |
+
<fieldset>
|
125 |
+
<TextareaControl
|
126 |
+
label="Message text"
|
127 |
+
value={attributes.onSubmission}
|
128 |
+
onChange={(onSubmission) => setAttributes({ onSubmission })}
|
129 |
+
/>
|
130 |
+
</fieldset>
|
131 |
+
</PanelRow>
|
132 |
+
</PanelBody>
|
133 |
+
<PanelBody title="Disclaimer settings" initialOpen={true}>
|
134 |
+
<PanelRow className="no-flex">
|
135 |
+
<fieldset>
|
136 |
+
<SelectControl
|
137 |
+
label="Permission to mail"
|
138 |
+
value={attributes.emailPermission}
|
139 |
+
options={[
|
140 |
+
{
|
141 |
+
label: "message",
|
142 |
+
value: "message",
|
143 |
+
},
|
144 |
+
{
|
145 |
+
label: "checkbox",
|
146 |
+
value: "checkbox",
|
147 |
+
},
|
148 |
+
]}
|
149 |
+
onChange={(emailPermission) =>
|
150 |
+
setAttributes({
|
151 |
+
...attributes,
|
152 |
+
emailPermission: emailPermission,
|
153 |
+
})
|
154 |
+
}
|
155 |
+
/>
|
156 |
+
</fieldset>
|
157 |
+
</PanelRow>
|
158 |
+
</PanelBody>
|
159 |
+
<PanelBody title="Field settings" initialOpen={true}>
|
160 |
+
<PanelRow className="no-flex">
|
161 |
+
<fieldset>
|
162 |
+
<SelectControl
|
163 |
+
label="First name field"
|
164 |
+
value={attributes.displayFirstName}
|
165 |
+
options={[
|
166 |
+
{
|
167 |
+
label: "Do not show",
|
168 |
+
value: FIELD_SETTING.NOTSHOW,
|
169 |
+
},
|
170 |
+
{
|
171 |
+
label: "Optional",
|
172 |
+
value: FIELD_SETTING.OPTIONAL,
|
173 |
+
},
|
174 |
+
{
|
175 |
+
label: "Required",
|
176 |
+
value: FIELD_SETTING.REQUIRED,
|
177 |
+
},
|
178 |
+
]}
|
179 |
+
onChange={(displayFirstName) =>
|
180 |
+
setAttributes({
|
181 |
+
displayFirstName: displayFirstName,
|
182 |
+
})
|
183 |
+
}
|
184 |
+
/>
|
185 |
+
</fieldset>
|
186 |
+
</PanelRow>
|
187 |
+
<PanelRow className="no-flex">
|
188 |
+
<fieldset>
|
189 |
+
<SelectControl
|
190 |
+
label="Last name field"
|
191 |
+
value={attributes.displayLastName}
|
192 |
+
options={[
|
193 |
+
{
|
194 |
+
label: "Do not show",
|
195 |
+
value: FIELD_SETTING.NOTSHOW,
|
196 |
+
},
|
197 |
+
{
|
198 |
+
label: "Optional",
|
199 |
+
value: FIELD_SETTING.OPTIONAL,
|
200 |
+
},
|
201 |
+
{
|
202 |
+
label: "Required",
|
203 |
+
value: FIELD_SETTING.REQUIRED,
|
204 |
+
},
|
205 |
+
]}
|
206 |
+
onChange={(displayLastName) =>
|
207 |
+
setAttributes({
|
208 |
+
displayLastName: displayLastName,
|
209 |
+
})
|
210 |
+
}
|
211 |
+
/>
|
212 |
+
</fieldset>
|
213 |
+
</PanelRow>
|
214 |
+
<PanelRow className="no-flex">
|
215 |
+
<fieldset>
|
216 |
+
<SelectControl
|
217 |
+
label="Telephone field"
|
218 |
+
value={attributes.displayTelephone}
|
219 |
+
options={[
|
220 |
+
{
|
221 |
+
label: "Do not show",
|
222 |
+
value: FIELD_SETTING.NOTSHOW,
|
223 |
+
},
|
224 |
+
{
|
225 |
+
label: "Optional",
|
226 |
+
value: FIELD_SETTING.OPTIONAL,
|
227 |
+
},
|
228 |
+
{
|
229 |
+
label: "Required",
|
230 |
+
value: FIELD_SETTING.REQUIRED,
|
231 |
+
},
|
232 |
+
]}
|
233 |
+
onChange={(displayTelephone) =>
|
234 |
+
setAttributes({
|
235 |
+
displayTelephone: displayTelephone,
|
236 |
+
})
|
237 |
+
}
|
238 |
+
/>
|
239 |
+
</fieldset>
|
240 |
+
</PanelRow>
|
241 |
+
</PanelBody>
|
242 |
+
</Panel>
|
243 |
+
</InspectorControls>
|
244 |
+
</BlockControls>
|
245 |
+
<form name="contact-form">
|
246 |
+
<RichText
|
247 |
+
tagName="h2"
|
248 |
+
onChange={(title) => {
|
249 |
+
setAttributes({ title: title });
|
250 |
+
}}
|
251 |
+
value={attributes.title}
|
252 |
+
/>
|
253 |
+
<RichText
|
254 |
+
tagName="p"
|
255 |
+
className="subTitle"
|
256 |
+
onChange={(subTitle) => {
|
257 |
+
setAttributes({ subTitle: subTitle });
|
258 |
+
}}
|
259 |
+
value={attributes.subTitle}
|
260 |
+
/>
|
261 |
+
{attributes.displayFirstName !== FIELD_SETTING.NOTSHOW && (
|
262 |
+
<div className="inputBlock">
|
263 |
+
<RichText
|
264 |
+
tagName="label"
|
265 |
+
className="firstNameLabel"
|
266 |
+
onChange={(firstNameLabel) => {
|
267 |
+
setAttributes({ firstNameLabel: firstNameLabel });
|
268 |
+
}}
|
269 |
+
value={attributes.firstNameLabel}
|
270 |
+
/>
|
271 |
+
{attributes.displayFirstName === FIELD_SETTING.REQUIRED && (
|
272 |
+
<p
|
273 |
+
className="required-text subTitle"
|
274 |
+
style={{ color: "#ee0000" }}
|
275 |
+
>
|
276 |
+
*
|
277 |
+
</p>
|
278 |
+
)}
|
279 |
+
<input name="first_name" type="text"></input>
|
280 |
+
</div>
|
281 |
+
)}
|
282 |
+
{attributes.displayLastName !== FIELD_SETTING.NOTSHOW && (
|
283 |
+
<div className="inputBlock">
|
284 |
+
<RichText
|
285 |
+
tagName="label"
|
286 |
+
className="lastNameLabel"
|
287 |
+
onChange={(lastNameLabel) => {
|
288 |
+
setAttributes({ lastNameLabel: lastNameLabel });
|
289 |
+
}}
|
290 |
+
value={attributes.lastNameLabel}
|
291 |
+
/>
|
292 |
+
{attributes.displayLastName === FIELD_SETTING.REQUIRED && (
|
293 |
+
<p
|
294 |
+
className="required-text subTitle"
|
295 |
+
style={{ color: "#ee0000" }}
|
296 |
+
>
|
297 |
+
*
|
298 |
+
</p>
|
299 |
+
)}
|
300 |
+
<input name="last_name" type="text"></input>
|
301 |
+
</div>
|
302 |
+
)}
|
303 |
+
{attributes.displayTelephone !== FIELD_SETTING.NOTSHOW && (
|
304 |
+
<div class="inputBlock">
|
305 |
+
<RichText
|
306 |
+
tagName="label"
|
307 |
+
className="lastNameLabel"
|
308 |
+
onChange={(telephoneLabel) => {
|
309 |
+
setAttributes({ telephoneLabel: telephoneLabel });
|
310 |
+
}}
|
311 |
+
value={attributes.telephoneLabel}
|
312 |
+
/>
|
313 |
+
{attributes.displayTelephone === FIELD_SETTING.REQUIRED && (
|
314 |
+
<p
|
315 |
+
className="required-text subTitle"
|
316 |
+
style={{ color: "#ee0000" }}
|
317 |
+
>
|
318 |
+
*
|
319 |
+
</p>
|
320 |
+
)}
|
321 |
+
<input name="telephone" type="text"></input>
|
322 |
+
</div>
|
323 |
+
)}
|
324 |
+
<div className="inputBlock">
|
325 |
+
<RichText
|
326 |
+
tagName="label"
|
327 |
+
className="emailLabel"
|
328 |
+
onChange={(emailLabel) => {
|
329 |
+
setAttributes({ emailLabel: emailLabel });
|
330 |
+
}}
|
331 |
+
value={attributes.emailLabel}
|
332 |
+
/>
|
333 |
+
<p className="required-text subTitle" style={{ color: "#ee0000" }}>
|
334 |
+
*
|
335 |
+
</p>
|
336 |
+
<input className="textwidget" name="email" type="text"></input>
|
337 |
+
</div>
|
338 |
+
{attributes.emailPermission == "message" && (
|
339 |
+
<span className="disclaimer">
|
340 |
+
{__(
|
341 |
+
"By submitting your information, you are granting us permission to email you. You may unsubscribe at any time.",
|
342 |
+
"cewp4"
|
343 |
+
)}
|
344 |
+
</span>
|
345 |
+
)}
|
346 |
+
{attributes.emailPermission == "checkbox" && (
|
347 |
+
<div>
|
348 |
+
<input
|
349 |
+
type="checkbox"
|
350 |
+
name={`consent_check_${clientId}`}
|
351 |
+
id={`consent_check_${clientId}`}
|
352 |
+
/>
|
353 |
+
<label htmlFor={`consent_check_${clientId}`} className="disclaimer">
|
354 |
+
{__("Can we send you an email from time to time?", "cewp4")}
|
355 |
+
</label>
|
356 |
+
</div>
|
357 |
+
)}
|
358 |
+
<br />
|
359 |
+
<button className="wp-block-button__link submit-button" type="button">
|
360 |
+
{__("Subscribe", "cewp4")}
|
361 |
+
</button>
|
362 |
+
</form>
|
363 |
+
</div>
|
364 |
+
);
|
365 |
+
}
|
src/blocks/subscribe/editor.scss
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.no-flex {
|
2 |
+
display: block;
|
3 |
+
}
|
4 |
+
|
5 |
+
.sub-header {
|
6 |
+
margin-bottom: 1em;
|
7 |
+
}
|
src/blocks/subscribe/index.js
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { registerBlockType } from "@wordpress/blocks";
|
2 |
+
import "./style.scss";
|
3 |
+
import Edit from "./edit";
|
4 |
+
import save from "./save";
|
5 |
+
|
6 |
+
// phpcs:disable
|
7 |
+
/**
|
8 |
+
* Subscribe block.
|
9 |
+
* Adds the gutenberg block subscibe so that users can add a contactform block
|
10 |
+
* for creative mail
|
11 |
+
* @package CreativeMail
|
12 |
+
*/
|
13 |
+
registerBlockType("ce4wp/subscribe", {
|
14 |
+
/**
|
15 |
+
* @see ./edit.js
|
16 |
+
*/
|
17 |
+
edit: Edit,
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @see ./save.js
|
21 |
+
*/
|
22 |
+
save,
|
23 |
+
supports: {
|
24 |
+
// Remove the support for wide alignment.
|
25 |
+
alignWide: false,
|
26 |
+
},
|
27 |
+
});
|
src/blocks/subscribe/save.js
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { __ } from "@wordpress/i18n";
|
2 |
+
import { useBlockProps, RichText } from "@wordpress/block-editor";
|
3 |
+
import { FIELD_SETTING } from "./edit";
|
4 |
+
// phpcs:disable
|
5 |
+
/**
|
6 |
+
* addOnSubmit.
|
7 |
+
* Adds the submit function to subscribe contact forms
|
8 |
+
* @package CreativeMail
|
9 |
+
*/
|
10 |
+
export default function save({ attributes, className }) {
|
11 |
+
return (
|
12 |
+
<div className={`wp-block-ce4wp-subscribe ${className ? className : ''}`}>
|
13 |
+
<div className="onSubmission" style={{ display: 'none' }}>
|
14 |
+
<RichText.Content
|
15 |
+
className="title"
|
16 |
+
tagName="h2"
|
17 |
+
value={attributes.title}
|
18 |
+
/>
|
19 |
+
<p className="subTitle">{__(attributes.onSubmission, "cewp4")}</p>
|
20 |
+
</div>
|
21 |
+
<form className="cm-contact-form" name="contact-form">
|
22 |
+
<input
|
23 |
+
className="list_id"
|
24 |
+
name="list_id"
|
25 |
+
type="hidden"
|
26 |
+
value={attributes.customList}
|
27 |
+
/>
|
28 |
+
<RichText.Content
|
29 |
+
className="title"
|
30 |
+
tagName="h2"
|
31 |
+
value={attributes.title}
|
32 |
+
/>{" "}
|
33 |
+
<RichText.Content
|
34 |
+
className="subTitle"
|
35 |
+
tagName="p"
|
36 |
+
value={attributes.subTitle}
|
37 |
+
/>
|
38 |
+
{attributes.displayFirstName !== FIELD_SETTING.NOTSHOW && (
|
39 |
+
<div className="inputBlock">
|
40 |
+
<RichText.Content
|
41 |
+
tagName="label"
|
42 |
+
value={attributes.firstNameLabel}
|
43 |
+
/>
|
44 |
+
{attributes.displayFirstName === FIELD_SETTING.REQUIRED && (
|
45 |
+
<span
|
46 |
+
className="wp-caption-text required-text"
|
47 |
+
style={{ color: "#ee0000" }}
|
48 |
+
>
|
49 |
+
*
|
50 |
+
</span>
|
51 |
+
)}
|
52 |
+
<input
|
53 |
+
className="firstName"
|
54 |
+
name="first_name"
|
55 |
+
type="text"
|
56 |
+
required={attributes.displayFirstName === FIELD_SETTING.REQUIRED}
|
57 |
+
/>
|
58 |
+
</div>
|
59 |
+
)}
|
60 |
+
{attributes.displayLastName !== FIELD_SETTING.NOTSHOW && (
|
61 |
+
<div className="inputBlock">
|
62 |
+
<RichText.Content
|
63 |
+
tagName="label"
|
64 |
+
value={attributes.lastNameLabel}
|
65 |
+
/>
|
66 |
+
{attributes.displayLastName === FIELD_SETTING.REQUIRED && (
|
67 |
+
<span
|
68 |
+
className="wp-caption-text required-text"
|
69 |
+
style={{ color: "#ee0000" }}
|
70 |
+
>
|
71 |
+
*
|
72 |
+
</span>
|
73 |
+
)}
|
74 |
+
<input
|
75 |
+
className="lastName"
|
76 |
+
name="last_name"
|
77 |
+
type="text"
|
78 |
+
required={attributes.displayFirstName === FIELD_SETTING.REQUIRED}
|
79 |
+
></input>
|
80 |
+
</div>
|
81 |
+
)}
|
82 |
+
{attributes.displayTelephone !== FIELD_SETTING.NOTSHOW && (
|
83 |
+
<div className="inputBlock">
|
84 |
+
<RichText.Content
|
85 |
+
tagName="label"
|
86 |
+
value={attributes.telephoneLabel}
|
87 |
+
/>
|
88 |
+
{attributes.displayTelephone === FIELD_SETTING.REQUIRED && (
|
89 |
+
<span
|
90 |
+
className="wp-caption-text required-text"
|
91 |
+
style={{ color: "#ee0000" }}
|
92 |
+
>
|
93 |
+
*
|
94 |
+
</span>
|
95 |
+
)}
|
96 |
+
<input
|
97 |
+
className="telephone"
|
98 |
+
name="telephone"
|
99 |
+
type="tel"
|
100 |
+
pattern="[+]?[0-9\(\)\s+-]{5,20}"
|
101 |
+
oninvalid={`setCustomValidity('${__("Please enter a valid phone number", "cewp4")}')`}
|
102 |
+
oninput="setCustomValidity('')"
|
103 |
+
required={attributes.displayFirstName === FIELD_SETTING.REQUIRED}
|
104 |
+
></input>
|
105 |
+
</div>
|
106 |
+
)}
|
107 |
+
<div className="inputBlock">
|
108 |
+
<RichText.Content tagName="label" value={attributes.emailLabel} />
|
109 |
+
<span
|
110 |
+
className="wp-caption-text required-text"
|
111 |
+
style={{ color: "#ee0000" }}
|
112 |
+
>
|
113 |
+
*
|
114 |
+
</span>
|
115 |
+
<input
|
116 |
+
className="email"
|
117 |
+
name="email"
|
118 |
+
type="email"
|
119 |
+
oninvalid={`setCustomValidity('${__("Please enter a valid email address", "cewp4")}')`}
|
120 |
+
oninput="setCustomValidity('')"
|
121 |
+
required
|
122 |
+
></input>
|
123 |
+
</div>
|
124 |
+
{attributes.emailPermission == "message" && (
|
125 |
+
<span className="disclaimer">
|
126 |
+
<input
|
127 |
+
className="consent_check"
|
128 |
+
name="consent"
|
129 |
+
type="hidden"
|
130 |
+
checked
|
131 |
+
></input>
|
132 |
+
{__(
|
133 |
+
"By submitting your information, you are granting us permission to email you. You may unsubscribe at any time.",
|
134 |
+
"cewp4"
|
135 |
+
)}
|
136 |
+
</span>
|
137 |
+
)}
|
138 |
+
{attributes.emailPermission == "checkbox" && (
|
139 |
+
<span>
|
140 |
+
<input
|
141 |
+
className="consent_check"
|
142 |
+
name={`consent_check_${attributes.blockId}`}
|
143 |
+
id={`consent_check_${attributes.blockId}`}
|
144 |
+
type="checkbox"
|
145 |
+
/>
|
146 |
+
<label
|
147 |
+
htmlFor={`consent_check_${attributes.blockId}`}
|
148 |
+
className="disclaimer"
|
149 |
+
>
|
150 |
+
{__("Can we send you an email from time to time?", "cewp4")}
|
151 |
+
</label>
|
152 |
+
</span>
|
153 |
+
)}
|
154 |
+
<button className="wp-block-button__link submit-button" type="submit">
|
155 |
+
{__("Subscribe", "cewp4")}
|
156 |
+
</button>
|
157 |
+
</form>
|
158 |
+
</div>
|
159 |
+
);
|
160 |
+
}
|
src/blocks/subscribe/style.scss
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.wp-block-ce4wp-subscribe {
|
2 |
+
max-width: 840px;
|
3 |
+
margin: 0 auto;
|
4 |
+
.title {
|
5 |
+
margin-bottom: 0;
|
6 |
+
}
|
7 |
+
.subTitle {
|
8 |
+
margin-top: 0;
|
9 |
+
font-size: 0.8em;
|
10 |
+
}
|
11 |
+
.disclaimer {
|
12 |
+
margin-top: 5px;
|
13 |
+
font-size: 0.8em;
|
14 |
+
.disclaimer-label {
|
15 |
+
margin-left: 10px;
|
16 |
+
}
|
17 |
+
}
|
18 |
+
.inputBlock {
|
19 |
+
width: 100%;
|
20 |
+
margin-bottom: 10px;
|
21 |
+
input {
|
22 |
+
width: 100%;
|
23 |
+
}
|
24 |
+
label {
|
25 |
+
display: inline-block;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
.submit-button {
|
29 |
+
margin-top: 10px;
|
30 |
+
display: block;
|
31 |
+
}
|
32 |
+
.required-text {
|
33 |
+
display: inline-block;
|
34 |
+
margin: 0;
|
35 |
+
padding: 0;
|
36 |
+
margin-left: 0.3em;
|
37 |
+
}
|
38 |
+
.onSubmission {
|
39 |
+
height: 0;
|
40 |
+
max-width: 840px;
|
41 |
+
margin: 0 auto;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
.ce4wp-link {
|
46 |
+
cursor: pointer;
|
47 |
+
}
|
src/clients/CreativeMailClient.php
CHANGED
@@ -51,6 +51,20 @@ class CreativeMailClient {
|
|
51 |
return $this->parse_most_recent_campaigns( $campaigns_data );
|
52 |
}
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
private function parse_most_recent_campaigns( $campaigns_data )
|
55 |
{
|
56 |
$most_recent_campaigns = [];
|
51 |
return $this->parse_most_recent_campaigns( $campaigns_data );
|
52 |
}
|
53 |
|
54 |
+
public function get_all_custom_lists()
|
55 |
+
{
|
56 |
+
$response = wp_remote_get(
|
57 |
+
EnvironmentHelper::get_app_gateway_url() . 'wordpress/v1.0/lists',
|
58 |
+
$this->get_default_headers()
|
59 |
+
);
|
60 |
+
|
61 |
+
if ( is_wp_error( $response ) ) {
|
62 |
+
throw new CreativeMailException( 'Could not get all custom lists' );
|
63 |
+
}
|
64 |
+
|
65 |
+
return json_decode( $response['body'], true );
|
66 |
+
}
|
67 |
+
|
68 |
private function parse_most_recent_campaigns( $campaigns_data )
|
69 |
{
|
70 |
$most_recent_campaigns = [];
|
src/helpers/EncryptionHelper.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
|
4 |
namespace CreativeMail\Helpers;
|
5 |
|
|
|
6 |
use Defuse\Crypto\Crypto;
|
7 |
use Defuse\Crypto\Key;
|
8 |
|
3 |
|
4 |
namespace CreativeMail\Helpers;
|
5 |
|
6 |
+
use CreativeMail\Managers\RaygunManager;
|
7 |
use Defuse\Crypto\Crypto;
|
8 |
use Defuse\Crypto\Key;
|
9 |
|
src/managers/ApiManager.php
CHANGED
@@ -290,6 +290,24 @@ class ApiManager
|
|
290 |
return true;
|
291 |
}
|
292 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
);
|
294 |
|
295 |
foreach ($routes as $route) {
|
@@ -297,6 +315,22 @@ class ApiManager
|
|
297 |
}
|
298 |
}
|
299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
private function get_plugin_info($onlyActivePlugins)
|
301 |
{
|
302 |
$result = array();
|
@@ -402,7 +436,7 @@ class ApiManager
|
|
402 |
$permission_callback = array( $this, 'validate_wp_admin' );
|
403 |
}
|
404 |
else {
|
405 |
-
$permission_callback = array(
|
406 |
}
|
407 |
|
408 |
// Make sure we at least have a path
|
@@ -611,7 +645,6 @@ class ApiManager
|
|
611 |
return $key;
|
612 |
}
|
613 |
|
614 |
-
|
615 |
/**
|
616 |
* Gets the configured WC REST API key ID.
|
617 |
*
|
290 |
return true;
|
291 |
}
|
292 |
),
|
293 |
+
array (
|
294 |
+
self::ROUTE_PATH => '/get_pages_with_ce_forms',
|
295 |
+
self::ROUTE_METHODS => 'GET',
|
296 |
+
self::ROUTE_CALLBACK => function ($request) {
|
297 |
+
if (version_compare($GLOBALS['wp_version'], '5.5', '<')) {
|
298 |
+
// This is to prevent CE from making the Gutenberg recommendation when Gutenberg isn't supported
|
299 |
+
return $this->modify_response(
|
300 |
+
new WP_REST_Response(
|
301 |
+
array(array( 'page_id' => 1, 'post_title' => '', 'post_status' => 'published' )),
|
302 |
+
200
|
303 |
+
)
|
304 |
+
);
|
305 |
+
}
|
306 |
+
|
307 |
+
$blocks = $this->find_pages_by_content_tag("wp:ce4wp/subscribe");
|
308 |
+
return $this->modify_response(new WP_REST_Response($blocks, 200));
|
309 |
+
}
|
310 |
+
)
|
311 |
);
|
312 |
|
313 |
foreach ($routes as $route) {
|
315 |
}
|
316 |
}
|
317 |
|
318 |
+
private function find_pages_by_content_tag($tag){
|
319 |
+
$pagesWithTag = array();
|
320 |
+
$pages = get_pages(); //defaults are type=page, status=published
|
321 |
+
if (empty($pages)){
|
322 |
+
return null;
|
323 |
+
}
|
324 |
+
|
325 |
+
foreach ($pages as $page){
|
326 |
+
$post_content = $page->post_content;
|
327 |
+
if (strpos($post_content, $tag) !== false){
|
328 |
+
array_push($pagesWithTag, ['page_id' => $page->ID, 'post_title' => $page->post_title, 'post_status' => $page->post_status]);
|
329 |
+
}
|
330 |
+
}
|
331 |
+
return $pagesWithTag;
|
332 |
+
}
|
333 |
+
|
334 |
private function get_plugin_info($onlyActivePlugins)
|
335 |
{
|
336 |
$result = array();
|
436 |
$permission_callback = array( $this, 'validate_wp_admin' );
|
437 |
}
|
438 |
else {
|
439 |
+
$permission_callback = array($this, 'validate_api_key' );
|
440 |
}
|
441 |
|
442 |
// Make sure we at least have a path
|
645 |
return $key;
|
646 |
}
|
647 |
|
|
|
648 |
/**
|
649 |
* Gets the configured WC REST API key ID.
|
650 |
*
|
src/managers/FormManager.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
namespace CreativeMail\Managers;
|
5 |
+
|
6 |
+
use CreativeMail\Clients\CreativeMailClient;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class CheckoutManager
|
10 |
+
*
|
11 |
+
* @package CreativeMail\Managers
|
12 |
+
*/
|
13 |
+
class FormManager
|
14 |
+
{
|
15 |
+
const NONCE = 'nonce';
|
16 |
+
const DOMAIN = 'ce4wp';
|
17 |
+
const TELEPHONE = 'telephone';
|
18 |
+
const FIRSTNAME = 'first_name';
|
19 |
+
const LASTNAME = 'last_name';
|
20 |
+
const EMAIL = 'email';
|
21 |
+
const CONSENT = 'consent';
|
22 |
+
const LISTID = 'list_id';
|
23 |
+
|
24 |
+
private $creative_mail_client;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* DashboardWidgetModule constructor.
|
28 |
+
*/
|
29 |
+
public function __construct()
|
30 |
+
{
|
31 |
+
$this->creative_mail_client = new CreativeMailClient();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Add hooks
|
36 |
+
*
|
37 |
+
* @since 1.4.0+
|
38 |
+
*/
|
39 |
+
public function add_hooks()
|
40 |
+
{
|
41 |
+
add_action('wp_ajax_ce4wp_form_submission', array($this, 'submit_contact'));
|
42 |
+
add_action('wp_ajax_nopriv_ce4wp_form_submission', array($this, 'submit_contact'));
|
43 |
+
add_action('wp_ajax_ce4wp_get_all_custom_lists', array($this, 'get_all_custom_lists'));
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* AJAX handler for subscribed contact.
|
49 |
+
*
|
50 |
+
* @since 1.4.0+
|
51 |
+
*/
|
52 |
+
public function submit_contact()
|
53 |
+
{
|
54 |
+
$data = filter_input_array(INPUT_POST, [
|
55 |
+
self::NONCE => FILTER_SANITIZE_STRING,
|
56 |
+
self::FIRSTNAME => FILTER_SANITIZE_STRING,
|
57 |
+
self::TELEPHONE => FILTER_SANITIZE_STRING,
|
58 |
+
self::LASTNAME => FILTER_SANITIZE_STRING,
|
59 |
+
self::EMAIL => FILTER_SANITIZE_EMAIL,
|
60 |
+
self::CONSENT => FILTER_SANITIZE_STRING,
|
61 |
+
self::LISTID => FILTER_SANITIZE_STRING
|
62 |
+
]);
|
63 |
+
|
64 |
+
if (empty($data[self::NONCE]) || !wp_verify_nonce($data[self::NONCE], 'ce4wp_form_submission')) {
|
65 |
+
wp_send_json_error(esc_html__('Invalid nonce.', self::DOMAIN));
|
66 |
+
}
|
67 |
+
|
68 |
+
do_action('ce4wp_contact_submission', $data);
|
69 |
+
|
70 |
+
wp_send_json_success();
|
71 |
+
}
|
72 |
+
|
73 |
+
public function get_all_custom_lists()
|
74 |
+
{
|
75 |
+
$data = filter_input_array(INPUT_POST, [
|
76 |
+
self::NONCE => FILTER_SANITIZE_STRING
|
77 |
+
]);
|
78 |
+
|
79 |
+
if (empty($data[self::NONCE]) || !wp_verify_nonce($data[self::NONCE], 'ce4wp_get_lists')) {
|
80 |
+
wp_send_json_error(esc_html__('Invalid nonce.', self::DOMAIN));
|
81 |
+
}
|
82 |
+
$list = $this->creative_mail_client->get_all_custom_lists();
|
83 |
+
if(isset($list)) {
|
84 |
+
wp_send_json_success($list);
|
85 |
+
}
|
86 |
+
else {
|
87 |
+
wp_send_json_error(esc_html__('Could not retrieve data.', self::DOMAIN));
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
src/managers/IntegrationManager.php
CHANGED
@@ -16,6 +16,7 @@ use CreativeMail\Modules\Contacts\Handlers\WpFormsPluginHandler;
|
|
16 |
use CreativeMail\Modules\Contacts\Handlers\JetpackPluginHandler;
|
17 |
use CreativeMail\Modules\Contacts\Handlers\NinjaFormsPluginHandler;
|
18 |
use CreativeMail\Modules\Contacts\Handlers\CalderaPluginHandler;
|
|
|
19 |
use ReflectionClass;
|
20 |
|
21 |
/**
|
@@ -57,6 +58,7 @@ class IntegrationManager
|
|
57 |
*/
|
58 |
public function add_hooks()
|
59 |
{
|
|
|
60 |
$active_plugins = array_filter(
|
61 |
$this->get_active_plugins(), function ($item) {
|
62 |
return array_search($item->get_slug(), $this->get_activated_plugins(), true) !== false;
|
@@ -76,6 +78,16 @@ class IntegrationManager
|
|
76 |
RaygunManager::get_instance()->exception_handler($e);
|
77 |
}
|
78 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
|
81 |
/**
|
16 |
use CreativeMail\Modules\Contacts\Handlers\JetpackPluginHandler;
|
17 |
use CreativeMail\Modules\Contacts\Handlers\NinjaFormsPluginHandler;
|
18 |
use CreativeMail\Modules\Contacts\Handlers\CalderaPluginHandler;
|
19 |
+
use CreativeMail\Modules\Contacts\Handlers\CreativeMailPluginHandler;
|
20 |
use ReflectionClass;
|
21 |
|
22 |
/**
|
58 |
*/
|
59 |
public function add_hooks()
|
60 |
{
|
61 |
+
$creativeMail= new Integration('creativemail', 'CreativeMail', 'creativ-email-wordpress-plugin/creative-mail-plugin.php', CreativeMailPluginHandler::class, true);
|
62 |
$active_plugins = array_filter(
|
63 |
$this->get_active_plugins(), function ($item) {
|
64 |
return array_search($item->get_slug(), $this->get_activated_plugins(), true) !== false;
|
78 |
RaygunManager::get_instance()->exception_handler($e);
|
79 |
}
|
80 |
}
|
81 |
+
try {
|
82 |
+
// use reflection to create instance of class
|
83 |
+
$class = new ReflectionClass($creativeMail->get_integration_handler());
|
84 |
+
$this->active_integrations[$creativeMail->get_slug()] = $class->newInstance();
|
85 |
+
|
86 |
+
// register hooks for integration class
|
87 |
+
$this->active_integrations[$creativeMail->get_slug()]->registerHooks();
|
88 |
+
} catch (\Exception $e) {
|
89 |
+
RaygunManager::get_instance()->exception_handler($e);
|
90 |
+
}
|
91 |
}
|
92 |
|
93 |
/**
|
src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php
CHANGED
@@ -64,7 +64,9 @@ class ContactFormSevenPluginHandler extends BaseContactFormPluginHandler
|
|
64 |
$contactModel->setBirthday($birthday);
|
65 |
}
|
66 |
|
67 |
-
$contactModel->setOptIn(
|
|
|
|
|
68 |
$contactModel->setEventType(CE4WP_CF7_EVENTTYPE);
|
69 |
|
70 |
return $contactModel;
|
64 |
$contactModel->setBirthday($birthday);
|
65 |
}
|
66 |
|
67 |
+
$contactModel->setOptIn(true);
|
68 |
+
$contactModel->setOptOut(false);
|
69 |
+
$contactModel->setOptActionBy(OptActionBy::Visitor);
|
70 |
$contactModel->setEventType(CE4WP_CF7_EVENTTYPE);
|
71 |
|
72 |
return $contactModel;
|
src/modules/contacts/Handlers/CreativeMailPluginHandler.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace CreativeMail\Modules\Contacts\Handlers;
|
4 |
+
|
5 |
+
define('CE4WP_EL_EVENTTYPE', 'WordPress - Creative Mail Form');
|
6 |
+
|
7 |
+
use CreativeMail\Managers\RaygunManager;
|
8 |
+
use CreativeMail\Modules\Contacts\Models\ContactModel;
|
9 |
+
use CreativeMail\Modules\Contacts\Models\OptActionBy;
|
10 |
+
|
11 |
+
class CreativeMailPluginHandler extends BaseContactFormPluginHandler
|
12 |
+
{
|
13 |
+
public function convertToContactModel($contact)
|
14 |
+
{
|
15 |
+
$contactModel = new ContactModel();
|
16 |
+
|
17 |
+
$contactModel->setEventType(CE4WP_EL_EVENTTYPE);
|
18 |
+
|
19 |
+
$contactModel->setOptIn(false);
|
20 |
+
$contactModel->setOptOut(false);
|
21 |
+
if (!empty($contact['consent'])) {
|
22 |
+
$consent_bool= $contact['consent'] == 'true';
|
23 |
+
$contactModel->setOptIn($consent_bool);
|
24 |
+
}
|
25 |
+
$contactModel->setOptActionBy(OptActionBy::Visitor);
|
26 |
+
|
27 |
+
if (!empty($contact['email'])) {
|
28 |
+
$contactModel->setEmail($contact['email']);
|
29 |
+
}
|
30 |
+
if (!empty($contact['first_name'])) {
|
31 |
+
$contactModel->setFirstName($contact['first_name']);
|
32 |
+
}
|
33 |
+
if (!empty($contact['last_name'])) {
|
34 |
+
$contactModel->setLastName($contact['last_name']);
|
35 |
+
}
|
36 |
+
if (!empty($contact['telephone'])) {
|
37 |
+
$contactModel->setPhone($contact['telephone']);
|
38 |
+
}
|
39 |
+
if (!empty($contact['list_id'])) {
|
40 |
+
$contactModel->setListId((int)$contact['list_id']);
|
41 |
+
}
|
42 |
+
return $contactModel;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function ceHandleCreativeEmailSubmission($data)
|
46 |
+
{
|
47 |
+
try {
|
48 |
+
$this->upsertContact($this->convertToContactModel($data));
|
49 |
+
} catch (\Exception $exception) {
|
50 |
+
RaygunManager::get_instance()->exception_handler($exception);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
public function registerHooks()
|
55 |
+
{
|
56 |
+
add_action('ce4wp_contact_submission', array($this, 'ceHandleCreativeEmailSubmission'), 10, 1);
|
57 |
+
}
|
58 |
+
|
59 |
+
public function unregisterHooks()
|
60 |
+
{
|
61 |
+
remove_action('ce4wp_contact_submission', array($this, 'ceHandleCreativeEmailSubmission'));
|
62 |
+
}
|
63 |
+
|
64 |
+
public function get_contacts($limit = null)
|
65 |
+
{
|
66 |
+
// We don't store locally yet
|
67 |
+
return null;
|
68 |
+
}
|
69 |
+
}
|
src/modules/contacts/Handlers/ElementorPluginHandler.php
CHANGED
@@ -45,7 +45,7 @@ class ElementorPluginHandler extends BaseContactFormPluginHandler
|
|
45 |
|
46 |
$contactModel->setEventType(CE4WP_EL_EVENTTYPE);
|
47 |
|
48 |
-
$contactModel->setOptIn(
|
49 |
$contactModel->setOptOut(false);
|
50 |
$contactModel->setOptActionBy(OptActionBy::Visitor);
|
51 |
|
45 |
|
46 |
$contactModel->setEventType(CE4WP_EL_EVENTTYPE);
|
47 |
|
48 |
+
$contactModel->setOptIn(true);
|
49 |
$contactModel->setOptOut(false);
|
50 |
$contactModel->setOptActionBy(OptActionBy::Visitor);
|
51 |
|
src/modules/contacts/Handlers/WooCommercePluginHandler.php
CHANGED
@@ -72,10 +72,12 @@ class WooCommercePluginHandler extends BaseContactFormPluginHandler
|
|
72 |
|
73 |
if (!is_null($checkbox_value)) {
|
74 |
$contactModel->setOptActionBy(1);
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
77 |
}
|
78 |
-
|
79 |
}
|
80 |
return $contactModel;
|
81 |
}
|
72 |
|
73 |
if (!is_null($checkbox_value)) {
|
74 |
$contactModel->setOptActionBy(1);
|
75 |
+
if ($checkbox_value === true){
|
76 |
+
$contactModel->setOptIn(true);
|
77 |
+
} elseif ($checkbox_value === false){
|
78 |
+
$contactModel->setOptIn(false);
|
79 |
+
}
|
80 |
}
|
|
|
81 |
}
|
82 |
return $contactModel;
|
83 |
}
|
src/modules/contacts/Managers/ContactsSyncManager.php
CHANGED
@@ -10,21 +10,21 @@ class ContactsSyncManager
|
|
10 |
|
11 |
public function __construct()
|
12 |
{
|
13 |
-
|
14 |
|
15 |
-
|
16 |
}
|
17 |
|
18 |
public function __destruct()
|
19 |
{
|
20 |
-
|
21 |
}
|
22 |
|
23 |
public function publish_contact_sync_request()
|
24 |
{
|
25 |
-
|
26 |
|
27 |
// Start the queue.
|
28 |
$this->contacts_sync_background_processor->save()->dispatch();
|
29 |
}
|
30 |
-
}
|
10 |
|
11 |
public function __construct()
|
12 |
{
|
13 |
+
$this->contacts_sync_background_processor = new ContactsSyncBackgroundProcessor();
|
14 |
|
15 |
+
add_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'publish_contact_sync_request'));
|
16 |
}
|
17 |
|
18 |
public function __destruct()
|
19 |
{
|
20 |
+
remove_action(CE4WP_SYNCHRONIZE_ACTION, array($this, 'publish_contact_sync_request'));
|
21 |
}
|
22 |
|
23 |
public function publish_contact_sync_request()
|
24 |
{
|
25 |
+
$this->contacts_sync_background_processor->push_to_queue(null);
|
26 |
|
27 |
// Start the queue.
|
28 |
$this->contacts_sync_background_processor->save()->dispatch();
|
29 |
}
|
30 |
+
}
|
src/modules/contacts/models/ContactModel.php
CHANGED
@@ -18,6 +18,7 @@ class ContactModel
|
|
18 |
public $contactAddresses;
|
19 |
public $eventType;
|
20 |
private $birthday;
|
|
|
21 |
|
22 |
function __construct()
|
23 |
{
|
@@ -153,6 +154,16 @@ class ContactModel
|
|
153 |
$this->birthday = $birthday;
|
154 |
}
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
function toArray()
|
157 |
{
|
158 |
$result = array(
|
@@ -166,7 +177,8 @@ class ContactModel
|
|
166 |
"opt_in" => $this->getOptIn(),
|
167 |
"opt_out" => $this->getOptOut(),
|
168 |
"opt_action_by" => $this->getOptActionBy(),
|
169 |
-
"event_type" => $this->getEventType()
|
|
|
170 |
);
|
171 |
|
172 |
$address = $this->getContactAddress();
|
18 |
public $contactAddresses;
|
19 |
public $eventType;
|
20 |
private $birthday;
|
21 |
+
private $listId;
|
22 |
|
23 |
function __construct()
|
24 |
{
|
154 |
$this->birthday = $birthday;
|
155 |
}
|
156 |
|
157 |
+
public function getListId()
|
158 |
+
{
|
159 |
+
return $this->listId;
|
160 |
+
}
|
161 |
+
|
162 |
+
public function setListId($listId)
|
163 |
+
{
|
164 |
+
$this->listId = $listId;
|
165 |
+
}
|
166 |
+
|
167 |
function toArray()
|
168 |
{
|
169 |
$result = array(
|
177 |
"opt_in" => $this->getOptIn(),
|
178 |
"opt_out" => $this->getOptOut(),
|
179 |
"opt_action_by" => $this->getOptActionBy(),
|
180 |
+
"event_type" => $this->getEventType(),
|
181 |
+
"list_id" => $this->getListId()
|
182 |
);
|
183 |
|
184 |
$address = $this->getContactAddress();
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit2db489663291a087b9625ad29c014f02::getLoader();
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -6,6 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
|
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
|
|
9 |
'CreativeMail\\Clients\\CreativeMailClient' => $baseDir . '/src/clients/CreativeMailClient.php',
|
10 |
'CreativeMail\\Constants\\EnvironmentNames' => $baseDir . '/src/constants/EnvironmentNames.php',
|
11 |
'CreativeMail\\CreativeMail' => $baseDir . '/src/CreativeMail.php',
|
@@ -22,6 +23,7 @@ return array(
|
|
22 |
'CreativeMail\\Managers\\CheckoutManager' => $baseDir . '/src/managers/CheckoutManager.php',
|
23 |
'CreativeMail\\Managers\\DatabaseManager' => $baseDir . '/src/managers/DatabaseManager.php',
|
24 |
'CreativeMail\\Managers\\EmailManager' => $baseDir . '/src/managers/EmailManager.php',
|
|
|
25 |
'CreativeMail\\Managers\\InstanceManager' => $baseDir . '/src/managers/InstanceManager.php',
|
26 |
'CreativeMail\\Managers\\IntegrationManager' => $baseDir . '/src/managers/IntegrationManager.php',
|
27 |
'CreativeMail\\Managers\\RaygunManager' => $baseDir . '/src/managers/RaygunManager.php',
|
@@ -34,6 +36,7 @@ return array(
|
|
34 |
'CreativeMail\\Modules\\Contacts\\Handlers\\BlueHostBuilderPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/BlueHostBuilderPluginHandler.php',
|
35 |
'CreativeMail\\Modules\\Contacts\\Handlers\\CalderaPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/CalderaPluginHandler.php',
|
36 |
'CreativeMail\\Modules\\Contacts\\Handlers\\ContactFormSevenPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php',
|
|
|
37 |
'CreativeMail\\Modules\\Contacts\\Handlers\\ElementorPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/ElementorPluginHandler.php',
|
38 |
'CreativeMail\\Modules\\Contacts\\Handlers\\FormidablePluginHandler' => $baseDir . '/src/modules/contacts/Handlers/FormidablePluginHandler.php',
|
39 |
'CreativeMail\\Modules\\Contacts\\Handlers\\GravityFormsPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/GravityFormsPluginHandler.php',
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
9 |
+
'CreativeMail\\Blocks\\LoadBlock' => $baseDir . '/src/blocks/LoadBlock.php',
|
10 |
'CreativeMail\\Clients\\CreativeMailClient' => $baseDir . '/src/clients/CreativeMailClient.php',
|
11 |
'CreativeMail\\Constants\\EnvironmentNames' => $baseDir . '/src/constants/EnvironmentNames.php',
|
12 |
'CreativeMail\\CreativeMail' => $baseDir . '/src/CreativeMail.php',
|
23 |
'CreativeMail\\Managers\\CheckoutManager' => $baseDir . '/src/managers/CheckoutManager.php',
|
24 |
'CreativeMail\\Managers\\DatabaseManager' => $baseDir . '/src/managers/DatabaseManager.php',
|
25 |
'CreativeMail\\Managers\\EmailManager' => $baseDir . '/src/managers/EmailManager.php',
|
26 |
+
'CreativeMail\\Managers\\FormManager' => $baseDir . '/src/managers/FormManager.php',
|
27 |
'CreativeMail\\Managers\\InstanceManager' => $baseDir . '/src/managers/InstanceManager.php',
|
28 |
'CreativeMail\\Managers\\IntegrationManager' => $baseDir . '/src/managers/IntegrationManager.php',
|
29 |
'CreativeMail\\Managers\\RaygunManager' => $baseDir . '/src/managers/RaygunManager.php',
|
36 |
'CreativeMail\\Modules\\Contacts\\Handlers\\BlueHostBuilderPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/BlueHostBuilderPluginHandler.php',
|
37 |
'CreativeMail\\Modules\\Contacts\\Handlers\\CalderaPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/CalderaPluginHandler.php',
|
38 |
'CreativeMail\\Modules\\Contacts\\Handlers\\ContactFormSevenPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php',
|
39 |
+
'CreativeMail\\Modules\\Contacts\\Handlers\\CreativeMailPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/CreativeMailPluginHandler.php',
|
40 |
'CreativeMail\\Modules\\Contacts\\Handlers\\ElementorPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/ElementorPluginHandler.php',
|
41 |
'CreativeMail\\Modules\\Contacts\\Handlers\\FormidablePluginHandler' => $baseDir . '/src/modules/contacts/Handlers/FormidablePluginHandler.php',
|
42 |
'CreativeMail\\Modules\\Contacts\\Handlers\\GravityFormsPluginHandler' => $baseDir . '/src/modules/contacts/Handlers/GravityFormsPluginHandler.php',
|
vendor/composer/autoload_psr4.php
CHANGED
@@ -13,5 +13,6 @@ return array(
|
|
13 |
'CreativeMail\\Integrations\\' => array($baseDir . '/src/integrations'),
|
14 |
'CreativeMail\\Helpers\\' => array($baseDir . '/src/helpers'),
|
15 |
'CreativeMail\\Constants\\' => array($baseDir . '/src/constants'),
|
|
|
16 |
'CreativeMail\\' => array($baseDir . '/src'),
|
17 |
);
|
13 |
'CreativeMail\\Integrations\\' => array($baseDir . '/src/integrations'),
|
14 |
'CreativeMail\\Helpers\\' => array($baseDir . '/src/helpers'),
|
15 |
'CreativeMail\\Constants\\' => array($baseDir . '/src/constants'),
|
16 |
+
'CreativeMail\\Blocks\\' => array($baseDir . '/src/blocks'),
|
17 |
'CreativeMail\\' => array($baseDir . '/src'),
|
18 |
);
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -22,15 +22,15 @@ class ComposerAutoloaderInit3bd42710fc65484e098479b31e8e3f23
|
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
-
spl_autoload_register(array('
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
-
spl_autoload_unregister(array('
|
28 |
|
29 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
if ($useStaticLoader) {
|
31 |
require_once __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
-
call_user_func(\Composer\Autoload\
|
34 |
} else {
|
35 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
foreach ($map as $namespace => $path) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit2db489663291a087b9625ad29c014f02
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
+
spl_autoload_register(array('ComposerAutoloaderInit2db489663291a087b9625ad29c014f02', 'loadClassLoader'), true, true);
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit2db489663291a087b9625ad29c014f02', 'loadClassLoader'));
|
28 |
|
29 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
if ($useStaticLoader) {
|
31 |
require_once __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit2db489663291a087b9625ad29c014f02::getInitializer($loader));
|
34 |
} else {
|
35 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
foreach ($map as $namespace => $path) {
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'F' =>
|
@@ -22,6 +22,7 @@ class ComposerStaticInit3bd42710fc65484e098479b31e8e3f23
|
|
22 |
'CreativeMail\\Integrations\\' => 26,
|
23 |
'CreativeMail\\Helpers\\' => 21,
|
24 |
'CreativeMail\\Constants\\' => 23,
|
|
|
25 |
'CreativeMail\\' => 13,
|
26 |
),
|
27 |
);
|
@@ -55,6 +56,10 @@ class ComposerStaticInit3bd42710fc65484e098479b31e8e3f23
|
|
55 |
array (
|
56 |
0 => __DIR__ . '/../..' . '/src/constants',
|
57 |
),
|
|
|
|
|
|
|
|
|
58 |
'CreativeMail\\' =>
|
59 |
array (
|
60 |
0 => __DIR__ . '/../..' . '/src',
|
@@ -72,6 +77,7 @@ class ComposerStaticInit3bd42710fc65484e098479b31e8e3f23
|
|
72 |
);
|
73 |
|
74 |
public static $classMap = array (
|
|
|
75 |
'CreativeMail\\Clients\\CreativeMailClient' => __DIR__ . '/../..' . '/src/clients/CreativeMailClient.php',
|
76 |
'CreativeMail\\Constants\\EnvironmentNames' => __DIR__ . '/../..' . '/src/constants/EnvironmentNames.php',
|
77 |
'CreativeMail\\CreativeMail' => __DIR__ . '/../..' . '/src/CreativeMail.php',
|
@@ -88,6 +94,7 @@ class ComposerStaticInit3bd42710fc65484e098479b31e8e3f23
|
|
88 |
'CreativeMail\\Managers\\CheckoutManager' => __DIR__ . '/../..' . '/src/managers/CheckoutManager.php',
|
89 |
'CreativeMail\\Managers\\DatabaseManager' => __DIR__ . '/../..' . '/src/managers/DatabaseManager.php',
|
90 |
'CreativeMail\\Managers\\EmailManager' => __DIR__ . '/../..' . '/src/managers/EmailManager.php',
|
|
|
91 |
'CreativeMail\\Managers\\InstanceManager' => __DIR__ . '/../..' . '/src/managers/InstanceManager.php',
|
92 |
'CreativeMail\\Managers\\IntegrationManager' => __DIR__ . '/../..' . '/src/managers/IntegrationManager.php',
|
93 |
'CreativeMail\\Managers\\RaygunManager' => __DIR__ . '/../..' . '/src/managers/RaygunManager.php',
|
@@ -100,6 +107,7 @@ class ComposerStaticInit3bd42710fc65484e098479b31e8e3f23
|
|
100 |
'CreativeMail\\Modules\\Contacts\\Handlers\\BlueHostBuilderPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/BlueHostBuilderPluginHandler.php',
|
101 |
'CreativeMail\\Modules\\Contacts\\Handlers\\CalderaPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/CalderaPluginHandler.php',
|
102 |
'CreativeMail\\Modules\\Contacts\\Handlers\\ContactFormSevenPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php',
|
|
|
103 |
'CreativeMail\\Modules\\Contacts\\Handlers\\ElementorPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/ElementorPluginHandler.php',
|
104 |
'CreativeMail\\Modules\\Contacts\\Handlers\\FormidablePluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/FormidablePluginHandler.php',
|
105 |
'CreativeMail\\Modules\\Contacts\\Handlers\\GravityFormsPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/GravityFormsPluginHandler.php',
|
@@ -159,10 +167,10 @@ class ComposerStaticInit3bd42710fc65484e098479b31e8e3f23
|
|
159 |
public static function getInitializer(ClassLoader $loader)
|
160 |
{
|
161 |
return \Closure::bind(function () use ($loader) {
|
162 |
-
$loader->prefixLengthsPsr4 =
|
163 |
-
$loader->prefixDirsPsr4 =
|
164 |
-
$loader->prefixesPsr0 =
|
165 |
-
$loader->classMap =
|
166 |
|
167 |
}, null, ClassLoader::class);
|
168 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit2db489663291a087b9625ad29c014f02
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'F' =>
|
22 |
'CreativeMail\\Integrations\\' => 26,
|
23 |
'CreativeMail\\Helpers\\' => 21,
|
24 |
'CreativeMail\\Constants\\' => 23,
|
25 |
+
'CreativeMail\\Blocks\\' => 20,
|
26 |
'CreativeMail\\' => 13,
|
27 |
),
|
28 |
);
|
56 |
array (
|
57 |
0 => __DIR__ . '/../..' . '/src/constants',
|
58 |
),
|
59 |
+
'CreativeMail\\Blocks\\' =>
|
60 |
+
array (
|
61 |
+
0 => __DIR__ . '/../..' . '/src/blocks',
|
62 |
+
),
|
63 |
'CreativeMail\\' =>
|
64 |
array (
|
65 |
0 => __DIR__ . '/../..' . '/src',
|
77 |
);
|
78 |
|
79 |
public static $classMap = array (
|
80 |
+
'CreativeMail\\Blocks\\LoadBlock' => __DIR__ . '/../..' . '/src/blocks/LoadBlock.php',
|
81 |
'CreativeMail\\Clients\\CreativeMailClient' => __DIR__ . '/../..' . '/src/clients/CreativeMailClient.php',
|
82 |
'CreativeMail\\Constants\\EnvironmentNames' => __DIR__ . '/../..' . '/src/constants/EnvironmentNames.php',
|
83 |
'CreativeMail\\CreativeMail' => __DIR__ . '/../..' . '/src/CreativeMail.php',
|
94 |
'CreativeMail\\Managers\\CheckoutManager' => __DIR__ . '/../..' . '/src/managers/CheckoutManager.php',
|
95 |
'CreativeMail\\Managers\\DatabaseManager' => __DIR__ . '/../..' . '/src/managers/DatabaseManager.php',
|
96 |
'CreativeMail\\Managers\\EmailManager' => __DIR__ . '/../..' . '/src/managers/EmailManager.php',
|
97 |
+
'CreativeMail\\Managers\\FormManager' => __DIR__ . '/../..' . '/src/managers/FormManager.php',
|
98 |
'CreativeMail\\Managers\\InstanceManager' => __DIR__ . '/../..' . '/src/managers/InstanceManager.php',
|
99 |
'CreativeMail\\Managers\\IntegrationManager' => __DIR__ . '/../..' . '/src/managers/IntegrationManager.php',
|
100 |
'CreativeMail\\Managers\\RaygunManager' => __DIR__ . '/../..' . '/src/managers/RaygunManager.php',
|
107 |
'CreativeMail\\Modules\\Contacts\\Handlers\\BlueHostBuilderPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/BlueHostBuilderPluginHandler.php',
|
108 |
'CreativeMail\\Modules\\Contacts\\Handlers\\CalderaPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/CalderaPluginHandler.php',
|
109 |
'CreativeMail\\Modules\\Contacts\\Handlers\\ContactFormSevenPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/ContactFormSevenPluginHandler.php',
|
110 |
+
'CreativeMail\\Modules\\Contacts\\Handlers\\CreativeMailPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/CreativeMailPluginHandler.php',
|
111 |
'CreativeMail\\Modules\\Contacts\\Handlers\\ElementorPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/ElementorPluginHandler.php',
|
112 |
'CreativeMail\\Modules\\Contacts\\Handlers\\FormidablePluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/FormidablePluginHandler.php',
|
113 |
'CreativeMail\\Modules\\Contacts\\Handlers\\GravityFormsPluginHandler' => __DIR__ . '/../..' . '/src/modules/contacts/Handlers/GravityFormsPluginHandler.php',
|
167 |
public static function getInitializer(ClassLoader $loader)
|
168 |
{
|
169 |
return \Closure::bind(function () use ($loader) {
|
170 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit2db489663291a087b9625ad29c014f02::$prefixLengthsPsr4;
|
171 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit2db489663291a087b9625ad29c014f02::$prefixDirsPsr4;
|
172 |
+
$loader->prefixesPsr0 = ComposerStaticInit2db489663291a087b9625ad29c014f02::$prefixesPsr0;
|
173 |
+
$loader->classMap = ComposerStaticInit2db489663291a087b9625ad29c014f02::$classMap;
|
174 |
|
175 |
}, null, ClassLoader::class);
|
176 |
}
|