- 状态
- 已解决
- 报告针对
- 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; }
在对文件进行任何更改之前,请务必先进行备份。