| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/themes/blocksy/inc/integrations/ |
Upload File : |
<?php
add_action(
'ss_after_extract_and_replace_urls_in_html',
function ($html_content, $url_extractor) {
if ($html_content instanceof \DOMDocument) {
$html_content = $html_content->saveHTML();
}
$pattern = '/<script[^>]*id=[\'"]ct-scripts-js-extra[\'"][^>]*>(.*?)<\/script>/is';
$blocksy_scripts = [];
if (preg_match_all($pattern, $html_content, $matches)) {
foreach ($matches[0] as $match) {
$script_content = preg_replace('/<script[^>]*id=[\'"]ct-scripts-js-extra[\'"][^>]*>/', '', $match);
$script_content = preg_replace('/<\/script>/', '', $script_content);
$blocksy_scripts[] = $script_content;
}
}
foreach ($blocksy_scripts as $single_script) {
$content = $single_script;
$all_components = explode('};', $content);
$ct_localizations = str_replace(
'var ct_localizations = ', '',
array_shift($all_components)
) . '}';
$decoded = json_decode($ct_localizations, true);
$decoded['ajax_url'] = $url_extractor->add_to_extracted_urls(
$decoded['ajax_url']
);
$decoded['public_url'] = str_replace(
'index.html',
'',
$url_extractor->add_to_extracted_urls($decoded['public_url'])
);
$decoded['rest_url'] = $url_extractor->add_to_extracted_urls(
$decoded['rest_url']
);
$decoded['dynamic_styles']['lazy_load'] = $url_extractor->add_to_extracted_urls(
$decoded['dynamic_styles']['lazy_load']
);
$decoded['dynamic_styles']['search_lazy'] = $url_extractor->add_to_extracted_urls(
$decoded['dynamic_styles']['search_lazy']
);
foreach ($decoded['dynamic_js_chunks'] as $index => $single_chunk) {
$decoded['dynamic_js_chunks'][$index]['url'] = $url_extractor
->add_to_extracted_urls(
$decoded['dynamic_js_chunks'][$index]['url']
);
}
foreach ($decoded['dynamic_styles_selectors'] as $index => $single_chunk) {
$decoded['dynamic_styles_selectors'][$index]['url'] = $url_extractor
->add_to_extracted_urls(
$decoded['dynamic_styles_selectors'][$index]['url']
);
}
$decoded['dynamic_styles_selectors'][0]['url'] = $url_extractor
->add_to_extracted_urls(
$decoded['dynamic_styles_selectors'][0]['url']
);
$result = 'var ct_localizations = ' . json_encode($decoded, JSON_UNESCAPED_UNICODE) . ';' . implode(
'};',
$all_components
);
$single_script = $result;
}
},
10, 2
);
// old version
// add_action(
// 'ss_after_setup_task',
// function () {
// \Simply_Static\Setup_Task::add_additional_files_to_db(
// get_template_directory() . '/static/bundle'
// );
// if (defined('BLOCKSY_PATH')) {
// \Simply_Static\Setup_Task::add_additional_files_to_db(
// BLOCKSY_PATH . '/static/bundle'
// );
// \Simply_Static\Setup_Task::add_additional_files_to_db(
// BLOCKSY_PATH . '/framework/premium/static/bundle'
// );
// }
// }
// );
// new version
add_filter(
'ss_additional_files',
function ($additional_files) {
$additional_files[] = get_template_directory() . '/static/bundle';
if (defined('BLOCKSY_PATH')) {
$additional_files[] = BLOCKSY_PATH . '/static/bundle';
$additional_files[] = BLOCKSY_PATH . '/framework/premium/static/bundle';
}
return $additional_files;
}
);