qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
550 stars 103 forks source link

LSB not showing up on ACF Options pages #1276

Open filtah opened 1 year ago

filtah commented 1 year ago

Hi all, The LSB is not loading on ACF options pages.

The 2 latest releases (3.12.1 ans 3.13) have this problem.

In addition, if you check the checkbox "Display language tabs" on the ACF tab under Languages, the tabs appear but are non functional.

The option page is added without any arguments, by simply calling acf_add_options_page(); from the theme's functions.php

I've tested ACF versions 5.12.3 and 6.0.6 both of which have the same problem.

So looks to me like the problem was introduced with changes to the ACF module in the 3.12.1 release.

herrvigg commented 1 year ago

This looks similar to #1287 but for another page. I tried to reproduce but I don't have the same problem.

How does the page look like? Do you see the standard switching buttons below "Options"? I suppose no, which explains why the additional ACF switching buttons don't work.

Here's what I get:

image

There's a div with id = acf-form-data which is the anchor for the switches.

<h1>Options</h1>
<form id="post" method="post" name="post">
  <div id="acf-form-data" class="acf-hidden">
 ....
herrvigg commented 1 year ago

@filtah could you also open a console, run this and give the result?

JSON.stringify(qTranslateConfig.page_config)
herrvigg commented 1 year ago

@filtah Please try again with last release 3.14.0 and if it still fails complete the required information asked above. I will close this ticket if there's no activity.

filtah commented 1 year ago
image

It works now with some styling issues and when using the language tabs. So you can close this issue.

Is there anyway to still get access to the deprecated fields? We still depend on these and will continue to do so, until its possible to select multilingual per field (and not globally per field type which is kind of useless to be honest). Really appreciate your work with this project, but will have to maintain a separate fork otherwise.

herrvigg commented 1 year ago

Mmm, I didn't do any major change for this between 3.13.0 and 3.14.0. Did you do something new? Would it be possible for you to reproduce the problem with older version and give what was asked with JSON.stringify(qTranslateConfig.page_config) and compare this with the new version?

Why do you still need the deprecated fields? They are still available, "deprecated" means you should use something else, in that case the standard fields. This came actually after a comment from one of the authors/maintainers of ACF. I will not remove them until we can find a solution for the kind of problems you mention here.

herrvigg commented 1 year ago

@filtah I'd like to have your feedback for the two questions above. Also noticing the layout of the ACF field doesn't look great in the screenshots you provided.

teleturniej-studio commented 1 year ago

I want to report the same problem. LSB is not showing up on ACF Options page. NB: The 'show language tabs' control in ACF related settings is checked, and the tabs don't show up at all anywhere. Below is the diagnostic dump from Qtranslate-XT.

Screenshot 2023-04-19 at 15 04 02

`{ "PHP_VERSION": "7.2.34", "WP_VERSION": "6.2", "QTX_VERSION": "3.14.1", "Plugins": [ "Advanced Custom Fields PRO 6.1.4", "qTranslate-XT 3.14.1" ] }

{ "default_language": "pl", "enabled_languages": [ "pl", "en" ], "locale": { "pl": "pl_PL", "en": "en_US" }, "date_format": { "pl": "%d/%m/%y", "en": "%A %B %e%q, %Y" }, "time_format": { "pl": "%H:%M", "en": "%I:%M %p" }, "url_mode": 2, "use_strftime": 3, "filter_options_mode": 0, "language_name_case": 0, "detect_browser_language": false, "hide_untranslated": false, "show_menu_alternative_language": false, "show_displayed_language_prefix": true, "show_alternative_content": false, "hide_default_language": true, "use_secure_cookie": false, "header_css_on": true, "text_field_filters": [], "disable_client_cookies": false, "url_info": { "cookie_lang_front": "pl", "cookie_lang_admin": "pl", "cookie_front_or_admin_found": true, "pagenow": "admin-ajax.php", "REQUEST_METHOD": "GET", "WP_ADMIN": true, "DOING_AJAX_POST": [], "scheme": "http", "host": "wok.art.pl", "path": "/dev/wp-admin/admin-ajax.php", "query": "action=admin_debug_info", "path-base": "/dev", "wp-path": "/wp-admin/admin-ajax.php", "language_neutral_path": true, "http_referer": "http://wok.art.pl/dev/wp-admin/options-general.php?page=qtranslate-xt", "referer_admin": true, "doing_front_end": false, "lang_cookie_admin": "pl", "lang_admin": "pl", "language": "pl", "set_cookie": false }, "language": "pl", "editor_mode": 0, "highlight_mode": 1, "auto_update_mo": true, "hide_lsb_copy_content": true, "lsb_style": "simple-buttons.css", "config_files": [ "./i18n-config.json" ], "custom_fields": [], "custom_field_classes": [], "post_type_excluded": [], "admin_enabled_modules": { "acf": true, "all-in-one-seo-pack": false, "events-made-easy": false, "jetpack": false, "google-site-kit": false, "gravity-forms": false, "woo-commerce": false, "wp-seo": false, "slugs": false }, "translator": {}, "qtrans_compatibility": false }

{ "cookies": [], "navigator": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15" }`

