public function get_dados($postID = false, $tipo_data = false) { $pautas = ''; $comments = ''; if ($postID === false) { $pautas = delibera_get_pautas_em(); $comments = delibera_wp_get_comments(); } else { $pautas = array(get_post($postID)); $comments = delibera_wp_get_comments(array('post_id' => $postID)); } $events = array(); foreach ($pautas as $pauta) { $data = strtotime($pauta->post_date_gmt); if (!array_key_exists($data, $events)) { $events[$data] = array(); } $events[$data][] = array('type' => 'pauta', 'title' => get_the_title($postID), 'body' => apply_filters('the_content', $pauta->post_content), 'date_event' => $data); } foreach ($comments as $comment) { $data = strtotime($comment->comment_date_gmt); if (!array_key_exists($data, $events)) { $events[$data] = array(); } $events[$data][] = array('type' => 'comment-' . get_comment_meta($comment->comment_ID, "delibera_comment_tipo", true), 'title' => "@" . $comment->comment_author, 'body' => apply_filters('comment_text', get_comment_text($comment->comment_ID)), 'date_event' => $data); } ksort($events, SORT_NUMERIC); return $this->filtrar($events, $tipo_data); }
/** * * Pega os ultimos conteúdos * @param string $tipo (option) 'pauta' ou 'comments', padrão 'pauta' * @param array $args (option) query padrão do post ou do comments * @param int $count (option) padrão 5 */ function delibera_ultimas($tipo = 'pauta', $args = array(), $count = 5) { switch ($tipo) { case 'pauta': $filtro = array('orderby' => 'modified', 'order' => 'DESC', 'posts_per_page' => $count); $filtro = array_merge($filtro, $args); return delibera_get_pautas_em($filtro, false); break; case 'comments': $filtro = array('orderby' => 'comment_date_gmt', 'order' => 'DESC', 'number' => $count, 'post_type' => 'pauta'); $filtro = array_merge($filtro, $args); return delibera_wp_get_comments($filtro); break; } }