deliciousbrains / wp-migrate-db

WordPress plugin that exports your database, does a find and replace on URLs and file paths, then allows you to save it to your computer.
https://wordpress.org/plugins/wp-migrate-db/
341 stars 515 forks source link

Incompatibility with Elementor Pro lightbox URLs #114

Closed bratvanov closed 2 years ago

bratvanov commented 3 years ago

In Elementor Pro, many widgets which can have a link added to them support the Lightbox setting - and when the URL is added to the lightbox, it will get URL-encoded as part of the Elementor template which is saved as JSON in the database under the "postmeta" table in the "meta_value" column (as longtext).

However, while WP Migrate DB can successfully find/replace all other URLs in website built using Elementor, it doesn't find/replace these lightbox URL-encoded URLs.

Example of the simplest Elementor template that contains a section with a column with a heading widget that has a lightbox link defined.

elementor-editor-lightbox

The template of this simple page as saved in the DB:

elementor-urlencoded-meta-value

The value of the "meta_value" column (after beautifying for readability) for example:

[
   {
      "id":"5bbf5b5",
      "elType":"section",
      "settings":[

      ],
      "elements":[
         {
            "id":"526f3d1",
            "elType":"column",
            "settings":{
               "_column_size":100,
               "_inline_size":null
            },
            "elements":[
               {
                  "id":"5e864ea",
                  "elType":"widget",
                  "settings":{
                     "title":"Add Your Heading Text Here",
                     "__dynamic__":{
                        "link":"[elementor-tag id=\"9706031\" name=\"lightbox\" settings=\"%7B%22type%22%3A%22image%22%2C%22image%22%3A%7B%22url%22%3A%22http%3A%2F%2Flocalhost%2Felementor%2Fsite%2Fwp-content%2Fuploads%2F1.png%22%2C%22id%22%3A49%7D%2C%22video_url%22%3A%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DE3QiD99jPAg%22%7D\"]"
                     }
                  },
                  "elements":[

                  ],
                  "widgetType":"heading"
               }
            ],
            "isInner":false
         }
      ],
      "isInner":false
   }
]

The specific part in question which contains the URLs is this:

"link":"[elementor-tag id=\"9706031\" name=\"lightbox\" settings=\"%7B%22type%22%3A%22image%22%2C%22image%22%3A%7B%22url%22%3A%22http%3A%2F%2Flocalhost%2Felementor%2Fsite%2Fwp-content%2Fuploads%2F1.png%22%2C%22id%22%3A49%7D%2C%22video_url%22%3A%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DE3QiD99jPAg%22%7D\"]"

After URL-decoding this specific part, we get this:

"link":"[elementor-tag id=\"9706031\" name=\"lightbox\" settings=\"{"type":"image","image":{"url":"http://localhost/elementor/site/wp-content/uploads/1.png","id":49},"video_url":"https://www.youtube.com/watch?v=E3QiD99jPAg"}\"]"

So the 2 URLs contained inside are now obvious - http://localhost/elementor/site/wp-content/uploads/1.png and https://www.youtube.com/watch?v=E3QiD99jPAg (for image lightbox and video lightbox).

WP Migrate DB can't find and replace either of these 2 URLs.

kevinwhoffman commented 2 years ago

Hi there, I know it's been a while, but I wanted to follow up before closing this out. Since the Find & Replace tool is looking for the exact string of characters that you provide, it unfortunately cannot tell whether a URL-encoded version of that string exists in the database.

Here are a couple of options that might help:

  1. Add an additional Find & Replace term that targets the URL-encoded version of the URL and updates it accordingly.
  2. If necessary, try using the regex functionality introduced in WP Migrate DB Pro 2.1.0.

If you need help writing the regex, please reopen and we'll do our best to assist.