Inpsyde\MultilingualPress\API\WPDBContentRelations::delete_relation PHP Method

delete_relation() public method

Delete a relation according to the given parameters.
public delete_relation ( integer $source_site_id, integer $target_site_id, integer $source_content_id, integer $target_content_id, string $type = 'post' ) : integer
$source_site_id integer Source blog ID.
$target_site_id integer Target blog ID.
$source_content_id integer Source post ID or term taxonomy ID.
$target_content_id integer Target post ID or term taxonomy ID.
$type string Content type.
return integer Number of deleted rows
    public function delete_relation($source_site_id, $target_site_id, $source_content_id, $target_content_id = 0, $type = 'post')
    {
        $where = ['ml_source_blogid' => $source_site_id, 'ml_source_elementid' => $source_content_id, 'ml_type' => $type];
        $where_format = ['%d', '%d', '%s'];
        if (0 < $target_site_id) {
            $where['ml_blogid'] = $target_site_id;
            $where_format[] = '%d';
        }
        if (0 < $target_content_id) {
            $where['ml_elementid'] = $target_content_id;
            $where_format[] = '%d';
        }
        $result = (int) $this->db->delete($this->table, $where, $where_format);
        $cache_key = $this->get_cache_key($source_site_id, $source_content_id, $type);
        wp_cache_delete($cache_key, $this->cache_group);
        \Inpsyde\MultilingualPress\debug(current_filter() . '/' . __METHOD__ . '/' . __LINE__ . " - {$this->db->last_query}");
        return $result;
    }