Plugin Directory

Changeset 2922761

Timestamp:
06/07/2023 09:29:23 AM (14 months ago)
Author:
davecpage
Message:

Updated to version 1.6.1

Location:
wp-dxp/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wp-dxp/trunk/README.txt

    r2916348 r2922761  
    44Requires at least: 6.0.0
    55Tested up to: 6.2.2
    6 Stable tag: 1.6.0
     6Stable tag: 1.6.
    77Requires PHP: 7.3
    88License: GPLv2 or later
     
    102102== Changelog ==
    103103
     104
     105
     106
     107
     108
    104109= 1.6 =
    105110* Redesigned the UI of the plugin ready for future expansion
  • wp-dxp/trunk/public/class-wp-dxp-public.php

    r2881249 r2922761  
    155155    public function getBlocksApi($req)
    156156    {
     157
    157158
    158159        $posts = [];
     
    200201                if(!empty($b['post_id'])){
    201202
    202                     $post = $this->getPost($b['post_id']);
     203                    $post = $this->getPost($b['post_id']);
    203204                    $GLOBALS['WP_DXP_POST_ID'] = $b['post_id'];
     205
    204206
    205207                    // do we have blocks for this post?
    206                     if($post['blocks']){
     208                    if($post['blocks']){
    207209
    208210                        // 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'])){
    210212                            $data[$i] = $this->renderBlock($block);
    211213                        }
     
    225227
    226228                        // do we have a valid post with blocks?
    227                         $post = $this->getPost($slot[0]);
     229                        $post = $this->getPost($slot[0]);
    228230                        $GLOBALS['WP_DXP_POST_ID'] = $slot[0];
    229 
    230                         if($post['blocks']){
     231                        $post = $dxp_post['post'];
     232
     233                        if($dxp_post['blocks']){
    231234
    232235                            // do we have a matchig block?
    233                             if($block = $this->findBlock($slot[1],$post['blocks'])){
     236                            if($block = $this->findBlock($slot[1],$post['blocks'])){
    234237                                $slotContent = $this->renderBlock($block);
    235238                            }
     
    265268
    266269                }
     270
     271
     272
    267273            }
    268274        }
     
    322328
    323329    private function getPost($id){
     330
    324331
    325332        // fetch and cache the post and parse
     
    331338
    332339            if($this->posts[$id]['post']){
     340
     341
    333342                $this->posts[$id]['blocks'] = parse_blocks($this->posts[$id]['post']->post_content);
    334343            }
  • 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  */
     1wp-dxp:empty {
     2  display: none !important;
     3}
  • wp-dxp/trunk/public/js/wp-dxp-public.js

    r2773988 r2922761  
    33    'use strict';
    44
    5     const debug = true;
     5    const debug = e;
    66    const delayed = {};
    77    const DateTime = luxon.DateTime;
     
    5656
    5757
    58    
     58
    5959    /*****
    6060        SECTION DETERMINES IF THE USER IS A NEW USER OR AN EXISTING USER - 'core_new_visitor'
     
    8484
    8585
    86     /***** 
     86    /*****
    8787        SECTION DETERMINES WHEN THE USER LAST VISITED THE SITE - 'core_users_last_visit'
    8888    *****/
     
    124124        var check = false;
    125125        (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)))
    127127            check = true;
    128128        })(navigator.userAgent||navigator.vendor||window.opera);
     
    162162        return "";
    163163    }
    164    
     164
    165165    function log(){
    166166        if(debug){
     
    177177        connectedCallback() {
    178178            if(this.slots || this.post_id){
    179            
     179
    180180                if(undefined === delayed[this.delayed]){
    181181                    delayed[this.delayed] = {
     
    184184                    };
    185185                }
    186            
     186
    187187                delayed[this.delayed].elements.push(this);
    188                
     188
    189189                log('Tag:',this);
    190190            }
     
    198198            return this.getAttribute('slot');
    199199        }
    200        
     200
    201201        get post_id() {
    202202            return this.getAttribute('post-id');
     
    214214            return this.getAttribute('filters');
    215215        }
    216        
     216
    217217        get delayed() {
    218218            let s = this.getAttribute('delayed');
     
    229229
    230230    $(window).on('load', function() {
    231    
     231
    232232        function parse(){
    233        
     233
    234234            Object.keys(delayed).forEach(function(delay){
    235            
     235
    236236                // a parse is underway for this delay
    237237                if(delayed[delay].parsing)
    238238                    return;
    239                    
     239
    240240                log('Parsing delayed:',delay);
    241    
     241
    242242                delayed[delay].parsing = true;
    243            
     243
    244244                const elements = delayed[delay].elements;
    245        
     245
    246246                const blocks = [];
    247247
     
    262262                        block.slots = JSON.parse(el.slots);
    263263                        block.template = el.template;
    264            
     264
    265265                        if(el.filters){
    266266                            block.filters = el.filters;
    267267                        }
    268268                    }
    269            
     269
    270270                    blocks.push(block);
    271271                }
    272                
     272
    273273                if(!blocks.length){
    274274                    delayed[delay].parsing = false;
     
    295295                    },
    296296                }).then(function(response){
    297            
     297
    298298                    const batch = [];
    299            
     299
    300300                    response.data.forEach(function(content){
    301                    
     301
    302302                        // process elements in order
    303303                        const el = elements.shift();
    304        
     304
    305305                        // do we have respective element content?
    306306                        if(content){
    307307                            batch.push([el,content]);
    308308                        }
    309            
     309
    310310                        // no content, remove the placeholder
    311311                        else{
    312312                            el.remove();
    313313                        }
    314                    
     314
    315315                    });
    316                    
     316
    317317                    if(batch.length){
    318318                        setTimeout(function(){
    319319
    320320                            batch.forEach(function(b){
    321                            
     321
    322322                                // replace placeholder element with real content
    323323                                let el = document.createElement('div');
    324324                                el.innerHTML = b[1];
    325325                                el = el.firstChild;
    326                                
     326
    327327                                if(Number(delay)){
    328328                                    el.classList.add('wp-dxp');
     
    345345
    346346                                b[0].replaceWith(el);
    347                                
     347
    348348                                if(Number(delay)){
    349349                                    setTimeout(function(){
     
    361361
    362362                    delayed[delay].parsing = false;
    363                    
     363
    364364                }).catch( err => {
    365365                    console.log(err);
     
    368368            });
    369369        }
    370        
     370
    371371        parse();
    372372
  • wp-dxp/trunk/wp-dxp.php

    r2916348 r2922761  
    1717 * Plugin URI:        https://filter.agency/about/wp-dxp/
    1818 * 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.0
     19 * Version:           1.6.
    2020 * Author:            Filter
    2121 * Author URI:        https://filter.agency
     
    3939 * Rename this for your plugin and update it as you release new versions.
    4040 */
    41 define( 'WP_DXP_VERSION', '1.6.0' );
     41define( 'WP_DXP_VERSION', '1.6.' );
    4242
    4343/**
Note: See TracChangeset for help on using the changeset viewer.