jQuery not defined when using TranslatePress plugin on Sage theme

Hello.
When I try to translate website with TranslatePress plugin (Translate Multilingual sites – TranslatePress – WordPress plugin | WordPress.org) I get a blank page…
in the console log It says that jQuery is not defined…
But jQuery is used and defined by theme correctly and working.

This problem on Sage versions from 9.0.6 and above and on WP different versions…
Please, help. Thanks.

Same problem on Wordpress Support forum.

This commit causes the problem with TranslatePress.

You can revert the commit or just skip Sage Blade rendering for TranslatePress. But is just an hack.

/**
 * Render page using Blade
 */
add_filter('template_include', function ($template) {
    if (strpos($template, 'translation-manager.php')) {
        return $template;
    }
    collect(['get_header', 'wp_head'])->each(function ($tag) {
        ob_start();
        do_action($tag);
        $output = ob_get_clean();
        remove_all_actions($tag);
        add_action($tag, function () use ($output) {
            echo $output;
        });
    });
    $data = collect(get_body_class())->reduce(function ($data, $class) use ($template) {
        return apply_filters("sage/template/{$class}/data", $data, $template);
    }, []);
    if ($template) {
        echo template($template, $data);
        return get_stylesheet_directory() . '/index.php';
    }
    return $template;
}, PHP_INT_MAX);
2 Likes

Big THANKS))) It’s Working correctly))