A. You need to be able to point to the correct post on the target site. i.e. there is a need to support complex relationships between content.
Requirements
- When content is cloned any relationships with other content should be maintained
Simple relationships in WordPress core
- Post parent
- Featured image
post->post_parent
relationship.
- Hierarchical post types such as pages use this relationship
- Attachments created using
Add Media
are created with apost_parent
of the current post
_thumbnail_id
.
Complex relationships ( extensions )
- Other post meta data fields may contain one or more references to other posts by post ID
- Each source post ID needs to be mapped to the correct target ID
- The server should ensure consistency of the mapping from source to target ID
Solution
We achieve this by passing a simple array of source to target IDs. e.g. for post 16878, which originally had no parent when cloned to 29936, but was then given one, the array we pass to the server may consist of:source | target | which is |
---|---|---|
16878 | 29936 | A simple mapping of the current post – it may be easier to use than accessing target |
4941 | 0 | Post parent – not known to have been cloned |
16362 | 0 | Featured image ( _thumbnail_id ) |
2384 | 0 | Plugin reference ( _plugin_ref ) – a field of type “noderef” |
_oik_clone_ids
.
- For each item of content that has been cloned, oik-clone stores the target server and post ID in post meta data keyed by ‘_oik_clone_ids’
- When the content is recloned this ID is passed to the server as the preferred target
- The server will then match this target
- For any source post IDs which are found in relationships oik-clone will build a mapping table of source to target post IDs
- This mapping table will be passed to the server
- oik-clone has built-in support for:
- _thumbnail_id
- “noderef” fields – recognised by oik base functions
- Use oik_clone_build_list filter to include your own mappings
Assumptions
- When any content is cloned, the content referenced in the relationships will also be cloned
Limitations
- Only supports relationships in post meta data
- Where relationships are cyclical cloning may need to be performed more than once
- Does not support post references maintained through slugs, URLs or HTML links
- Does not support yet support oik custom image link fields ( _bw_image_link )
- Any extension plugin is needed in both source and target servers