/**
  * Process data when submit form add/edit view
  *
  * @return void
  */
 static function view_submit()
 {
     if (empty($_POST)) {
         return;
     }
     PT_CV_Functions::_nonce_check('form_nonce', 'view_submit');
     /**
      * INSERT VIEW
      */
     // View title
     $title = esc_sql($_POST[PT_CV_PREFIX . 'view-title']);
     // Current post id ( 0 if new view )
     $cur_post_id = esc_sql($_POST[PT_CV_PREFIX . 'post-id']);
     // Insert post
     if (!$cur_post_id) {
         $post_id = PT_CV_Functions::post_insert(array('ID' => $cur_post_id, 'title' => $title));
     } else {
         $post_id = $cur_post_id;
     }
     /**
      * ADD/UPDATE CUSTOM FIELDS
      */
     // Get current view id, = 0 if it is new view
     $cur_view_id = esc_sql($_POST[PT_CV_PREFIX . 'view-id']);
     $view_id = empty($cur_view_id) ? PT_CV_Functions::string_random() : $cur_view_id;
     update_post_meta($post_id, PT_CV_META_ID, $view_id);
     update_post_meta($post_id, PT_CV_META_SETTINGS, (array) $_POST);
     // Update post title
     if (strpos($title, '[ID:') === false) {
         PT_CV_Functions::post_insert(array('ID' => $post_id, 'title' => sprintf('%s [ID: %s]', $title, $view_id)));
     }
     /**
      * redirect to edit page
      */
     $edit_link = PT_CV_Functions::view_link($view_id);
     wp_redirect($edit_link);
     exit;
 }
 /**
  * Filter link of Title in All Views page
  */
 public function filter_get_edit_post_link($edit_link, $post_id, $context)
 {
     // Get current post type
     $post_type = PT_CV_Functions::admin_current_post_type();
     if ($post_type != PT_CV_POST_TYPE) {
         return $edit_link;
     }
     // Get View id
     $view_id = get_post_meta($post_id, PT_CV_META_ID, true);
     $edit_link = PT_CV_Functions::view_link($view_id);
     return $edit_link;
 }