- 状态
- 已解决
- 报告针对
- WPML Multilingual CMS 4.6.5
- 解决于
- WPML Multilingual CMS 4.8
- 相关插件/主题
- Elementor
- 主题标签
- Compatibility
问题概述
目前,当您使用 Elementor 的 Social Icons 小工具时,无法翻译其链接和属性。
临时解决方法
在继续操作之前,请确保对您的站点进行完整备份。
- 将以下 PHP 代码添加到您主题的 functions.php 文件中:
add_action('init', function () { add_filter('wpml_elementor_widgets_to_translate', function ($widgets) { $widgets['social-icons'] = [ 'conditions' => ['widgetType' => 'social-icons'], 'fields' => [], 'integration-class' => 'elementorSocialIcons' ]; return $widgets; }); /** * Class to translate the Elementor social-icons widget. * * @see wpmltriage-481 */ class elementorSocialIcons extends WPML_Elementor_Module_With_Items { /** * @return string */ public function get_items_field() { return 'social_icon_list'; } /** * @return array */ public function get_fields() { return [ 'link' => [ 'url', 'custom_attributes' ] ]; } /** * @param string $field * * @return string */ protected function get_title($field) { switch ($field) { case 'url': return esc_html__('Social Icon: URL', 'elementor'); case 'custom_attributes': return esc_html__('Social Icon: Custom Attributes', 'elementor'); default: return ''; } } /** * @param string $field * * @return string */ protected function get_editor_type($field) { switch ($field) { case 'custom_attributes': return 'LINE'; case 'url': return 'LINK'; default: return ''; } } } }); - 更新您的 Elementor 页面并重新进行翻译。