-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Second issue #2476
Second issue #2476
Conversation
# Conflicts: # dt-assets/js/comments.js # dt-assets/js/settings.js # dt-assets/js/shared-functions.js # dt-core/admin/js/dt-options.js
|
||
<tr class="language-row" data-lang="<?php echo esc_html( $language_key ) ?>"> | ||
<td class='lang_key'><?php echo esc_html( $language_key ) ?></td> | ||
<td class='default_label'><?php echo esc_html( isset( $dt_global_languages_list[$language_key] ) ? $dt_global_languages_list[$language_key]['label'] : '' ) ?></td> | ||
<td class='custom_label'><input type="text" placeholder="Custom Label" name="language_label[<?php echo esc_html( $language_key ) ?>][default]" value="<?php echo esc_html( ( !isset( $dt_global_languages_list[$language_key] ) || ( isset( $dt_global_languages_list[$language_key] ) && $dt_global_languages_list[$language_key]['label'] != $language_option['label'] ) ) ? $language_option['label'] : '' ) ?>"></td> | ||
<td class='iso_code'><input type="text" placeholder="ISO 639-3 code" maxlength="3" name="language_code[<?php echo esc_html( $language_key ) ?>]" value="<?php echo esc_html( $language_option['iso_639-3'] ?? '' ) ?>"></td> | ||
<td class='custom_label'><input type="text" placeholder="Custom Label" name="language_label[<?php echo esc_html( $language_key ) ?>][default]" value="<?php echo esc_html( $language_option['label'] ?? '' )?>"></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CptHappyHands keep the "custom" label blank if the admin has not saved a custom label yet. This should not be filled with the default label.
<td class='custom_label'><input type="text" placeholder="Custom Label" name="language_label[<?php echo esc_html( $language_key ) ?>][default]" value="<?php echo esc_html( ( !isset( $dt_global_languages_list[$language_key] ) || ( isset( $dt_global_languages_list[$language_key] ) && $dt_global_languages_list[$language_key]['label'] != $language_option['label'] ) ) ? $language_option['label'] : '' ) ?>"></td> | ||
<td class='iso_code'><input type="text" placeholder="ISO 639-3 code" maxlength="3" name="language_code[<?php echo esc_html( $language_key ) ?>]" value="<?php echo esc_html( $language_option['iso_639-3'] ?? '' ) ?>"></td> | ||
<td class='custom_label'><input type="text" placeholder="Custom Label" name="language_label[<?php echo esc_html( $language_key ) ?>][default]" value="<?php echo esc_html( $language_option['label'] ?? '' )?>"></td> | ||
<td class='iso_code'><input type="text" placeholder="ISO 639-3 code" maxlength="3" name="language_code[<?php echo esc_html( $language_key ) ?>]" value="<?php echo esc_html( $language_option['flag'] ?? '' ) ?>"></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was iso_639-3 replaced with 'flag' here on accident?
native_name: '', | ||
flag: '', | ||
rtl: false, | ||
enabled: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we only want to save custom_label, iso_639-3 and enabled.
The rest should be removed
}, | ||
success: function (response) { | ||
var languages = JSON.parse(response); | ||
console.log(languages, 'success line 40'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @CptHappyHands !
You can do window.location.reload()
on the success for now.
Some in the other ajax
/** | ||
* @todo: | ||
* only save user provided customizations to the dt_working_languages options | ||
* this includes labels, the iso code, the enabled status and translations | ||
* does not include: the key, default labels etc | ||
*/ | ||
|
||
recursive_array_update( $saved_language_options, $params ); | ||
update_option( 'dt_working_languages', $saved_language_options, false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CptHappyHands
Here we only want to save the custom values the admin has entered. Not any that are default.
So if the admin sets english to enabled:
We'd do saved_language_options[en_US]['enabled'] = true
I expect a lot of the code from process_languages_box() would be copied here.
Closing this one in favor of: #2500 |
for troubleshooting