filtah commented 1 year ago

@herrvigg

Why do you still need the deprecated fields? They are still available, "deprecated" means you should use something else, in that case the standard fields. This came actually after a https://github.com/qtranslate/qtranslate-xt/issues/1186#issuecomment-1157156909. I will not remove them until we can find a solution for the kind of problems you mention here.

Yeah, I get this, but the fields are not available as you said. I would have expected them to still be available, just marked deprecated. See, they are missing from the list:

image
filtah commented 1 year ago

OK, just seen this in the latest release doh!

image

This looks ideal to be honest, will give that a spin. Thanks :)

filtah commented 1 year ago

I think there's a bug here though - I cant unselect all the standard fields, if I uncheck them all, after the page reloads, they are all re-checked again! The most I can uncheck is 2 of them, it doesn't matter which 2:

image

Same thing happens when attempting to uncheck the group sub fields!

image
filtah commented 1 year ago

@herrvigg

I'm running ACF Pro 5.12.4 on a fairly clean WP install with a custom theme, completely default language config, untouched, so the language tabs are not enabled.

This is from 14.2:

{"pages":{"admin.php":"","comment.php":"","nav-menus.php":"","profile.php":"","user-edit.php":"","user-new.php":"","widgets.php":""},"anchors":{"acf-form-data":{"where":"after"}},"forms":{"wpbody-content":{"fields":{"acf-form-data-title":{"jquery":"#acf-form-data ~ h2, .acf-postbox h3, .acf-menu-settings h2","encode":"display"},"acf-field-label":{"jquery":".acf-label > label, .acf-label > p.description","encode":"display"},"acf-admin-field-title":{"jquery":".acf-postbox .postbox-header h2","encode":"display"}}}},"keys":["acf-forms"]}

I don't see the LSBs on the Options page.

This is from 14.0:

{"pages":{"admin.php":"","comment.php":"","nav-menus.php":"","profile.php":"","user-edit.php":"","user-new.php":"","widgets.php":""},"anchors":{"acf-form-data":{"where":"after"}},"forms":{"wpbody-content":{"fields":{"acf-form-data-title":{"jquery":"#acf-form-data ~ h2, .acf-postbox h3, .acf-menu-settings h2","encode":"display"},"acf-field-label":{"jquery":".acf-label > label, .acf-label > p.description","encode":"display"},"acf-admin-field-title":{"jquery":".acf-postbox .postbox-header h2","encode":"display"}}}},"keys":["acf-forms"]}

I don't see the LSBs on the Options page.

I get this printed in the footer (WP_DEBUG enabled)

<b>Deprecated</b>: Hook qtranslate_admin_page_config is <strong>deprecated</strong> since version 3.14.0 with no alternative available. No clear use case, create a request on https://github.com/qtranslate/qtranslate-xt/issues if needed. in <b>/var/www/vhosts/ibiza-formentera.com/httpdocs/wp-includes/functions.php</b> on line <b>5798</b>

This is from 13.0:

{"pages":{"admin.php":"","comment.php":"","nav-menus.php":"","user-edit.php":"","user-new.php":"","widgets.php":""},"anchors":{"acf-form-data":{"where":"after"}},"forms":{"wpbody-content":{"fields":{"acf-form-data-title":{"jquery":"#acf-form-data ~ h2, .acf-postbox h3, .acf-menu-settings h2","encode":"display"},"acf-field-label":{"jquery":".acf-label > label, .acf-label > p.description","encode":"display"},"acf-admin-field-title":{"jquery":".acf-postbox .postbox-header h2","encode":"display"}}}},"keys":["acf-forms"]}

