Skip to content

Commit

Permalink
Use a XHR link that has a trailing slash on it, to avoid 302's that e…
Browse files Browse the repository at this point in the history
…at into the request budget.
  • Loading branch information
dd32 committed Apr 15, 2024
1 parent effe5c9 commit 98541df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions includes/class-gp-translation-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
);
Expand Down Expand Up @@ -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' ),
)
Expand Down
6 changes: 3 additions & 3 deletions js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion js/translation-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 98541df

Please sign in to comment.