Settings Page Error
-
I’m having two issues with this plugin.
1. The settings page for ACF Extended is throwing an error. Undefined array key “path” from the following line:
/plugins/acf-extended/includes/admin/settings.php:622
2. When I try to save or sync fields using acf json the file is deleted instead of updating. When I turn off acf extended this works as expected.Any idea on either of these? Thanks!
- This topic was modified 2 days, 12 hours ago by benbranyon.
- This topic was modified 2 days, 12 hours ago by benbranyon.
-
Hello,
Thanks for the feedback!
1. The “ACF > Settings” page you see in the WP Admin menu is a page added by ACF Extended. This screen will recap all ACF settings defined in code. You can read more about ACF settings here.
As you can see in the ACF documentation, thepath
setting is a default setting that is essential to the functioning of ACF:Absolute path to ACF plugin folder including trailing slash. Defaults to
plugin_dir_path()
The error message you shared suggests it has been deleted/removed. Note it seems it hasn’t been updated/changed using existing ACF methods with
acf_update_setting()
, but completely deleted, which isn’t normal and might break ACF.In fact, in order to reproduce this warning message, a code similar to this must be used (which should be avoided, as it doesn’t respect native ACF core logic):
add_action('acf/init', function(){
unset(acf()->settings['path']);
});I would suspect some custom code/hook somewhere either in your theme or a third party plugin which remove that setting. Ideally, you should find it and fix it to avoid more issues.
- Do you have any particular custom ACF Pro setup?
- Is ACF Pro installed as a plugin?
- Do you know which version of ACF Pro do you use?
2. By default, ACF automatically save any Field Group as a json file if there is a folder named
/acf-json/
in your theme, everytime you update a Field Group in the ACF UI.With ACF Extended, you can control that behavior and define which Field Group should be saved as Json. In the ACF UI, when editing a Field Group, on the right side you’ll find the “AutoSync Settings” with checkboxes that let you choose if the Field Group should be saved as a Json and/or PHP file (See screenshot).
By default, ACF Extended respects the default ACF behavior and will automatically check the “Json Sync” checkbox if there is a
/acf-json/
folder in your theme. So all your Field Groups will behave the same as usual. However, if you unchecked this checkbox and saved the Field Group at some point, it won’t be saved as Json. If you want to keep saving the Json files, please make sure this checkbox is checked.Thanks!
Regards.
Thanks for the reply.
1. It is quite strange. The path setting seems to be set correctly in ACF Pro, but when I try to debug it in ACF Extended it’s empty. We do have ACF Pro installed as an mu-plugin which is a little bit different of a setup, but I don’t think it would cause this issue? Currently on version 6.3.11. We are also using Advanced Custom Fields?Multilingual, but turning that plugin off doesn’t seem to fix the issue.
2. Interesting, I don’t seem to have that Advanced Settings metabox on my field group edit screen. We do have some custom code for ACF json loading, so I might have to dig deeper into that.Hello,
Thanks for the details!
1. Using ACF Pro as
mu-plugin
should not remove thepath
setting on its own. Here is a video showing ACF Pro setup asmu-plugin
on a blank WP Install.If you want to test it, here is the code I used in the
/mu-plugins/acf-pro.php
file:<?php
require_once(__DIR__ . '/advanced-custom-fields-pro/acf.php');The ACF Pro folder being in
/mu-plugins/advanced-custom-fields-pro
. You should get the same result, with thepath
correctly set in the “ACF > Settings” page on a blank WP Install like in the video.You can check if your ACF path setting has been removed or not, using the following code in your theme’s
functions.php
file:add_action('acf/init', function(){
$has_path = isset(acf()->settings['path']) ? 'true' : 'false';
acf_log('acf path found:', $has_path);
}, 100);This will log the information in your
/wp-content/debug.log
file with theWP_DEBUG
&WP_DEBUG_LOG
enabled in thewp-config.php
file. You can read more about how to enable theWP_DEBUG_LOG
in our guide here.In order to isolate the issue on your setup, I would recommend clone your website on a development / staging environment using Duplicator, or with your hosting backup solution. Then try to disable all your plugins one-by-one (at the exception of ACF Pro & ACF Extended) until you find which one cause the issue.
If the problem persists, try switch to the native WP Twenty Twenty Two theme, to make sure you don’t have any custom code in your theme which would break the feature.
In all cases you should be able to confirm it works like I did, by setting up a clean WP install with ACF Pro + ACF Extended only.
2. If you have some custom hooks/code for the ACF Json sync feature, I would recommend to double check the
json
and thelocal
ACF settings are correctly enabled (they are enabled by default). You will see their status in the “ACF > Settings” page too. Additionally, please make sure that you use available hooks in the ACF documentation here.Another thing you could check, is the “Screen options” in your Field Group UI and make sure the “Advanced Settings” checkbox is correctly checked to display the related metabox. See screenshot.
To debug your custom Json code/hook, you can use the same method as described above, by disabling all plugins and using a blank theme. Then add your Json related hooks one by one until you find which one that seems to be problematic.
Let me know if you found something!
Thanks!
Regards.
- I’ve been doing some more debugging and found something interesting. When I change the priority to anything below 10 for the
acf/init
action on line 22 inacf-extendend/includes/admin/settings.php
this error goes away and the correct path is shown. It seemsacf_post_init()
wasn’t firing at all with the priority value set to 100 for our setup. Soadd_action('acf/init', array($this, 'acf_post_init'), 9);
works on our setup, butadd_action('acf/init', array($this, 'acf_post_init'), 100);
doesn’t work. I’m not sure exactly what would cause that in our code base. We are using the acf/init hook elsewhere in the codebase, but I’m not seeing any other priorities that should interfere.
2. When I make the update to fix the settings page I see that the Json is enabled and the custom path for our acf-json folder is correct. Still whenever I try to save or sync a field group the file gets deleted instead of updated. When I turn off acf-extended it works as expected. Is there anything in the plugin that would modify this functionality?
- This reply was modified 1 day, 5 hours ago by benbranyon.
Hello,
Thanks for the details!
1. If you want to isolate the issue more easily, please check the section in my previous answer where I explain you how to do it.
2. Have you checked the “Screen Options” as in my screenshot? Maybe the “Advanced Settings” metabox is just hidden?
Ideally to debug both issues, you should disable all your plugins at the exception of ACF Pro (in plugin mode, not mu, just in case you have custom code in mu) & ACF Extended.
So you have a setup that is basically “blank”, and the only custom code is in your theme (if that’s where your custom code/hooks are). Then comment big portion of your code in the
functions.php
with/* */
.Start big, and comment everything, refresh the “ACF > Settings” page, and the
path
should be working. Which means the issue is somewhere in your big/* */
infunctions.php
. Then decomment some big chunk of code, check “ACF > Settings” again… etc. Keep decommenting until you find the code/file that break thepath
again.This way you can isolate it like a funnel.
Regards.
Yes, I’m already debugging on my local copy of the website with all of the other plugins turned off except ACF Pro and ACF Extended. We do have a pretty custom version of WordPress built on Sage10, so it may be that your plugin just has some issues with that setup. I’ve isolated the settings page issue down to that line of code I mentioned previously, so I might just patch it myself with a composer patch. Otherwise the ACF path shows up correctly in our theme and everywhere else. I will keep investigating and update this thread if I find anything else.
- You must be logged in to reply to this topic.