Skip to content
Merged
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [1.6.2] (2025-10-02)

### Fixed
* Updated widget registration to use modern Elementor API (`elementor/widgets/register` hook instead of deprecated `elementor/widgets/widgets_registered`)
* Fixed widget asset dependency names to match registered CSS/JS handles (resolved loading issues)
* Removed buggy option check that prevented widget rendering in some cases
* Ensured widget renders consistently when added to pages via Elementor editor
* Improved widget compatibility with Elementor 3.x and newer versions

## [1.6.1] (2024-11-11)

### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codesnippetspro/translentor",
"version": "1.6.1",
"version": "1.6.2",
"description": "Translentor - Elementor-specific translation tool for WordPress.",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
Expand Down
18 changes: 15 additions & 3 deletions src/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ Owner: Code Snippets
Contributors: codesnippetspro, bungeshea, ver3, lightbulbman, 0aksmith
Donate link: https://translentor.com/contact/
Tags: translate elementor, elementor translator, automatic translation, ai translation
Requires at least: 4.0
Tested up to: 6.4.3
Stable tag: 1.6.1
Tested up to: 6.8.3
Requires PHP: 7.4
Requires at least: 6.6
Requires Plugins: elementor
Stable tag: 1.6.2
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -116,6 +118,16 @@ Translentor is by far the easiest Wordpress Translation Plugin available. There

== Changelog ==

= 1.6.2 (2025-10-02) =

__Fixed__
* Updated widget registration to use modern Elementor API for better compatibility with Elementor 3.x+
* Fixed widget asset dependency names to ensure proper CSS/JS loading
* Removed hidden database option check that prevented widget from rendering in some sites
* Improved widget rendering consistency across all Elementor-built pages
* Enhanced compatibility with latest Elementor versions


= 1.6.1 (2024-11-11) =

__Changed__
Expand Down
4 changes: 2 additions & 2 deletions src/translentor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Translentor
* Plugin URI: https://translentor.com
* Description: This plugin adds a language translator widget to the Elementor Page Builder.
* Version: 1.6.1
* Version: 1.6.2
* Author: Code Snippets Pro
* Author URI: https://translentor.com
* Domain Path: translentor
Expand All @@ -13,7 +13,7 @@

define('translentor_DIR_Main', plugin_dir_path(__FILE__));
define('translentor_URL', plugin_dir_url(__FILE__));
define('translentor_VERSION', '1.6.1');
define('translentor_VERSION', '1.6.2');
define('translentor_slug', 'translentor');
define('translentor_category_icon', 'fa fa-plug');
define('translentor_category', 'Translator');
Expand Down
54 changes: 34 additions & 20 deletions src/translentor/website-translator/widget/tanslentor_widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @package SMW
*/


// Elementor Classes.
use Elementor\Widget_Base;
use Elementor\Utils;
use Elementor\Controls_Manager;
Expand All @@ -32,11 +30,16 @@ class translentor_elementor_widget extends \Elementor\Widget_Base
{

protected $position;

/**
* Static flag to track if Google Translate script has been loaded
* Prevents duplicate script loading when multiple widgets are on the same page
*/
private static $script_loaded = false;

public function __construct($data = [], $args = null)
{
parent::__construct($data, $args);


}

public function get_name()
Expand All @@ -57,21 +60,21 @@ public function get_icon()
public function get_categories()
{
return [ 'translentor-category' ];
//return [ 'general' ];
}

public function get_style_depends()
{
return [ 'translentor-website-translentor' ];
return [
'translentor-website-translator-css',
'translentor-website-translator-toast-css'
];
}

public function get_script_depends()
{
return [

'translentor-website-translentor',
'translentor-website-translentor-toast'

'translentor-website-translator-js',
'translentor-website-translator-toast-js'
];
}

Expand Down Expand Up @@ -1527,10 +1530,7 @@ protected function render()
);

$selected = array();
if(get_option('google_translation')=='yes')
{

?>
?>

<div <?php echo $this->get_render_attribute_string( 'toast_title' ); ?>><?php echo esc_html($settings['toast_title']);?></div>
<div <?php echo $this->get_render_attribute_string( 'toast_position' ); ?>><?php echo esc_html($settings['toast_position']);?></div>
Expand Down Expand Up @@ -1580,6 +1580,7 @@ protected function render()
$location="right: 0px;
left: 0px;
text-align: center;";
$position='position: relative';
$class="t-footer-center-side";
}
$this->add_render_attribute(
Expand Down Expand Up @@ -1619,6 +1620,7 @@ protected function render()
$location="right: 0px;
left: 0px;
text-align: center;";
$position='position: relative';
$class="t-footer-center-side";
}
$this->add_render_attribute(
Expand Down Expand Up @@ -1787,6 +1789,11 @@ protected function render()
</ul>
</div>
</div>
<?php
// Only load Google Translate script once per page (prevent duplicate loading when multiple widgets exist)
if (!self::$script_loaded) {
self::$script_loaded = true;
?>
<script src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

<script>
Expand All @@ -1803,6 +1810,9 @@ function googleTranslateElementInit() {
console.log('Init');
}
</script>
<?php
}
?>
<script>
jQuery('.drop_footer').on('click', function() {
if (jQuery(this).attr('data-click-state') == 1) {
Expand Down Expand Up @@ -1859,6 +1869,7 @@ function googleTranslateElementInit() {
$location="right: 0px;
left: 0px;
text-align: center;";
$position='position: relative';
$class="t-center-side";
}
$this->add_render_attribute(
Expand Down Expand Up @@ -1897,6 +1908,7 @@ function googleTranslateElementInit() {
$location="right: 0px;
left: 0px;
text-align: center;";
$position='position: relative';
$class="t-center-side";
}
$this->add_render_attribute(
Expand Down Expand Up @@ -2060,6 +2072,11 @@ function googleTranslateElementInit() {
</ul>
</div>
</div>
<?php
// Only load Google Translate script once per page (prevent duplicate loading when multiple widgets exist)
if (!self::$script_loaded) {
self::$script_loaded = true;
?>
<script src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

<script>
Expand All @@ -2076,6 +2093,9 @@ function googleTranslateElementInit() {
console.log('Init');
}
</script>
<?php
}
?>
<script>
jQuery('.drop').on('click', function() {
if (jQuery(this).attr('data-click-state') == 1) {
Expand All @@ -2093,12 +2113,6 @@ function googleTranslateElementInit() {
<?php
echo '<h6 style="color: transparent;background: transparent; display:none;">hide</h6>';
}


// update_option('translentor_settings_elementor',$elementor_setting);
}


}
protected function content_template() {
?>
Expand Down
26 changes: 13 additions & 13 deletions src/widgets/index.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
use Elementor\Plugin;



// load_styles();
// load_scripts();

add_action( 'elementor/widgets/widgets_registered', function()
{

require_once translentor_DIR_Main . 'translentor/website-translator/widget.php';

}
);
/**
* Register Translentor Widget with Elementor
* Using modern Elementor API (elementor/widgets/register hook)
*/
add_action( 'elementor/widgets/register', function( $widgets_manager ) {

// Load widget class file
require_once translentor_DIR_Main . 'translentor/website-translator/widget.php';

// Register the widget with Elementor using modern API
$widgets_manager->register( new \translentor_elementor_widget() );

});

// function load_styles()
// {
Expand Down