Esempio n. 1
0
 public function load_markup()
 {
     $data = json_decode(stripslashes($_POST['data']), true);
     //if (!is_numeric($data['post_id'])) die('error');
     $content = '';
     global $post;
     if (!empty($data['post_id'])) {
         if (is_numeric($data['post_id'])) {
             $post = get_post($data['post_id']);
             if (!$post) {
                 return $this->_out(new Upfront_JsonResponse_Error('Unknown post.'));
             }
         } else {
             $post = apply_filters('upfront-this_post-unknown_post', $post, $data);
             if (empty($post->ID) || $post->ID !== $data['post_id']) {
                 $this->_out(new Upfront_JsonResponse_Error('Invalid post.'));
             }
         }
     } else {
         if ($data['post_type']) {
             $post = Upfront_ThisPostView::get_new_post($data['post_type']);
         } else {
             $this->_out(new Upfront_JsonResponse_Error('Not enough data.'));
         }
     }
     Upfront_ThisPostView::prepare_post($post);
     $content = Upfront_ThisPostView::get_template_markup($post, $data['properties']);
     $this->_out(new Upfront_JsonResponse_Success(array("filtered" => $content)));
 }