elegantthemes / create-divi-extension

MIT License
186 stars 59 forks source link

Divi Builder Cache #162

Open meronivalerio opened 6 years ago

meronivalerio commented 6 years ago

Problem Description

When I change fields in "get_fields" method, they don't change in module builder. I tryed to clear site cache, localStorage and change browser, but the error persists.

Steps To Reproduce

  1. define fields in "get_fields"
  2. open module in builder
  3. add a field in "get_fields"
  4. reopen module in builder
jcdotnet commented 6 years ago

Hi @meronivalerio, I've tried this approach:

function test_clear_cache() {
    // clears the et_pb_test_module module from the Divi Builder cache
    echo '<script> 
            localStorage.removeItem("et_pb_templates_et_pb_test_module"); 
        </script>';
}

function test_plugins_loaded() { //
    add_action('admin_head', 'test_clear_cache');   
}
add_action('plugins_loaded', 'test_plugins_loaded'); 

but it doesn't work for me. Once the item is removed from localstorage I have to reload the page in order to open the module in the builder.

Any suggestions? Have you managed to make it work?

Thank you.

meronivalerio commented 6 years ago

Hi @jcdotnet, I've tried already to clear localStorage (and cache) like you, but it doesn't work for me either. For now I have not found a solution; I am changing the slug of the module every time I save, so the parameters are updated, but it is not a valid solution. I hope someone can help us

xxtesaxx commented 6 years ago

That is very odd. Normally adding a window.localStorage.clear(); to a JS file, which is enqueued in the admin area, solves this issue

IvanBrkicNeuralab commented 5 years ago

Having the same issue, Clearing localStorage does not help.

kroleg commented 5 years ago

Having same issue. I don't see my fields at all in backend. BUT all fields are accessible in Visual Builder. Couple of times i saw that when i open module settings my fields (deinfed in get_fields) are quickly show and then dissapear. Tried to clear wordpress cache and localStorage. Didn't help

xxtesaxx commented 5 years ago

Are you all using the new "show_if" conditional logic? I found that this causes fields to not show up on the BB. Also, using toggle slugs which I did not define myself sometimes caused issues.

If you rely on the BB, instead of show_if, you might want to fall back to the old "depends_show_if" conditional logic

kroleg commented 5 years ago

@xxtesaxx thank you!

What helped me (i didn't have show_if):

  1. Remove toggle_slug property from all fields (no idea what it does i just copypasted it from tutorial)
  2. Remove all instances of your module from page
  3. Do a localStorage.clear() in console
  4. Reload page
  5. Add your module (wait for it to load, it can take soem time)
  6. It works!
IvanBrkicNeuralab commented 5 years ago

@xxtesaxx I can confirm it works for me too. Thank you. So this example doesn't work anymore because of the 'main_content' toggle slug.

xxtesaxx commented 5 years ago

You can add the main_content toggle (or any other toggle you like) manually either in init() via $this->settings_modal_toggles or via the respective function get_settings_modal_toggles() and then it will work too.

Be aware the the Backend Builder caches the settings so after chaning them, you will need to run a localStorage.clear() and reload the page for them to show up. In my plugins, I have put this in a admin.js so I get the localStorage.clear() on every page load.

wolfgangdie commented 5 years ago

I have been working recently on the Divi custom modules and I could notice the problem that occurs when adding new fields.

In principle, as mentioned above, I tried to clean the site cache, the localStorage and even use different browsers without any success. I could also notice that if these steps had no effect, the problem should be properly in the plugin or in the internal logic used by WordPress.

This led me to a quick "solution": every time I made a change on the fields of the custom module, it is only necessary to deactivate and then activate again from the administrator the plugin created with npx create-divi-extension, refresh the page where we are testing the module and thus, the change in the fields can be seen in the frontend builder.

Sumit89612 commented 3 years ago

You can use ET_Core_PageResource::remove_static_resources from /core/components.PageResources.php

xxtesaxx commented 3 years ago

Is this still an issue? I haven't experienced issues with this in - well - years, actually. Just the other day I was changing the default value of a settings and simply reloading the page was enough to see the effects.

Sumit89612 commented 3 years ago

Is this still an issue? I haven't experienced issues with this in - well - years, actually. Just the other day I was changing the default value of a settings and simply reloading the page was enough to see the effects.

The issue is that if we change any design related part from visual builder then it is not reflecting untill we clear static css cache from setting. Can you please explain with some short example. It would be greateful.