diff --git a/filters/fix_agroexpert_links.php b/filters/fix_agroexpert_links.php new file mode 100644 index 0000000..1ab5149 --- /dev/null +++ b/filters/fix_agroexpert_links.php @@ -0,0 +1,30 @@ +'])) { + $end++; + } + + // Вырежем саму ссылку + $link = substr($content, $pos, $end - $pos); + + // Если не заканчивается на / и нет query/anchor + if (!str_ends_with($link, '/') && !str_contains($link, '?') && !str_contains($link, '#')) { + $link_fixed = $link . '/'; + $content = substr_replace($content, $link_fixed, $pos, strlen($link)); + $position = $pos + strlen($link_fixed); // Продвигаемся дальше + } else { + $position = $end; + } + } + + return $content; +} + +add_filter('the_content', 'fix_agroexpert_links'); diff --git a/functions.php b/functions.php index 3a9c0ad..7d349d4 100644 --- a/functions.php +++ b/functions.php @@ -31,6 +31,8 @@ function redirect_non_admin_users() { add_action('admin_init', 'redirect_non_admin_users'); + require_once get_template_directory() . '/filters/fix_agroexpert_links.php'; + define('ENPART', 740); define('EN_PARTS', '746,741,742,743,744,745'); diff --git a/single.php b/single.php index a9c3df4..86aea8c 100644 --- a/single.php +++ b/single.php @@ -43,8 +43,13 @@