get_results($wpdb->prepare( "SELECT ID, post_date_gmt FROM {$wpdb->posts} WHERE ID IN ({$ph})", $chunk ), ARRAY_A); foreach ((array) $rows as $r) { $id = (int) $r['ID']; $ts = strtotime((string) $r['post_date_gmt'] . ' UTC'); $memo[$id] = ($ts && $ts > 0) ? $ts : null; if (null !== $memo[$id]) { $out[$id] = $memo[$id]; } } } foreach ($ask as $id) { if (!array_key_exists($id, $memo)) { $memo[$id] = null; } } return $out; } public static function partition($source_type, $source_id, array $targets) { $inside = array(); $outside = array(); if (!self::applies_to($source_type)) { foreach ($targets as $t) { $inside[] = (int) $t[0]; } return array('inside' => $inside, 'outside' => $outside); } $evergreen = self::evergreen_types(); $ids = array((int) $source_id); foreach ($targets as $t) { $ids[] = (int) $t[0]; } $dates = self::dates($ids); $anchor = isset($dates[(int) $source_id]) ? $dates[(int) $source_id] : 0; $span = self::months() * 30.44 * DAY_IN_SECONDS; foreach ($targets as $t) { $tid = (int) $t[0]; $type = isset($t[1]) ? (string) $t[1] : ''; if (in_array($type, $evergreen, true) || $anchor <= 0 || empty($dates[$tid])) { $inside[] = $tid; continue; } if (abs($dates[$tid] - $anchor) <= $span) { $inside[] = $tid; } else { $outside[] = $tid; } } return array('inside' => $inside, 'outside' => $outside); } }