Changeset 2264429
- Timestamp:
- 03/20/2020 10:41:00 AM (6 years ago)
- Location:
- experience-manager/trunk
- Files:
-
- 7 added
- 16 edited
-
assets/codemirror/codemirror.js (modified) (16 diffs)
-
experience-manager.php (modified) (2 diffs)
-
includes/backend/class.tma_settings.php (modified) (2 diffs)
-
includes/backend/segment/banner.php (added)
-
includes/backend/segment/categories.php (modified) (1 diff)
-
includes/backend/segment/class.segment-editor-help.php (modified) (1 diff)
-
includes/backend/segment/class.segment-editor-metabox.php (modified) (2 diffs)
-
includes/backend/segment/class.segment-editor.php (modified) (4 diffs)
-
includes/backend/segment/class.segment-request.php (added)
-
includes/backend/segment/class.segment-validator.php (added)
-
includes/backend/segment/description.php (modified) (4 diffs)
-
includes/class.cookie.php (modified) (1 diff)
-
includes/class.plugins.php (modified) (2 diffs)
-
includes/class.request.php (modified) (12 diffs)
-
includes/modules/ads/advanced/class.advanced_ads.php (modified) (1 diff)
-
includes/modules/class.integrations.php (modified) (2 diffs)
-
includes/modules/messages/wp-popups (added)
-
includes/modules/messages/wp-popups/class.wp-popups.php (added)
-
includes/modules/messages/wp-popups/index.php (added)
-
includes/tma_functions.php (modified) (4 diffs)
-
pages/hosting.php (added)
-
readme.txt (modified) (3 diffs)
-
tma-autoload.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
experience-manager/trunk/assets/codemirror/codemirror.js
r2192435 r2264429 174 174 } 175 175 176 var Delayed = function() {this.id = null;}; 176 var Delayed = function() { 177 this.id = null; 178 this.f = null; 179 this.time = 0; 180 this.handler = bind(this.onTimeout, this); 181 }; 182 Delayed.prototype.onTimeout = function (self) { 183 self.id = 0; 184 if (self.time <= +new Date) { 185 self.f(); 186 } else { 187 setTimeout(self.handler, self.time - +new Date); 188 } 189 }; 177 190 Delayed.prototype.set = function (ms, f) { 178 clearTimeout(this.id); 179 this.id = setTimeout(f, ms); 191 this.f = f; 192 var time = +new Date + ms; 193 if (!this.id || time < this.time) { 194 clearTimeout(this.id); 195 this.id = setTimeout(this.handler, ms); 196 this.time = time; 197 } 180 198 }; 181 199 … … 468 486 order.push(new BidiSpan(0, start, i$7)); 469 487 } else { 470 var pos = i$7, at = order.length ;488 var pos = i$7, at = order.length, isRTL = direction == "rtl" ? 1 : 0; 471 489 for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {} 472 490 for (var j$2 = pos; j$2 < i$7;) { 473 491 if (countsAsNum.test(types[j$2])) { 474 if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); }492 if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); at += isRTL; } 475 493 var nstart = j$2; 476 494 for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {} 477 495 order.splice(at, 0, new BidiSpan(2, nstart, j$2)); 496 at += isRTL; 478 497 pos = j$2; 479 498 } else { ++j$2; } … … 2192 2211 function updateLineWidgets(cm, lineView, dims) { 2193 2212 if (lineView.alignable) { lineView.alignable = null; } 2213 var isWidget = classTest("CodeMirror-linewidget"); 2194 2214 for (var node = lineView.node.firstChild, next = (void 0); node; node = next) { 2195 2215 next = node.nextSibling; 2196 if (node.className == "CodeMirror-linewidget") 2197 { lineView.node.removeChild(node); } 2216 if (isWidget.test(node.className)) { lineView.node.removeChild(node); } 2198 2217 } 2199 2218 insertLineWidgets(cm, lineView, dims); … … 2225 2244 var wrap = ensureLineWrapped(lineView); 2226 2245 for (var i = 0, ws = line.widgets; i < ws.length; ++i) { 2227 var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget" );2246 var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget" + (widget.className ? " " + widget.className : "")); 2228 2247 if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true"); } 2229 2248 positionLineWidget(widget, node, lineView, dims); … … 2948 2967 catch (e) { return null } 2949 2968 var coords = coordsChar(cm, x, y), line; 2950 if (forRect && coords.xRel == 1&& (line = getLine(cm.doc, coords.line).text).length == coords.ch) {2969 if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { 2951 2970 var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; 2952 2971 coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); … … 3537 3556 3538 3557 function setScrollTop(cm, val, forceScroll) { 3539 val = Math.m in(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val);3558 val = Math.max(0, Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val)); 3540 3559 if (cm.display.scroller.scrollTop == val && !forceScroll) { return } 3541 3560 cm.doc.scrollTop = val; … … 3547 3566 // aligned. 3548 3567 function setScrollLeft(cm, val, isScroller, forceScroll) { 3549 val = Math.m in(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);3568 val = Math.max(0, Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth)); 3550 3569 if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return } 3551 3570 cm.doc.scrollLeft = val; … … 6268 6287 return {undo: done, redo: undone} 6269 6288 }, 6270 clearHistory: function() {this.history = new History(this.history.maxGeneration);}, 6289 clearHistory: function() { 6290 var this$1 = this; 6291 6292 this.history = new History(this.history.maxGeneration); 6293 linkedDocs(this, function (doc) { return doc.history = this$1.history; }, true); 6294 }, 6271 6295 6272 6296 markClean: function() { … … 6521 6545 if (files && files.length && window.FileReader && window.File) { 6522 6546 var n = files.length, text = Array(n), read = 0; 6523 var loadFile = function (file, i) { 6524 if (cm.options.allowDropFileTypes && 6525 indexOf(cm.options.allowDropFileTypes, file.type) == -1) 6526 { return } 6527 6528 var reader = new FileReader; 6529 reader.onload = operation(cm, function () { 6530 var content = reader.result; 6531 if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { content = ""; } 6532 text[i] = content; 6533 if (++read == n) { 6547 var markAsReadAndPasteIfAllFilesAreRead = function () { 6548 if (++read == n) { 6549 operation(cm, function () { 6534 6550 pos = clipPos(cm.doc, pos); 6535 6551 var change = {from: pos, to: pos, 6536 text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())), 6552 text: cm.doc.splitLines( 6553 text.filter(function (t) { return t != null; }).join(cm.doc.lineSeparator())), 6537 6554 origin: "paste"}; 6538 6555 makeChange(cm.doc, change); 6539 setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); 6556 setSelectionReplaceHistory(cm.doc, simpleSelection(clipPos(cm.doc, pos), clipPos(cm.doc, changeEnd(change)))); 6557 })(); 6558 } 6559 }; 6560 var readTextFromFile = function (file, i) { 6561 if (cm.options.allowDropFileTypes && 6562 indexOf(cm.options.allowDropFileTypes, file.type) == -1) { 6563 markAsReadAndPasteIfAllFilesAreRead(); 6564 return 6565 } 6566 var reader = new FileReader; 6567 reader.onerror = function () { return markAsReadAndPasteIfAllFilesAreRead(); }; 6568 reader.onload = function () { 6569 var content = reader.result; 6570 if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { 6571 markAsReadAndPasteIfAllFilesAreRead(); 6572 return 6540 6573 } 6541 }); 6574 text[i] = content; 6575 markAsReadAndPasteIfAllFilesAreRead(); 6576 }; 6542 6577 reader.readAsText(file); 6543 6578 }; 6544 for (var i = 0; i < n; ++i) { loadFile(files[i], i); }6579 for (var i = 0; i < files.length; i++) { readTextFromFile(files[i], i); } 6545 6580 } else { // Normal drop 6546 6581 // Don't do a replace if the drop happened inside of the selected text. … … 6852 6887 function endOfLine(visually, cm, lineObj, lineNo, dir) { 6853 6888 if (visually) { 6889 if (cm.doc.direction == "rtl") { dir = -dir; } 6854 6890 var order = getOrder(lineObj, cm.doc.direction); 6855 6891 if (order) { … … 7106 7142 var order = getOrder(line, cm.doc.direction); 7107 7143 if (!order || order[0].level == 0) { 7108 var firstNonWS = Math.max( 0, line.text.search(/\S/));7144 var firstNonWS = Math.max(start.ch, line.text.search(/\S/)); 7109 7145 var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch; 7110 7146 return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky) … … 7222 7258 { cm.replaceSelection("", null, "cut"); } 7223 7259 } 7260 if (gecko && !mac && !handled && code == 46 && e.shiftKey && !e.ctrlKey && document.execCommand) 7261 { document.execCommand("cut"); } 7224 7262 7225 7263 // Turn mouse into crosshair when Alt is held on Mac. … … 7927 7965 // handled in onMouseDown for these browsers. 7928 7966 on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); }); 7967 on(d.input.getField(), "contextmenu", function (e) { 7968 if (!d.scroller.contains(e.target)) { onContextMenu(cm, e); } 7969 }); 7929 7970 7930 7971 // Used to suppress mouse event handling when a touch happens … … 8667 8708 var origDir = dir; 8668 8709 var lineObj = getLine(doc, pos.line); 8710 var lineDir = visually && doc.direction == "rtl" ? -dir : dir; 8669 8711 function findNextLine() { 8670 var l = pos.line + dir;8712 var l = pos.line + lineDir; 8671 8713 if (l < doc.first || l >= doc.first + doc.size) { return false } 8672 8714 pos = new Pos(l, pos.ch, pos.sticky); … … 8682 8724 if (next == null) { 8683 8725 if (!boundToLine && findNextLine()) 8684 { pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir); }8726 { pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir); } 8685 8727 else 8686 8728 { return false } … … 9759 9801 addLegacyProps(CodeMirror); 9760 9802 9761 CodeMirror.version = "5. 49.0";9803 CodeMirror.version = "5.52.0"; 9762 9804 9763 9805 return CodeMirror; -
experience-manager/trunk/experience-manager.php
r2246815 r2264429 5 5 Description: The integration for the experience platform. 6 6 Author: Thorsten Marx 7 Version: 3.2.07 Version: 4.0.0 8 8 Author URI: https://wp-digitalexperience.com/ 9 9 Text Domain: tma-webtools … … 14 14 } 15 15 16 define("TMA_EXPERIENCE_MANAGER_VERSION", " 3.2.0");16 define("TMA_EXPERIENCE_MANAGER_VERSION", "4.0.0"); 17 17 define("TMA_EXPERIENCE_MANAGER_SEGMENT_MATCHING_ALL", "all"); 18 18 define("TMA_EXPERIENCE_MANAGER_SEGMENT_MATCHING_ANY", "any"); -
experience-manager/trunk/includes/backend/class.tma_settings.php
r2237695 r2264429 52 52 add_submenu_page('experience-manager/pages/tma-webtools-admin.php', __("Dashboard", "tma-webtools"), __("Dashboard", "tma-webtools"), 'manage_options', 'experience-manager/pages/tma-webtools-admin.php', null); 53 53 add_submenu_page('experience-manager/pages/tma-webtools-admin.php', __("Settings", "tma-webtools"), __("Settings", "tma-webtools"), 'manage_options', 'tma-webtools-setting-admin', array($this, 'plugin_page')); 54 55 if (tma_exm_dependencies_fulfilled(["module-hosting"])) { 56 add_submenu_page('experience-manager/pages/tma-webtools-admin.php', __("Hosting", "tma-webtools"), __("Hosting", "tma-webtools"), 'manage_options', 'experience-manager/pages/hosting.php', null); 57 } 54 58 } 55 59 … … 58 62 array( 59 63 'id' => 'tma_webtools_option', 60 'title' => __('Basic Settings', ' wedevs')64 'title' => __('Basic Settings', 'tma-webtools') 61 65 ), 62 66 // array( -
experience-manager/trunk/includes/backend/segment/categories.php
r2215120 r2264429 4 4 <p> 5 5 Generate category pathes to use in the category rule <b>"rule(CATEGORY).field("c_categories").path(...)"</b>. 6 Generate category pathes to use in the category rule <b>"{ "conditional" : "category", "field" : "c_categories", "path" : "..." }"</b>. 6 7 Copy the value with leading und ending slash. 7 8 </p> -
experience-manager/trunk/includes/backend/segment/class.segment-editor-help.php
r2215120 r2264429 86 86 function updateSegment() { 87 87 if (window.exmSegmentEditor) { 88 let segmentData = "segment().site('" + exm_siteid + "')"; 88 let segmentObject = {}; 89 segmentObject.site = exm_siteid; 90 segmentObject.conditional = "and"; 91 92 segmentObject.conditions = []; 89 93 let selectedVisit = document.querySelector("input[name='exm_visit']:checked").value; 90 let rules = [];91 94 if (selectedVisit === "first") { 92 rules.push("rule(FIRSTVISIT)")95 segmentObject.conditions.push({"conditional": "firstvisit"}) 93 96 } else if (selectedVisit === "returning") { 94 rules.push("not(rule(FIRSTVISIT))")97 segmentObject.conditions.push({"conditional": "not", "conditions": [{"conditional": "firstvisit"}]}) 95 98 } 96 99 let devices = []; 97 100 if (document.querySelector("[name='exm_device_mobile']").checked) { 98 devices.push(" 'Mobile Phone'");101 devices.push("Mobile Phone"); 99 102 } 100 103 if (document.querySelector("[name='exm_device_desktop']").checked) { 101 devices.push(" 'Desktop'");104 devices.push("Desktop"); 102 105 } 103 106 if (document.querySelector("[name='exm_device_tablet']").checked) { 104 devices.push(" 'Tablet'");107 devices.push("Tablet"); 105 108 } 106 109 if (devices.length > 0) { 107 rules.push("rule(KEYVALUE).name('device.type').values([" + devices.join(",") + "])");110 segmentObject.conditions.push({"conditional": "keyvalue", "name": "device.type", "values": devices}); 108 111 } 109 112 110 113 let selectedOrder = document.querySelector("input[name='exm_order']:checked").value; 111 114 if (selectedOrder === "none") { 112 rules.push("rule(ECOMMERCE_ORDER).exact().count(0)")115 segmentObject.conditions.push({"conditional": "ecommerce_order", "count": 0, "exact" : true}); 113 116 } else if (selectedOrder === "first") { 114 rules.push("rule(ECOMMERCE_ORDER).exact().count(1)")117 segmentObject.conditions.push({"conditional": "ecommerce_order", "count": 1}); 115 118 } else if (selectedOrder === "active") { 116 rules.push("rule(ECOMMERCE_ORDER).count(3)")119 segmentObject.conditions.push({"conditional": "ecommerce_order", "count": 3}); 117 120 } 118 121 let selectedCoupon = document.querySelector("input[name='exm_coupon']:checked").value; 119 122 if (selectedCoupon === "none") { 120 rules.push("rule(ECOMMERCE_COUPON).exact().count(0)")123 segmentObject.conditions.push({"conditional": "ecommerce_coupon", "count": 0, "exact" : true}); 121 124 } else if (selectedCoupon === "lover") { 122 rules.push("rule(ECOMMERCE_COUPON).count(1)")125 segmentObject.conditions.push({"conditional": "ecommerce_coupon", "count": 1}); 123 126 } 124 127 125 segmentData += ".and(" + rules.join(",") + ")"; 126 window.exmSegmentEditor.setValue(segmentData); 128 window.exmSegmentEditor.setValue(JSON.stringify(segmentObject, null, "\t")); 127 129 } 128 130 } -
experience-manager/trunk/includes/backend/segment/class.segment-editor-metabox.php
r2215120 r2264429 57 57 SegmentType::$TYPE // Post type 58 58 ); 59 60 add_meta_box( 61 'tma_segment_editor_support', // Unique ID 62 'Support', // Box title 63 [$this, 'support_banner'], // Content callback, must be of type callable 64 SegmentType::$TYPE // Post type 65 ); 59 66 } 60 67 68 public function support_banner($post) { 69 include 'banner.php'; 70 } 71 61 72 public function description($post) { 62 73 include 'description.php'; … … 104 115 lineNumbers: true, 105 116 matchBrackets: true, 106 mode: "javascript" 117 //mode: "javascript" 118 mode : "application/json" 107 119 }); 108 120 </script> -
experience-manager/trunk/includes/backend/segment/class.segment-editor.php
r2235008 r2264429 62 62 } 63 63 64 $value = get_post_meta($post->ID, 'tma_segment_synced', true); 65 64 $segment = SegmentRequest::getInstance()->load_segment($post->ID); 65 66 $value = FALSE; 67 if ($segment && property_exists($segment, "attributes") && property_exists($segment->attributes, "modified") && 68 $post->post_modified === $segment->attributes->modified) { 69 $value = true; 70 } 66 71 if ($value) { 67 72 ?> … … 135 140 136 141 $siteid = tma_exm_get_site(); 137 $ post_data= array(142 $segment = array( 138 143 'name' => $post->post_title, 139 144 'externalId' => $ID, 140 145 'site' => $siteid, 141 146 'active' => $post->post_status === "publish", 142 'dsl' => $this->get_segment_dsl($post->ID), 143 'period' => $this->get_segment_period($post->ID) 147 'content' => $this->get_segment_dsl($post->ID), 148 'period' => $this->get_segment_period($post->ID), 149 'attributes' => [ 150 'modified' => $post->post_modified 151 ] 144 152 ); 145 153 146 154 tma_exm_log("post data"); 147 tma_exm_log(json_encode($post_data)); 148 149 $request = new \TMA\ExperienceManager\TMA_Request(); 150 $error = FALSE; 151 try { 152 $response = $request->post("/rest/audience", $post_data); 153 154 if ($response !== FALSE) { 155 $code = wp_remote_retrieve_response_code($response); 156 $body_string = wp_remote_retrieve_body($response); 157 $body = json_decode($body_string); 158 tma_exm_log("code " . $code); 159 tma_exm_log("body " . $body_string); 160 161 if ($code === 200) { 162 if ($body->status === "ok") { 163 update_post_meta( 164 $ID, 165 'tma_segment_synced', 166 true 167 ); 168 } else { 169 $error = new \WP_Error("error", $response->body->message); 170 } 171 } else { 172 $error = new \WP_Error("error", "Error while accessing Experience Platform"); 173 } 174 } else { 175 $error = new \WP_Error("error", "Error while accessing Experience Platform"); 176 } 177 } catch (Exception $ex) { 178 $error = new \WP_Error("error", "error publishing audience: " . $ex->getMessage()); 179 } catch (\Unirest\Exception $uex) { 180 $error = new \WP_Error("error", "error publishing audience: " . $uex->getMessage()); 181 } 182 if ($error) { 183 update_post_meta( 184 $ID, 185 'tma_segment_synced', 186 false 187 ); 155 tma_exm_log(json_encode($segment)); 156 157 $valid = SegmentValidator::getInstance()->validate($segment['content']); 158 if ($valid !== TRUE) { 159 $error = new \WP_Error("error", $valid); 160 } else { 161 $error = SegmentRequest::getInstance()->save_segment($ID, $post, $segment); 162 } 163 if ($error !== FALSE) { 188 164 $user_id = get_current_user_id(); 189 165 set_transient("tma_segment_errors_{$post->ID}_{$user_id}", $error, 45); … … 198 174 public function delete($ID) { 199 175 tma_exm_log("delete"); 200 201 delete_post_meta(202 $ID,203 'tma_segment_synced'204 );205 176 206 177 $site = tma_exm_get_site(); … … 220 191 $request = new \TMA\ExperienceManager\TMA_Request(); 221 192 $request->delete("/rest/audience?wpid=" . $ID . "&site=" . $site); 222 update_post_meta(223 $ID,224 'tma_segment_synced',225 false226 );227 193 } 228 194 -
experience-manager/trunk/includes/backend/segment/description.php
r2246815 r2264429 16 16 </style> 17 17 <div class="tma_webtools"> 18 <?php 19 $siteid = ""; 20 if (isset(get_option('tma_webtools_option')['webtools_siteid'])) { 21 $siteid = get_option('tma_webtools_option')['webtools_siteid']; 22 } 23 ?> 24 <h2>Your Site id: <b><?php echo $siteid; ?></b></h2> 18 25 19 <div> 26 20 <p> 27 Your segment definition must start with: <b>segment().site("<?php echo $siteid; ?>")</b> 28 </p> 29 <p> 30 Then a segment definition is simply a sequence of rules linked by AND, OR or NOT. 31 <br/> 32 <i>segment().site("<?php echo $siteid; ?>").<b>and</b>(<rules>)</i> 33 <br/> 34 <i>segment().site("<?php echo $siteid; ?>").<b>or</b>(<rules>)</i> 35 <br/> 36 <i>segment().site("<?php echo $siteid; ?>").<b>not</b>(<rules>)</i> 21 The segment definition is basicly a list of conditionals, written in a simple JSON format. 37 22 </p> 38 23 </div> 39 24 40 <h3> Rules</h3>25 <h3>Conditionals</h3> 41 26 <div> 42 27 <p> … … 45 30 All nested rules must match. 46 31 <br /> 47 <b> and(<list of rules>)</b>32 <b>{ "conditional" : "and", "conditions" : [...]}</b> 48 33 </p> 49 34 <p> … … 52 37 One of the nested rules must match. 53 38 <br /> 54 <b> or(<list of rules>)</b>39 <b>{ "conditional" : "or", "conditions" : [...]}</b> 55 40 </p> 56 41 <p> … … 59 44 None of the nested rules must match. 60 45 <br /> 61 <b> not(<list of rules>)</b>46 <b>{ "conditional" : "not", "conditions" : [...]}</b> 62 47 </p> 63 48 <p> 64 <span class="headline">P AGEVIEW</span>49 <span class="headline">PageView</span> 65 50 <br /> 66 Test if a user has viewed a specific page or posttype. By confention use <posttype>#<slug>51 Test if a user has viewed a specific page or posttype. 67 52 <br /> 68 <b> rule(PAGEVIEW)</b>53 <b>{ "conditional" : "pageview" }</b> 69 54 <br /> 70 55 <span class="subheadline">Examples</span><br/> 71 <span>User has visited the homepage: </span><b> .rule(PAGEVIEW).page('the id').type('page').count(1)</b>56 <span>User has visited the homepage: </span><b>{ "conditional" : "pageview" , "page" : "page_id", "type" : "page", "count" : 1 }</b> 72 57 <br /> 73 <span>User has visited a product page: </span><b>.rule(PAGEVIEW).page('the id').type('product').count(1)</b>58 <span>User has visited a WooCommerce product page: </span><b>{ "conditional" : "pageview" , "page" : "product_id", "type" : "product", "count" : 1 }</b> 74 59 </p> 75 60 <p> 76 <span class="headline">E VENT</span>61 <span class="headline">Event</span> 77 62 <br /> 78 63 A specific event. See <a href="#events">Events Section</a> for all tracked events. 79 64 <br /> 80 <b> rule(EVENT)</b>65 <b>{ "conditional" : "event" }</b> 81 66 <br /> 82 67 <span class="subheadline">Examples</span><br/> 83 <span>User has visited at least two page: </span><b> rule(EVENT).event("pageview").count(2)</b>68 <span>User has visited at least two page: </span><b>{ "conditional" : "event", "event" : "pageview", "count" : 2 }</b> 84 69 </p> 85 70 <p> 86 <span class="headline">F IRSTVISIT</span>71 <span class="headline">FirstVisit</span> 87 72 <br /> 88 73 Check if it is the first visit of a customer. 89 74 <br /> 90 <b> rule(FIRSTVISIT)</b>75 <b>{ "conditional" : "firstvisit"}</b> 91 76 </p> 92 77 <p> 93 <span class="headline">C ATEGORY</span>78 <span class="headline">Category</span> 94 79 <br /> 95 80 Check if a user has visited posts or products of a specific category. 96 81 User the category path generator to get the correct path: <a href="#exm_categories">Category path generator</a> 97 82 <br /> 98 <b> rule(CATEGORY).field('c_categories')</b>83 <b>{ "conditional" : "category", "field" : "c_categories"}</b> 99 84 <br /> 100 85 <span class="subheadline">Examples</span><br/> 101 <span>User has visited at least two post of a category: </span><b> rule(CATEGORY).path('/news/local').field('c_categories').count(2)</b>86 <span>User has visited at least two post of a category: </span><b>{ "conditional" : "category", "field" : "c_categories", "path" : "/news/local/", count: 2 }</b> 102 87 <br/> 103 <span>User has visited at least two products of the category T-Shirts: </span><b> rule(CATEGORY).path('/tshirts/').field('c_categories').count(2)</b>88 <span>User has visited at least two products of the category T-Shirts: </span><b>{ "conditional" : "category", "field" : "c_categories", "path" : "/tshirts/", count: 2 }</b> 104 89 </p> 105 90 <p> 106 <span class="headline">K EYVALUE</span>91 <span class="headline">KeyValue</span> 107 92 <br /> 108 93 The KeyValue-Rule is a generic rule that is used for many purposes. 109 94 <br /> 110 <b> rule(KEYVALUE).name('browser.name').values(['Chrome', 'Firefox'])</b>95 <b>{ "conditional" : "keyvalue"}</b> 111 96 <br /> 112 97 "browser.name" (e.g. Chrome, Firefox, Edge, Safari) <br/> 113 98 "device.type" (e.g. Mobile Phone, Desktop, Tablet, Console, TV Device) <br/> 114 99 <span class="subheadline">Examples</span><br/> 115 <span>User uses firefox or chrome browser: </span><b> rule(KEYVALUE).name('browser.name').values(['Chrome', 'Firefox'])</b>100 <span>User uses firefox or chrome browser: </span><b>{ "conditional" : "keyvalue", "name" : "browser.name", "values": ["Chrome", "Firefox"] }</b> 116 101 <br/> 117 <span>User uses a desktop pc: </span><b> rule(KEYVALUE).name('device.type').values(['Desktop'])</b>102 <span>User uses a desktop pc: </span><b>{ "conditional" : "keyvalue", "name" : "device.type", "values": ["Desktop"] }</b> 118 103 </p> 119 104 </div> -
experience-manager/trunk/includes/class.cookie.php
r2201127 r2264429 55 55 } 56 56 } 57 setcookie($name, $value, time() + $expire, '/', $cookieDomain, true);57 setcookie($name, $value, time() + $expire, '/', $cookieDomain, false, false); 58 58 } 59 59 -
experience-manager/trunk/includes/class.plugins.php
r2246815 r2264429 30 30 31 31 public function woocommerce() { 32 return in_array('woocommerce/woocommerce.php', $this->plugins); 32 return in_array('woocommerce/woocommerce.php', $this->plugins) 33 && is_plugin_active('woocommerce/woocommerce.php'); 33 34 } 34 35 public function easydigitaldownloads() { 35 return in_array('easy-digital-downloads/easy-digital-downloads.php', $this->plugins); 36 return in_array('easy-digital-downloads/easy-digital-downloads.php', $this->plugins) 37 && is_plugin_active('easy-digital-downloads/easy-digital-downloads.php') ; 36 38 } 37 39 … … 45 47 public function popup_maker() { 46 48 return in_array('popup-maker/popup-maker.php', $this->plugins); 49 } 50 51 public function wp_popups() { 52 return in_array('wp-popups-lite/wp-popups-lite.php', $this->plugins); 47 53 } 48 54 -
experience-manager/trunk/includes/class.request.php
r2235008 r2264429 49 49 * setup the request object and return 50 50 */ 51 public function get($url, $parameters = NULL, $headers = ['Content-Type' => "application/json"]) {51 public function get($url, $parameters = NULL, $headers = ['Content-Type' => 'text/plain', 'Accept' => 'application/json']) { 52 52 53 53 if (!isset($this->options["webtools_apikey"]) || !isset($this->options['webtools_url'])) { … … 57 57 tma_exm_log("get request: " . $url); 58 58 59 $webtools_url = $this-> clean_webtools_url($this->options['webtools_url']) . $this->clean_url($url);59 $webtools_url = $this->get_webtools_url() . $this->clean_url($url); 60 60 // $headers["apikey"] = $this->options["webtools_apikey"]; 61 61 62 $parameters = array();63 62 $parameters['method'] = "GET"; 64 63 $parameters['timeout'] = "45"; … … 67 66 // $parameters['headers']['Content-Type'] = "text/plain"; 68 67 $parameters['headers']['apikey'] = $this->options["webtools_apikey"]; 68 $parameters['headers']['site'] = tma_exm_get_site(); 69 69 70 70 tma_exm_log(json_encode($parameters)); … … 85 85 } 86 86 87 $webtools_url = $this-> clean_webtools_url($this->options['webtools_url']) . $this->clean_url($url);87 $webtools_url = $this->get_webtools_url() . $this->clean_url($url); 88 88 89 89 $parameters = array(); … … 94 94 $parameters['headers']['Content-Type'] = "application/json"; 95 95 $parameters['headers']['apikey'] = $this->options["webtools_apikey"]; 96 $parameters['headers']['site'] = tma_exm_get_site(); 96 97 97 98 return $this->garded(function () use ($webtools_url, $parameters) { … … 109 110 return FALSE; 110 111 } 111 $webtools_url = $this-> clean_webtools_url($this->options['webtools_url']) . $this->clean_url($url);112 $webtools_url = $this->get_webtools_url() . $this->clean_url($url); 112 113 113 114 $parameters = array(); … … 119 120 $parameters['headers']['Accept'] = "application/json"; 120 121 $parameters['headers']['apikey'] = $this->options["webtools_apikey"]; 122 $parameters['headers']['site'] = tma_exm_get_site(); 121 123 122 124 return $this->garded(function () use ($webtools_url, $parameters) { … … 134 136 return FALSE; 135 137 } 136 $webtools_url = $this-> clean_webtools_url($this->options['webtools_url']) . $this->clean_url($url);138 $webtools_url = $this->get_webtools_url() . $this->clean_url($url); 137 139 138 140 $parameters = array(); … … 144 146 $parameters['headers']['Accept'] = "application/json"; 145 147 $parameters['headers']['apikey'] = $this->options["webtools_apikey"]; 148 $parameters['headers']['site'] = tma_exm_get_site(); 146 149 147 150 return $this->garded(function () use ($webtools_url, $parameters) { … … 227 230 return FALSE; 228 231 } 232 233 private function get_webtools_url() { 234 $url = $this->options['webtools_url']; 235 if (!tma_endsWith($url, "/")) { 236 return $url . "/"; 237 } 238 return $url; 239 } 229 240 230 241 public function track($event, $page, $customAttributes = null) { … … 238 249 $vid = \TMA\ExperienceManager\TMA_COOKIE_HELPER::getInstance()->getCookie(TMA_COOKIE_HELPER::$COOKIE_VISIT, UUID::v4(), TMA_COOKIE_HELPER::$COOKIE_VISIT_EXPIRE); 239 250 $apikey = $this->options["webtools_apikey"]; 240 $url = $this-> options['webtools_url'];251 $url = $this->get_webtools_url(); 241 252 $siteid = tma_exm_get_site(); 242 253 … … 285 296 $url = $this->options['webtools_url'] . 'rest/userinformation/user?apikey=' . $apikey . '&user=' . $userid 286 297 . '&site=' . $site; 298 tma_exm_log("url: " . $url); 287 299 $result = $this->loadContent($url, '{"user" : {"segments" : []}, "status" : "ok", "default": true}'); 288 300 -
experience-manager/trunk/includes/modules/ads/advanced/class.advanced_ads.php
r2201127 r2264429 54 54 $settings_segments = $settings['segments']; 55 55 56 $uid = \TMA\ExperienceManager\TMA_COOKIE_HELPER::getInstance()->getCookie(TMA_COOKIE_HELPER::$COOKIE_USER, UUID::v4(), TMA_COOKIE_HELPER::$COOKIE_USER_EXPIRE); 57 $request = new TMA_Request(); 58 $response = $request->getSegments($uid); 59 60 $user_segments = []; 61 if ($response !== NULL) { 62 $user_segments = tma_exm_get_user_segments(); 63 } 56 $user_segments = tma_exm_get_user_segments(); 64 57 65 58 //$user_segments = array_map('trim', $user_segments); -
experience-manager/trunk/includes/modules/class.integrations.php
r2246815 r2264429 56 56 \TMA\ExperienceManager\TMA_PopupMakerIntegration::getInstance()->init(); 57 57 } 58 if (\TMA\ExperienceManager\Plugins::getInstance()->wp_popups() && $this->shouldInit("messaging_wp-popups")) { 59 \TMA\ExperienceManager\WP_Popups::getInstance(); 60 } 61 58 62 if (\TMA\ExperienceManager\Plugins::getInstance()->advanced_ads() && $this->shouldInit("messaging_advancedads")) { 59 63 \TMA\ExperienceManager\TMA_AdvancedAdsIntegration::getInstance()->init(); … … 126 130 ), 127 131 array( 132 'name' => 'messaging_wp-popups', 133 'label' => __("Enable WP Popups integration?", "tma-webtools"), 134 'desc' => __("Enable targeting in the WP Popups", "tma-webtools"), 135 'disable' => !\TMA\ExperienceManager\Plugins::getInstance()->wp_popups(), 136 'type' => 'toggle', 137 'default' => '' 138 ), 139 array( 128 140 'name' => 'messaging_advancedads', 129 141 'label' => __("Enable Advanced Ads integration?", "tma-webtools"), -
experience-manager/trunk/includes/tma_functions.php
r2246815 r2264429 18 18 $user_segments = TMA\ExperienceManager\ShortCode_TMA_CONTENT::array_flat($user_segments); 19 19 tma_exm_log(json_encode($user_segments)); 20 20 $settings_segments = array_map('trim', $settings_segments); 21 $user_segments = array_map('trim', $user_segments); 22 $attr_segments = array_map('intval', $attr_segments); 23 $user_segments = array_map('intval', $user_segments); 21 24 return TMA\ExperienceManager\ShortCode_TMA_CONTENT::matching_mode_all($user_segments, $settings_segments); 22 25 } … … 26 29 tma_exm_log(json_encode($settings_segments)); 27 30 $user_segments = TMA\ExperienceManager\ShortCode_TMA_CONTENT::array_flat($user_segments); 31 $settings_segments = array_map('trim', $settings_segments); 32 $user_segments = array_map('trim', $user_segments); 33 $attr_segments = array_map('intval', $attr_segments); 34 $user_segments = array_map('intval', $user_segments); 28 35 tma_exm_log(json_encode($user_segments)); 29 36 … … 32 39 33 40 function tma_exm_get_user_segments($defaultValue = []) { 41 tma_exm_log("tma_exm_get_user_segments"); 34 42 $request = new TMA\ExperienceManager\TMA_Request(); 35 43 $response = $request->getSegments(\TMA\ExperienceManager\TMA_Request::getUserID()); 36 tma_exm_log( json_encode($response));44 tma_exm_log("tma_exm_get_user_segments: " . json_encode($response)); 37 45 if ($response !== NULL && $response !== FALSE && $response->status === "ok" && property_exists($response->user, "actionSystem")) { 38 46 // $tma_config['user_segments'] = $response->user->actionSystem->segments; … … 146 154 147 155 function tma_exm_is_elementor_active() { 148 return \TMA\ExperienceManager\Plugins::getInstance()->elementor() && (\Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode());156 return \TMA\ExperienceManager\Plugins::getInstance()->elementor() && class_exists('\Elementor\Plugin') && (\Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode()); 149 157 } 150 158 function tma_exm_beaver_is_preview() { 151 return \TMA\ExperienceManager\Plugins::getInstance()->beaver() && \FLBuilderModel::is_builder_active();159 return \TMA\ExperienceManager\Plugins::getInstance()->beaver() && class_exists('\FLBuilderModel') && \FLBuilderModel::is_builder_active(); 152 160 } 153 161 function tma_exm_is_editor_active() { -
experience-manager/trunk/readme.txt
r2246815 r2264429 4 4 Requires at least: 4.4.1 5 5 Tested up to: 5.3.2 6 Stable tag: 3.2.07 Version: 3.2.06 Stable tag: 4.0.0 7 Version: 4.0.0 8 8 License: GPLv2 or later 9 9 … … 27 27 * Support for Cache Plugins 28 28 * Support for [Popup Maker](https://wppopupmaker.com/) 29 * Support for [WP Popups](https://wppopups.com/) 29 30 * Support for [Advanced Ads](https://wpadvancedads.com/) 30 31 … … 65 66 66 67 == Changelog == 68 69 4.0.0 70 * New json based segment definition language introduced 71 * Fix segmente sync state 72 * Integration into WP Popups added 73 * JS <-> PHP cookie issue fixed 74 75 Important: This version needs at least version 5.0.0 of the Experience Platform! 67 76 68 77 3.2.0 -
experience-manager/trunk/tma-autoload.php
r2246815 r2264429 25 25 // Popup Maker 26 26 "TMA\ExperienceManager\TMA_PopupMakerIntegration" => "includes/modules/messages/popup-maker/class.popup-maker.php", 27 // WP Popups 28 "TMA\ExperienceManager\WP_Popups" => "includes/modules/messages/wp-popups/class.wp-popups.php", 27 29 // Elementor 28 30 "TMA\ExperienceManager\Elementor_Integration" => "includes/modules/editors/elementor/class.elementor_integration.php", … … 45 47 "TMA\ExperienceManager\Segment\SegmentEditorHelp" => "includes/backend/segment/class.segment-editor-help.php", 46 48 "TMA\ExperienceManager\Segment\SegmentEditorMetaBoxes" => "includes/backend/segment/class.segment-editor-metabox.php", 49 "TMA\ExperienceManager\Segment\SegmentRequest" => "includes/backend/segment/class.segment-request.php", 50 "TMA\ExperienceManager\Segment\SegmentValidator" => "includes/backend/segment/class.segment-validator.php", 47 51 // Event Tracking 48 52 "TMA\ExperienceManager\Events\WC_TRACKER" => "includes/modules/events/class.woocommerce_tracker.php",
Note: See TracChangeset
for help on using the changeset viewer.