diff options
author | Yury German <blueknight@gentoo.org> | 2017-01-24 23:51:34 -0500 |
---|---|---|
committer | Yury German <blueknight@gentoo.org> | 2017-01-24 23:51:34 -0500 |
commit | 3c539a4713a80181af84c1fedc742436f75c92c4 (patch) | |
tree | e1896c286f3fb98337a6297465974c65f1fe8f26 /plugins/jetpack/sync/class.jetpack-sync-module-meta.php | |
parent | Update theme twentyfifteen to 1.7 (diff) | |
download | blogs-gentoo-3c539a4713a80181af84c1fedc742436f75c92c4.tar.gz blogs-gentoo-3c539a4713a80181af84c1fedc742436f75c92c4.tar.bz2 blogs-gentoo-3c539a4713a80181af84c1fedc742436f75c92c4.zip |
updating jetpack plugin
Diffstat (limited to 'plugins/jetpack/sync/class.jetpack-sync-module-meta.php')
-rw-r--r-- | plugins/jetpack/sync/class.jetpack-sync-module-meta.php | 67 |
1 files changed, 5 insertions, 62 deletions
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-meta.php b/plugins/jetpack/sync/class.jetpack-sync-module-meta.php index d1b07b67..917bcefa 100644 --- a/plugins/jetpack/sync/class.jetpack-sync-module-meta.php +++ b/plugins/jetpack/sync/class.jetpack-sync-module-meta.php @@ -1,7 +1,6 @@ <?php class Jetpack_Sync_Module_Meta extends Jetpack_Sync_Module { - private $meta_types = array( 'post', 'comment' ); public function name() { return 'meta'; @@ -22,7 +21,10 @@ class Jetpack_Sync_Module_Meta extends Jetpack_Sync_Module { */ public function get_objects_by_id( $object_type, $config ) { global $wpdb; - if ( ! in_array( $object_type, $this->meta_types ) ) { + + $table = _get_meta_table( $object_type ); + + if ( ! $table ) { return array(); } @@ -32,18 +34,7 @@ class Jetpack_Sync_Module_Meta extends Jetpack_Sync_Module { $meta_key = $config['meta_key']; $ids = $config['ids']; - - if ( ! $this->is_meta_key_allowed( $meta_key ) ) { - return array(); - } - - if ( 'post' == $object_type ) { - $table = $wpdb->postmeta; - $object_id_column = 'post_id'; - } else { - $table = $wpdb->commentmeta; - $object_id_column = 'comment_id'; - } + $object_id_column = $object_type.'_id'; // Sanitize so that the array only has integer values $ids_string = implode( ', ', array_map( 'intval', $ids ) ); @@ -68,52 +59,4 @@ class Jetpack_Sync_Module_Meta extends Jetpack_Sync_Module { return $meta_objects; } - - public function init_listeners( $callable ) { - foreach ( $this->meta_types as $meta_type ) { - add_action( "added_{$meta_type}_meta", $callable, 10, 4 ); - add_action( "updated_{$meta_type}_meta", $callable, 10, 4 ); - add_action( "deleted_{$meta_type}_meta", $callable, 10, 4 ); - - $whitelist_handler = array( $this, 'filter_meta_' . $meta_type ); - add_filter( "jetpack_sync_before_enqueue_added_{$meta_type}_meta", $whitelist_handler ); - add_filter( "jetpack_sync_before_enqueue_updated_{$meta_type}_meta", $whitelist_handler ); - add_filter( "jetpack_sync_before_enqueue_deleted_{$meta_type}_meta", $whitelist_handler ); - } - } - // POST Meta - function get_post_meta_whitelist() { - return Jetpack_Sync_Settings::get_setting( 'post_meta_whitelist' ); - } - - function is_whitelisted_post_meta( $meta_key ) { - // _wpas_skip_ is used by publicize - return in_array( $meta_key, $this->get_post_meta_whitelist() ) || wp_startswith( $meta_key, '_wpas_skip_' ); - } - - // Comment Meta - function get_comment_meta_whitelist() { - return Jetpack_Sync_Settings::get_setting( 'comment_meta_whitelist' ); - } - - function is_whitelisted_comment_meta( $meta_key ) { - return in_array( $meta_key, $this->get_comment_meta_whitelist() ); - } - - function is_post_type_allowed( $post_id ) { - $post = get_post( $post_id ); - return ! in_array( $post->post_type, Jetpack_Sync_Settings::get_setting( 'post_types_blacklist' ) ); - } - - function filter_meta_post( $args ) { - if ( ! $this->is_whitelisted_post_meta( $args[2] ) ) { - return false; - } - return ( $this->is_post_type_allowed( $args[1] ) ? $args : false ); - } - - function filter_meta_comment( $args ) { - return ( $this->is_whitelisted_comment_meta( $args[2] ) ? $args : false ); - } - } |