This snippet translates the Elementor Load more button in the Posts widget using Ajax. There’s a bug that prevents this from being done the usual way
<?php
add_action('wp_ajax_wpd_translate_button', 'wpd_translate_btn');
add_action('wp_ajax_nopriv_wpd_translate_button', 'wpd_translate_btn');
function wpd_translate_btn() {
$lang = $_POST['lang'] ?? 'en';
$load_more = '';
$loading = '';
switch($lang) {
case 'en':
$load_more = 'Load more';
break;
case 'cs':
$load_more = 'Načíst další';
break;
case 'sk':
$load_more = 'Načítať ďalšiu';
break;
case 'hu':
$load_more = 'Töltsön be többet';
break;
case 'hr':
$load_more = 'Učitaj više';
break;
case 'sr':
$load_more = 'Učitaj više';
break;
case 'mne':
$load_more = 'Učitaj više';
break;
case 'bs':
$load_more = 'Učitaj još';
break;
case 'sl':
$load_more = 'Naloži več';
break;
case 'de':
$load_more = 'Mehr laden';
break;
case 'pl':
$load_more = 'Załaduj więcej';
break;
case 'ru':
$load_more = 'Загрузи больше';
break;
case 'lt':
$load_more = 'Įkelkite daugiau';
break;
case 'el':
$load_more = 'Φόρτωσε περισσότερα';
break;
}
switch ($lang) {
case 'en':
$loading = 'Loading...';
break;
case 'cs':
$loading = 'Načítání...';
break;
case 'sk':
$loading = 'Načítavanie...';
break;
case 'hu':
$loading = 'Betöltés...';
break;
case 'hr':
$loading = 'Učitavam...';
break;
case 'sr':
$loading = 'Loading...';
break;
case 'mne':
$loading = 'Loading...';
break;
case 'bs':
$loading = 'Učitavanje...';
break;
case 'sl':
$loading = 'Nalaganje...';
break;
case 'de':
$loading = 'Wird geladen...';
break;
case 'pl':
$loading = 'Ładowanie...';
break;
case 'ru':
$loading = 'Загружается...';
break;
case 'lt':
$loading = 'Įkeliama...';
break;
case 'el':
$loading = 'Φόρτωση...';
break;
}
wp_send_json_success([
'load_more' => $load_more,
'loading' => $loading,
]);
}
add_action('wp_footer', function () {
//if (!is_archive())
//return;
?>
<script>
jQuery(document).ready(function () {
const $loadMore = $('.ecs-load-more-button');
$.ajax({
method: 'POST',
url: '/wp-admin/admin-ajax.php',
data: {
action: 'wpd_translate_button',
lang: '<?=apply_filters('wpml_current_language', NULL)?>'
},
success: function(res){
const settings = JSON.parse($loadMore.attr('data-settings'));
settings.loading_text = res.data.loading;
settings.text = res.data.load_more;
$loadMore.find('span').text(settings.text);
$loadMore.attr('data-settings', JSON.stringify(settings));
}
});
});
</script>
<?php
});
This snippet translates the Elementor Load more button in the Posts widget using Ajax. There’s a bug that prevents this from being done the usual way
Cookie | Duration | Description |
---|---|---|
__stripe_mid | 1 year | Stripe sets this cookie cookie to process payments. |
__stripe_sid | 30 minutes | Stripe sets this cookie cookie to process payments. |
cookielawinfo-checkbox-advertisement | 1 year | Set by the GDPR Cookie Consent plugin, this cookie is used to record the user consent for the cookies in the "Advertisement" category . |
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
elementor | never | This cookie is used by the website's WordPress theme. It allows the website owner to implement or change the website's content in real-time. |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Cookie | Duration | Description |
---|---|---|
_gh_sess | session | GitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form. |
Cookie | Duration | Description |
---|---|---|
_octo | 1 year | No description available. |
logged_in | 1 year | No description available. |
m | 2 years | No description available. |
TDPrJV | 1 day | No description |
wNiYbt | 1 day | No description |