Skip to content
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

Generalize double checkboxes in QTX options #1177

Merged
merged 1 commit into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions admin/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,11 @@ $(function () {
}
});
})

// Checkboxes with double-check has associated checkbox(es) depending on it.
$('.qtranxs_double_check').on('click', function () {
const check = $($(this).attr('data-double-check')); // There may be more than one checkbox (CSS selector).
check.prop('disabled', !$(this).prop('checked'));
check.prop('checked', false);
});
});
6 changes: 3 additions & 3 deletions admin/qtx_admin_options_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function qtranxf_edit_config() {
$original_lang = &$q_config['posted']['original_lang'];

// check for action
if ( isset( $_POST['qtranslate_reset'] ) && isset( $_POST['qtranslate_reset2'] ) ) {
if ( isset( $_POST['qtranslate_reset_all'] ) && isset( $_POST['qtranslate_reset_confirm'] ) ) {
$messages[] = __( 'qTranslate has been reset.', 'qtranslate' );
} elseif ( isset( $_POST['default_language'] ) ) {
// TODO: remove temporary hack - restore QTS options for master dev before migration.
Expand Down Expand Up @@ -343,7 +343,7 @@ function qtranxf_reset_config() {
qtranxf_add_message( __( 'Admin notices have been reset. You will see all applicable notices on admin pages and may dismiss them again.', 'qtranslate' ) );
}

if ( ! isset( $_POST['qtranslate_reset'] ) || ! isset( $_POST['qtranslate_reset2'] ) ) {
if ( ! isset( $_POST['qtranslate_reset_all'] ) || ! isset( $_POST['qtranslate_reset_confirm'] ) ) {
return;
}

Expand Down Expand Up @@ -381,7 +381,7 @@ function qtranxf_reset_config() {
delete_option( 'qtranslate_versions' );
delete_option( 'qtranslate_disable_header_css' );

if ( isset( $_POST['qtranslate_reset3'] ) ) {
if ( isset( $_POST['qtranslate_reset_terms'] ) ) {
delete_option( 'qtranslate_term_name' );
}

Expand Down
25 changes: 17 additions & 8 deletions admin/qtx_import_export.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ function qtranxf_admin_section_import_export( $request_uri ) {
<label for="qtranslate_import_slugs_migrate">
<input type="checkbox" name="qtranslate_import_slugs_migrate"
id="qtranslate_import_slugs_migrate"
value="1"
onclick="let c=jQuery('#qtranslate_import_slugs_confirm'); c.prop('disabled', !jQuery(this).prop('checked')); c.prop('checked', false);"/>
class="qtranxs_double_check" data-double-check="#qtranslate_import_slugs_confirm"
value="1"/>
<?php _e( 'Migrate slugs options, post and term meta from legacy QTS plugin to qTranslate.', 'qtranslate' ); ?>
</label>
<br/>
Expand All @@ -253,20 +253,29 @@ function qtranxf_admin_section_import_export( $request_uri ) {
<tr>
<th scope="row"><?php _e( 'Reset qTranslate', 'qtranslate' ) ?></th>
<td>
<label for="qtranslate_reset"><input type="checkbox" name="qtranslate_reset" id="qtranslate_reset"
value="1"/> <?php _e( 'Check this box and click Save Changes to reset all qTranslate settings.', 'qtranslate' ) ?>
<label for="qtranslate_reset_all">
<input type="checkbox" name="qtranslate_reset_all" id="qtranslate_reset_all"
class="qtranxs_double_check"
data-double-check="#qtranslate_reset_confirm,#qtranslate_reset_terms"
value="1"/>
<?php _e( 'Check this box and click Save Changes to reset all qTranslate settings.', 'qtranslate' ) ?>
</label>
<br/>
<label for="qtranslate_reset2"><input type="checkbox" name="qtranslate_reset2" id="qtranslate_reset2"
value="1"/> <?php _e( 'Yes, I really want to reset qTranslate.', 'qtranslate' ) ?>
<label for="qtranslate_reset_confirm">
<input type="checkbox" name="qtranslate_reset_confirm" id="qtranslate_reset_confirm"
value="1" <?php disabled( true ) ?>/>
<?php _e( 'Yes, I really want to reset qTranslate.', 'qtranslate' ) ?>
</label>
<br/>
<label for="qtranslate_reset3"><input type="checkbox" name="qtranslate_reset3" id="qtranslate_reset3"
value="1"/> <?php _e( 'Also delete Translations for Categories/Tags/Link Categories.', 'qtranslate' ) ?>
<label for="qtranslate_reset_terms">
<input type="checkbox" name="qtranslate_reset_terms" id="qtranslate_reset_terms"
value="1" <?php disabled( true ) ?>/>
<?php _e( 'Also delete Translations for Categories/Tags/Link Categories.', 'qtranslate' ) ?>
</label>
<br/>
<small><?php _e( 'If something isn\'t working correctly, you can always try to reset all qTranslate settings. A Reset won\'t delete any posts but will remove all settings (including all languages added).', 'qtranslate' ) ?></small>
<br/>
<br/>
<label for="qtranslate_reset_admin_notices"><input type="checkbox" name="qtranslate_reset_admin_notices"
id="qtranslate_reset_admin_notices"
value="1"/> <?php _e( 'Reset admin notices.', 'qtranslate' ) ?>
Expand Down
2 changes: 1 addition & 1 deletion dist/options.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion qtranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* Designed as interface for other plugin integration. The documentation is available at
* https://github.com/qtranslate/qtranslate-xt/wiki/Integration-Guide/
*/
define( 'QTX_VERSION', '3.11.4' );
define( 'QTX_VERSION', '3.12.0.dev.0' );

if ( ! defined( 'QTRANSLATE_FILE' ) ) {
define( 'QTRANSLATE_FILE', __FILE__ );
Expand Down