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
546 stars 103 forks source link

[ACF Module] Function WP_Scripts::localize was called incorrectly #1341

Closed hirasso closed 1 year ago

hirasso commented 1 year ago

Describe the bug When on one of my post edit screens, I am getting this warning:

Notice: Function WP_Scripts::localize was called incorrectly. The $l10n parameter must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script() function instead. Please see Debugging in WordPress for more information. (This message was added in version 5.7.0.) in /.../wp-includes/functions.php on line 5867

A backtrace lead me to this line:

wp_localize_script( 'qtranslate-acf', 'qTranslateModuleAcf', get_option( QTX_OPTIONS_MODULE_ACF ) );

This option is an empty string for me, leading to the error being displayed. I tried de-activating and re-activating qtranslate-xt, but it doesn't help.

To Reproduce Steps to reproduce the behavior:

  1. Set WP_DEBUG to true
  2. Go to page 'post.php' or 'post-new.php'
  3. See error

Expected behavior No error

Screenshots If applicable, add screenshots to help explain your problem.

Debug info Go to <YOUR_SITE>/wp-admin/options-general.php?page=qtranslate-xt#troubleshooting. I can't access this tab at the moment. Seems to be another issue, it's just blank:

image

WordPress Version `6.2.2`
Qtranslate-XT Version `3.15.1`
ACF PRO Version `2.0.15`
hirasso commented 1 year ago

Ok, I found out why the settings screen was broken. qtranxf_get_admin_highlight_css was not matching any cases (QTX_HIGHLIGHT_MODE_BORDER_LEFT, QTX_HIGHLIGHT_MODE_BORDER, ...) and thus breaking (assert( false );). This is probably another bug? Removing that line made the tabs come back. Here's the (relevant) debugging information:

Versions:

{
  "PHP_VERSION": "8.0.8",
  "WP_VERSION": "6.2.2",
  "QTX_VERSION": "3.15.1",
  "Plugins": [
    "ACF Autosize 2.0.15",
    "Advanced Custom Fields: Unique ID Field 1.0.0",
    "Admin Collapse Subpages 2.4",
    "Admin Post Navigation 2.1",
    "Advanced Custom Fields PRO 6.1.6",
    "Category Checklist Tree 1.3.2",
    "Check &amp; Log Email 1.0.7",
    "Classic Editor 1.6.3",
    "Debug Bar 1.1.4",
    "Yoast Duplicate Post 4.5",
    "Email Address Encoder 1.0.22",
    "Enable Media Replace 4.1.2",
    "Filenames to latin 2.7",
    "Git Updater 12.2.1",
    "iOS Images Fixer 1.2.4",
    "Limit Login Attempts 1.7.2",
    "Loop Post Navigation Links 3.0.2",
    "Post Type Switcher 3.2.1",
    "qTranslate-XT 3.15.1",
    "Regenerate Thumbnails 3.1.5",
    "Relevanssi 4.20.0",
    "Rewrite Rules Inspector 1.3.1",
    "RH Admin Utilities 1.9.0",
    "RH Privacy Consent 1.1.2",
    "RH Shortcodes 1.1.3",
    "RH Updater 1.2.0",
    "Safe SVG 2.1.1",
    "External Links 6.8.1",
    "Simple Page Ordering 2.5.0",
    "YIKES Simple Taxonomy Ordering 2.3.4",
    "Term Management Tools 2.0.1",
    "User Switching 1.7.0",
    "WordPress Importer 0.8.1",
    "Yoast SEO 20.7",
    "Media Library Categories Premium 2.1.1",
    "WP Super Cache 1.9.4",
    "WP-Sweep 1.1.8",
    "WP Sync DB 1.6"
  ]
}

I also de-activated the ACF module and re-activated it again. Now the other warning is gone.

herrvigg commented 1 year ago

Good catch, there's a bug the first time when the option does not exist. When you save the QTX options once it will go away. The CSS is something else, need to check better.

herrvigg commented 1 year ago

Released in 3.15.2.