| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; // Exit if accessed directly |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Duplicate Post Plugin Compatibility |
| 9 |
* |
| 10 |
* @class PH_Duplicate_Post |
| 11 |
* @version 1.0.0 |
| 12 |
* @package PropertyHive/Classes/ |
| 13 |
* @category Class |
| 14 |
* @author PropertyHive |
| 15 |
*/ |
| 16 |
class PH_Duplicate_Post { |
| 17 |
|
| 18 |
/** @var PH_Duplicate_Post The single instance of the class */ |
| 19 |
protected static $_instance = null; |
| 20 |
|
| 21 |
/** |
| 22 |
* Hook in methods |
| 23 |
*/ |
| 24 |
public static function init() |
| 25 |
{ |
| 26 |
add_action( 'duplicate_post_post_copy', array( __CLASS__, 'sort_out_concat_fields' ), 10 ); |
| 27 |
} |
| 28 |
|
| 29 |
public static function sort_out_concat_fields( $new_post_id ) |
| 30 |
{ |
| 31 |
delete_post_meta( $new_post_id, '_address_concatenated' ); |
| 32 |
delete_post_meta( $new_post_id, '_features_concatenated' ); |
| 33 |
delete_post_meta( $new_post_id, '_descriptions_concatenated' ); |
| 34 |
delete_post_meta( $new_post_id, '_owner_details' ); |
| 35 |
|
| 36 |
$prefix = '_imported_ref_'; |
| 37 |
$all_meta = get_post_meta($new_post_id); |
| 38 |
foreach ($all_meta as $meta_key => $meta_values) |
| 39 |
{ |
| 40 |
if ( strpos($meta_key, $prefix ) === 0 ) |
| 41 |
{ |
| 42 |
delete_post_meta($new_post_id, $meta_key); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
$post = get_post( $new_post_id ); |
| 47 |
do_action( "save_post", $new_post_id, $post, false ); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
PH_Duplicate_Post::init(); |