Skip to content

Commit

Permalink
Merge branch 'master' into fix_language_detect_slugs
Browse files Browse the repository at this point in the history
  • Loading branch information
spleen1981 committed Sep 25, 2023
2 parents 171e2be + 5c1e48b commit 6f5aee7
Show file tree
Hide file tree
Showing 10 changed files with 1,063 additions and 1,045 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 3.15.2
* Fix missing base `QTX_Translator` hooks in admin (#1337)
* Fix ACF settings for post type and taxonomy (#1342)
* Fix localize script with missing ACF options (#1341)
* Fix Slugs paged custom post types archives (#1340)

### 3.15.1
* Fix undefined `str_starts_with` with PHP 7 (#1334)
* Fix wrong PHP types with date/time filters (#1335)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Developed by: new qTranslate community, from qTranslate-X by John Clause and qTr
Contributors: herrvigg, johnclause, chineseleper, Vavooon, grafcom
Tags: multilingual, language, admin, tinymce, bilingual, widget, switcher, i18n, l10n, multilanguage, translation
Requires at least: 5.0
Tested up to: 6.2
Tested up to: 6.2.2
Requires PHP: 7.1
Stable tag: N/A
License: GPLv2 or later
Expand Down
2 changes: 1 addition & 1 deletion dist/modules/acf.js

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

22 changes: 16 additions & 6 deletions js/acf/qtranslatex.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ $(window).on('load', function () {

qtx.enableLanguageSwitchingButtons('block');

// Type of field e.g. text, textarea, wysiwyg.
const isTranslatableStandardField = function (fieldType) {
return !!window.qTranslateModuleAcf?.standard_fields?.[fieldType];
}
const isTranslatableGroupSubField = function (fieldType) {
return !!window.qTranslateModuleAcf?.group_sub_fields?.[fieldType];
// Type of sub-field in a group e.g. label, instructions, default_value.
const isTranslatableGroupSubField = function (groupType) {
return !!window.qTranslateModuleAcf?.group_sub_fields?.[groupType];
}

const postType = $('#post_type').val();
Expand All @@ -36,19 +38,24 @@ $(window).on('load', function () {
return;
}

const isTranslatableElementForPostType = function (element, postType) {
// For special ACF post type settings we usually care only about the sub-groups types.
if (postType === 'acf-post-type' || postType === 'acf-taxonomy') {
return isTranslatableGroupSubField('label') && element.id.match(/acf_(post_type|taxonomy)-labels.*/);
}
// The general case is for content fields, not in ACF settings.
return isTranslatableStandardField(element.type);
}
// Add hooks for translatable standard fields, defined as field type -> selector.
const fieldTypes = {
text: 'input:text',
textarea: 'textarea', // only regular textarea, not wysiwyg editors (.wp-editor-area).
};
$.each(fieldTypes, function (fieldType, selector) {
if (!isTranslatableStandardField(fieldType)) {
return;
}
acf.findFields({type: fieldType}).each(function () {
// The hooks must be set on the child elements found by the selector, assuming a single one by field.
$(this).find(selector).each(function () {
if (!qtx.hasContentHook(this)) {
if (!qtx.hasContentHook(this) && isTranslatableElementForPostType(this, postType)) {
qtx.addContentHookB(this);
}
});
Expand Down Expand Up @@ -95,4 +102,7 @@ $(window).on('load', function () {
// // call the original handler
// repeaterFieldRemove.call(this, $el);
// }

// LSB might have been skipped due to missing hooks, create them now if new hooks have been set.
qtx.setupLanguageSwitch();
});
Loading

0 comments on commit 6f5aee7

Please sign in to comment.