We've recently updated Metabox and our extension, unfortunaltey i can't tell which version we had previously installed. Since this update to todays latest version of Metabox and all the extension we're using, we are facing the following issue which wasn't one for more than 1,5 years.
We have "post" fields to choose posts/pages rom any post types and as field_type we are using "selected_advanced". This ends in https://example.com/wp-admin/admin-ajax.php 400 (Bad Request). If i change to field_type "select" all is working correctly.
Here's a code snippet, hope this helps:
'fields' => [ [ 'id' => 'login_page_id', 'name' => _x( 'Login page', 'admin', 'demo' ), 'desc' => _x( 'Choose your default login page. This will change the login page URL of WordPress to point to the chosen page.', 'admin', 'demo' ), 'type' => 'post', 'post_type' => 'any', 'field_type' => 'select_advanced', 'placeholder' => _x( 'Default WordPress login page', 'admin', 'demo' ) ],
Please advise, the "select" option is hard to use in environments with hundreds of posts/pages.
We updated Meta Box last year to add Ajax support for object fields, to improve the performance on sites with thousands of posts.
Can you try reinstalling Meta Box? And clear the browser cache before trying again? I think there might be something like missing files or caching of old JS files.
Thank you for looking into this! I really appreciate it!
I reinstalled Meta Box and cleared the browser cache. I also created a very new WP site, still no joy.
The ajax call ends as a 400 (badrequest).
I don't think it is a caching issue. It also is not a general ajax issue, since other ajax calls working as expected.
I've checked with others in my team, they experiencing the same issue. In the select box it displays "The results couldn't be loaded", once i change the "field_type" from "select_advanced" to "select" all is working, but i've mentioned that earlier in our conversation.
Not sure if this might help you to sort this out, but we're using this with your "settings page extension" implemented through.
Can you share the full code of the meta box and settings page to test? I can't replicate the bug on my end :(.
we've figured it out.
In our code we don't add our metabox code to your filter array on admin pages where it shouldn't be displayed.
It seems like that your AJAX call triggers the filter execution and because we're not adding our code on admin-ajax.php it breaks somehow your ajax call.
We've workaround it and all is working for us.
Thanks for assistance, we're really appreciate your effort!