WordPress.org

Plugin Directory

Changeset 275219 for posts-to-posts


Ignore:
Timestamp:
08/13/10 10:29:17 (4 years ago)
Author:
scribu
Message:

allow = 'both' in p2p_get_connected()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • posts-to-posts/trunk/api.php

    r271766 r275219  
    104104 * 
    105105 * @param int $post_id One end of the connection 
    106  * @param string $direction The direction of the connection. Can be 'to' or 'from' 
     106 * @param string $direction The direction of the connection. Can be 'to', 'from' or 'both' 
    107107 * @param string|array $post_type The post type of the connected posts. 
    108108 * @param string $output Can be 'ids' or 'objects' 
     
    112112 */ 
    113113function p2p_get_connected( $post_id, $direction = 'to', $post_type = 'any', $output = 'ids' ) { 
    114     $ids = Posts2Posts::get_connected( $post_id, $direction ); 
     114    if ( 'both' == $direction ) { 
     115        $to = Posts2Posts::get_connected( $post_id, 'to' ); 
     116        $from = Posts2Posts::get_connected( $post_id, 'from' ); 
     117        $ids = array_merge( $to, array_diff( $from, $to ) ); 
     118    } else { 
     119        $ids = Posts2Posts::get_connected( $post_id, $direction ); 
     120    } 
    115121 
    116122    if ( empty( $ids ) ) 
Note: See TracChangeset for help on using the changeset viewer.