| 1 |
<?php |
| 2 |
namespace YayMail\Page\Source; |
| 3 |
|
| 4 |
defined( 'ABSPATH' ) || exit; |
| 5 |
|
| 6 |
class UpdateElement { |
| 7 |
|
| 8 |
public $updateElements = null; |
| 9 |
|
| 10 |
public function __construct() { |
| 11 |
$this->updateElements = array(); |
| 12 |
|
| 13 |
//Filter to add new updated Element's properties |
| 14 |
add_filter( |
| 15 |
'yaymail_addon_get_updated_elements', |
| 16 |
function( $element ) { |
| 17 |
$result = array_merge( |
| 18 |
$element, |
| 19 |
array() |
| 20 |
); |
| 21 |
return $result; |
| 22 |
} |
| 23 |
); |
| 24 |
$this->updateElements = apply_filters( 'yaymail_addon_get_updated_elements', $this->updateElements ); |
| 25 |
} |
| 26 |
public function merge_new_props_to_elements( $yaymail_elements ) { |
| 27 |
if ( is_array( $yaymail_elements ) || is_object( $yaymail_elements ) ) { |
| 28 |
foreach ( $yaymail_elements as $key => $element ) { |
| 29 |
if ( isset( $this->updateElements[ $element['type'] ] ) ) { |
| 30 |
$yaymail_elements[ $key ]['settingRow'] = wp_parse_args( $yaymail_elements[ $key ]['settingRow'], $this->updateElements[ $element['type'] ] ); |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
return $yaymail_elements; |
| 35 |
} |
| 36 |
} |
| 37 |
|