diff --git a/inc/class-opalestate-install.php b/inc/class-opalestate-install.php index 0090625b..19768a24 100755 --- a/inc/class-opalestate-install.php +++ b/inc/class-opalestate-install.php @@ -93,8 +93,6 @@ class Opalestate_Install { $options['currency_position'] = 'before'; $options['measurement_unit'] = 'sqft'; $options['google_map_api_keys'] = 'AIzaSyCfMVNIa7khIqYHCw6VBn8ShUWWm4tjbG8'; - $options['admin_approve'] = 'on'; - $options['require_input_price'] = 'on'; $options['from_name'] = get_bloginfo( 'name' ); $options['from_email'] = get_bloginfo( 'admin_email' ); $options['message_log'] = 1; @@ -129,6 +127,7 @@ class Opalestate_Install { $options['enable_agency_reviews'] = 'on'; $options['enable_agent_reviews'] = 'on'; + $options['admin_approve'] = 'on'; $options['enable_submission_tab_media'] = 'on'; $options['enable_submission_tab_location'] = 'on'; $options['enable_submission_tab_amenities'] = 'on'; diff --git a/inc/property/class-metabox-property-admin.php b/inc/property/class-metabox-property-admin.php index a791201e..1b38fa0a 100755 --- a/inc/property/class-metabox-property-admin.php +++ b/inc/property/class-metabox-property-admin.php @@ -240,7 +240,7 @@ class Opalestate_Property_MetaBox { 'name' => esc_html__( 'Regular Price', 'opalestate-pro' ) . $currency, 'type' => 'text', 'description' => esc_html__( 'Enter amount without currency', 'opalestate-pro' ), - 'attributes' => opalestate_get_option( 'require_input_price' ) ? [ 'required' => 'required' ] : '', + 'attributes' => [ 'required' => 'required' ], 'before_row' => '
' ) : '';
-
- $data = [
+ $data = [
'post_title' => sanitize_text_field( $_POST[ $prefix . 'title' ] ),
'post_author' => $user_id,
'post_status' => $post_status,
@@ -457,14 +469,14 @@ class OpalEstate_Submission {
if ( empty( $data['post_title'] ) || empty( $data['post_author'] ) ) {
return opalestate_output_msg_json( false,
- __( 'Please enter data for all require fields before submitting', 'opalestate-pro' ),
- array(
- 'heading' => esc_html__('Submission Information' ,'opalestate-pro')
- )) ;
+ __( 'Please enter data for all require fields before submitting', 'opalestate-pro' ),
+ [
+ 'heading' => esc_html__( 'Submission Information', 'opalestate-pro' ),
+ ] );
}
-
+
$post_id = wp_insert_post( $data, true );
-
+
if ( ! empty( $post_id ) && ! empty( $_POST['object_id'] ) ) {
$_POST['object_id'] = (int) $post_id;
@@ -478,68 +490,73 @@ class OpalEstate_Submission {
/**
* Fetch sanitized values
*/
- cmb2_get_metabox_form( $metaboxes[ $prefix. 'front' ], $post_id );
+ cmb2_get_metabox_form( $metaboxes[ $prefix . 'front' ], $post_id );
$cmb = $this->cmb2_get_metabox();
$sanitized_values = $cmb->get_sanitized_values( $_POST );
$cmb->save_fields( $post_id, 'post', $sanitized_values );
// Create featured image
$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 );
- }
- unset( $_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 );
}
- // remove meta field;
+ // Remove meta field.
update_post_meta( $post_id, $prefix . 'featured_image', null );
+
+ // Update SKU.
+ if ( 'on' == opalestate_get_option( 'enable_submission_generate_sku', 'off' ) ) {
+ $sku_generated = apply_filters( 'opalestate_submission_sku_generated', sanitize_text_field( opalestate_options( 'submission_sku_prefix', 'SKU' ) . $post_id ) );
+ update_post_meta( $post_id, $prefix . 'sku', $sku_generated );
+ }
+
//redirect
$_SESSION['messages'][] = [ 'success', esc_html__( 'Property has been successfully updated.', 'opalestate-pro' ) ];
do_action( "opalestate_process_submission_after", $user_id, $post_id, $edit );
if ( $edit ) {
- $type = OpalEstate()->session->set( 'submission' , 'edit' );
- $message = esc_html__('The property has updated completed with new information', 'opalestate-pro' );
+ $type = OpalEstate()->session->set( 'submission', 'edit' );
+ $message = esc_html__( 'The property has updated completed with new information', 'opalestate-pro' );
do_action( "opalestate_processed_edit_submission", $user_id, $post_id );
} else {
- $type = OpalEstate()->session->get( 'submission' , 'addnew' );
- $message = esc_html__('You have submitted the property successful', 'opalestate-pro' );
+ $type = OpalEstate()->session->get( 'submission', 'addnew' );
+ $message = esc_html__( 'You have submitted the property successful', 'opalestate-pro' );
do_action( "opalestate_processed_new_submission", $user_id, $post_id );
}
// set ready of attachment for use.
- if( $this->new_attachmenet_ids ){
+ if ( $this->new_attachmenet_ids ) {
foreach ( $this->new_attachmenet_ids as $_id ) {
delete_post_meta( $_id, '_pending_to_use_', 1 );
}
}
- //
-
return opalestate_output_msg_json( true,
$message,
- array(
- 'heading' => esc_html__('Submission Information' ,'opalestate-pro'),
- 'redirect' => opalestate_submssion_page( $post_id, array('do' => 'completed') )
- )) ;
+ [
+ 'heading' => esc_html__( 'Submission Information', 'opalestate-pro' ),
+ 'redirect' => opalestate_submssion_page( $post_id, [ 'do' => 'completed' ] ),
+ ] );
}
} else {
return opalestate_output_msg_json( fales,
- __('Currently, your account was blocked, please keep contact admin to resolve this!.', 'opalestate-pro' ),
- array('heading' => esc_html__('Submission Information' ,'opalestate-pro') )
- ) ;
+ __( 'Currently, your account was blocked, please keep contact admin to resolve this!.', 'opalestate-pro' ),
+ [ 'heading' => esc_html__( 'Submission Information', 'opalestate-pro' ) ]
+ );
}
}
return opalestate_output_msg_json( fales,
- __('Sorry! Your submitted datcould not save a at this time', 'opalestate-pro' ),
- array('heading' => esc_html__('Submission Information', 'opalestate-pro') )
- ) ;
+ __( 'Sorry! Your submitted datcould not save a at this time', 'opalestate-pro' ),
+ [ 'heading' => esc_html__( 'Submission Information', 'opalestate-pro' ) ]
+ );
}
}
@@ -547,57 +564,57 @@ class OpalEstate_Submission {
*
*
*/
- private function get_field_name( $field ){
- return OPALESTATE_PROPERTY_PREFIX.$field;
+ private function get_field_name( $field ) {
+ return OPALESTATE_PROPERTY_PREFIX . $field;
}
/**
+ * Process upload files.
*
- *
+ * @param int $post_id Post ID.
*/
- private function process_upload_files ( $post_id ) {
+ private function process_upload_files( $post_id ) {
//upload images for featured and gallery images
- if( isset($_FILES) && !empty($_FILES) ){
+ if ( isset( $_FILES ) && ! empty( $_FILES ) ) {
///
- $fields = array(
- $this->get_field_name('gallery'),
- $this->get_field_name('featured_image'),
- );
+ $fields = [
+ $this->get_field_name( 'gallery' ),
+ $this->get_field_name( 'featured_image' ),
+ ];
- foreach( $_FILES as $key => $value ) {
+ foreach ( $_FILES as $key => $value ) {
// allow processing in fixed collection
- if( in_array($key, $fields) ){
- $ufile = $_FILES[$key];
+ if ( in_array( $key, $fields ) ) {
+ $ufile = $_FILES[ $key ];
/// /////
- if( isset( $ufile['name'] ) && is_array( $ufile['name'] ) ){
- $output = array();
+ if ( isset( $ufile['name'] ) && is_array( $ufile['name'] ) ) {
+ $output = [];
- foreach ( $ufile['name'] as $f_key => $f_value ) {
- $loop_file = array(
- 'name' => $ufile['name'][$f_key],
- 'type' => $ufile['type'][$f_key],
- 'tmp_name' => $ufile['tmp_name'][$f_key],
- 'error' => $ufile['error'][$f_key],
- 'size' => $ufile['size'][$f_key]
- );
- $new_atm = $this->upload_image( $loop_file, $post_id );
- if( $new_atm ){
- $_POST[$key] = isset($_POST[$key]) ? $_POST[$key] : array();
- $_POST[$key][$new_atm['attachment_id']] = $new_atm['url'];
- $this->new_attachmenet_ids[$new_atm['attachment_id']] = $new_atm['attachment_id'];
+ foreach ( $ufile['name'] as $f_key => $f_value ) {
+ $loop_file = [
+ 'name' => $ufile['name'][ $f_key ],
+ 'type' => $ufile['type'][ $f_key ],
+ 'tmp_name' => $ufile['tmp_name'][ $f_key ],
+ 'error' => $ufile['error'][ $f_key ],
+ 'size' => $ufile['size'][ $f_key ],
+ ];
+ $new_atm = $this->upload_image( $loop_file, $post_id );
+ if ( $new_atm ) {
+ $_POST[ $key ] = isset( $_POST[ $key ] ) ? $_POST[ $key ] : [];
+ $_POST[ $key ][ $new_atm['attachment_id'] ] = $new_atm['url'];
+ $this->new_attachmenet_ids[ $new_atm['attachment_id'] ] = $new_atm['attachment_id'];
}
}
- }
- ///
- elseif( isset($ufile['name']) ) {
- $new_atm = $this->upload_image( $ufile, $post_id );
- if( $new_atm ){
- $_POST[$key][$new_atm['attachment_id']] = $new_atm['url'];
- $this->new_attachmenet_ids[$new_atm['attachment_id']] = $new_atm['attachment_id'];
+ } ///
+ elseif ( isset( $ufile['name'] ) ) {
+ $new_atm = $this->upload_image( $ufile, $post_id );
+ if ( $new_atm ) {
+ $_POST[ $key ][ $new_atm['attachment_id'] ] = $new_atm['url'];
+ $this->new_attachmenet_ids[ $new_atm['attachment_id'] ] = $new_atm['attachment_id'];
}
}
//// / //
@@ -605,56 +622,53 @@ class OpalEstate_Submission {
}
// for group files
- $fields = array(
- $this->get_field_name('public_floor_group')
- );
+ $fields = [
+ $this->get_field_name( 'public_floor_group' ),
+ ];
+ foreach ( $_FILES as $key => $value ) {
+ if ( in_array( $key, $fields ) ) {
+ $ufile = $_FILES[ $key ];
- foreach( $_FILES as $key => $value ) {
+ if ( isset( $ufile['name'] ) && is_array( $ufile['name'] ) ) {
+ $output = [];
+ foreach ( $ufile['name'] as $f_key => $f_value ) {
- if( in_array($key, $fields) ){
- $ufile = $_FILES[$key];
+ foreach ( $f_value as $u_key => $u_v ) {
+ $loop_file = [
+ 'name' => $ufile['name'][ $f_key ][ $u_key ],
+ 'type' => $ufile['type'][ $f_key ][ $u_key ],
+ 'tmp_name' => $ufile['tmp_name'][ $f_key ][ $u_key ],
+ 'error' => $ufile['error'][ $f_key ][ $u_key ],
+ 'size' => $ufile['size'][ $f_key ][ $u_key ],
+ ];
- if( isset( $ufile['name'] ) && is_array( $ufile['name'] ) ){
- $output = array();
- foreach ( $ufile['name'] as $f_key => $f_value ) {
+ $new_atm = $this->upload_image( $loop_file, $post_id );
+ if ( $new_atm ) {
- foreach( $f_value as $u_key => $u_v ) {
- $loop_file = array(
- 'name' => $ufile['name'][$f_key][$u_key],
- 'type' => $ufile['type'][$f_key][$u_key],
- 'tmp_name' => $ufile['tmp_name'][$f_key][$u_key],
- 'error' => $ufile['error'][$f_key][$u_key],
- 'size' => $ufile['size'][$f_key][$u_key]
- );
-
- $new_atm = $this->upload_image( $loop_file, $post_id );
- if( $new_atm ){
-
- $_POST[$key][$f_key][$u_key] = $new_atm['attachment_id'];
- $this->new_attachmenet_ids[$new_atm['attachment_id']] = $new_atm['attachment_id'];
+ $_POST[ $key ][ $f_key ][ $u_key ] = $new_atm['attachment_id'];
+ $this->new_attachmenet_ids[ $new_atm['attachment_id'] ] = $new_atm['attachment_id'];
}
}
}
- }
+ }
}
}
}
}
-
/**
* Process upload images for properties
*/
- public function upload_image( $submitted_file, $parent_id=0 ){
+ public function upload_image( $submitted_file, $parent_id = 0 ) {
return opalesate_upload_image( $submitted_file, $parent_id );
}
/**
* FrontEnd Submission
*/
- private function cleanup() {
- $user_id = get_current_user_id();
+ private function cleanup() {
+ $user_id = get_current_user_id();
opalestate_clean_attachments( $user_id );
}
diff --git a/templates/submission/completed.php b/templates/submission/completed.php
index 43f0780a..90acb5bb 100755
--- a/templates/submission/completed.php
+++ b/templates/submission/completed.php
@@ -1,27 +1,33 @@
-session->get( 'submission' );
+$post = get_post( $post_id );
+$type = OpalEstate()->session->get( 'submission' );
?>
-session->set( 'submission', null ); ?>
\ No newline at end of file
+
+session->set( 'submission', null ); ?>