bobbingwide / oik-clone

Clone content between sites
https://www.oik-plugins.com/oik-plugins/oik-clone-clone-your-wordpress-content/
GNU General Public License v2.0
5 stars 0 forks source link

Find a way to ensure featured image is set after initial clone #50

Closed bobbingwide closed 3 years ago

bobbingwide commented 4 years ago

For some time now the process to create and clone new content which has a featured image has been as follows.

  1. Create the content
  2. Upload and attach the featured image
  3. View the content
  4. In the output of the cloned / cloned shortcode clone both the content and the featured image.
  5. Edit the content - check the SEO meta description, correct a typo or something, update the taxonomies, then Update.
  6. View the content again
  7. Clone the post again.

Step 4. clones the post and the child attachment but doesn't set the correct ID for the featured image. Step 7. resolves the issue because the logic finds the mapped ID for the featured image

Requirement

Simplify the process by reducing the number of manual steps necessary

Proposed solution

Update the clone logic to reperform the first clone if a child attachment is also cloned.

bobbingwide commented 4 years ago

I've prototyped some code that does the following.

  1. In oik_clone_maybe_perform_clones, calls $clone->reclone_these after $clone->clone_these
  2. In clone_these, after calling $node->cloneme, we call maybe_reprocess_node to see if the post may need recloning.
  3. Maybe_reprocess_node adds the node to the reprocess list if the thumbnail for the post has not been cloned.
  4. The reclone these logic processes the same list of nodes as clone_these checking each node to see if it's in the reprocess_node list.
  5. If it is then the post is (re)cloned.

So, for a new oik-plugins post we'd expect to see oik-plugins post to be recloned if the featured image ( child attachment ) was cloned.

Informal integration / system testing

I'm testing this new logic by cloning a load of plugin and blocks that I catalogued locally in November 2019 but did not, for one reason or another, clone to the live site.

Then I might have a play with herbmiller.me

bobbingwide commented 3 years ago

I put this solution onto Susan's site a while ago. It's been working fine. It's now been delivered in oik-clone v2.0.0, so I'm closing it.