| 1 |
<?php |
| 2 |
/** |
| 3 |
* Builder Plugin Compatibility Code |
| 4 |
* |
| 5 |
* @package Themify_Builder |
| 6 |
* @subpackage Themify_Builder/classes |
| 7 |
*/ |
| 8 |
|
| 9 |
class Themify_Builder_Plugin_Compat_DuplicatePosts { |
| 10 |
|
| 11 |
static function init() { |
| 12 |
add_filter( 'option_duplicate_post_blacklist', array( __CLASS__, 'dp_meta_backlist'), 10, 2 ); |
| 13 |
add_action('dp_duplicate_post', array( __CLASS__, 'dp_duplicate_builder_data'), 10, 2); |
| 14 |
add_action('dp_duplicate_page', array( __CLASS__, 'dp_duplicate_builder_data'), 10, 2); |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Backlist builder meta_key from duplicate post settings custom fields |
| 19 |
*/ |
| 20 |
public static function dp_meta_backlist(string $value,string $option ):string { |
| 21 |
$list_arr = explode(',', $value ); |
| 22 |
$list_arr[] = '_themify_builder_settings_json'; |
| 23 |
return implode( ',', $list_arr ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Action to duplicate builder data. |
| 28 |
* |
| 29 |
* @access public |
| 30 |
* @param int $new_id |
| 31 |
* @param object $post |
| 32 |
*/ |
| 33 |
public static function dp_duplicate_builder_data( $new_id, $post ) { |
| 34 |
$builder_data = ThemifyBuilder_Data_Manager::get_data( $post->ID ); // get builder data from original post |
| 35 |
ThemifyBuilder_Data_Manager::save_data( $builder_data, $new_id ); // save the data for the new post |
| 36 |
} |
| 37 |
} |