1 | <?php |
||
6 | abstract class Jetpack_Sync_Module { |
||
7 | const ARRAY_CHUNK_SIZE = 10; |
||
8 | |||
9 | abstract public function name(); |
||
10 | |||
11 | // override these to set up listeners and set/reset data/defaults |
||
12 | public function init_listeners( $callable ) { |
||
14 | |||
15 | public function init_full_sync_listeners( $callable ) { |
||
17 | |||
18 | public function init_before_send() { |
||
20 | |||
21 | public function set_defaults() { |
||
23 | |||
24 | public function reset_data() { |
||
26 | |||
27 | public function enqueue_full_sync_actions( $config ) { |
||
31 | |||
32 | public function estimate_full_sync_actions( $config ) { |
||
36 | |||
37 | public function get_full_sync_actions() { |
||
40 | |||
41 | protected function count_actions( $action_names, $actions_to_count ) { |
||
44 | |||
45 | protected function get_check_sum( $values ) { |
||
48 | |||
49 | protected function still_valid_checksum( $sums_to_check, $name, $new_sum ) { |
||
56 | |||
57 | protected function enqueue_all_ids_as_action( $action_name, $table_name, $id_field, $where_sql ) { |
||
90 | |||
91 | protected function get_metadata( $ids, $meta_type ) { |
||
92 | global $wpdb; |
||
93 | $table = _get_meta_table( $meta_type ); |
||
94 | $id = $meta_type . '_id'; |
||
95 | if ( ! $table ) { |
||
96 | return array(); |
||
97 | } |
||
98 | |||
99 | return array_map( |
||
100 | array( $this, 'unserialize_meta' ), |
||
101 | $wpdb->get_results( "SELECT $id, meta_key, meta_value, meta_id FROM $table WHERE $id IN ( " . implode( ',', wp_parse_id_list( $ids ) ) . ' )', OBJECT ) |
||
102 | ); |
||
103 | } |
||
104 | |||
105 | protected function get_term_relationships( $ids ) { |
||
106 | global $wpdb; |
||
107 | |||
108 | return $wpdb->get_results( "SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id IN ( " . implode( ',', wp_parse_id_list( $ids ) ) . ' )', OBJECT ); |
||
109 | } |
||
110 | |||
111 | public function unserialize_meta( $meta ) { |
||
115 | } |
||
116 |