-
Notifications
You must be signed in to change notification settings - Fork 37
Feature request: Copy post meta / manage separate meta translation #117
Comments
Thanks for your requirements. The plugin can handle post meta data. But it is not possible out of the box. It is required, that you include the meta data. For WooCommerce: we have an additional plugin, that can sync all Woo data about the network, with the API from MLP. The plugin is currently in a beta status, but you can test it. If you like, send me f.bueltgeATinpsydeDOTcom an Mail and I will send you information and the plugin. As example to sync post meta data see this gist. https://gist.github.com/toscho/6393c79aacba0983a96a Best regards and thanks for feedback. |
Hello Frank, Thanks for the info! I've started a addon to automate metafield syncing but I have some questions. Thanks! |
Hi there, I don't know exactly which way you want to do this, so what do you want/need here? For a given blog with switch_to_blog( $blog_id );
$connected_blog_ids = array_keys( mlp_get_available_languages_titles() );
restore_current_blog(); For a given post with $mlp_language_api = apply_filters( 'mlp_language_api', NULL );
$interlinked_posts = is_a( $mlp_language_api, 'Mlp_Language_Api_Interface' )
? $mlp_language_api->get_related_content_ids( $blog_id, $post_id )
: array(); Anything else? |
I'm not sure but I think I need the last one, only it doesn't work for mee. This is in short what I'm trying to do with a separate plugin: class Multilingualpress_Custom_Post_Meta_Sync {
public function setup() {
/* get linked post in combination with site id's */
}
}
add_action( 'mlp_and_wp_loaded', array( new Multilingualpress_Custom_Post_Meta_Sync(), 'setup' ) ); I need these in order to store the values correctly across the network. |
Update: class Multilingualpress_Custom_Post_Meta_Sync {
public function setup() {
add_filter('mlp_pre_save_post_meta', array ( $this, 'register_meta_fields' ), 10, 2);
}
public function register_meta_fields( array $post_meta ) {
$blog_id = get_current_blog_id();
$post_id = intval($_POST['post_ID']);
$type = $_POST['post_type'];//get_post_type($post_id);
$mlp_language_api = apply_filters( 'mlp_language_api', NULL );
$interlinked_posts = is_a( $mlp_language_api, 'Mlp_Language_Api_Interface' )
? $mlp_language_api->get_related_content_ids( $blog_id, $post_id, $type )
: array();
/* $interlinked_posts is always an empty array */
}
}
add_action( 'mlp_and_wp_loaded', array( new Multilingualpress_Custom_Post_Meta_Sync(), 'setup' ) ); $interlinked_posts is always an empty array... can't figure out why. |
Hi there, I copied your code to my theme's I have a network with two blogs, each having one post. The blogs have a language, are related to each other, and the posts are translations of each other. How does your setup look like? Are there any translations for the post in question? |
I've got it working now, don't exacly know why but the first time it didn't work so I started looking into the MLP source code and saw the post_type ($type) value, thats where I went wrong since it required the "post" post_type. I've made a quick first try for a plugin.. its a v0.1-beta1 (at most) but if you guy's could take a look that would be great! Single post_meta values are working now, you can enable them in the network settings of MLP. I'm still struggling with post_meta with multiple values so that won't work right now. |
ADD: Also I've found this function which does the same aparently: |
@JoryHogeveen We have a plugin that sync all data from WooCommerce. I can send this to you, that you have an example and a plugin for tests. If you will test the plugin, then send me a mail - f.bueltgeATinpsydeDOTcom |
I've send you an email! I would like to see/test this addon. But the reason I've started the above was not for WooCommerce only but more as an allround post-meta sync addon. |
I've just started to investigate syncing of post meta and I was hitting a wall with the deletion of post meta. Let me explain what I mean. Simply copying over post meta more or less boils down to this. (Leaving out all checks for empty data and alike for the sake of simplicity in this example)
The problem is that when you delete post meta on one side it stays on the other languages. This also seems not to be addressed by the solutions from @toscho or @JoryHogeveen. I still haven't thought this through and deletion might not always make sense, but it definitely is relevant in some situations. So I had a look if I can hook somewhere to delete post meta but I couldn't find anything. The relevant line seems to be this: Maybe one could add a check there if the value is null/empty/false and delete the metadata in such a case. I've seen this approach with CMB2: Once again this is just a braindump to see if you have any better ideas or there already is a working approach for this with the current codebase. |
Related to #125 |
It would be awesome if one could manage the translations of post-metadata.
Optimal situation would be that one can select which metadata to sync and which to translate.
Is such a feature possible in the near future?
This could be troublesome with plugins like WooCommerce or Event Manager but I hope it can be done.
For me, this is a big reason to use this plugin.
The text was updated successfully, but these errors were encountered: