Ejemplo n.º 1
0
 /**
  * AJAX handler for rows
  * @return string JSON response
  */
 public static function ajaxHandler()
 {
     if (!isset($_POST['post'])) {
         wp_send_json_error('Data not set');
     }
     $post = json_decode(stripslashes($_POST['post']), true);
     if (!isset($post['post_id'])) {
         wp_send_json_error('Data not set');
     }
     $data = new Cornerstone_Data_Controller($post['post_id']);
     if (!$data->isValid()) {
         wp_send_json_error('Post not valid');
     }
     $update = $data->update($post);
     if (is_wp_error($update)) {
         wp_send_json_error($update->get_error_message());
     }
     // Suppress PHP error output unless debugging
     if (CS()->common()->isDebug()) {
         return wp_send_json_success($update);
     }
     return @wp_send_json_success($update);
 }
Ejemplo n.º 2
0
 public function rows()
 {
     Cornerstone_Data_Controller::ajaxHandler();
 }
Ejemplo n.º 3
0
 /**
  * Pull the meta data for this post and prepare it for javascript
  * @return array
  */
 public function getPostData()
 {
     return array('post_id' => get_the_id(), 'elements' => Cornerstone_Data_Controller::getPostRows());
 }