Load GTranslate on click | WordPress.org

[ad_1]

Hello,
we used to load the GTranslate Shortcode by click (for reasons of data protection). Recently it stopped loading. Do you havy any idea, what could be the reason why?

This is the button used in our theme:

<button id="trigger_translation">Google Translate aktivieren</button>

This is in the functions.php
(When I insert a shortcode from another plugin there, it works)

// Translation on click
function runTranslation() {
  if ( isset($_REQUEST) ) {
    echo do_shortcode( '[gtranslate]' );
  }
  die();
}
add_action( 'wp_ajax_runTranslation', 'runTranslation' );
add_action( 'wp_ajax_nopriv_runTranslation', 'runTranslation' );

This is the javascript code:

// load translation
	$('#trigger_translation').click(function(e) {
		e.preventDefault();

		$.ajax({
		  url: '/wp-admin/admin-ajax.php',
		  type: 'GET',
		  data: {
			'action' : 'runTranslation',
		  },
		  success:function(data) {
			  $('#translation').html(data);
		  }
		});
	});
	
});
  • This topic was modified 1 hour, 16 minutes ago by hcsweb.

The page I need help with: [log in to see the link]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer