Fix Description submission.

This commit is contained in:
Hoang Huu 2019-12-06 14:10:12 +07:00
parent 26a14d2998
commit 9c9670155a
2 changed files with 11 additions and 5 deletions

View File

@ -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

View File

@ -499,9 +499,11 @@ 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' ] ) ) {
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 {
delete_post_thumbnail( $post_id );