Make Revision Page hook

Description

The action hook is executed at the end of “make revision” of a page. Use this hook to copy data from the original/published article to the revised article.

The page hook supports hierarchical articles.

Usage

add_action('owf_duplicate_page', 'copy_post_meta_info', 10, 2);

Parameters

  • $new_id – ID of the new/revised page
  • $original_page – page to copy the data from

Example

add_action('owf_duplicate_page', 'copy_post_meta_info', 10, 2);

function copy_post_meta_info($new_id, $post) {
	$post_meta_keys = get_post_custom_keys($post->ID);

	if (empty($post_meta_keys))
		return;

	foreach ($post_meta_keys as $meta_key) {
		$meta_values = get_post_custom_values($meta_key, $post->ID);
		foreach ($meta_values as $meta_value) {
			$meta_value = maybe_unserialize($meta_value);
			add_post_meta($new_id, $meta_key, $meta_value);
		}
	}
}

Source Code

The action hook in located in class-ow-revision-service.php