Function Reference: gdlist_create_connection_for_each_post
Summary
This function has not been documented yet.
Source File
gdlist_create_connection_for_each_post() is located in geodir_list_manager/geodir_list_manager.php [Line: 583]
Source Code
function gdlist_create_connection_for_each_post($cur_post_id, $post_ids) {
$listed_posts = gdlist_get_all_listed_posts($cur_post_id);
$listed_post_ids = array();
foreach($listed_posts as $key => $title) {
$listed_post_ids[] = (string) $key;
}
$removed_ids = array_diff($listed_post_ids, $post_ids);
$added_ids = array_diff($post_ids, $listed_post_ids);
if ( current_user_can('edit_post', $cur_post_id) ) {
foreach($added_ids as $pid) {
$con_type = get_post_type( $pid ).'_to_gd_list';
$args = array(
'from' => $pid,
'to' => $cur_post_id
);
//$exists = p2p_connection_exists($con_type, $args);
//if(!$exists) {
p2p_create_connection($con_type, $args);
//}
}
foreach($removed_ids as $pid) {
$con_type = get_post_type( $pid ).'_to_gd_list';
$args = array(
'from' => $pid,
'to' => $cur_post_id
);
//$exists = p2p_connection_exists($con_type, $args);
//if($exists) {
p2p_delete_connections($con_type, $args);
//}
}
}
}