About code snippets
The snippets provided here have been taken from larger code projects and will probably not run out of the box. Often configurations are included or other unknown objects will be accessed but the idea of the snippet should be clear.
Checking for missing custom contactfields
If you are about to just report the usage of customfields that do not exist the following snippet might be of help. It reads all used fields from a configuration array as it uses a mapping from some database columns to Maileon fields.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function checkForMissingCustomcontactfields() { global $logHandler; $contactsService = new \com_maileon_api_contacts_ContactsService($this->config['MAILEON']); $contactsService->setDebug($this->config['DEBUG']); $response = $contactsService->getCustomFields(); if (!$response->isSuccess()) { $msg = "Unable to get customfields: " . $response->toString(); $logHandler->processFatalError(new \Exception($msg)); } $missing = array(); foreach ($this->config['DB']['TABLES']['CONTACTS']['MAPPING'] as $key => $value) { if ($value['TYPE'] == "CUSTOM" && !empty($value['MAILEON_FIELD_NAME']) && !array_key_exists($value['MAILEON_FIELD_NAME'], $response->getResult()->custom_fields)) { $missing[] = $value['MAILEON_FIELD_NAME']; } } if (sizeof($missing) > 0) { $msg = "Missing custom contactfields: " . join($missing, ", "); $logHandler->processFatalError(new \Exception($msg)); } } |
Creating custom contactfields if required
In this case we create a simple boolean custom field if not available.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
<!DOCTYPE html> <html class="no-js" lang="de-DE"> <head> <link rel="profile" href="http://gmpg.org/xfn/11" /> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Maileon Developers « </title> <meta name='robots' content='max-image-preview:large' /> <link rel='dns-prefetch' href='//d1n0x3qji82z53.cloudfront.net' /> <link rel='dns-prefetch' href='//ajax.googleapis.com' /> <link rel="alternate" type="application/rss+xml" title="Maileon Developers » Feed" href="https://maileon.dev/feed/" /> <link rel="alternate" type="application/rss+xml" title="Maileon Developers » Kommentar-Feed" href="https://maileon.dev/comments/feed/" /> <script type="text/javascript"> /* <![CDATA[ */ window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/svg\/","svgExt":".svg","source":{"concatemoji":"https:\/\/maileon.dev\/wp-includes\/js\/wp-emoji-release.min.js?ver=6.4.1"}}; /*! This file is auto-generated */ !function(i,n){var o,s,e;function c(e){try{var t={supportTests:e,timestamp:(new Date).valueOf()};sessionStorage.setItem(o,JSON.stringify(t))}catch(e){}}function p(e,t,n){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(t,0,0);var t=new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data),r=(e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(n,0,0),new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data));return t.every(function(e,t){return e===r[t]})}function u(e,t,n){switch(t){case"flag":return n(e,"\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f","\ud83c\udff3\ufe0f\u200b\u26a7\ufe0f")?!1:!n(e,"\ud83c\uddfa\ud83c\uddf3","\ud83c\uddfa\u200b\ud83c\uddf3")&&!n(e,"\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f","\ud83c\udff4\u200b\udb40\udc67\u200b\udb40\udc62\u200b\udb40\udc65\u200b\udb40\udc6e\u200b\udb40\udc67\u200b\udb40\udc7f");case"emoji":return!n(e,"\ud83e\udef1\ud83c\udffb\u200d\ud83e\udef2\ud83c\udfff","\ud83e\udef1\ud83c\udffb\u200b\ud83e\udef2\ud83c\udfff")}return!1}function f(e,t,n){var r="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?new OffscreenCanvas(300,150):i.createElement("canvas"),a=r.getContext("2d",{willReadFrequently:!0}),o=(a.textBaseline="top",a.font="600 32px Arial",{});return e.forEach(function(e){o[e]=t(a,e,n)}),o}function t(e){var t=i.createElement("script");t.src=e,t.defer=!0,i.head.appendChild(t)}"undefined"!=typeof Promise&&(o="wpEmojiSettingsSupports",s=["flag","emoji"],n.supports={everything:!0,everythingExceptFlag:!0},e=new Promise(function(e){i.addEventListener("DOMContentLoaded",e,{once:!0})}),new Promise(function(t){var n=function(){try{var e=JSON.parse(sessionStorage.getItem(o));if("object"==typeof e&&"number"==typeof e.timestamp&&(new Date).valueOf()<e.timestamp+604800&&"object"==typeof e.supportTests)return e.supportTests}catch(e){}return null}();if(!n){if("undefined"!=typeof Worker&&"undefined"!=typeof OffscreenCanvas&&"undefined"!=typeof URL&&URL.createObjectURL&&"undefined"!=typeof Blob)try{var e="postMessage("+f.toString()+"("+[JSON.stringify(s),u.toString(),p.toString()].join(",")+"));",r=new Blob([e],{type:"text/javascript"}),a=new Worker(URL.createObjectURL(r),{name:"wpTestEmojiSupports"});return void(a.onmessage=function(e){c(n=e.data),a.terminate(),t(n)})}catch(e){}c(n=f(s,u,p))}t(n)}).then(function(e){for(var t in e)n.supports[t]=e[t],n.supports.everything=n.supports.everything&&n.supports[t],"flag"!==t&&(n.supports.everythingExceptFlag=n.supports.everythingExceptFlag&&n.supports[t]);n.supports.everythingExceptFlag=n.supports.everythingExceptFlag&&!n.supports.flag,n.DOMReady=!1,n.readyCallback=function(){n.DOMReady=!0}}).then(function(){return e}).then(function(){var e;n.supports.everything||(n.readyCallback(),(e=n.source||{}).concatemoji?t(e.concatemoji):e.wpemoji&&e.twemoji&&(t(e.twemoji),t(e.wpemoji)))}))}((window,document),window._wpemojiSettings); /* ]]> */ </script> <link rel='stylesheet' id='crayon-css' href='https://maileon.dev/wp-content/plugins/crayon-syntax-highlighter/css/min/crayon.min.css?ver=_2.7.2_beta' type='text/css' media='all' /> <style id='wp-emoji-styles-inline-css' type='text/css'> img.wp-smiley, img.emoji { display: inline !important; border: none !important; box-shadow: none !important; height: 1em !important; width: 1em !important; margin: 0 0.07em !important; vertical-align: -0.1em !important; background: none !important; padding: 0 !important; } </style> <link rel='stylesheet' id='wp-block-library-css' href='https://maileon.dev/wp-includes/css/dist/block-library/style.min.css?ver=6.4.1' type='text/css' media='all' /> <style id='classic-theme-styles-inline-css' type='text/css'> /*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} </style> <style id='global-styles-inline-css' type='text/css'> body{--wp--preset--color--black: #000000;--wp--preset--color--cyan-bluish-gray: #abb8c3;--wp--preset--color--white: #ffffff;--wp--preset--color--pale-pink: #f78da7;--wp--preset--color--vivid-red: #cf2e2e;--wp--preset--color--luminous-vivid-orange: #ff6900;--wp--preset--color--luminous-vivid-amber: #fcb900;--wp--preset--color--light-green-cyan: #7bdcb5;--wp--preset--color--vivid-green-cyan: #00d084;--wp--preset--color--pale-cyan-blue: #8ed1fc;--wp--preset--color--vivid-cyan-blue: #0693e3;--wp--preset--color--vivid-purple: #9b51e0;--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%);--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan: linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%);--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange: linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%);--wp--preset--gradient--luminous-vivid-orange-to-vivid-red: linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%);--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray: linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%);--wp--preset--gradient--cool-to-warm-spectrum: linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%);--wp--preset--gradient--blush-light-purple: linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%);--wp--preset--gradient--blush-bordeaux: linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%);--wp--preset--gradient--luminous-dusk: linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%);--wp--preset--gradient--pale-ocean: linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%);--wp--preset--gradient--electric-grass: linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%);--wp--preset--gradient--midnight: linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%);--wp--preset--font-size--small: 13px;--wp--preset--font-size--medium: 20px;--wp--preset--font-size--large: 36px;--wp--preset--font-size--x-large: 42px;--wp--preset--spacing--20: 0.44rem;--wp--preset--spacing--30: 0.67rem;--wp--preset--spacing--40: 1rem;--wp--preset--spacing--50: 1.5rem;--wp--preset--spacing--60: 2.25rem;--wp--preset--spacing--70: 3.38rem;--wp--preset--spacing--80: 5.06rem;--wp--preset--shadow--natural: 6px 6px 9px rgba(0, 0, 0, 0.2);--wp--preset--shadow--deep: 12px 12px 50px rgba(0, 0, 0, 0.4);--wp--preset--shadow--sharp: 6px 6px 0px rgba(0, 0, 0, 0.2);--wp--preset--shadow--outlined: 6px 6px 0px -3px rgba(255, 255, 255, 1), 6px 6px rgba(0, 0, 0, 1);--wp--preset--shadow--crisp: 6px 6px 0px rgba(0, 0, 0, 1);}:where(.is-layout-flex){gap: 0.5em;}:where(.is-layout-grid){gap: 0.5em;}body .is-layout-flow > .alignleft{float: left;margin-inline-start: 0;margin-inline-end: 2em;}body .is-layout-flow > .alignright{float: right;margin-inline-start: 2em;margin-inline-end: 0;}body .is-layout-flow > .aligncenter{margin-left: auto !important;margin-right: auto !important;}body .is-layout-constrained > .alignleft{float: left;margin-inline-start: 0;margin-inline-end: 2em;}body .is-layout-constrained > .alignright{float: right;margin-inline-start: 2em;margin-inline-end: 0;}body .is-layout-constrained > .aligncenter{margin-left: auto !important;margin-right: auto !important;}body .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)){max-width: var(--wp--style--global--content-size);margin-left: auto !important;margin-right: auto !important;}body .is-layout-constrained > .alignwide{max-width: var(--wp--style--global--wide-size);}body .is-layout-flex{display: flex;}body .is-layout-flex{flex-wrap: wrap;align-items: center;}body .is-layout-flex > *{margin: 0;}body .is-layout-grid{display: grid;}body .is-layout-grid > *{margin: 0;}:where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;}:where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-color{color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-color{color: var(--wp--preset--color--white) !important;}.has-pale-pink-color{color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-color{color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-color{color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-color{color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-color{color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-color{color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-color{color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-color{color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-color{color: var(--wp--preset--color--vivid-purple) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-background-color{background-color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-pale-pink-background-color{background-color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-background-color{background-color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-background-color{background-color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-background-color{background-color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-background-color{background-color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-background-color{background-color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-background-color{background-color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-background-color{background-color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-background-color{background-color: var(--wp--preset--color--vivid-purple) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-border-color{border-color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-pale-pink-border-color{border-color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-border-color{border-color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-border-color{border-color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-border-color{border-color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-border-color{border-color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-border-color{border-color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-border-color{border-color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-border-color{border-color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-border-color{border-color: var(--wp--preset--color--vivid-purple) !important;}.has-vivid-cyan-blue-to-vivid-purple-gradient-background{background: var(--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple) !important;}.has-light-green-cyan-to-vivid-green-cyan-gradient-background{background: var(--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan) !important;}.has-luminous-vivid-amber-to-luminous-vivid-orange-gradient-background{background: var(--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange) !important;}.has-luminous-vivid-orange-to-vivid-red-gradient-background{background: var(--wp--preset--gradient--luminous-vivid-orange-to-vivid-red) !important;}.has-very-light-gray-to-cyan-bluish-gray-gradient-background{background: var(--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray) !important;}.has-cool-to-warm-spectrum-gradient-background{background: var(--wp--preset--gradient--cool-to-warm-spectrum) !important;}.has-blush-light-purple-gradient-background{background: var(--wp--preset--gradient--blush-light-purple) !important;}.has-blush-bordeaux-gradient-background{background: var(--wp--preset--gradient--blush-bordeaux) !important;}.has-luminous-dusk-gradient-background{background: var(--wp--preset--gradient--luminous-dusk) !important;}.has-pale-ocean-gradient-background{background: var(--wp--preset--gradient--pale-ocean) !important;}.has-electric-grass-gradient-background{background: var(--wp--preset--gradient--electric-grass) !important;}.has-midnight-gradient-background{background: var(--wp--preset--gradient--midnight) !important;}.has-small-font-size{font-size: var(--wp--preset--font-size--small) !important;}.has-medium-font-size{font-size: var(--wp--preset--font-size--medium) !important;}.has-large-font-size{font-size: var(--wp--preset--font-size--large) !important;}.has-x-large-font-size{font-size: var(--wp--preset--font-size--x-large) !important;} .wp-block-navigation a:where(:not(.wp-element-button)){color: inherit;} :where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;} :where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;} .wp-block-pullquote{font-size: 1.5em;line-height: 1.6;} </style> <link rel='stylesheet' id='jquery-ui-standard-css-css' href='//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css?ver=6.4.1' type='text/css' media='all' /> <link rel='stylesheet' id='ce_responsive-css' href='https://maileon.dev/wp-content/plugins/simple-embed-code/css/video-container.min.css?ver=2.3.5' type='text/css' media='all' /> <link rel='stylesheet' id='toc-screen-css' href='https://maileon.dev/wp-content/plugins/table-of-contents-plus/screen.min.css?ver=2309' type='text/css' media='all' /> <link rel='stylesheet' id='tw-bootstrap-css' href='https://maileon.dev/wp-content/themes/the-bootstrap/css/bootstrap.min.css?ver=2.0.3' type='text/css' media='all' /> <link rel='stylesheet' id='the-bootstrap-css' href='https://maileon.dev/wp-content/themes/the-bootstrap/style.min.css?ver=2.0.1' type='text/css' media='all' /> <link rel='stylesheet' id='fancybox-css' href='https://maileon.dev/wp-content/plugins/easy-fancybox/fancybox/1.5.4/jquery.fancybox.min.css?ver=6.4.1' type='text/css' media='screen' /> <script type="text/javascript" src="https://maileon.dev/wp-includes/js/jquery/jquery.min.js?ver=3.7.1" id="jquery-core-js"></script> <script type="text/javascript" src="https://maileon.dev/wp-includes/js/jquery/jquery-migrate.min.js?ver=3.4.1" id="jquery-migrate-js"></script> <script type="text/javascript" id="crayon_js-js-extra"> /* <![CDATA[ */ var CrayonSyntaxSettings = {"version":"_2.7.2_beta","is_admin":"0","ajaxurl":"https:\/\/maileon.dev\/wp-admin\/admin-ajax.php","prefix":"crayon-","setting":"crayon-setting","selected":"crayon-setting-selected","changed":"crayon-setting-changed","special":"crayon-setting-special","orig_value":"data-orig-value","debug":""}; var CrayonSyntaxStrings = {"copy":"Press %s to Copy, %s to Paste","minimize":"Click To Expand Code"}; /* ]]> */ </script> <script type="text/javascript" src="https://maileon.dev/wp-content/plugins/crayon-syntax-highlighter/js/min/crayon.min.js?ver=_2.7.2_beta" id="crayon_js-js"></script> <script type="text/javascript" src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js?ver=6.4.1" id="ace-js"></script> <link rel="https://api.w.org/" href="https://maileon.dev/wp-json/" /><link rel="alternate" type="application/json" href="https://maileon.dev/wp-json/wp/v2/pages/2" /><link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://maileon.dev/xmlrpc.php?rsd" /> <meta name="generator" content="WordPress 6.4.1" /> <link rel="canonical" href="https://maileon.dev/" /> <link rel='shortlink' href='https://maileon.dev/' /> <link rel="alternate" type="application/json+oembed" href="https://maileon.dev/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fmaileon.dev%2F" /> <link rel="alternate" type="text/xml+oembed" href="https://maileon.dev/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fmaileon.dev%2F&format=xml" /> <script type="text/javascript" src="https://maileon.dev/wp-content/plugins/si-captcha-for-wordpress/captcha/si_captcha.js?ver=1700729855"></script> <!-- begin SI CAPTCHA Anti-Spam - login/register form style --> <style type="text/css"> .si_captcha_small { width:175px; height:45px; padding-top:10px; padding-bottom:10px; } .si_captcha_large { width:250px; height:60px; padding-top:10px; padding-bottom:10px; } img#si_image_com { border-style:none; margin:0; padding-right:5px; float:left; } img#si_image_reg { border-style:none; margin:0; padding-right:5px; float:left; } img#si_image_log { border-style:none; margin:0; padding-right:5px; float:left; } img#si_image_side_login { border-style:none; margin:0; padding-right:5px; float:left; } img#si_image_checkout { border-style:none; margin:0; padding-right:5px; float:left; } img#si_image_jetpack { border-style:none; margin:0; padding-right:5px; float:left; } img#si_image_bbpress_topic { border-style:none; margin:0; padding-right:5px; float:left; } .si_captcha_refresh { border-style:none; margin:0; vertical-align:bottom; } div#si_captcha_input { display:block; padding-top:15px; padding-bottom:5px; } label#si_captcha_code_label { margin:0; } input#si_captcha_code_input { width:65px; } p#si_captcha_code_p { clear: left; padding-top:10px; } .si-captcha-jetpack-error { color:#DC3232; } </style> <!-- end SI CAPTCHA Anti-Spam - login/register form style --> <style type="text/css" id="custom-background-css"> body.custom-background { background-color: #efefef; } </style> <!--[if lt IE 9]> <script src="https://maileon.dev/wp-content/themes/the-bootstrap/js/html5shiv.min.js" type="text/javascript"></script> <script src="https://maileon.dev/wp-content/themes/the-bootstrap/js/respond.min.js" type="text/javascript"></script> <![endif]--> </head> <body class="home page-template-default page page-id-2 custom-background content-sidebar"> <div class="container"> <div id="page" class="hfeed row"> <header id="branding" role="banner" class="span12"> <nav class="subnav clearfix"><ul id="menu-main" class="nav nav-pills pull-right"><li id="menu-item-667" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-667 dropdown" data-dropdown="dropdown"><a href="https://maileon.dev/api/" class="dropdown-toggle" data-toggle="dropdown">Docs <b class="caret"></b></a> <ul class="dropdown-menu"> <li id="menu-item-509" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-509"><a href="https://maileon.dev/api/rest-api-1-0/">Rest API v1.0</a></li> <li id="menu-item-2434" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2434"><a href="https://maileon.dev/api/maileon-api-clients/">API Clients</a></li> <li id="menu-item-2512" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2512"><a href="https://maileon.dev/api/webhooks-maileon/">Webhooks – Incoming (Calls from Third-Party- Application towards Maileon)</a></li> <li id="menu-item-2431" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2431"><a href="https://maileon.dev/api/webhooks_external/">Webhooks – Outgoing (Calls from Maileon to Third-Party-Webhoook)</a></li> <li id="menu-item-3176" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3176"><a href="https://maileon.dev/rss-feeds/">RSS Feeds</a></li> <li id="menu-item-3259" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3259"><a href="https://maileon.dev/code-snippets/">Code Snippets</a></li> </ul> </li> <li id="menu-item-2441" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2441"><a href="https://maileon.dev/newsletter/">Newsletter</a></li> <li id="menu-item-2442" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2442"><a href="https://maileon.dev/wp-login.php?action=login">Login</a></li> <li id="menu-item-2444" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2444"><a href="https://maileon.dev/sitemap/">Sitemap</a></li> </ul></nav> <hgroup> <h1 id="site-title"> <a href="https://maileon.dev/" title="Maileon Developers" rel="home"> <span>Maileon Developers</span> </a> </h1> <h2 id="site-description"></h2> </hgroup> <a id="header-image" href="https://maileon.dev/" title="Maileon Developers" rel="home"> <img src="https://maileon.dev/wp-content/uploads/copy-xqlogo.jpg" width="198" height="63" alt="" /> </a> <nav id="access" role="navigation"> <h3 class="assistive-text">Main menu</h3> <div class="skip-link"><a class="assistive-text" href="#content" title="Skip to primary content">Skip to primary content</a></div> <div class="skip-link"><a class="assistive-text" href="#secondary" title="Skip to secondary content">Skip to secondary content</a></div> <div class="navbar navbar-inverse"> <div class="navbar-inner"> <div class="container"> <!-- .btn-navbar is used as the toggle for collapsed navbar content --> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <div class="nav-collapse"> <div class="menu-main-container"><ul id="menu-main-1" class="nav"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-667 dropdown" data-dropdown="dropdown"><a href="https://maileon.dev/api/" class="dropdown-toggle" data-toggle="dropdown">Docs <b class="caret"></b></a> <ul class="dropdown-menu"> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-509"><a href="https://maileon.dev/api/rest-api-1-0/">Rest API v1.0</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2434"><a href="https://maileon.dev/api/maileon-api-clients/">API Clients</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2512"><a href="https://maileon.dev/api/webhooks-maileon/">Webhooks – Incoming (Calls from Third-Party- Application towards Maileon)</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2431"><a href="https://maileon.dev/api/webhooks_external/">Webhooks – Outgoing (Calls from Maileon to Third-Party-Webhoook)</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3176"><a href="https://maileon.dev/rss-feeds/">RSS Feeds</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3259"><a href="https://maileon.dev/code-snippets/">Code Snippets</a></li> </ul> </li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2441"><a href="https://maileon.dev/newsletter/">Newsletter</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2442"><a href="https://maileon.dev/wp-login.php?action=login">Login</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2444"><a href="https://maileon.dev/sitemap/">Sitemap</a></li> </ul></div> <form id="searchform" class="navbar-search pull-right" method="get" action="https://maileon.dev/"> <label for="s" class="assistive-text hidden">Search</label> <input type="search" class="search-query" name="s" id="s" placeholder="Search" /> </form> </div> </div> </div> </div> </nav><!-- #access --> </header><!-- #branding --> <div id="primary" class="span8"> <div class="breadcrumbs"> </div> <div id="content" role="main"> <article id="post-2" class="post-2 page type-page status-publish hentry"> <header class="page-header"> <h1 class="entry-title">Welcome Developers</h1> </header><!-- .entry-header --> <div class="entry-content clearfix"> <p>Read our technical documentations, learn how to connect your system to Maileon by using the API and more. Here you will find code samples, tutorials, tools and help for developers to integrate Maileon efficiently and easy into your own applications.</p> <p>Please note that this portal is currently not complete as work on the API continues and new releases are published regularly. We suggest you check this documentation before you start working with the API or make changes to your existing API connection as ressources and methods may have changed.</p> </div><!-- .entry-content --> </article><!-- #post-2 --> </div><!-- #content --> </div><!-- #primary --> <section id="secondary" class="widget-area span4" role="complementary"> <aside id="recently_updated_pages-4" class="widget well Recently_Updated_Pages"><h2 class="widget-title">Change Log</h2><ul><li class='page_item page-item-1763'><a href='https://maileon.dev/api/rest-api-1-0/transactions/create-transactions/' title='Create Transactions'>Create Transactions</a></li><li class='page_item page-item-684'><a href='https://maileon.dev/api/rest-api-1-0/mailings/create-mailing/' title='Create Mailing'>Create Mailing</a></li><li class='page_item page-item-316'><a href='https://maileon.dev/api/rest-api-1-0/' title='Rest API v1.0'>Rest API v1.0</a></li><li class='page_item page-item-4068'><a href='https://maileon.dev/api/rest-api-1-0/mailing-blacklists/update-mailing-blacklist/' title='Update Mailing Blacklist'>Update Mailing Blacklist</a></li><li class='page_item page-item-4074'><a href='https://maileon.dev/api/rest-api-1-0/mailing-blacklists/delete-mailing-blacklist/' title='Delete Mailing Blacklist'>Delete Mailing Blacklist</a></li><li class='page_item page-item-4049'><a href='https://maileon.dev/api/rest-api-1-0/mailing-blacklists/create-mailing-blacklist/' title='Create Mailing Blacklist'>Create Mailing Blacklist</a></li><li class='page_item page-item-4060'><a href='https://maileon.dev/api/rest-api-1-0/mailing-blacklists/get-mailing-blacklist/' title='Get Mailing Blacklist'>Get Mailing Blacklist</a></li><li class='page_item page-item-4056'><a href='https://maileon.dev/api/rest-api-1-0/mailing-blacklists/get-mailing-blacklists/' title='Get Mailing Blacklists'>Get Mailing Blacklists</a></li><li class='page_item page-item-4079'><a href='https://maileon.dev/api/rest-api-1-0/mailing-blacklists/add-expressions-to-mailing-blacklist/' title='Add expressions to Mailing Blacklist'>Add expressions to Mailing Blacklist</a></li><li class='page_item page-item-4090'><a href='https://maileon.dev/api/rest-api-1-0/mailing-blacklists/' title='Mailing Blacklists'>Mailing Blacklists</a></li></ul></aside></section><!-- #secondary .widget-area --> <footer id="colophon" role="contentinfo" class="span12"> <div id="page-footer" class="well clearfix"> <nav class="subnav"><ul id="menu-main-2" class="credits nav nav-pills pull-left"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-667 dropdown" data-dropdown="dropdown"><a href="https://maileon.dev/api/" class="dropdown-toggle" data-toggle="dropdown">Docs <b class="caret"></b></a> <ul class="dropdown-menu"> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-509"><a href="https://maileon.dev/api/rest-api-1-0/">Rest API v1.0</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2434"><a href="https://maileon.dev/api/maileon-api-clients/">API Clients</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2512"><a href="https://maileon.dev/api/webhooks-maileon/">Webhooks – Incoming (Calls from Third-Party- Application towards Maileon)</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2431"><a href="https://maileon.dev/api/webhooks_external/">Webhooks – Outgoing (Calls from Maileon to Third-Party-Webhoook)</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3176"><a href="https://maileon.dev/rss-feeds/">RSS Feeds</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3259"><a href="https://maileon.dev/code-snippets/">Code Snippets</a></li> </ul> </li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2441"><a href="https://maileon.dev/newsletter/">Newsletter</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2442"><a href="https://maileon.dev/wp-login.php?action=login">Login</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2444"><a href="https://maileon.dev/sitemap/">Sitemap</a></li> </ul></nav> <div class="footer-logo" align="right"> <a href="http://www.xqueue.de" target="_blank"> <img src="http://dev.maileon.com/wp-content/uploads/xqlogo.jpg"> </a> </div> </div><!-- #page-footer .well .clearfix --> </footer><!-- #colophon --> </div><!-- #page --> </div><!-- .container --> <!-- 70 queries. 0,947 seconds. --> <script type="text/javascript" id="toc-front-js-extra"> /* <![CDATA[ */ var tocplus = {"smooth_scroll":"1","visibility_show":"show","visibility_hide":"hide","visibility_hide_by_default":"1","width":"Auto"}; /* ]]> */ </script> <script type="text/javascript" src="https://maileon.dev/wp-content/plugins/table-of-contents-plus/front.min.js?ver=2309" id="toc-front-js"></script> <script type="text/javascript" src="https://maileon.dev/wp-content/themes/the-bootstrap/js/bootstrap.min.js?ver=2.0.3" id="tw-bootstrap-js"></script> <script type="text/javascript" src="https://maileon.dev/wp-content/themes/the-bootstrap/js/the-bootstrap.min.js?ver=2.0.1" id="the-bootstrap-js"></script> <script type="text/javascript" src="https://maileon.dev/wp-content/plugins/easy-fancybox/fancybox/1.5.4/jquery.fancybox.min.js?ver=6.4.1" id="jquery-fancybox-js"></script> <script type="text/javascript" id="jquery-fancybox-js-after"> /* <![CDATA[ */ var fb_timeout, fb_opts={'overlayShow':true,'hideOnOverlayClick':true,'showCloseButton':true,'margin':20,'enableEscapeButton':true,'autoScale':true }; if(typeof easy_fancybox_handler==='undefined'){ var easy_fancybox_handler=function(){ jQuery([".nolightbox","a.wp-block-fileesc_html__button","a.pin-it-button","a[href*='pinterest.com\/pin\/create']","a[href*='facebook.com\/share']","a[href*='twitter.com\/share']"].join(',')).addClass('nofancybox'); jQuery('a.fancybox-close').on('click',function(e){e.preventDefault();jQuery.fancybox.close()}); /* IMG */ var fb_IMG_select=jQuery('a[href*=".jpg" i]:not(.nofancybox,li.nofancybox>a),area[href*=".jpg" i]:not(.nofancybox),a[href*=".gif" i]:not(.nofancybox,li.nofancybox>a),area[href*=".gif" i]:not(.nofancybox),a[href*=".png" i]:not(.nofancybox,li.nofancybox>a),area[href*=".png" i]:not(.nofancybox)'); fb_IMG_select.addClass('fancybox image').attr('rel','gallery'); jQuery('a.fancybox,area.fancybox,.fancybox>a').each(function(){jQuery(this).fancybox(jQuery.extend(true,{},fb_opts,{'transitionIn':'elastic','easingIn':'easeOutBack','transitionOut':'elastic','easingOut':'easeInBack','opacity':false,'hideOnContentClick':false,'titleShow':true,'titlePosition':'over','titleFromAlt':true,'showNavArrows':true,'enableKeyboardNav':true,'cyclic':false}))}); };}; var easy_fancybox_auto=function(){setTimeout(function(){jQuery('a#fancybox-auto,#fancybox-auto>a').first().trigger('click')},1000);}; jQuery(easy_fancybox_handler);jQuery(document).on('post-load',easy_fancybox_handler); jQuery(easy_fancybox_auto); /* ]]> */ </script> <script type="text/javascript" src="https://maileon.dev/wp-content/plugins/easy-fancybox/vendor/jquery.easing.min.js?ver=1.4.1" id="jquery-easing-js"></script> <script type="text/javascript" src="https://maileon.dev/wp-content/plugins/easy-fancybox/vendor/jquery.mousewheel.min.js?ver=3.1.13" id="jquery-mousewheel-js"></script> <script type="text/javascript" src="https://maileon.dev/wp-content/plugins/page-links-to/dist/new-tab.js?ver=3.3.6" id="page-links-to-js"></script> </body> </html> |
Creating transaction types if not available
The idea behind this snippet is that you provide a transaction name and a transaction id in a configuration array. If the ID is not set, the script will search for a transaction with the given name. If that is not found, it will be set up using all the attributes which are also predefined in the configuration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
function checkTransactionType() { global $errorHandler; // If not set manually try finding it automatically if (empty($this->config['ORDER_IMPORTER']['TRANSACTION_TYPE_ID'])) { $transactionsService = new \com_maileon_api_transactions_TransactionsService($this->config['MAILEON']); $transactionsService->setDebug($this->config['DEBUG']); // Get from maileon the transaction type. If it does not exist: create it $response = $transactionsService->getTransactionTypes(1, 1000); // Print all results if ($response->isSuccess()) { $transactionTypeId = null; foreach ($response->getResult() as $transactionType) { if ($transactionType->name == $this->config['ORDER_IMPORTER']['TRANSACTION_TYPE_NAME']) { $transactionTypeId = $transactionType->id; } } if (empty($transactionTypeId)) { $transactionTypeId = $this->createTransactionType(); } } $this->config['ORDER_IMPORTER']['TRANSACTION_TYPE_ID'] = intval($transactionTypeId); $errorHandler->getErrorLogger()->warning("No transaction type set for order transactions. Please set config['ORDER_IMPORTER']['TRANSACTION_TYPE_ID'] to '$transactionTypeId'", 'checkTransactionType'); } } function createTransactionType() { global $errorHandler; $transactionsService = new \com_maileon_api_transactions_TransactionsService($this->config['MAILEON']); $transactionsService->setDebug($this->config['DEBUG']); $attributes = array(); foreach ($this->config['DB']['TABLES']['ORDERS']['MAPPING'] as $key => $value) { if (!empty($value['TYPE']) && $value['TYPE'] == "IGNORE") { // Some special fields like email, just ignore it continue; } array_push($attributes, new \com_maileon_api_transactions_AttributeType(null, $value['MAILEON_TX_ATTRIBUTE_NAME'], \com_maileon_api_transactions_DataType::getDataType($value['MAILEON_TX_ATTRIBUTE_DATATYPE']), false)); } $transactionType = new \com_maileon_api_transactions_TransactionType(null, $this->config['ORDER_IMPORTER']['TRANSACTION_TYPE_NAME'], $attributes, 365); $response = $transactionsService->createTransactionType($transactionType); if (!$response->isSuccess()) { $errorHandler->processFatalError(new \Exception("Unable create transaction type: " . $response->getBodyData())); } else { $errorHandler->getInfoLogger()->warning("No transaction type found for submitting orders. Created type with ID " . $response->getResult()); } return $response->getResult(); } |