Skip to content

Instantly share code, notes, and snippets.

@marcusig
Created May 20, 2021 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusig/913ecc374b5924f85e957195d9a9d7ff to your computer and use it in GitHub Desktop.
Save marcusig/913ecc374b5924f85e957195d9a9d7ff to your computer and use it in GitHub Desktop.
<?php
add_filter( 'mkl_pc_get_configurator_data_js_output', function( $output, $id ) {
if ( class_exists( 'GTranslate' ) && is_user_logged_in() && current_user_can( 'edit_posts' ) ) {
// Add compatibility with GTranslate premium, enabling users to manually update translations.
$output = 'var PC = PC || {};'."\n";
$output .= 'PC.productData = PC.productData || {};'."\n";
$output .= "fetch('/wp-admin/admin-ajax.php?action=pc_get_data&data=init&fe=1&id={$id}&ver=" . time() . "').then(r => r.json()).then(data => {PC.productData.prod_$id = data;});";
}
return $output;
}, 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment