Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin doesn't have support for multi-language plugins #75

Open
JoaoFreitas2002 opened this issue Feb 25, 2024 · 1 comment
Open

Plugin doesn't have support for multi-language plugins #75

JoaoFreitas2002 opened this issue Feb 25, 2024 · 1 comment

Comments

@JoaoFreitas2002
Copy link

I am using Polylang plugin and no matter the language, always return the same page.

I don't know how the other multi-language plugin work, but for polylang you can change the function to this:

public function custom_404_pro_redirect()
{
    global $wpdb;
    if (is_404()) {
        $sql                     = 'SELECT * FROM ' . $wpdb->prefix . $this->helpers->table_options;
        $sql_result              = $wpdb->get_results($sql);
        $row_mode                = $sql_result[0];
        $row_mode_page           = $sql_result[1];
        $row_mode_url            = $sql_result[2];
        $row_send_email          = $sql_result[3];
        $row_logging_enabled     = $sql_result[4];
        $row_redirect_error_code = $sql_result[5];
        if ($row_logging_enabled->value) {
            self::custom_404_pro_log($row_send_email->value);
        }
        if ($row_mode->value === "page") {
            $page = get_post($row_mode_page->value);

        //Polylang
        if (function_exists("pll_get_post")) {
            $translated_page_id = pll_get_post($row_mode_page->value, pll_current_language());
            $page = get_post($translated_page_id);
        }

            wp_redirect($page->guid, $row_redirect_error_code->value);
        } elseif ($row_mode->value === 'url') {
            wp_redirect($row_mode_url->value, $row_redirect_error_code->value);
        }
    }
}
@kunalnagar
Copy link
Owner

@JoaoFreitas2002 - thanks for this! I'll take a look and see what can be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants