Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. $response = array();
  2. $response['success'] = false;
  3.  
  4. if( ! isset( $_REQUEST['file_upload_nonce'] ) || !wp_verify_nonce( $_REQUEST['file_upload_nonce'], 'file_upload_nonce' ) ) {
  5.  
  6. }
  7.  
  8. if( ! empty( $_FILES ) ) {
  9.  
  10. foreach( $_FILES as $file ) {
  11.  
  12. if( ! empty( $_REQUEST['id'] ) ) {
  13. $settings = get_option( "awsm" . preg_replace('/[^da-z]/i', '', $_REQUEST['id']) . "_upload_settings" );
  14. $settings = json_decode( base64_decode( $settings ) );
  15. }
  16.  
  17. $defaul_settings = $this->settings;
  18.  
  19.  
  20. $bail = false;
  21. $pathinfo = pathinfo( $file['name'] );
  22.  
  23. if( empty( $pathinfo ) || ! is_array( $file ) ) {
  24. $bail = true;
  25. }
  26.  
  27.  
  28. $bail = apply_filters( "awsm_bail_upload", $bail, $file, $settings );
  29.  
  30. if( ! $bail ) {
  31. $media = $this->awsm_process_file( $file );
  32. $response['success'] = false !== $media;
  33. $response['media_uri'] = $media;
  34. } else {
  35. $response['success'] = false;
  36. }
  37.  
  38. $response["settings"] = $settings;
  39. $response["file"] = $file;
  40.  
  41.  
  42. $new_data = array(
  43.  
  44. 'post_parent' => 60,
  45. 'post_title' => 'Applications',
  46. 'post_status' => 'publish',
  47. 'post_type' => 'awsm_job_application'
  48. );
  49. $application = wp_insert_post( $new_data );
  50.  
  51.  
  52.  
  53. }
  54. }
  55. echo json_encode( $response );
  56. exit;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement