class.jetpack-sync-module-meta.php
| 1 | <?php |
| 2 | |
| 3 | class Jetpack_Sync_Module_Meta extends Jetpack_Sync_Module { |
| 4 | private $meta_types = array( 'post', 'comment' ); |
| 5 | |
| 6 | public function name() { |
| 7 | return 'meta'; |
| 8 | } |
| 9 | |
| 10 | public function init_listeners( $callable ) { |
| 11 | $whitelist_handler = array( $this, 'filter_meta' ); |
| 12 | |
| 13 | foreach ( $this->meta_types as $meta_type ) { |
| 14 | add_action( "added_{$meta_type}_meta", $callable, 10, 4 ); |
| 15 | add_action( "updated_{$meta_type}_meta", $callable, 10, 4 ); |
| 16 | add_action( "deleted_{$meta_type}_meta", $callable, 10, 4 ); |
| 17 | |
| 18 | add_filter( "jetpack_sync_before_enqueue_added_{$meta_type}_meta", $whitelist_handler ); |
| 19 | add_filter( "jetpack_sync_before_enqueue_updated_{$meta_type}_meta", $whitelist_handler ); |
| 20 | add_filter( "jetpack_sync_before_enqueue_deleted_{$meta_type}_meta", $whitelist_handler ); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | function filter_meta( $args ) { |
| 25 | if ( '_' === $args[2][0] && |
| 26 | ! in_array( $args[2], Jetpack_Sync_Defaults::$default_whitelist_meta_keys ) && |
| 27 | ! wp_startswith( $args[2], '_wpas_skip_' ) |
| 28 | ) { |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | if ( in_array( $args[2], Jetpack_Sync_Settings::get_setting( 'meta_blacklist' ) ) ) { |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | return $args; |
| 37 | } |
| 38 | } |
| 39 |