/**
  * Retrieve ranking
  *
  * Overrides the $type to set to 'post', then passes through to the post
  * endpoints.
  *
  * @see WP_JSON_Posts::get_posts()
  */
 public function get_ranking($filter = array(), $context = 'view')
 {
     $ids = sga_ranking_get_date($filter);
     $posts_list = array();
     foreach ($ids as $id) {
         $posts_list[] = get_post($id);
     }
     $response = new WP_JSON_Response();
     if (!$posts_list) {
         $response->set_data(array());
         return $response;
     }
     // holds all the posts data
     $struct = array();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT');
     foreach ($posts_list as $post) {
         $post = get_object_vars($post);
         // Do we have permission to read this post?
         if (!$this->check_read_permission($post)) {
             continue;
         }
         $response->link_header('item', json_url('/posts/' . $post['ID']), array('title' => $post['post_title']));
         $post_data = $this->prepare_post($post, $context);
         if (is_wp_error($post_data)) {
             continue;
         }
         $struct[] = $post_data;
     }
     $response->set_data($struct);
     return $response;
 }
function sga_ranking_shortcode($atts)
{
    $ids = sga_ranking_get_date($atts);
    if (empty($ids)) {
        return;
    }
    $cnt = 1;
    $output = '<ol class="sga-ranking">';
    foreach ($ids as $id) {
        $output .= '<li class="sga-ranking-list sga-ranking-list-' . $cnt . '">' . apply_filters('sga_ranking_before_title', '', $id, $cnt) . '<a href="' . get_permalink($id) . '" title="' . get_the_title($id) . '">' . get_the_title($id) . '</a>' . apply_filters('sga_ranking_after_title', '', $id, $cnt) . '</li>';
        $cnt++;
    }
    $output .= '</ol>';
    return $output;
}