krot

bitrix убрать kernel_main

Dec 2nd, 2015
423
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. php_interface/init.php
  2. AddEventHandler("main", "OnEndBufferContent", "deleteKernelJs");
  3. function deleteKernelJs(&$content) {
  4.    global $USER, $APPLICATION;
  5.    if((is_object($USER) && $USER->IsAuthorized()) || strpos($APPLICATION->GetCurDir(), "/bitrix/")!==false) return;
  6.    if($APPLICATION->GetProperty("save_kernel") == "Y") return;
  7.  
  8.    $arPatternsToRemove = Array(
  9.       '/<script.+?src=".+?kernel_main\/kernel_main\.js\?\d+"><\/script\>/',
  10.       '/<script.+?src=".+?bitrix\/js\/main\/core\/core[^"]+"><\/script\>/',
  11.       '/<script.+?>BX\.(setCSSList|setJSList)\(\[.+?\]\).*?<\/script>/',
  12.       '/<script.+?>if\(\!window\.BX\)window\.BX.+?<\/script>/',
  13.       '/<script[^>]+?>\(window\.BX\|\|top\.BX\)\.message[^<]+<\/script>/',
  14.    );
  15.  
  16.    $content = preg_replace($arPatternsToRemove, "", $content);
  17.    $content = preg_replace("/\n{2,}/", "\n\n", $content);
  18. }
RAW Paste Data