Changeset 2922761
- Timestamp:
- 06/07/2023 09:29:23 AM (14 months ago)
- Location:
- wp-dxp/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-dxp/trunk/README.txt
r2916348 r2922761 4 4 Requires at least: 6.0.0 5 5 Tested up to: 6.2.2 6 Stable tag: 1.6. 06 Stable tag: 1.6. 7 7 Requires PHP: 7.3 8 8 License: GPLv2 or later … … 102 102 == Changelog == 103 103 104 105 106 107 108 104 109 = 1.6 = 105 110 * Redesigned the UI of the plugin ready for future expansion -
wp-dxp/trunk/public/class-wp-dxp-public.php
r2881249 r2922761 155 155 public function getBlocksApi($req) 156 156 { 157 157 158 158 159 $posts = []; … … 200 201 if(!empty($b['post_id'])){ 201 202 202 $ post = $this->getPost($b['post_id']);203 $post = $this->getPost($b['post_id']); 203 204 $GLOBALS['WP_DXP_POST_ID'] = $b['post_id']; 205 204 206 205 207 // do we have blocks for this post? 206 if($ post['blocks']){208 if($post['blocks']){ 207 209 208 210 // do we have a matching block? 209 if($block = $this->findBlock($b['block_id'],$ post['blocks'])){211 if($block = $this->findBlock($b['block_id'],$post['blocks'])){ 210 212 $data[$i] = $this->renderBlock($block); 211 213 } … … 225 227 226 228 // do we have a valid post with blocks? 227 $ post = $this->getPost($slot[0]);229 $post = $this->getPost($slot[0]); 228 230 $GLOBALS['WP_DXP_POST_ID'] = $slot[0]; 229 230 if($post['blocks']){ 231 $post = $dxp_post['post']; 232 233 if($dxp_post['blocks']){ 231 234 232 235 // do we have a matchig block? 233 if($block = $this->findBlock($slot[1],$ post['blocks'])){236 if($block = $this->findBlock($slot[1],$post['blocks'])){ 234 237 $slotContent = $this->renderBlock($block); 235 238 } … … 265 268 266 269 } 270 271 272 267 273 } 268 274 } … … 322 328 323 329 private function getPost($id){ 330 324 331 325 332 // fetch and cache the post and parse … … 331 338 332 339 if($this->posts[$id]['post']){ 340 341 333 342 $this->posts[$id]['blocks'] = parse_blocks($this->posts[$id]['post']->post_content); 334 343 } -
wp-dxp/trunk/public/css/wp-dxp-public.css
r2864337 r2922761 1 /** 2 * All of the CSS for your public-facing functionality should be 3 * included in this file. 4 */ 1 wp-dxp:empty { 2 display: none !important; 3 } -
wp-dxp/trunk/public/js/wp-dxp-public.js
r2773988 r2922761 3 3 'use strict'; 4 4 5 const debug = true;5 const debug = e; 6 6 const delayed = {}; 7 7 const DateTime = luxon.DateTime; … … 56 56 57 57 58 58 59 59 /***** 60 60 SECTION DETERMINES IF THE USER IS A NEW USER OR AN EXISTING USER - 'core_new_visitor' … … 84 84 85 85 86 /***** 86 /***** 87 87 SECTION DETERMINES WHEN THE USER LAST VISITED THE SITE - 'core_users_last_visit' 88 88 *****/ … … 124 124 var check = false; 125 125 (function(a){ 126 if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) 126 if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) 127 127 check = true; 128 128 })(navigator.userAgent||navigator.vendor||window.opera); … … 162 162 return ""; 163 163 } 164 164 165 165 function log(){ 166 166 if(debug){ … … 177 177 connectedCallback() { 178 178 if(this.slots || this.post_id){ 179 179 180 180 if(undefined === delayed[this.delayed]){ 181 181 delayed[this.delayed] = { … … 184 184 }; 185 185 } 186 186 187 187 delayed[this.delayed].elements.push(this); 188 188 189 189 log('Tag:',this); 190 190 } … … 198 198 return this.getAttribute('slot'); 199 199 } 200 200 201 201 get post_id() { 202 202 return this.getAttribute('post-id'); … … 214 214 return this.getAttribute('filters'); 215 215 } 216 216 217 217 get delayed() { 218 218 let s = this.getAttribute('delayed'); … … 229 229 230 230 $(window).on('load', function() { 231 231 232 232 function parse(){ 233 233 234 234 Object.keys(delayed).forEach(function(delay){ 235 235 236 236 // a parse is underway for this delay 237 237 if(delayed[delay].parsing) 238 238 return; 239 239 240 240 log('Parsing delayed:',delay); 241 241 242 242 delayed[delay].parsing = true; 243 243 244 244 const elements = delayed[delay].elements; 245 245 246 246 const blocks = []; 247 247 … … 262 262 block.slots = JSON.parse(el.slots); 263 263 block.template = el.template; 264 264 265 265 if(el.filters){ 266 266 block.filters = el.filters; 267 267 } 268 268 } 269 269 270 270 blocks.push(block); 271 271 } 272 272 273 273 if(!blocks.length){ 274 274 delayed[delay].parsing = false; … … 295 295 }, 296 296 }).then(function(response){ 297 297 298 298 const batch = []; 299 299 300 300 response.data.forEach(function(content){ 301 301 302 302 // process elements in order 303 303 const el = elements.shift(); 304 304 305 305 // do we have respective element content? 306 306 if(content){ 307 307 batch.push([el,content]); 308 308 } 309 309 310 310 // no content, remove the placeholder 311 311 else{ 312 312 el.remove(); 313 313 } 314 314 315 315 }); 316 316 317 317 if(batch.length){ 318 318 setTimeout(function(){ 319 319 320 320 batch.forEach(function(b){ 321 321 322 322 // replace placeholder element with real content 323 323 let el = document.createElement('div'); 324 324 el.innerHTML = b[1]; 325 325 el = el.firstChild; 326 326 327 327 if(Number(delay)){ 328 328 el.classList.add('wp-dxp'); … … 345 345 346 346 b[0].replaceWith(el); 347 347 348 348 if(Number(delay)){ 349 349 setTimeout(function(){ … … 361 361 362 362 delayed[delay].parsing = false; 363 363 364 364 }).catch( err => { 365 365 console.log(err); … … 368 368 }); 369 369 } 370 370 371 371 parse(); 372 372 -
wp-dxp/trunk/wp-dxp.php
r2916348 r2922761 17 17 * Plugin URI: https://filter.agency/about/wp-dxp/ 18 18 * Description: Use WordPress as a digital experience platform, adding personalization and conditional rules to the content that your users see and can interact with. Compete with commercial enterprise platforms and add your own rules to match user behavior on, then show or hide blocks based on if your conditions are met. 19 * Version: 1.6. 019 * Version: 1.6. 20 20 * Author: Filter 21 21 * Author URI: https://filter.agency … … 39 39 * Rename this for your plugin and update it as you release new versions. 40 40 */ 41 define( 'WP_DXP_VERSION', '1.6. 0' );41 define( 'WP_DXP_VERSION', '1.6.' ); 42 42 43 43 /**
Note: See TracChangeset
for help on using the changeset viewer.