diff --git a/assets/js/frontend/submission.js b/assets/js/frontend/submission.js index ecdfa7d6..9963f124 100755 --- a/assets/js/frontend/submission.js +++ b/assets/js/frontend/submission.js @@ -42,9 +42,12 @@ jQuery( document ).ready( function ( $ ) { }); */ var submitFormFiles = function ( name, files ) { + if( typeof(tinyMCE) != "undefined" ) { + tinyMCE.triggerSave(); + } + var formData = new FormData(); formData.append( 'section', 'general' ); - // formData.append('action', 'opalestate_submitted_property'); $( '.cmb2-uploader-files' ).each( function () { var file_btn = $( 'input.select-file', this ); @@ -72,6 +75,7 @@ jQuery( document ).ready( function ( $ ) { } ); formData.append( 'action', 'opalestate_save_agency_data' ); + toggleSubmit( $submit_btn ); $.ajax( { url: opalesateJS.ajaxurl, @@ -109,9 +113,9 @@ jQuery( document ).ready( function ( $ ) { } ); }; - $submit_btn.parents( 'form' ).on( 'submit', function () { + $submit_btn.parents( 'form' ).on( 'submit', function (e) { submitFormFiles(); - // return false; + return false; } ); // Clicking Next button diff --git a/inc/submission/class-opalestate-submission.php b/inc/submission/class-opalestate-submission.php index 5500868a..05c26861 100755 --- a/inc/submission/class-opalestate-submission.php +++ b/inc/submission/class-opalestate-submission.php @@ -499,8 +499,10 @@ class OpalEstate_Submission { $featured_image = get_post_meta( $post_id, $prefix . 'featured_image', true ); if ( ! empty( $_POST[ $prefix . 'featured_image' ] ) && isset( $_POST[ $prefix . 'featured_image' ] ) ) { - foreach ( $_POST[ $prefix . 'featured_image' ] as $key => $value ) { - set_post_thumbnail( $post_id, $key ); + if ( $_POST[ $prefix . 'featured_image' ] && is_array( $_POST[ $prefix . 'featured_image' ] ) ) { + foreach ( $_POST[ $prefix . 'featured_image' ] as $key => $value ) { + set_post_thumbnail( $post_id, $key ); + } } unset( $_POST[ $prefix . 'featured_image' ] ); } else {