This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

How to Use Page Revisions with Layout Builder

  • Creator
    Topic
  • #20485
    Brett
    Participant

    I am just curious, does the layout builder work with page revisions so you can go back to a previously saved version of the page?

Viewing 15 replies - 1 through 15 (of 27 total)
  • Author
    Replies
  • #20486
    Jason Bobich
    Keymaster

    The elements of a page’s custom layout is just a big piece of data saved to the _tb_builder_elements meta value of a page. I’m honestly not sure if WordPress’s page revisions work with meta data, but I have a feeling not. However, if not, I’d have to imagine there’s a plugin, code snippet, or something out there that could incorporate meta data to page revisions.

    #23710
    Brett
    Participant

    I wanted to revisit this and say there is a plugin available now that saves meta data to page revisions. https://wordpress.org/plugins/wp-post-meta-revisions/

    #23723
    Jason Bobich
    Keymaster

    That is sounds extremely useful! Thanks for posting.

    #23725
    askwpgirl
    Participant

    Sweet. Thanks, Brett!

    #23728
    Brett
    Participant

    No problem. Jumpstart has always been far and away my favorite framework/theme to build sites with but the inability to revert to previously saved versions of pages always made me nervous when clients started getting in their hands on things.

    I haven’t done a lot of testing with this but it seems to work from what I’ve seen so far. If you install it and mess around with it is love to hear what you think.

    #23732
    askwpgirl
    Participant

    Thanks, Brett. I Tweeted the developer, and he said it should be built into core soon, so we will need to keep track when it is and remove the plugin.

    I will play with it. Had a client issue today that this would have solved. I’m totally paranoid about clients deleting sections and elements that have been painstakingly set up.

    Brett, can you send me a message at http://askwpgirl.com/contact/ I’d like to send you info about the Jump Start Google Group I moderate and find out more about the type of development work you do?

    #23735
    Brett
    Participant

    That is awesome news. With things like the layout builder and advanced custom fields, that is a must have option.

    #23847
    Brett
    Participant

    @askwpgirl, I send you a message through you contact form, did you receive that?

    #25441
    askwpgirl
    Participant

    The plugin mentioned by Brett requires you to add all the meta keys to filter to a function:

    function add_meta_keys_to_revision( $keys ) {
        $keys[] = 'meta-key-to-revision';
        return $keys;
    }
    add_filter( 'wp_post_revision_meta_keys', 'add_meta_keys_to_revision' );

    How would you recommend loading up the _tb_builder_elements in that function?

    Brett – have you given this a try yet? I’ve had several clients accidentally delete their layout elements, which has been a pain to recover from backup. I think this is why so many other layout builders insert all the crazy shortcode into the content area of the page since the page content is revisioned.

    #25443
    Jason Bobich
    Keymaster

    Unfortunately it’s not fully possible because it’s not as simple as designating just a few meta keys that the builder uses. _tb_builder_elements is one, but there are several other ones created every time you use a columns element, where the met key has a randomly generated ID on it, for example.

    You could always save a layout to a template as a backup. — For example, you have a page with a custom layout. Then, click “Save to Template.” Then, if you want to roll it back just apply that template as the starting point for that page, and the layout has been rolled back to when you saved that template.

    #25445
    askwpgirl
    Participant

    Thanks, that’s what I thought. Yes, I have employed the strategy of saving Custom Layouts as templates. That seemed the best solution if they aren’t making a lot of changes to it.

    I wonder if we could create a plugin or add a feature to the Template Builder plugin that would automatically save a custom layout as a template on each update with a max # of versions? I could see that being very useful in the future as people use the layout builder more and more. When the Template Builder is used to construct a lot of pages, manually saving as template becomes a bit onerous. It is becoming a bigger deal and is a competitive issue with other layout builder plugins that are able to roll back.

    #25448
    Jason Bobich
    Keymaster

    Honestly, it’s never come up to me other than in this topic. But apparently this isn’t very difficult to add to WordPress when saving the custom layouts to the page:

    https://johnblackbourn.com/post-meta-revisions-wordpress

    I will look into it later for the Layout Builder, but don’t have time at the moment. It probably wouldn’t make sense to have it as a separate plugin just because the layout builder is already building and saving this data; so the layout builder plugin itself might as well just push it to the revision data at the same time as the article above says to do.

    https://github.com/themeblvd/theme-blvd-layout-builder/issues/13

    #25449
    askwpgirl
    Participant

    You are my hero.

    #25629
    kennethfeldman
    Participant

    Hey, as a temporary (safety) fallback:

    Is there a way to simply remove the DELETE (and maybe the DUPLICATE) link in the builder elements (at least for non-admin users)?

    #25632
    askwpgirl
    Participant

    I like Kenneth’s idea!

Viewing 15 replies - 1 through 15 (of 27 total)

You must be logged in to reply to this topic.