Skip to content

Commit

Permalink
Title validation added to quick edit (page & redirect)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylephillips committed Nov 8, 2014
1 parent 0a2a7c5 commit 54a3c71
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions includes/class-np-repository-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function updateOrder($posts, $parent = 0)
*/
public function updatePost($data)
{
$this->validation->checkEmpty($data['post_title'], __('Title', 'nestedpages'));
$date = $this->validation->validateDate($data);
if ( !isset($_POST['comment_status']) ) $data['comment_status'] = 'closed';

Expand Down Expand Up @@ -252,6 +253,7 @@ private function updateLinkTarget($data)
*/
public function updateRedirect($data)
{
$this->validation->checkEmpty($data['post_title'], __('Label', 'nestedpages'));
$updated_post = array(
'ID' => sanitize_text_field($data['post_id']),
'post_title' => sanitize_text_field($data['post_title']),
Expand Down
13 changes: 13 additions & 0 deletions includes/class-np-validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,17 @@ public function validateRedirect($data)
}


/**
* Validate a string isn't empty
*/
public function checkEmpty($var, $title)
{
if ( $var == "" ){
$message = __('Please provide a ', 'nestedpages') . $title;
return wp_send_json(array('status' => 'error', 'message' => $message));
die();
}
}


}

0 comments on commit 54a3c71

Please sign in to comment.