Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1.  
  2. function fundcode_association_save_meta_box( $post_id ) {
  3. $err = false;
  4. $message = '';
  5. $type = 'error';
  6.  
  7. // Check if our nonce is set.
  8. if ( ! isset( $_POST['fundcode_post_class_nonce'] ) ) {
  9. return;
  10. }
  11.  
  12. // Verify that the nonce is valid.
  13. if ( ! wp_verify_nonce( $_POST['fundcode_post_class_nonce'], basename( __FILE__ ) ) ) {
  14. return;
  15. }
  16.  
  17. // If this is an autosave, our form has not been submitted, so we don't want to do anything.
  18. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
  19. return;
  20. }
  21.  
  22. // Save occasion
  23. if ( isset( $_POST['fundcode-occasion'] ) )
  24. {
  25. if(!empty($_POST['fundcode-occasion']))
  26. {
  27. $my_data = sanitize_text_field( $_POST['fundcode-occasion'] );
  28. update_post_meta( $post_id, 'fundcode_occasion', $my_data );
  29. }
  30. else
  31. {
  32. $err = true;
  33. $message .= "Occasion can't be empty.<br />";
  34. update_post_meta( $post_id, 'fundcode_occasion', '' );
  35. }
  36. }
  37.  
  38. // Save association
  39. if ( isset( $_POST['fundcode-association'] ) ) {
  40. if(!empty($_POST['fundcode-association']))
  41. {
  42. $my_data = sanitize_text_field( $_POST['fundcode-association'] );
  43. update_post_meta( $post_id, 'fundcode_association', $my_data );
  44. }
  45. else
  46. {
  47. $err = true;
  48. $message .= "Association can't be empty.<br />";
  49. update_post_meta( $post_id, 'fundcode_association', '' );
  50. }
  51. }
  52.  
  53. if($err)
  54. {
  55. EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ) ;
  56. }
  57. }
  58. add_action( 'save_post', 'fundcode_association_save_meta_box', 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement