Plugin Directory

Changeset 2117416


Ignore:
Timestamp:
07/04/2019 08:54:17 AM (7 years ago)
Author:
nikmelnik
Message:
  • добавлен функционал для срабатывания шорткодов;
  • подправлена работа кэша;
  • другие мелкие фиксы и правки.
Location:
realbig-media/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • realbig-media/trunk/asyncBlockInserting.js

    r2115464 r2117416  
    2525// }
    2626
     27if (typeof endedSc === 'undefined') {
     28    var endedSc = false;
     29}
     30if (typeof endedCc === 'undefined') {
     31    var endedCc = false;
     32}
     33
     34// "sc" in variables - mark for shortcode variable
    2735function shortcodesInsert() {
    28     let gatheredBlocks = document.querySelectorAll('percentPointerClass');
     36    let gatheredBlocks = document.querySelectorAll('.percentPointerClass.scMark');
    2937    let scBlockId = -1;
    3038    let scAdId = -1;
     
    3341    let okStates = ['done','refresh-wait','no-block','fetched'];
    3442    let scContainer;
     43    let scRepeatFuncLaunch = false;
    3544
    3645    if (gatheredBlocks&&gatheredBlocks.length > 0) {
    3746        for (let i = 0; i < gatheredBlocks.length; i++) {
    3847            gatheredBlockChild = gatheredBlocks[i].children[0];
    39             scAdId = -1;
     48            if (!gatheredBlockChild) {
     49                continue;
     50            }
     51            scAdId = -3;
     52            blockStatus = null;
     53            scContainer = null;
    4054
    4155            scAdId = gatheredBlockChild.getAttribute('data-aid');
    4256            blockStatus = gatheredBlockChild.getAttribute('data-state');
    4357
    44             if (blockStatus&&okStates.includes(blockStatus)&&scAdId > 0) {
    45                 scContainer = document.querySelector('.shortcodes[data-id='+scAdId+']');
    46 
    47                 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    48                 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    49                 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    50 
    51                 // scBlockId = gatheredBlockChild.getAttribute('data-id');
    52             }
    53         }
     58            if (scAdId > 0) {
     59                if (blockStatus&&okStates.includes(blockStatus)) {
     60                    scContainer = gatheredBlocks[i].parentElement.querySelector('.shortcodes[data-id="'+scAdId+'"]');
     61                    if (scContainer) {
     62                        if (blockStatus=='no-block') {
     63                            gatheredBlockChild.innerHTML = '';
     64                        } else {
     65                            gatheredBlockChild.innerHTML = scContainer.innerHTML;
     66                        }
     67                        scContainer.remove();
     68                    }
     69                    gatheredBlocks[i].classList.remove('scMark');
     70                } else {
     71                    scRepeatFuncLaunch = true;
     72                }
     73            } else if (scAdId == -3||scAdId === null) {
     74                scRepeatFuncLaunch = true;
     75            }
     76        }
     77
     78        if (scRepeatFuncLaunch) {
     79            // console.log('shortcodes-alert');
     80            setTimeout(function () {
     81                shortcodesInsert();
     82            }, 100);
     83        }
     84    } else {
     85        endedSc = true;
     86    }
     87}
     88
     89function clearUnsuitableCache(cuc_cou) {
     90    let scAdId = -1;
     91    let ccRepeat = false;
     92
     93    let gatheredBlocks = document.querySelectorAll('.percentPointerClass .content_rb');
     94
     95    if (gatheredBlocks&&gatheredBlocks.length > 0) {
     96        for (let i = 0; i < gatheredBlocks.length; i++) {
     97            if (gatheredBlocks[i]['dataset']['aid']&&gatheredBlocks[i]['dataset']['aid'] < 0) {
     98                if ((gatheredBlocks[i]['dataset']["state"]=='no-block')||(['done','fetched','refresh-wait'].includes(gatheredBlocks[i]['dataset']["state"]))) {
     99                    gatheredBlocks[i]['innerHTML'] = '';
     100                } else {
     101                    ccRepeat = true;
     102                }
     103            } else if (!gatheredBlocks[i]['dataset']['aid']) {
     104                ccRepeat = true;
     105            }
     106        }
     107        if (cuc_cou < 50) {
     108            if (ccRepeat) {
     109                // console.log('cache-alert:'+cuc_cou);
     110                setTimeout(function () {
     111                    clearUnsuitableCache(cuc_cou+1);
     112                }, 100);
     113            }
     114        } else {
     115            endedCc = true;
     116        }
     117    } else {
     118        endedCc = true;
    54119    }
    55120}
     
    392457        window.addEventListener('load', function () {
    393458            if (repeat = true) {
     459                // console.log('async-blocks-alert');
    394460                setTimeout(function () {
    395461                    asyncBlocksInsertingFunction(blockSettingArray, contentLength)
     
    404470function asyncFunctionLauncher() {
    405471    if (window.jsInputerLaunch !== undefined&&jsInputerLaunch == 15) {
    406         // if () {
    407472        asyncBlocksInsertingFunction(blockSettingArray, contentLength);
    408         // }
     473        if (!endedSc) {
     474            shortcodesInsert();
     475        }
     476        if (!endedCc) {
     477            // clearUnsuitableCache(0);
     478        }
    409479    } else {
     480        // console.log('wait-async-blocks-launch-alert');
    410481        setTimeout(function () {
    411482            asyncFunctionLauncher();
    412         }, 50)
     483        }, 50);
    413484    }
    414485}
     
    491562    }
    492563    if (repeatSearch == 1) {
     564        // console.log('insertings-alert');
    493565        setTimeout(function () {
    494566            asyncInsertingsInsertingFunction(insertingsArray);
    495         }, 50)
     567        }, 100)
    496568    }
    497569}
     
    501573        asyncInsertingsInsertingFunction(insertingsArray);
    502574    } else {
     575        // console.log('insertings-launch-alert');
    503576        setTimeout(function () {
    504577            insertingsFunctionLaunch();
    505         }, 50)
     578        }, 100)
    506579    }
    507580}
  • realbig-media/trunk/readyAdGather.js

    r2115464 r2117416  
    5656        }
    5757
    58         clearUnsuitableCache();
     58        // clearUnsuitableCache();
    5959       
    6060        blocks = JSON.stringify(blocks);
    6161        sendReadyBlocksNew(blocks);
    62     }
    63 }
    64 
    65 function clearUnsuitableCache() {
    66     let gatheredBlocks = document.querySelectorAll('.percentPointerClass .content_rb');
    67 
    68     if (gatheredBlocks&&gatheredBlocks.length > 0) {
    69         for (let i = 0; i < gatheredBlocks; i++) {
    70             if ((gatheredBlocks[i]['dataset']["state"]=='no-block')||(['done','fetched'].includes(gatheredBlocks[i]['dataset']["state"])&&gatheredBlocks[i]['dataset']['aid'] < 0)) {
    71                 gatheredBlocks[i]['innerHTML'] = '';
    72             }
    73         }
    7462    }
    7563}
  • realbig-media/trunk/realbigForWP.php

    r2115464 r2117416  
    1414Plugin name:  Realbig Media
    1515Description:  Плагин для монетизации от RealBig.media
    16 Version:      0.1.26.69
     16Version:      0.1.26.70
    1717Author:       Realbig Team
    1818License:      GPLv2 or later
     
    153153        $GLOBALS['realbigForWP_version'] = $pluginData['Version'];
    154154    } else {
    155         $GLOBALS['realbigForWP_version'] = '0.1.26.69';
     155        $GLOBALS['realbigForWP_version'] = '0.1.26.70';
    156156    }
    157157    $lastSuccessVersionGatherer = get_option('realbig_status_gatherer_version');
     
    518518//      $rotatorUrl = $prefix."://".$getDomain."/".$getRotator.".min.js";
    519519
    520         if (!empty($GLOBALS['kill_rb'])&&$GLOBALS['kill_rb']==2) {
     520        if (!empty($GLOBALS['dev_mode'])&&!empty($GLOBALS['kill_rb'])&&$GLOBALS['kill_rb']==2) {
    521521            $rotatorUrl = "HTTPS://ex.ua";
    522522        } else {
     
    669669//    }
    670670
    671 //    if (empty(apply_filters('wp_doing_cron', defined('DOING_CRON')&&DOING_CRON))&&!is_admin()) {
     671    if (empty(apply_filters('wp_doing_cron', defined('DOING_CRON')&&DOING_CRON))&&!is_admin()) {
    672672//      $penyok_stoparik = 0;
    673 //
     673
    674674//      function test_sc_oval_exec() {
    675675//          return '<div style="width: 100px; height: 20px; border: 1px solid black; background-color: #0033cc; border-radius: 30%;"></div>';
    676676//      }
    677677//      add_shortcode('test_sc_oval', 'test_sc_oval_exec');
    678 //
    679 //      add_filter('the_content', 'RFWP_activateShortCodes', 502);
    680 //    }
     678
     679        add_filter('the_content', 'RFWP_activateShortCodes', 502);
     680    }
    681681    /************* end blocks for text ************************************************************************************/
    682682    /************* adding insertings in text *****************************************************/
     
    775775                $rotatorResponce = wp_safe_remote_head($rotatorUrl, ['timeout' => 1]);
    776776
    777                 $cachedBlocks = '';
    778 //              if (!is_array($rotatorResponce)||(!empty($rotatorResponce['response']['code'])&&$rotatorResponce['response']['code']!=200)) {
    779 //                  ?><!--<script>console.log('using cache')</script>--><?php
    780                 $mobileCheck = RFWP_wp_is_mobile();
    781                 $GLOBALS['rb_mobile_check'] = $mobileCheck;
    782                 if (!empty($mobileCheck)) {
    783                     $cachedBlocks = get_posts(['post_type' => 'rb_block_mobile_new','numberposts' => 100]);
    784                 } else {
    785                     $cachedBlocks = get_posts(['post_type' => 'rb_block_desktop_new','numberposts' => 100]);
    786                 }
     777                $cachedBlocks = '';
     778                if (!is_array($rotatorResponce)||(!empty($rotatorResponce['response']['code'])&&$rotatorResponce['response']['code']!=200)) {
     779    //                  ?><!--<script>console.log('using cache')</script>--><?php
     780                    $mobileCheck = RFWP_wp_is_mobile();
     781                    $GLOBALS['rb_mobile_check'] = $mobileCheck;
     782                    if (!empty($mobileCheck)) {
     783                        $cachedBlocks = get_posts(['post_type' => 'rb_block_mobile_new','numberposts' => 100]);
     784                    } else {
     785                        $cachedBlocks = get_posts(['post_type' => 'rb_block_desktop_new','numberposts' => 100]);
     786                    }
     787
     788//                $cachedBlocks = null;
     789                }
     790
    787791                $shortcodesGathered = get_posts(['post_type' => 'rb_shortcodes','numberposts' => -1]);
    788 
    789792                $shortcodes = [];
    790793                foreach ($shortcodesGathered AS $k=>$item) {
    791                     if (empty($shortcodes[$item->post_excerpt])) {
    792                         $shortcodes[$item->post_excerpt] = [];
     794                    if (empty($shortcodes[$item->post_excerpt])) {
     795                        $shortcodes[$item->post_excerpt] = [];
    793796                    }
    794                     $shortcodes[$item->post_excerpt][$item->post_title] = $item;
     797                    $shortcodes[$item->post_excerpt][$item->post_title] = $item;
    795798                }
    796                 $shortcodes = null;
    797 
    798 //                $cachedBlocks = null;
    799 //              }
     799//                $shortcodes = null;
    800800
    801801                if (!empty($content)) {
     
    805805                }
    806806                require_once (dirname(__FILE__)."/textEditing.php");
     807//              $content = RFWP_addIcons($fromDb, $content, 'content', null, null, $shortcodes);
    807808                $content = RFWP_addIcons($fromDb, $content, 'content', $cachedBlocks, null, $shortcodes);
    808809
     
    832833
    833834    function RFWP_activateShortCodes($content) {
    834         $penyok_stoparik = 0;
     835//      $penyok_stoparik = 0;
    835836        $content = do_shortcode($content);
    836837        return $content;
  • realbig-media/trunk/textEditing.php

    r2115464 r2117416  
    351351
    352352                    $fromDb[$k]->text = "<div class='percentPointerClass marked ".$shortcodesMark." coveredAd' data-id='".$item['id']."' style='clear:both;'>".$elementText."</div>".$shortcodesText;
    353                     $elementText = "<div class='percentPointerClass' data-id='".$item['id']."' style='clear:both;'>".$elementText."</div>".$shortcodesText;
     353                    $elementText = "<div class='percentPointerClass ".$shortcodesMark."' data-id='".$item['id']."' style='clear:both;'>".$elementText."</div>".$shortcodesText;
    354354
    355355                    $editedContent = preg_replace( '~(<blockquote[^>]*?\>)~i', '<bq_mark_begin>$1', $editedContent, -1);
     
    533533        }
    534534    }
     535
     536    function RFWP_wp_cache_gathering($cachedBlocks) {
     537        $scriptString = '';
     538    }
    535539
    536540    function RFWP_wp_is_mobile_old() {
Note: See TracChangeset for help on using the changeset viewer.