Home Forums General Issues Local JSON vs. Register via PHP vs. WP Database


Local JSON vs. Register via PHP vs. WP Database

  • I have broken things in my multisite network and I’m pretty sure it’s connected with my having tried to switch to registering my field groups via PHP in my custom plugin after having done most of my development using a local JSON folder inside the plugin.

    I am wondering how each method (local JSON, register via PHP, and create via the ACF UI in WP admin) affect the database. Could I have conflicting info about the field groups in the database that is causing problems?

    The errors I am getting in the WP dash include:

    1. Post Editor: “Updating failed. The response is not a valid JSON response.”
    2. Post Editor > Categories meta box: existing categories and their checkboxes are missing (they are, however, visible in “Quick Edit” mode on the All Posts page)
    3. Media Library: struggling to find and display library contents. Grid view tends to totally fail, while list view tends to work.
    4. Post Editor: Featured image meta box spins without displaying previously set images.

    I realize not all of the above may be related to ACF, however, all the above go away when I disable my plugin. I suspect that #2, #3 and #4 above are consequences of the server timing out with whatever is causing #1.

    Of possible significance: when I initially switched my plugin from pointing to its non-standard JSON save and load location, I rediscovered the acf-json folder in my theme.

    The reason I tried to switch to registering via PHP after developing with a custom acf-json folder in my plugin was that another plugin, Network Posts Extended, running on my main site, would only display ACF field content if I manually synced the ACF field groups on each and every subsite. (I wanted to avoid having to log into 90 or so subsites to do this, and to avoid needing to remember to do it on future subsites.)

  • All of your issues look to me like there is a php error during AJAX requests that is causing the request to fail “The response is not a valid JSON response.” The first step is to turn on debugging and error logging, check your error log and clear up any php errors and warnings if there are any.

  • Thanks, @hube2.

    Some poorly commented out code seems to have been the culprit. It wasn’t throwing any debug statements, but I discovered when deactivating / activating the plugin, the WP dash would display a message about my plugin producing 72 “unexpected” characters. That was as precise as it got.

    I would still *like* to know why I can’t seem to get my fields to be 100% functional across the network without using local JSON and manually synching at each subsite, but I can move forward for now.

  • If you put your field groups into PHP and the file is loaded by all sites then they will work on all sites.

    JSON files should work on all sites if they are loaded by all sites and syncing should not be needed. I have a couple of site in multisite that use JSON files. Not only do I not sync the groups to all sites, but they don’t even exist in the DB for sub sites, only the main site. All of the sites use the same theme so any changes I make to the field groups are automatically reflected in the sub sites. The only place the DB version of any site is used is when you edit the field group. Under all other conditions, if the field group exists as json then the json will be loaded.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.