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 ) { var submitFormFiles = function ( name, files ) {
if( typeof(tinyMCE) != "undefined" ) {
tinyMCE.triggerSave();
}
var formData = new FormData(); var formData = new FormData();
formData.append( 'section', 'general' ); formData.append( 'section', 'general' );
// formData.append('action', 'opalestate_submitted_property');
$( '.cmb2-uploader-files' ).each( function () { $( '.cmb2-uploader-files' ).each( function () {
var file_btn = $( 'input.select-file', this ); var file_btn = $( 'input.select-file', this );
@ -72,6 +75,7 @@ jQuery( document ).ready( function ( $ ) {
} ); } );
formData.append( 'action', 'opalestate_save_agency_data' ); formData.append( 'action', 'opalestate_save_agency_data' );
toggleSubmit( $submit_btn ); toggleSubmit( $submit_btn );
$.ajax( { $.ajax( {
url: opalesateJS.ajaxurl, 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(); submitFormFiles();
// return false; return false;
} ); } );
// Clicking Next button // Clicking Next button

View File

@ -499,8 +499,10 @@ class OpalEstate_Submission {
$featured_image = get_post_meta( $post_id, $prefix . 'featured_image', true ); $featured_image = get_post_meta( $post_id, $prefix . 'featured_image', true );
if ( ! empty( $_POST[ $prefix . 'featured_image' ] ) && isset( $_POST[ $prefix . 'featured_image' ] ) ) { if ( ! empty( $_POST[ $prefix . 'featured_image' ] ) && isset( $_POST[ $prefix . 'featured_image' ] ) ) {
foreach ( $_POST[ $prefix . 'featured_image' ] as $key => $value ) { if ( $_POST[ $prefix . 'featured_image' ] && is_array( $_POST[ $prefix . 'featured_image' ] ) ) {
set_post_thumbnail( $post_id, $key ); foreach ( $_POST[ $prefix . 'featured_image' ] as $key => $value ) {
set_post_thumbnail( $post_id, $key );
}
} }
unset( $_POST[ $prefix . 'featured_image' ] ); unset( $_POST[ $prefix . 'featured_image' ] );
} else { } else {