WPML
Статус
Решено
Заявлено для
WPML Multilingual CMS 4.6.5
Решено в
WPML Multilingual CMS 4.8
Связанный плагин/тема
Elementor
Теги темы
Compatibility

Обзор проблемы

В настоящее время, когда Вы используете виджет Иконки соцсетей Elementor , невозможно перевести его ссылки и атрибуты.

Обходное решение

Пожалуйста, перед продолжением убедитесь, что у Вас есть полная резервная копия Вашего сайта.


  • Добавьте следующий 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 и переведите её снова.

Все известные проблемы →