function test_storage() { $post_id = $this->generate_post('post'); $actor_id = $this->generate_post('actor'); p2p_type('normal')->connect($post_id, $actor_id); p2p_type('normal')->connect($actor_id, $post_id, array('foo' => 'bar')); wp_delete_post($post_id, true); $this->assertEmpty(p2p_get_connections('normal', array('from' => $post_id, 'fields' => 'p2p_id'))); $this->assertEmpty(p2p_get_connections('normal', array('to' => $post_id, 'fields' => 'p2p_id'))); }
function mini_archive_post2post_objects($objects, $query) { extract($query); if ($type == 'post2post' && isset($direction)) { $connected = p2p_get_connections($term, array('fields' => 'p2p_' . $direction)); $added_ids = array(); foreach ($connected as $post_id) { if (!in_array($post_id, $added_ids)) { $added_ids[] = $post_id; $post = get_post($post_id); $objects[] = (object) array('slug' => $post->ID, 'name' => $post->post_title); } } } return $objects; }
/** * Delete one or more connections. * * @param int $p2p_type A valid connection type. * @param array $args Connection information. * * @return int Number of connections deleted */ function p2p_delete_connections($p2p_type, $args = array()) { $args['fields'] = 'p2p_id'; return p2p_delete_connection(p2p_get_connections($p2p_type, $args)); }
public function get_p2p_id($from, $to) { $ids = p2p_get_connections($this->name, array('direction' => $this->direction, 'from' => $from, 'to' => $to, 'fields' => 'p2p_id')); if (!empty($ids)) { return reset($ids); } return false; }
protected function is_fave($item_id) { $count = p2p_get_connections(APP_FAVORITES_CONNECTION, array('direction' => 'from', 'from' => $item_id, 'to' => get_current_user_id(), 'fields' => 'count')); return (bool) $count; }