I don't see the LSBs on the Options page.

This is from 12.1:

Uncaught ReferenceError: qTranslateConfig is not defined at <anonymous>:1:16

I don't see the LSBs on the Options page.

This is from 12.0:

{"pages":{"admin.php":"page="},"anchors":{"acf-qtranslate-lsb-shim":{"where":"after"}},"forms":{"wpwrap":{"fields":{"lsb-shim":{"jquery":"#acf-qtranslate-lsb-shim","encode":"display"},"acf5-field-group-handle":{"jquery":".acf-postbox h2 span,.acf-postbox h3 span","encode":"display"},"acf5-field-label":{"jquery":".acf-field .acf-label label","encode":"display"},"acf5-field-description":{"jquery":".acf-field .acf-label p.description","encode":"display"}}}},"keys":["acf-display-nodes"]}

I see the LSBs!

Seems like its the only version.

herrvigg commented 1 year ago

Thanks for these details, this is helpful.

I think there's a bug here though - I cant unselect all the standard fields, if I uncheck them all, after the page reloads, they are all re-checked again!

Good catch for finding a bug with the options, I can reproduce this. Will fix. But this should not have impacts on the LSB with the options, so we can ignore this issue here.

LSB is not showing up on ACF Options page.

I can't reproduce the problem with the options page in the current version. I test with ACF Pro 6.0.3 but I don't think there's a major difference with ACF Pro 5.12.4 for that part. I made major changes for ACF in 13.0 by removing the "shim" element used as anchor. The configurations from 13.0 to 14.2 are similar, they look correct to me. We can ignore the errors in 12.1 (weird but gone in 13.0) and 14.0 (not related).

@filtah @teleturniej-studio there are two things to check on the options page: 1) what is the URL of the option page? In my case it's http://localhost/wp-admin/admin.php?page=acf-options. This should match one of the pages elements in the page config. In my case it matches admin.php. I expect you to have the same at least for a basic acf_add_options_page() call. 2) check if you find the anchor element: this should be an element with id=acf-form-data. In my case I find it right below the post element. This is how the LSB are created, they will be placed after that element. If you don't have this element the LSB won't be created.

<form id="post" method="post" name="post">
  <div id="acf-form-data" class="acf-hidden">
  ...
    <h2 class="hndle ui-sortable-handle">(fr) opt-group</h2>        <-- that's the ACF group selected for the options

NB: The 'show language tabs' control in ACF related settings is checked, and the tabs don't show up at all anywhere

These tabs are very specific, they came from the legay ACF integration plugin. It's like an additional feature, but if the standard LSB don't appear the page is broken so I don't expect to work normally. We must fix the LSB first.

herrvigg commented 1 year ago

An easy way to check for the anchor is to write this in the browser console:

jQuery('#acf-form-data').length

You'll get 1 if found, otherwise 0.

herrvigg commented 1 year ago

I released the fix for settings #1332 in 3.15.0, but expect no change for the options page. I'd really like to understand that problem I'm not able to reproduce so we can fix it soon without reverting the old design from 3.12.0. with the artificial "shim" object that I don't like, it should be considered as a legacy hack. Keep me updated with your findings and we can iterate quickly on this.

teleturniej-studio commented 1 year ago

Thank you @herrvigg.

what is the URL of the option page? In my case it's http://localhost/wp-admin/admin.php?page=acf-options.

That's the solution. I was using a custom page name. Upon registering an options page with a default name ('acf-options') the LSB came back.

filtah commented 1 year ago

For me still simply doesn't work. Im always registering the options page without any arguments, so the url is standard. http://doman.tld/wp-admin/admin.php?page=acf-options

@herrvigg : are you using a specific action to register the function?

I have this for example in my theme options.php:

add_action('acf/init', function() {
    acf_add_options_page();
});

btw, i have the anchor:

<div id="acf-form-data" class="acf-hidden">
    <input type="hidden" id="_acf_screen" name="_acf_screen" value="options">
    <input type="hidden" id="_acf_post_id" name="_acf_post_id" value="options">
    <input type="hidden" id="_acf_validation" name="_acf_validation" value="1">
    <input type="hidden" id="_acf_nonce" name="_acf_nonce" value="1a800d3608">
    <input type="hidden" id="_acf_changed" name="_acf_changed" value="0">
</div>