Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions includes/Relationships/PostToPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct( $from, $to, $name, $args = array() ) {
$this->from = $from;
$this->to = $to;
$this->id = strtolower( get_class( $this ) ) . "-{$name}-{$from}-" . implode( '.', $to );

parent::__construct( $name, $args );
}

Expand Down Expand Up @@ -234,7 +234,7 @@ public function save_sort_data( $object_id, $ordered_ids ) {
'order' => $order
);
}

$fields = array(
'id1' => '%d',
'id2' => '%d',
Expand All @@ -245,6 +245,17 @@ public function save_sort_data( $object_id, $ordered_ids ) {
/** @var \TenUp\ContentConnect\Tables\PostToPost $table */
$table = Plugin::instance()->get_table( 'p2p' );
$table->replace_bulk( $fields, $data );

/**
* Fires after a relationship order has been updated
* @since 1.7.0
*
* @param int $object_id ID of the post we're ordering on.
* @param int[] $ordered_ids IDs of the posts being ordered
* @param string $name relationship name
* @param string $type relationship type (post-to-post|post-to-user|user-to-post)
*/
do_action( 'tenup-content-connect-update-relationships-order', $object_id, $ordered_ids, $this->name, 'post-to-post' );
}

}
10 changes: 10 additions & 0 deletions includes/Relationships/PostToUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ public function save_post_to_user_sort_data( $object_id, $ordered_user_ids ) {
/** @var \TenUp\ContentConnect\Tables\PostToUser $table */
$table = Plugin::instance()->get_table( 'p2u' );
$table->replace_bulk( $fields, $data );

/**
* This action is documented in PostToPost.php
*/
do_action( 'tenup-content-connect-update-relationships-order', $object_id, $ordered_ids, $this->name, 'post-to-user' );
}

/**
Expand Down Expand Up @@ -266,6 +271,11 @@ public function save_user_to_post_sort_data( $user_id, $ordered_post_ids ) {
/** @var \TenUp\ContentConnect\Tables\PostToUser $table */
$table = Plugin::instance()->get_table( 'p2u' );
$table->replace_bulk( $fields, $data );

/**
* This action is documented in PostToPost.php
*/
do_action( 'tenup-content-connect-update-relationships-order', $user_id, $ordered_post_ids, $this->name, 'user-to-post' );
}

}