Skip to content

Commit

Permalink
adding original object list to o2o_set_connected_to hook
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jul 12, 2014
1 parent b66441b commit 1c474e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Contributors: prettyboymp, klangley, csloisel, markparolisi, jeffstieler
Tags: relationships, mapping, connections, many-to-many
Requires at least: 3.6
Tested up to: 3.8
Stable tag: 1.2.2
Stable tag: 1.2.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down
2 changes: 1 addition & 1 deletion objects-to-objects.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Objects to Objects
Version: 1.2.2
Version: 1.2.3
Plugin URI: http://voceplatforms.com
Description: A WordPress plugin/module that provides the ability to map relationships between posts and other post types.
Author: Voce Platforms
Expand Down
7 changes: 5 additions & 2 deletions src/connection-types/taxonomy/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,19 @@ public function set_connected_to( $from_object_id, $connected_to_ids = array( ),
return ( bool ) $term_id;
} );

$current_term_ids = $this->get_connected_terms( $from_object_id );
if ( $append && $this->is_sortable( 'to' ) ) {
$current_term_ids = $this->get_connected_terms( $from_object_id );
$term_ids = array_unique( array_merge( $current_term_ids, $term_ids ), SORT_NUMERIC );
$append = false; //core's append doesn't handle sort
}

$result = wp_set_object_terms( $from_object_id, $term_ids, $this->taxonomy, $append );

wp_cache_delete( $from_object_id, $this->taxonomy . '_relationships_ordered' );
do_action( 'o2o_set_connected_to', $from_object_id, $connected_to_ids, $this->name, $append );
if ( has_action( 'o2o_set_connected_to' ) ) {
$original_object_ids = array_map( array( $this, 'get_object_termID' ), $current_term_ids );
do_action( 'o2o_set_connected_to', $from_object_id, $connected_to_ids, $this->name, $append, $original_object_ids );
}
return is_wp_error( $result ) ? $result : true;
}

Expand Down

0 comments on commit 1c474e9

Please sign in to comment.