PluginProbe
Property Hive / 2.3.0
Property Hive v2.3.0
2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 1.4.62 All 260 releases
propertyhive / includes / class-ph-duplicate-post.php

class-ph-duplicate-post.php in Property Hive 2.3.0, at includes/class-ph-duplicate-post.php

52 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WordPress core hook save_post; renaming it would break the core hook contract.
48 do_action( "save_post", $new_post_id, $post, false );
49 }
50 }
51
52 PH_Duplicate_Post::init();