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

Option for enabling / disabling cloning by post by slave server #37

Closed bobbingwide closed 3 years ago

bobbingwide commented 5 years ago

When you’ve created new content or updated existing content how do you control where it gets cloned to?

https://github.com/bobbingwide/oik-clone/issues/34#issuecomment-499370589

In the process of creating blocks.wp.a2z content was pushed and pulled between a number of sites in the WPMS network. Running reconciliation between blocks.wp.a2z and blocks.wp-a2z.org is fine for the time being. But it won’t be possible to clone new content with core.wp.a2z ( and/or core.wp-a2z.org ) unless we know which of the possible targets are valid for a particular post.

It appears that we need to be able to record per post and per server whether or not a particular post is destined for that server. What changes to the post meta structure do we need to make to be able to achieve this. And how do those changes affect the clone and cloned shortcodes etc?

bobbingwide commented 4 years ago

In LBB2 p 106 I tabulated the options for a

and what it means for Push or Pull.

DNC TBC Means for push Means for pull
null null Yes Yes
Yes No No No
No Yes Yes Yes

Questions

Is it possible to have different settings on master and slave? and if so, what would the behaviour be on a push or pull?

Musings

Originally the default logic was to clone everything. So, logically it makes more sense to create a new check box that marks content as Do Not Clone.

Changes required?

file function
admin/oik-clone-meta-box.php oik_clone_box
admin/oik-save-post.php oik_clone_update_slave_target, oik_clone_id_cloned
admin/class-oik-clone-reset-ids.php
admin/class-oik-clone-reset-slave.php
shortcodes/oik-cloned.php
bobbingwide commented 4 years ago

My first solution was to extend the _oik_clone_ids post meta structure to include a new value for Do Not Clone. This might not have been a good idea. There are times when information is not available to set values for each of the fields in the arrays. An example is when a post is first being written, so has not yet been cloned.

It would be better to have a new post meta field called _oik_clone_dnc. This would be an array of slaves where $dnc equals 'on'. A simpler structure.

bobbingwide commented 4 years ago

screenshot-4

I've created a new Do Not Clone meta box where you have to select the slaves to which you don't want cloning to be performed. The values can be set before the post is initially published.

Some requirements

bobbingwide commented 4 years ago

Some more requirements

Note: This data is being cloned in the current development version. I noticed that it causes a problem when the post is viewed in the slave. Not sure why though.

Warning: Invalid argument supplied for foreach() in 
C:\apache\htdocs\wordpress\wp-content\plugins\oik-clone\admin\class-oik-clone-meta-clone-dnc.php on line 78

On the master the value is a:1:{i:0;s:16:"https://s.b/wp52";} On the slave the value is s:34:"a:1:{i:0;s:16:"https://s.b/wp53";}";

bobbingwide commented 4 years ago

The solution developed so far appears to be working for push cloning from blocks.wp.a2z to blocks.wp-a2z.org and a selected sub domain of wp.a2z. It requires the right configuration and some degree of mental control. I haven’t yet worked out the most efficient way of defining the targets for each post when the source is blocks.wp.a2z. And the [clone][cloned] shortcodes don’t indicate the potential targets for a new post.

On the whole I think it’s been a worthwhile exercise.

bobbingwide commented 4 years ago

I’ve noticed that when WooCommerce is activated the check boxes in the two new meta boxes don’t show the ticks when selected. Something like this happened before with oik-weight-zone-shipping. Should this be a separate issue?

bobbingwide commented 3 years ago

oik-clone v2.0.0 is now released. Susan's been using the facility for the past couple of months selectively cloning from her playarea site to hampshire-eft.co.uk and/or livethelifeyouwantclub.co.uk. Closing for now.