diff --git a/includes/class-gp-translation-helpers.php b/includes/class-gp-translation-helpers.php index bb4d41a2..3a0459b9 100644 --- a/includes/class-gp-translation-helpers.php +++ b/includes/class-gp-translation-helpers.php @@ -187,7 +187,7 @@ public function pre_tmpl_load( string $template, array $args ):void { } $translation_helpers_settings = array( - 'th_url' => gp_url_project( $args['project'], gp_url_join( $args['locale_slug'], $args['translation_set_slug'], '-get-translation-helpers' ) ), + 'th_url' => gp_url_project( $args['project'], gp_url_join( $args['locale_slug'], $args['translation_set_slug'], '-get-translation-helpers', '{ID}' ) ), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'gp_optin_optout' ), ); @@ -424,7 +424,7 @@ public function register_comment_feedback_js( $template, $translation_set ) { 'gp-translation-helpers-editor', '$gp_translation_helpers_editor', array( - 'translation_helper_url' => gp_url_project( $translation_set['project']->path, gp_url_join( $translation_set['locale_slug'], $translation_set['translation_set']->slug, '-get-translation-helpers' ) ), + 'translation_helper_url' => gp_url_project( $translation_set['project']->path, gp_url_join( $translation_set['locale_slug'], $translation_set['translation_set']->slug, '-get-translation-helpers', '{ID}' ) ), 'reply_text' => esc_attr__( 'Reply' ), 'cancel_reply_text' => esc_html__( 'Cancel reply' ), ) diff --git a/js/editor.js b/js/editor.js index 52c66976..45b2048c 100644 --- a/js/editor.js +++ b/js/editor.js @@ -115,7 +115,7 @@ jQuery( function( $ ) { const postId = $commentform.attr( 'id' ).split( '-' )[ 1 ]; const divDiscussion = $commentform.closest( '.meta.discussion' ); const rowId = divDiscussion.attr( 'data-row-id' ); - const requestUrl = $gp_translation_helpers_editor.translation_helper_url + rowId + '?nohc'; + const requestUrl = $gp_translation_helpers_editor.translation_helper_url.replace( '{ID}, rowId ); const submitComment = function( formdata ) { $.ajax( { @@ -278,7 +278,7 @@ jQuery( function( $ ) { */ function loadTabsAndDivs( element ) { const rowId = element.closest( 'tr.editor' ).attr( 'id' ).substring( 7 ); - const requestUrl = $gp_translation_helpers_editor.translation_helper_url + rowId + '?nohc'; + const requestUrl = $gp_translation_helpers_editor.translation_helper_url.replace( '{ID}, rowId ); if ( translationHelpersCache[ rowId ] !== undefined ) { updateDataInTabs( translationHelpersCache[ rowId ], rowId ); } else { @@ -328,7 +328,7 @@ jQuery( function( $ ) { */ function cacheTranslationHelpersForARow( editor ) { const rowId = editor.attr( 'row' ); - const requestUrl = $gp_translation_helpers_editor.translation_helper_url + rowId + '?nohc'; + const requestUrl = $gp_translation_helpers_editor.translation_helper_url.replace( '{ID}', rowId ); if ( ! rowId ) { return; } diff --git a/js/translation-helpers.js b/js/translation-helpers.js index e3951e54..20956342 100644 --- a/js/translation-helpers.js +++ b/js/translation-helpers.js @@ -35,7 +35,7 @@ $gp.translation_helpers = ( const originalId = $helpers.parent().attr( 'row' ); // eslint-disable-line vars-on-top const replytocom = $helpers.parent().attr( 'replytocom' ); // eslint-disable-line vars-on-top - var requestUrl = $gp_translation_helpers_settings.th_url + originalId + '?nohc'; // eslint-disable-line + let requestUrl = $gp_translation_helpers_settings.th_url.replace( '{ID}', originalId ) + '?'; if ( which ) { requestUrl = requestUrl + '&helpers[]=' + which;