Please tell me, using GPT chat I was able to solve the problem, will this be the right solution?
i changed this code
// Generate canonical URL on all pages
function osc_generate_canonical() {
if(osc_always_generate_canonical_enabled()) {
View::newInstance()->_exportVariableToView('canonical', osc_get_current_url());
}
}
osc_add_hook('init', 'osc_generate_canonical', 1);
on which the GPT chat was created
// Generate canonical URL on all pages
function osc_generate_canonical() {
if (osc_always_generate_canonical_enabled()) {
$currentUrl = osc_get_current_url();
// Remove trailing slash if it exists
$currentUrl = rtrim($currentUrl, '/');
View::newInstance()->_exportVariableToView('canonical', $currentUrl);
}
}
osc_add_hook('init', 'osc_generate_canonical', 1);