loading = $loading;
}
function run_optimization($photonClass, $buffer) {
/* if ($this->loading == 'default') { */
/* return $buffer; */
/* } */
$this->js_mode = $photonClass->js_mode;
// Combine patterns to extract script src attributes and inline script contents
$pattern = '/'; // Remove other script tags
} elseif ($photonClass->js_mode == 2) {
if ($photonClass->cache_js && !$photonClass->use_cdn) {
return $photonClass->optimize_external_js($tag);
} else {
return $tag;
}
}
}, $buffer);
// if ($photonClass->use_cdn) {
// $cdn_file_responses = $photonClass->parallelCurlRequests($photonClass->cdn_upload_queue, [], 'GET');
// for ($i = 0; $i < count($cdn_file_responses); $i++) {
// $original_file = $photonClass->original_files_for_cdn[$i];
// $cdnData = json_decode($cdn_file_responses[$i]);
// if ($cdnData && isset($cdnData->status) && $cdnData->status === 'success' && isset($cdnData->filePath)) {
// // Use the CDN file path in your WordPress code
// $cdnFilePath = $cdnData->filePath;
// /* $cdn_file = 'https://cdn.berqwp.com' . $cdnFilePath; */
// $cdn_file = $cdnFilePath;
// if (($photonClass->js_mode == 1 || $photonClass->js_mode == 0) && strpos($cdn_file, '.js') !== false) {
// foreach ($script_tags_to_replace as $script_tag) {
// if (strpos($script_tag, $original_file) !== false) {
// $origional_tag_base64 = esc_attr(base64_encode($script_tag));
// $script_tag = str_replace($original_file, $cdn_file, $script_tag);
// $tag = esc_attr(base64_encode($script_tag));
// $buffer = str_replace($origional_tag_base64, $tag, $buffer);
// }
// }
// // $original_file = base64_encode($original_file);
// // $cdn_file = base64_encode($cdn_file);
// }
// $buffer = str_replace($original_file, $cdn_file, $buffer);
// }
// }
// }
if ($this->loading !== 'default') {
add_filter('berqwp_buffer_before_closing_body', [$this, 'script']);
}
unset($photonClass);
return $buffer;
}
function script($script_html) {
$script_html .= "
";
$script_html .= "
";
return $script_html;
}
}