function get_or_push_thumbnail($thumbnail_id, $site) { $master = new Master($this->client); $image = get_post($thumbnail_id); $mapping = get_post_meta($thumbnail_id, MAPPING_META_KEY, true); if ($mapping && isset($mapping[$site])) { $remote_id = $mapping[$site]; } else { $remote_id = $master->push($image, $site); } $this->update_attachment_metadata($site, $thumbnail_id, $remote_id); return $remote_id; }
function test_existing_term_meta_is_pushed_when_new_term_is_created_on_remote_wp() { $master = new Master(); $taxonomy = 'post_tag'; $term = wp_insert_term('test_term', $taxonomy, array('description' => 'test description')); $term_id = $term['term_id']; $meta_id = update_term_meta($term_id, "test_meta_key", "dummy"); if (is_wp_error($term)) { var_dump($term); throw new Exception("Error in wp_insert_term"); } $result = wp_set_post_terms($this->ID, array($term_id), $taxonomy); $master->push($this->post, $this->site); $mapping = get_term_meta($term_id, MAPPING_META_KEY, true); $remote_id = $mapping[$this->site]; $this->assertEquals("dummy", get_term_meta($remote_id, "test_meta_key", true)); }