WPML
ステータス
解決済み
報告対象
WPML Multilingual CMS 3.3.5
解決されたバージョン
3.4

問題の概要

404エラー:

「Failed to load resource: the server responded with a status of 404 (Not Found)」

admin_url( ‘admin-ajax.php’ )を呼び出すと発生します。

この問題は、「言語ごとに異なるドメイン」設定を使用している場合に発生します。

admin_url( ‘admin-ajax.php’ )を呼び出すと、次のように表示されます。

http://secondary-language-domain.com/secondary-lang-code/wp-admin/admin-ajax.php

本来は以下の通りです:

http://secondary-language-domain.com/wp-admin/admin-ajax.php

これにより、次の404エラーが発生します。

「Failed to load resource: the server responded with a status of 404 (Not Found)」

次のリリースで修正されます。

回避策

FTPにログインし、wp-content/plugins/sitepress-multilingual-cms/inc/url-handling/wpml-url-converter.class.phpにあるwpml-url-converter.class.phpファイルを見つけます。

admin_url_filter関数(39行目付近)を検索し、以下のコード:

public function admin_url_filter( $url, $path ) {
    if ( 'admin-ajax.php' === $path ) {
        $url = $this->get_admin_ajax_url( $url );
    }
    return $url;
}

を次のように変更します。
public function admin_url_filter( $url, $path ) {
    if ( ( strpos( $url, 'http://' ) === 0 
      || strpos( $url, 'https://' ) === 0 ) 
      && 'admin-ajax.php' === $path 
      && $this->wpml_wp_api->is_front_end() ) {
        global $sitepress;
    
        $url = $this->convert_url( $url,
        $sitepress->get_current_language() );
    }

    return $url;
}

ファイルを変更する前には、必ずバックアップを作成してください。

すべての既知の問題 →