PHP Class Inpsyde\MultilingualPress\API\WPDBContentRelations

Since: 3.0.0
Inheritance: implements Inpsyde\MultilingualPress\API\ContentRelations
Show file Open project: inpsyde/multilingual-press

Public Methods

Method Description
__construct ( Inpsyde\MultilingualPress\Database\Table $table, Inpsyde\MultilingualPress\API\SiteRelations $site_relations ) Constructor. Sets up the properties.
delete_relation ( integer $source_site_id, integer $target_site_id, integer $source_content_id, integer $target_content_id, string $type = 'post' ) : integer Delete a relation according to the given parameters.
duplicate_relations ( integer $source_site_id, integer $destination_site_id, string $type = '' ) : integer Copies all relations of the given (or any) content type from the given source site to the given destination site.
get_element_for_site ( integer $source_site_id, integer $target_site_id, integer $source_content_id, string $type ) : integer Return the term taxonomy ID of the given target site for the given source term.
get_existing_translation_ids ( integer $source_site_id, integer $target_site_id, integer $source_content_id, integer $target_content_id, string $type ) : array Return the existing translation IDs according to the given parameters.
get_relations ( integer $source_site_id, integer $source_content_id, string $type = 'post' ) : array Return an array with site IDs as keys and content IDs as values.
get_translation_ids ( integer $source_site_id, integer $target_site_id, integer $source_content_id, integer $target_content_id, string $type ) : array Return the existing (or new) translation IDs according to the given parameters.
has_site_relations ( integer $site_id, string $type = '' ) : boolean Checks if the site with the given ID has any relations of the given (or any) content type.
relate_all_posts ( integer $source_site_id, integer $destination_site_id ) : integer Relates all posts between the given source site and the given destination site.
relate_all_terms ( integer $source_site_id, integer $destination_site_id ) : integer Relates all terms between the given source site and the given destination site.
set_relation ( integer $source_site_id, integer $target_site_id, integer $source_content_id, integer $target_content_id, string $type = 'post' ) : boolean Set a relation according to the given parameters.

Private Methods

Method Description
clean_up_duplicated_translation_ids ( array $relations, string $type ) : integer Delete duplicate database entries.
get_cache_key ( integer $source_site_id, integer $source_content_id, string $type ) : string Return the cache key for the given arguments.
get_new_translation_ids ( integer $source_site_id, integer $source_content_id, string $type ) : array Return new translation IDs for the given parameters.
insert_row ( integer $source_site_id, integer $target_site_id, integer $source_content_id, integer $target_content_id, string $type ) : integer Insert a row into the link table.

Method Details

__construct() public method

Constructor. Sets up the properties.
Since: 3.0.0
public __construct ( Inpsyde\MultilingualPress\Database\Table $table, Inpsyde\MultilingualPress\API\SiteRelations $site_relations )
$table Inpsyde\MultilingualPress\Database\Table Content relations table object.
$site_relations Inpsyde\MultilingualPress\API\SiteRelations Site relations API object.

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

duplicate_relations() public method

This method is suited to be used after site duplication, because both sites are assumed to have the exact same content IDs.
Since: 3.0.0
public duplicate_relations ( integer $source_site_id, integer $destination_site_id, string $type = '' ) : integer
$source_site_id integer Source site ID.
$destination_site_id integer Destination site ID.
$type string Optional. Content type. Defaults to empty string.
return integer The number of relations duplicated.

get_element_for_site() public method

Return the term taxonomy ID of the given target site for the given source term.
public get_element_for_site ( integer $source_site_id, integer $target_site_id, integer $source_content_id, string $type ) : 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.
$type string Content type.
return integer

get_existing_translation_ids() public method

Return the existing translation IDs according to the given parameters.
public get_existing_translation_ids ( integer $source_site_id, integer $target_site_id, integer $source_content_id, integer $target_content_id, string $type ) : array
$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 array

get_relations() public method

Return an array with site IDs as keys and content IDs as values.
public get_relations ( integer $source_site_id, integer $source_content_id, string $type = 'post' ) : array
$source_site_id integer Source blog ID.
$source_content_id integer Source post ID or term taxonomy ID.
$type string Content type.
return array

get_translation_ids() public method

Return the existing (or new) translation IDs according to the given parameters.
public get_translation_ids ( integer $source_site_id, integer $target_site_id, integer $source_content_id, integer $target_content_id, string $type ) : array
$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 array

has_site_relations() public method

Checks if the site with the given ID has any relations of the given (or any) content type.
Since: 3.0.0
public has_site_relations ( integer $site_id, string $type = '' ) : boolean
$site_id integer Site ID.
$type string Optional. Content type. Defaults to empty string.
return boolean Whether or not the site with the given ID has any relations of the given (or any) content type.

relate_all_posts() public method

This method is suited to be used after site duplication, because both sites are assumed to have the exact same post IDs. Furthermore, the current site is assumed to be either the source site or the destination site.
Since: 3.0.0
public relate_all_posts ( integer $source_site_id, integer $destination_site_id ) : integer
$source_site_id integer Source site ID.
$destination_site_id integer Destination site ID.
return integer The number of relations inserted.

relate_all_terms() public method

This method is suited to be used after site duplication, because both sites are assumed to have the exact same term taxonomy IDs. Furthermore, the current site is assumed to be either the source site or the destination site.
Since: 3.0.0
public relate_all_terms ( integer $source_site_id, integer $destination_site_id ) : integer
$source_site_id integer Source site ID.
$destination_site_id integer Destination site ID.
return integer The number of relations inserted.

set_relation() public method

Set a relation according to the given parameters.
public set_relation ( integer $source_site_id, integer $target_site_id, integer $source_content_id, integer $target_content_id, string $type = 'post' ) : boolean
$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 boolean