Fix submission bug.
This commit is contained in:
parent
8d86aa767d
commit
57f4284fb9
@ -93,8 +93,6 @@ class Opalestate_Install {
|
|||||||
$options['currency_position'] = 'before';
|
$options['currency_position'] = 'before';
|
||||||
$options['measurement_unit'] = 'sqft';
|
$options['measurement_unit'] = 'sqft';
|
||||||
$options['google_map_api_keys'] = 'AIzaSyCfMVNIa7khIqYHCw6VBn8ShUWWm4tjbG8';
|
$options['google_map_api_keys'] = 'AIzaSyCfMVNIa7khIqYHCw6VBn8ShUWWm4tjbG8';
|
||||||
$options['admin_approve'] = 'on';
|
|
||||||
$options['require_input_price'] = 'on';
|
|
||||||
$options['from_name'] = get_bloginfo( 'name' );
|
$options['from_name'] = get_bloginfo( 'name' );
|
||||||
$options['from_email'] = get_bloginfo( 'admin_email' );
|
$options['from_email'] = get_bloginfo( 'admin_email' );
|
||||||
$options['message_log'] = 1;
|
$options['message_log'] = 1;
|
||||||
@ -129,6 +127,7 @@ class Opalestate_Install {
|
|||||||
$options['enable_agency_reviews'] = 'on';
|
$options['enable_agency_reviews'] = 'on';
|
||||||
$options['enable_agent_reviews'] = 'on';
|
$options['enable_agent_reviews'] = 'on';
|
||||||
|
|
||||||
|
$options['admin_approve'] = 'on';
|
||||||
$options['enable_submission_tab_media'] = 'on';
|
$options['enable_submission_tab_media'] = 'on';
|
||||||
$options['enable_submission_tab_location'] = 'on';
|
$options['enable_submission_tab_location'] = 'on';
|
||||||
$options['enable_submission_tab_amenities'] = 'on';
|
$options['enable_submission_tab_amenities'] = 'on';
|
||||||
|
@ -240,7 +240,7 @@ class Opalestate_Property_MetaBox {
|
|||||||
'name' => esc_html__( 'Regular Price', 'opalestate-pro' ) . $currency,
|
'name' => esc_html__( 'Regular Price', 'opalestate-pro' ) . $currency,
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'description' => esc_html__( 'Enter amount without currency', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter amount without currency', 'opalestate-pro' ),
|
||||||
'attributes' => opalestate_get_option( 'require_input_price' ) ? [ 'required' => 'required' ] : '',
|
'attributes' => [ 'required' => 'required' ],
|
||||||
'before_row' => '<div class="row-group-features group-has-three group-price clearfix"><h3>' . ( is_admin() ? "" : esc_html__( 'Price', 'opalestate-pro' ) ) . '</h3>', // callback
|
'before_row' => '<div class="row-group-features group-has-three group-price clearfix"><h3>' . ( is_admin() ? "" : esc_html__( 'Price', 'opalestate-pro' ) ) . '</h3>', // callback
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@ -59,14 +59,13 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
public function get_fields_groups() {
|
public function get_fields_groups() {
|
||||||
return [
|
return [
|
||||||
'general' => [ 'status' => true, 'title' => esc_html__( 'General', 'opalestate-pro' ) ],
|
'general' => [ 'status' => true, 'title' => esc_html__( 'General', 'opalestate-pro' ) ],
|
||||||
|
|
||||||
'media' => [ 'status' => $this->is_enabled_tab( 'media' ), 'title' => esc_html__( 'Media', 'opalestate-pro' ) ],
|
'media' => [ 'status' => $this->is_enabled_tab( 'media' ), 'title' => esc_html__( 'Media', 'opalestate-pro' ) ],
|
||||||
'location' => [ 'status' => $this->is_enabled_tab( 'location' ), 'title' => esc_html__( 'Location', 'opalestate-pro' ) ],
|
'location' => [ 'status' => $this->is_enabled_tab( 'location' ), 'title' => esc_html__( 'Location', 'opalestate-pro' ) ],
|
||||||
'information' => [ 'status' => $this->is_enabled_tab( 'information' ), 'title' => esc_html__( 'Information', 'opalestate-pro' ) ],
|
'information' => [ 'status' => $this->is_enabled_tab( 'information' ), 'title' => esc_html__( 'Information', 'opalestate-pro' ) ],
|
||||||
'amenities' => [ 'status' => $this->is_enabled_tab( 'amenities' ), 'title' => esc_html__( 'Amenities', 'opalestate-pro' ) ],
|
'amenities' => [ 'status' => $this->is_enabled_tab( 'amenities' ), 'title' => esc_html__( 'Amenities', 'opalestate-pro' ) ],
|
||||||
'facilities' => [ 'status' => $this->is_enabled_tab( 'facilities' ), 'title' => esc_html__( 'Facilities', 'opalestate-pro' ) ],
|
'facilities' => [ 'status' => $this->is_enabled_tab( 'facilities' ), 'title' => esc_html__( 'Facilities', 'opalestate-pro' ) ],
|
||||||
'apartments' => [ 'status' => $this->is_enabled_tab( 'apartments' ), 'title' => esc_html__( 'Apartments', 'opalestate-pro' ) ],
|
'apartments' => [ 'status' => $this->is_enabled_tab( 'apartments' ), 'title' => esc_html__( 'Apartments', 'opalestate-pro' ) ],
|
||||||
'floor_plans' => [ 'status' => $this->is_enabled_tab( 'floor_plans' ), 'title' => esc_html__( 'Floor plans', 'opalestate-pro' ) ]
|
'floor_plans' => [ 'status' => $this->is_enabled_tab( 'floor_plans' ), 'title' => esc_html__( 'Floor plans', 'opalestate-pro' ) ],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +76,7 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
if ( ! empty( $_GET['id'] ) ) {
|
if ( ! empty( $_GET['id'] ) ) {
|
||||||
$post = get_post( intval( $_GET['id'] ) );
|
$post = get_post( intval( $_GET['id'] ) );
|
||||||
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( absint( $_GET['id'] ) ) );
|
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( absint( $_GET['id'] ) ) );
|
||||||
$post_id = $post->ID;
|
$post_id = $post->ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
$currency = opalestate_currency_symbol() ? ' (' . opalestate_currency_symbol() . ')' : ' ($)';
|
$currency = opalestate_currency_symbol() ? ' (' . opalestate_currency_symbol() . ')' : ' ($)';
|
||||||
@ -95,7 +94,6 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'default' => $post_id,
|
'default' => $post_id,
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Title', 'opalestate-pro' ) . '<span class="required"> *</span>',
|
'name' => esc_html__( 'Title', 'opalestate-pro' ) . '<span class="required"> *</span>',
|
||||||
'id' => $prefix . 'title',
|
'id' => $prefix . 'title',
|
||||||
@ -107,20 +105,19 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Description', 'opalestate-pro' ),
|
'name' => esc_html__( 'Description', 'opalestate-pro' ),
|
||||||
'id' => $prefix . 'text',
|
'id' => $prefix . 'text',
|
||||||
'type' => 'wysiwyg',
|
'type' => 'wysiwyg',
|
||||||
'default' => ! empty( $post ) ? $post->post_content : '',
|
'default' => ! empty( $post ) ? $post->post_content : '',
|
||||||
'before_row' => '<hr>',
|
'before_row' => '<hr>',
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'id' => $prefix . 'price',
|
'id' => $prefix . 'price',
|
||||||
'name' => esc_html__( 'Regular Price', 'opalestate-pro' ) . $currency . '<span class="required"> *</span>',
|
'name' => esc_html__( 'Regular Price', 'opalestate-pro' ) . $currency . '<span class="required"> *</span>',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'description' => esc_html__( 'Enter amount without currency', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter amount without currency', 'opalestate-pro' ),
|
||||||
'attributes' => opalestate_get_option( 'require_input_price' ) ? [ 'required' => 'required' ] : '',
|
'attributes' => [ 'required' => 'required' ],
|
||||||
'before_row' => '<hr><div class="field-row-2">', // callback
|
'before_row' => '<hr><div class="field-row-2">',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => $prefix . 'saleprice',
|
'id' => $prefix . 'saleprice',
|
||||||
@ -141,26 +138,26 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'description' => esc_html__( 'After Price Label (e.g. "per month")', 'opalestate-pro' ),
|
'description' => esc_html__( 'After Price Label (e.g. "per month")', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Statuses', 'opalestate-pro' ),
|
'name' => esc_html__( 'Statuses', 'opalestate-pro' ),
|
||||||
'id' => $prefix . 'status',
|
'id' => $prefix . 'status',
|
||||||
'type' => 'taxonomy_select',
|
'type' => 'taxonomy_select',
|
||||||
'taxonomy' => 'opalestate_status',
|
'taxonomy' => 'opalestate_status',
|
||||||
'class' => 'form-control',
|
'class' => 'form-control',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'required' => 'required',
|
'required' => 'required',
|
||||||
],
|
],
|
||||||
'before_row' => '</div><hr><div class="field-row-2">', // callback
|
'before_row' => '</div><hr><div class="field-row-2">', // callback
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Types', 'opalestate-pro' ),
|
'name' => esc_html__( 'Types', 'opalestate-pro' ),
|
||||||
'id' => $prefix . 'type',
|
'id' => $prefix . 'type',
|
||||||
'type' => 'taxonomy_select',
|
'type' => 'taxonomy_select',
|
||||||
'taxonomy' => 'opalestate_types',
|
'taxonomy' => 'opalestate_types',
|
||||||
'class' => 'form-control',
|
'class' => 'form-control',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'required' => 'required',
|
'required' => 'required',
|
||||||
],
|
],
|
||||||
'after_row' => '</div><hr><button type="button" class="submission-next-btn btn btn-primary">' . esc_html__( 'Next Step', 'opalestate-pro' ) . '</button></div>', // callback
|
'after_row' => '</div><hr><button type="button" class="submission-next-btn btn btn-primary">' . esc_html__( 'Next Step', 'opalestate-pro' ) . '</button></div>', // callback
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -168,12 +165,11 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function metaboxes_media_fields() {
|
public function metaboxes_media_fields() {
|
||||||
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
|
|
||||||
if( isset($_GET['id']) ){
|
if ( isset( $_GET['id'] ) ) {
|
||||||
$post_id = intval( $_GET['id'] );
|
$post_id = intval( $_GET['id'] );
|
||||||
$id = get_post_thumbnail_id( $post_id );
|
$id = get_post_thumbnail_id( $post_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
$prefix = OPALESTATE_PROPERTY_PREFIX;
|
$prefix = OPALESTATE_PROPERTY_PREFIX;
|
||||||
@ -183,8 +179,8 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'id' => "{$prefix}featured_image",
|
'id' => "{$prefix}featured_image",
|
||||||
'name' => esc_html__( 'Featured Image', 'opalestate-pro' ),
|
'name' => esc_html__( 'Featured Image', 'opalestate-pro' ),
|
||||||
'type' => 'uploader',
|
'type' => 'uploader',
|
||||||
'single' => true,
|
'single' => true,
|
||||||
'value' => $id,
|
'value' => $id,
|
||||||
'description' => esc_html__( 'Select one or more images to show as gallery', 'opalestate-pro' ),
|
'description' => esc_html__( 'Select one or more images to show as gallery', 'opalestate-pro' ),
|
||||||
'before_row' => '<div id="opalestate-submission-media" class="opalestate-tab-content">',
|
'before_row' => '<div id="opalestate-submission-media" class="opalestate-tab-content">',
|
||||||
|
|
||||||
@ -202,7 +198,7 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'id' => "{$prefix}video",
|
'id' => "{$prefix}video",
|
||||||
'name' => esc_html__( 'Video', 'opalestate-pro' ),
|
'name' => esc_html__( 'Video', 'opalestate-pro' ),
|
||||||
'type' => 'text_url',
|
'type' => 'text_url',
|
||||||
'before_row' => '<hr>',
|
'before_row' => '<hr>',
|
||||||
'description' => esc_html__( 'Input for videos, audios from Youtube, Vimeo and all supported sites by WordPress. It has preview feature.', 'opalestate-pro' ),
|
'description' => esc_html__( 'Input for videos, audios from Youtube, Vimeo and all supported sites by WordPress. It has preview feature.', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -210,15 +206,15 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'name' => esc_html__( '360° Virtual Tour', 'opalestate-pro' ),
|
'name' => esc_html__( '360° Virtual Tour', 'opalestate-pro' ),
|
||||||
'type' => 'textarea_small',
|
'type' => 'textarea_small',
|
||||||
'description' => esc_html__( 'Input iframe to show 360° Virtual Tour.', 'opalestate-pro' ),
|
'description' => esc_html__( 'Input iframe to show 360° Virtual Tour.', 'opalestate-pro' ),
|
||||||
'before_row' => '<hr>'
|
'before_row' => '<hr>',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => "{$prefix}attachments",
|
'id' => "{$prefix}attachments",
|
||||||
'name' => esc_html__( 'Attachments', 'opalestate-pro' ),
|
'name' => esc_html__( 'Attachments', 'opalestate-pro' ),
|
||||||
'type' => 'uploader',
|
'type' => 'uploader',
|
||||||
'before_row' => '<hr>',
|
'before_row' => '<hr>',
|
||||||
'show_icon' => true,
|
'show_icon' => true,
|
||||||
'accept' => 'application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
'accept' => 'application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
'options' => [
|
'options' => [
|
||||||
'url' => true, // Hide the text input for the url
|
'url' => true, // Hide the text input for the url
|
||||||
],
|
],
|
||||||
@ -244,40 +240,40 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'before_row' => '<div id="opalestate-submission-information" class="opalestate-tab-content"><div class="field-row-2">',
|
'before_row' => '<div id="opalestate-submission-information" class="opalestate-tab-content"><div class="field-row-2">',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Parking', 'opalestate-pro' ),
|
'name' => esc_html__( 'Parking', 'opalestate-pro' ),
|
||||||
'id' => $prefix . 'parking',
|
'id' => $prefix . 'parking',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'attributes' => array(
|
'attributes' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'pattern' => '\d*',
|
'pattern' => '\d*',
|
||||||
),
|
],
|
||||||
'sanitization_cb' => 'absint',
|
'sanitization_cb' => 'absint',
|
||||||
'escape_cb' => 'absint',
|
'escape_cb' => 'absint',
|
||||||
'description' => esc_html__( 'Enter number of Parking', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter number of Parking', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Bedrooms', 'opalestate-pro' ),
|
'name' => esc_html__( 'Bedrooms', 'opalestate-pro' ),
|
||||||
'id' => $prefix . 'bedrooms',
|
'id' => $prefix . 'bedrooms',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'attributes' => array(
|
'attributes' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'pattern' => '\d*',
|
'pattern' => '\d*',
|
||||||
),
|
],
|
||||||
'sanitization_cb' => 'absint',
|
'sanitization_cb' => 'absint',
|
||||||
'escape_cb' => 'absint',
|
'escape_cb' => 'absint',
|
||||||
'description' => esc_html__( 'Enter number of bedrooms', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter number of bedrooms', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Bathrooms', 'opalestate-pro' ),
|
'name' => esc_html__( 'Bathrooms', 'opalestate-pro' ),
|
||||||
'id' => $prefix . 'bathrooms',
|
'id' => $prefix . 'bathrooms',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'attributes' => array(
|
'attributes' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'pattern' => '\d*',
|
'pattern' => '\d*',
|
||||||
),
|
],
|
||||||
'sanitization_cb' => 'absint',
|
'sanitization_cb' => 'absint',
|
||||||
'escape_cb' => 'absint',
|
'escape_cb' => 'absint',
|
||||||
'description' => esc_html__( 'Enter number of bathrooms', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter number of bathrooms', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Plot Size', 'opalestate-pro' ),
|
'name' => esc_html__( 'Plot Size', 'opalestate-pro' ),
|
||||||
@ -286,16 +282,16 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'description' => esc_html__( 'Enter size of Plot as 20x30, 20x30x40, 20x30x40x50', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter size of Plot as 20x30, 20x30x40, 20x30x40x50', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Area Size', 'opalestate-pro' ),
|
'name' => esc_html__( 'Area Size', 'opalestate-pro' ),
|
||||||
'id' => $prefix . 'areasize',
|
'id' => $prefix . 'areasize',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'attributes' => array(
|
'attributes' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'pattern' => '\d*',
|
'pattern' => '\d*',
|
||||||
),
|
],
|
||||||
'sanitization_cb' => 'absint',
|
'sanitization_cb' => 'absint',
|
||||||
'escape_cb' => 'absint',
|
'escape_cb' => 'absint',
|
||||||
'description' => esc_html__( 'Enter size of area in sqft', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter size of area in sqft', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Orientation', 'opalestate-pro' ),
|
'name' => esc_html__( 'Orientation', 'opalestate-pro' ),
|
||||||
@ -304,43 +300,43 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'description' => esc_html__( 'Enter Orientation of property', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter Orientation of property', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Living Rooms', 'opalestate-pro' ),
|
'name' => esc_html__( 'Living Rooms', 'opalestate-pro' ),
|
||||||
'id' => "{$prefix}livingrooms",
|
'id' => "{$prefix}livingrooms",
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'attributes' => array(
|
'attributes' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'pattern' => '\d*',
|
'pattern' => '\d*',
|
||||||
),
|
],
|
||||||
'sanitization_cb' => 'absint',
|
'sanitization_cb' => 'absint',
|
||||||
'escape_cb' => 'absint',
|
'escape_cb' => 'absint',
|
||||||
'description' => esc_html__( 'Enter Number of Living Rooms', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter Number of Living Rooms', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Kitchens', 'opalestate-pro' ),
|
'name' => esc_html__( 'Kitchens', 'opalestate-pro' ),
|
||||||
'id' => "{$prefix}kitchens",
|
'id' => "{$prefix}kitchens",
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'attributes' => array(
|
'attributes' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'pattern' => '\d*',
|
'pattern' => '\d*',
|
||||||
),
|
],
|
||||||
'sanitization_cb' => 'absint',
|
'sanitization_cb' => 'absint',
|
||||||
'escape_cb' => 'absint',
|
'escape_cb' => 'absint',
|
||||||
'description' => esc_html__( 'Enter Number of Kitchens', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter Number of Kitchens', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Rooms', 'opalestate-pro' ),
|
'name' => esc_html__( 'Rooms', 'opalestate-pro' ),
|
||||||
'id' => "{$prefix}amountrooms",
|
'id' => "{$prefix}amountrooms",
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'attributes' => array(
|
'attributes' => [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
'pattern' => '\d*',
|
'pattern' => '\d*',
|
||||||
),
|
],
|
||||||
'sanitization_cb' => 'absint',
|
'sanitization_cb' => 'absint',
|
||||||
'escape_cb' => 'absint',
|
'escape_cb' => 'absint',
|
||||||
'description' => esc_html__( 'Enter Number of Amount Rooms', 'opalestate-pro' ),
|
'description' => esc_html__( 'Enter Number of Amount Rooms', 'opalestate-pro' ),
|
||||||
'after_row' => '</div><hr><button type="button" class="submission-back-btn btn btn-primary">' . esc_html__( 'Previous Step',
|
'after_row' => '</div><hr><button type="button" class="submission-back-btn btn btn-primary">' . esc_html__( 'Previous Step',
|
||||||
'opalestate-pro' ) . '</button><button type="button" class="submission-next-btn btn btn-primary">' . esc_html__( 'Next Step', 'opalestate-pro' ) . '</button></div>',
|
'opalestate-pro' ) . '</button><button type="button" class="submission-next-btn btn btn-primary">' . esc_html__( 'Next Step', 'opalestate-pro' ) . '</button></div>',
|
||||||
|
|
||||||
],
|
],
|
||||||
@ -372,10 +368,10 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'taxonomy' => 'opalestate_city',
|
'taxonomy' => 'opalestate_city',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Postal Code / Zip', 'opalestate-pro' ),
|
'name' => esc_html__( 'Postal Code / Zip', 'opalestate-pro' ),
|
||||||
'id' => $prefix . 'zipcode',
|
'id' => $prefix . 'zipcode',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'after_row'=> '</div><hr>'
|
'after_row' => '</div><hr>',
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -387,10 +383,10 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Google Map View', 'opalestate-pro' ),
|
'name' => esc_html__( 'Google Map View', 'opalestate-pro' ),
|
||||||
'id' => $prefix . 'enablemapview',
|
'id' => $prefix . 'enablemapview',
|
||||||
'type' => 'switch',
|
'type' => 'switch',
|
||||||
'options' => [
|
'options' => [
|
||||||
0 => esc_html__( 'No', 'opalestate-pro' ),
|
0 => esc_html__( 'No', 'opalestate-pro' ),
|
||||||
1 => esc_html__( 'Yes', 'opalestate-pro' ),
|
1 => esc_html__( 'Yes', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
@ -414,13 +410,13 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
$prefix = OPALESTATE_PROPERTY_PREFIX;
|
$prefix = OPALESTATE_PROPERTY_PREFIX;
|
||||||
$fields = [
|
$fields = [
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Amenities', 'opalestate-pro' ),
|
'name' => esc_html__( 'Amenities', 'opalestate-pro' ),
|
||||||
'id' => $prefix . 'amenity',
|
'id' => $prefix . 'amenity',
|
||||||
'type' => 'taxonomy_multicheck',
|
'type' => 'taxonomy_multicheck',
|
||||||
'before_row' => '<div id="opalestate-submission-amenities" class="opalestate-tab-content">',
|
'before_row' => '<div id="opalestate-submission-amenities" class="opalestate-tab-content">',
|
||||||
'after_row' => '<button type="button" class="submission-back-btn btn btn-primary">' . esc_html__( 'Previous Step',
|
'after_row' => '<button type="button" class="submission-back-btn btn btn-primary">' . esc_html__( 'Previous Step',
|
||||||
'opalestate-pro' ) . '</button><button type="button" class="submission-next-btn btn btn-primary">' . esc_html__( 'Next Step', 'opalestate-pro' ) . '</button></div>',
|
'opalestate-pro' ) . '</button><button type="button" class="submission-next-btn btn btn-primary">' . esc_html__( 'Next Step', 'opalestate-pro' ) . '</button></div>',
|
||||||
'taxonomy' => 'opalestate_amenities',
|
'taxonomy' => 'opalestate_amenities',
|
||||||
'render_row_cb' => [ $this, 'amenities_html_callback' ],
|
'render_row_cb' => [ $this, 'amenities_html_callback' ],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -437,7 +433,7 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'type' => 'group',
|
'type' => 'group',
|
||||||
'before_group' => '<div id="opalestate-submission-facilities" class="opalestate-tab-content">',
|
'before_group' => '<div id="opalestate-submission-facilities" class="opalestate-tab-content">',
|
||||||
'after_group' => '<button type="button" class="submission-back-btn btn btn-primary">' . esc_html__( 'Previous Step',
|
'after_group' => '<button type="button" class="submission-back-btn btn btn-primary">' . esc_html__( 'Previous Step',
|
||||||
'opalestate-pro' ) . '</button><button type="button" class="submission-next-btn btn btn-primary">' . esc_html__( 'Next Step', 'opalestate-pro' ) . '</button></div>',
|
'opalestate-pro' ) . '</button><button type="button" class="submission-next-btn btn btn-primary">' . esc_html__( 'Next Step', 'opalestate-pro' ) . '</button></div>',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
[
|
[
|
||||||
'id' => $prefix . 'public_facilities_key',
|
'id' => $prefix . 'public_facilities_key',
|
||||||
@ -480,7 +476,7 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'id' => $prefix . 'apartments',
|
'id' => $prefix . 'apartments',
|
||||||
'type' => 'group',
|
'type' => 'group',
|
||||||
'after_group' => '<button type="button" class="submission-back-btn btn btn-primary">' . esc_html__( 'Previous Step',
|
'after_group' => '<button type="button" class="submission-back-btn btn btn-primary">' . esc_html__( 'Previous Step',
|
||||||
'opalestate-pro' ) . '</button><button type="button" class="submission-next-btn btn btn-primary">' . esc_html__( 'Next Step', 'opalestate-pro' ) . '</button></div>',
|
'opalestate-pro' ) . '</button><button type="button" class="submission-next-btn btn btn-primary">' . esc_html__( 'Next Step', 'opalestate-pro' ) . '</button></div>',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
[
|
[
|
||||||
'id' => $prefix . 'apartment_plot',
|
'id' => $prefix . 'apartment_plot',
|
||||||
@ -590,10 +586,10 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
'type' => 'textarea_small',
|
'type' => 'textarea_small',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'id' => "{$prefix}floor_image_id",
|
'id' => "{$prefix}floor_image_id",
|
||||||
'name' => esc_html__( 'Image Preview', 'opalestate-pro' ),
|
'name' => esc_html__( 'Image Preview', 'opalestate-pro' ),
|
||||||
'type' => 'uploader',
|
'type' => 'uploader',
|
||||||
'single' => 1,
|
'single' => 1,
|
||||||
|
|
||||||
'query_args' => [
|
'query_args' => [
|
||||||
'type' => [
|
'type' => [
|
||||||
@ -625,8 +621,8 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
/**
|
/**
|
||||||
* Manually render a field column display.
|
* Manually render a field column display.
|
||||||
*
|
*
|
||||||
* @param array $field_args Array of field arguments.
|
* @param array $field_args Array of field arguments.
|
||||||
* @param CMB2_Field $field The field object
|
* @param CMB2_Field $field The field object
|
||||||
*/
|
*/
|
||||||
public function amenities_html_callback( $field_args, $field ) {
|
public function amenities_html_callback( $field_args, $field ) {
|
||||||
$id = $field->args( 'id' );
|
$id = $field->args( 'id' );
|
||||||
@ -646,34 +642,34 @@ class Opalestate_Property_MetaBox_Submission {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div id="opalestate-submission-amenities" class="opalestate-tab-content">
|
<div id="opalestate-submission-amenities" class="opalestate-tab-content">
|
||||||
<div class="cmb-row cmb-type-taxonomy-multicheck cmb2-id-opalestate-ppt-amenity" data-fieldtype="taxonomy_multicheck">
|
<div class="cmb-row cmb-type-taxonomy-multicheck cmb2-id-opalestate-ppt-amenity" data-fieldtype="taxonomy_multicheck">
|
||||||
<div class="cmb-th">
|
<div class="cmb-th">
|
||||||
<label for="<?php echo esc_attr( $name ); ?>"><?php echo esc_html( $label ); ?></label>
|
<label for="<?php echo esc_attr( $name ); ?>"><?php echo esc_html( $label ); ?></label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cmb-td">
|
<div class="cmb-td">
|
||||||
<ul class="cmb2-checkbox-list list-inline cmb2-list">
|
<ul class="cmb2-checkbox-list list-inline cmb2-list">
|
||||||
<?php foreach ( $amenites as $key => $amenity ) : ?>
|
<?php foreach ( $amenites as $key => $amenity ) : ?>
|
||||||
<li>
|
<li>
|
||||||
<input type="checkbox" class="cmb2-option" name="<?php echo esc_attr( $name ); ?>[]" id="opalestate_ppt_amenity<?php echo esc_attr( $key + 1 ); ?>"
|
<input type="checkbox" class="cmb2-option" name="<?php echo esc_attr( $name ); ?>[]" id="opalestate_ppt_amenity<?php echo esc_attr( $key + 1 ); ?>"
|
||||||
value="<?php echo esc_attr( $amenity->slug ); ?>">
|
value="<?php echo esc_attr( $amenity->slug ); ?>">
|
||||||
<label for="opalestate_ppt_amenity<?php echo esc_attr( $key + 1 ); ?>">
|
<label for="opalestate_ppt_amenity<?php echo esc_attr( $key + 1 ); ?>">
|
||||||
<?php
|
<?php
|
||||||
if ( $image_id = get_term_meta( $amenity->term_id, 'opalestate_amt_image_id', true )) {
|
if ( $image_id = get_term_meta( $amenity->term_id, 'opalestate_amt_image_id', true ) ) {
|
||||||
echo opalestate_get_image_by_id( $image_id );
|
echo opalestate_get_image_by_id( $image_id );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<?php echo esc_html( $amenity->name ); ?>
|
<?php echo esc_html( $amenity->name ); ?>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="submission-back-btn btn btn-primary"><?php esc_html_e( 'Previous Step', 'opalestate-pro' ); ?></button>
|
<button type="button" class="submission-back-btn btn btn-primary"><?php esc_html_e( 'Previous Step', 'opalestate-pro' ); ?></button>
|
||||||
<button type="button" class="submission-next-btn btn btn-primary"><?php esc_html_e( 'Next Step', 'opalestate-pro' ); ?></button>
|
<button type="button" class="submission-next-btn btn btn-primary"><?php esc_html_e( 'Next Step', 'opalestate-pro' ); ?></button>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class OpalEstate_Submission {
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public $new_attachmenet_ids = array();
|
public $new_attachmenet_ids = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -88,14 +88,14 @@ class OpalEstate_Submission {
|
|||||||
*/
|
*/
|
||||||
public function register_shortcodes() {
|
public function register_shortcodes() {
|
||||||
$shortcodes = [
|
$shortcodes = [
|
||||||
'submission' => [
|
'submission' => [
|
||||||
'code' => 'submission',
|
'code' => 'submission',
|
||||||
'label' => esc_html__( 'Submission Form', 'opalestate-pro' ),
|
'label' => esc_html__( 'Submission Form', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
'submission_list' => [
|
'submission_list' => [
|
||||||
'code' => 'submission_list',
|
'code' => 'submission_list',
|
||||||
'label' => esc_html__( 'My Properties', 'opalestate-pro' ),
|
'label' => esc_html__( 'My Properties', 'opalestate-pro' ),
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ( $shortcodes as $shortcode ) {
|
foreach ( $shortcodes as $shortcode ) {
|
||||||
@ -107,7 +107,7 @@ class OpalEstate_Submission {
|
|||||||
* Is submission page. 'submission_page' option in General Setting
|
* Is submission page. 'submission_page' option in General Setting
|
||||||
*/
|
*/
|
||||||
public function setting_content_tab( $tabs ) {
|
public function setting_content_tab( $tabs ) {
|
||||||
$tabs['submission_page'] = esc_html__( 'Submission Page', 'opalestate-pro' );
|
$tabs['submission_page'] = esc_html__( 'Submission', 'opalestate-pro' );
|
||||||
|
|
||||||
return $tabs;
|
return $tabs;
|
||||||
}
|
}
|
||||||
@ -145,23 +145,20 @@ class OpalEstate_Submission {
|
|||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'options' => [
|
'options' => [
|
||||||
'' => esc_html__( 'Show Login Form', 'opalestate-pro' ),
|
'' => esc_html__( 'Show Login Form', 'opalestate-pro' ),
|
||||||
'login_submission' => esc_html__( 'Show Login Form and Submission Form', 'opalestate-pro' ),
|
'login_submission' => esc_html__( 'Show Login Form and Submission Form', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Enable Admin Approve', 'opalestate-pro' ),
|
'name' => esc_html__( 'Enable Admin Approve', 'opalestate-pro' ),
|
||||||
'desc' => esc_html__( 'the Property will be auto approve when user submit, if you do not enable it.', 'opalestate-pro' ),
|
'desc' => esc_html__( 'Admin must review and approve before properties are published.', 'opalestate-pro' ),
|
||||||
'id' => 'admin_approve',
|
'id' => 'admin_approve',
|
||||||
'type' => 'checkbox',
|
'type' => 'switch',
|
||||||
],
|
'options' => [
|
||||||
[
|
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
|
||||||
'name' => esc_html__( 'Enable Require Price', 'opalestate-pro' ),
|
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
|
||||||
'desc' => esc_html__( 'Enable or Disable require user enter price and price label.', 'opalestate-pro' ),
|
],
|
||||||
'id' => 'require_input_price',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => esc_html__( 'Submission Tab Settings', 'opalestate-pro' ),
|
'name' => esc_html__( 'Submission Tab Settings', 'opalestate-pro' ),
|
||||||
@ -240,6 +237,30 @@ class OpalEstate_Submission {
|
|||||||
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
|
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'name' => esc_html__( 'Submission Settings', 'opalestate-pro' ),
|
||||||
|
'id' => 'opalestate_title_submission_settings',
|
||||||
|
'type' => 'title',
|
||||||
|
'before_row' => '<hr>',
|
||||||
|
'after_row' => '<hr>',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => esc_html__( 'Generate property SKU', 'opalestate-pro' ),
|
||||||
|
'desc' => esc_html__( 'Enable automatic generate property SKU.', 'opalestate-pro' ),
|
||||||
|
'id' => 'enable_submission_generate_sku',
|
||||||
|
'type' => 'switch',
|
||||||
|
'options' => [
|
||||||
|
'on' => esc_html__( 'Enable', 'opalestate-pro' ),
|
||||||
|
'off' => esc_html__( 'Disable', 'opalestate-pro' ),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => esc_html__( 'Property SKU prefix', 'opalestate-pro' ),
|
||||||
|
'desc' => esc_html__( 'Prefix for property SKU.', 'opalestate-pro' ),
|
||||||
|
'id' => 'submission_sku_prefix',
|
||||||
|
'type' => 'text',
|
||||||
|
'default' => 'SKU',
|
||||||
|
],
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@ -258,8 +279,8 @@ class OpalEstate_Submission {
|
|||||||
* Is submission page. 'submission_page' option in General Setting
|
* Is submission page. 'submission_page' option in General Setting
|
||||||
*/
|
*/
|
||||||
public function render_button_edit() {
|
public function render_button_edit() {
|
||||||
|
|
||||||
global $post, $current_user;
|
global $post, $current_user;
|
||||||
|
|
||||||
wp_get_current_user();
|
wp_get_current_user();
|
||||||
|
|
||||||
if ( $current_user->ID == $post->post_author ) {
|
if ( $current_user->ID == $post->post_author ) {
|
||||||
@ -281,13 +302,12 @@ class OpalEstate_Submission {
|
|||||||
return opalestate_get_option( 'submission_page' ) == $post->ID;
|
return opalestate_get_option( 'submission_page' ) == $post->ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Register metabox.
|
||||||
*
|
*
|
||||||
*
|
* @return \Opalestate_Property_MetaBox_Submission
|
||||||
*/
|
*/
|
||||||
public function register_metabox() {
|
public function register_metabox() {
|
||||||
|
|
||||||
$metabox = new Opalestate_Property_MetaBox_Submission();
|
$metabox = new Opalestate_Property_MetaBox_Submission();
|
||||||
|
|
||||||
add_filter( 'cmb2_meta_boxes', [ $metabox, 'register_form' ], 9999 );
|
add_filter( 'cmb2_meta_boxes', [ $metabox, 'register_form' ], 9999 );
|
||||||
@ -299,22 +319,21 @@ class OpalEstate_Submission {
|
|||||||
* FrontEnd Submission
|
* FrontEnd Submission
|
||||||
*/
|
*/
|
||||||
public function submission() {
|
public function submission() {
|
||||||
|
|
||||||
global $current_user;
|
global $current_user;
|
||||||
|
|
||||||
if ( ! is_user_logged_in() ) {
|
if ( ! is_user_logged_in() ) {
|
||||||
echo opalestate_load_template_path( 'submission/require-login' );
|
echo opalestate_load_template_path( 'submission/require-login' );
|
||||||
if( empty(opalestate_get_option("submission_show_content")) ){
|
if ( empty( opalestate_get_option( "submission_show_content" ) ) ) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isset($_GET['do']) && $_GET['do'] == 'completed' ){
|
if ( isset( $_GET['do'] ) && $_GET['do'] == 'completed' ) {
|
||||||
|
|
||||||
OpalEstate()->session->set( 'submission', 'addnew' );
|
OpalEstate()->session->set( 'submission', 'addnew' );
|
||||||
|
|
||||||
echo opalestate_load_template_path( 'submission/completed' );
|
echo opalestate_load_template_path( 'submission/completed' );
|
||||||
return ;
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove all dirty images before edit/create new a property
|
// remove all dirty images before edit/create new a property
|
||||||
@ -324,7 +343,6 @@ class OpalEstate_Submission {
|
|||||||
wp_enqueue_style( 'opalesate-submission' );
|
wp_enqueue_style( 'opalesate-submission' );
|
||||||
wp_enqueue_style( 'opalesate-cmb2-front' );
|
wp_enqueue_style( 'opalesate-cmb2-front' );
|
||||||
|
|
||||||
|
|
||||||
$metabox = $this->register_metabox();
|
$metabox = $this->register_metabox();
|
||||||
$metaboxes = apply_filters( 'cmb2_meta_boxes', [] );
|
$metaboxes = apply_filters( 'cmb2_meta_boxes', [] );
|
||||||
|
|
||||||
@ -334,7 +352,7 @@ class OpalEstate_Submission {
|
|||||||
}
|
}
|
||||||
$post_id = 0;
|
$post_id = 0;
|
||||||
|
|
||||||
if( is_user_logged_in() ) {
|
if ( is_user_logged_in() ) {
|
||||||
// CMB2 is getting fields values from current post what means it will fetch data from submission page
|
// CMB2 is getting fields values from current post what means it will fetch data from submission page
|
||||||
// We need to remove all data before.
|
// We need to remove all data before.
|
||||||
$post_id = ! empty( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
|
$post_id = ! empty( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
|
||||||
@ -352,9 +370,10 @@ class OpalEstate_Submission {
|
|||||||
|
|
||||||
if ( $post_id && ! opalestate_is_own_property( $post_id, $current_user->ID ) ) {
|
if ( $post_id && ! opalestate_is_own_property( $post_id, $current_user->ID ) ) {
|
||||||
echo opalestate_load_template_path( 'parts/has-warning' );
|
echo opalestate_load_template_path( 'parts/has-warning' );
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return opalestate_load_template_path( 'submission/submission-form',
|
return opalestate_load_template_path( 'submission/submission-form',
|
||||||
[
|
[
|
||||||
'post_id' => $post_id,
|
'post_id' => $post_id,
|
||||||
@ -369,6 +388,7 @@ class OpalEstate_Submission {
|
|||||||
*/
|
*/
|
||||||
public function cmb2_get_metabox() {
|
public function cmb2_get_metabox() {
|
||||||
$object_id = 'fake-oject-id';
|
$object_id = 'fake-oject-id';
|
||||||
|
|
||||||
return cmb2_get_metabox( OPALESTATE_PROPERTY_PREFIX . 'front', $object_id );
|
return cmb2_get_metabox( OPALESTATE_PROPERTY_PREFIX . 'front', $object_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,32 +403,25 @@ class OpalEstate_Submission {
|
|||||||
|
|
||||||
$user_id = get_current_user_id();
|
$user_id = get_current_user_id();
|
||||||
$edit = false;
|
$edit = false;
|
||||||
$prefix = OPALESTATE_PROPERTY_PREFIX;
|
$prefix = OPALESTATE_PROPERTY_PREFIX;
|
||||||
$blocked = OpalEstate_User::is_blocked();
|
$blocked = OpalEstate_User::is_blocked();
|
||||||
|
|
||||||
// Setup and sanitize data
|
// Setup and sanitize data
|
||||||
if ( isset( $_POST[ $prefix . 'title' ] ) && ! $blocked && $user_id ) {
|
if ( isset( $_POST[ $prefix . 'title' ] ) && ! $blocked && $user_id ) {
|
||||||
|
|
||||||
$metabox = $this->register_metabox();
|
$metabox = $this->register_metabox();
|
||||||
$metaboxes = apply_filters( 'cmb2_meta_boxes', [] );
|
$metaboxes = apply_filters( 'cmb2_meta_boxes', [] );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$post_id = ! empty( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : false;
|
$post_id = ! empty( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : false;
|
||||||
|
|
||||||
if( $post_id ){
|
if ( $post_id ) {
|
||||||
do_action( 'opalestate_process_edit_submission_before' );
|
do_action( 'opalestate_process_edit_submission_before' );
|
||||||
} else {
|
} else {
|
||||||
do_action( 'opalestate_process_submission_before' );
|
do_action( 'opalestate_process_submission_before' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$review_before = opalestate_get_option( 'admin_approve' );
|
|
||||||
|
|
||||||
$post_status = 'pending';
|
$post_status = 'pending';
|
||||||
|
|
||||||
if ( ! $review_before ) {
|
if ( 'on' != opalestate_get_option( 'admin_approve', 'on' ) ) {
|
||||||
$post_status = 'publish';
|
$post_status = 'publish';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,8 +437,7 @@ class OpalEstate_Submission {
|
|||||||
$post_content = isset( $_POST[ $prefix . 'text' ] ) ? wp_kses( $_POST[ $prefix . 'text' ],
|
$post_content = isset( $_POST[ $prefix . 'text' ] ) ? wp_kses( $_POST[ $prefix . 'text' ],
|
||||||
'<b><strong><i><em><h1><h2><h3><h4><h5><h6><pre><code><span><p>' ) : '';
|
'<b><strong><i><em><h1><h2><h3><h4><h5><h6><pre><code><span><p>' ) : '';
|
||||||
|
|
||||||
|
$data = [
|
||||||
$data = [
|
|
||||||
'post_title' => sanitize_text_field( $_POST[ $prefix . 'title' ] ),
|
'post_title' => sanitize_text_field( $_POST[ $prefix . 'title' ] ),
|
||||||
'post_author' => $user_id,
|
'post_author' => $user_id,
|
||||||
'post_status' => $post_status,
|
'post_status' => $post_status,
|
||||||
@ -457,10 +469,10 @@ class OpalEstate_Submission {
|
|||||||
|
|
||||||
if ( empty( $data['post_title'] ) || empty( $data['post_author'] ) ) {
|
if ( empty( $data['post_title'] ) || empty( $data['post_author'] ) ) {
|
||||||
return opalestate_output_msg_json( false,
|
return opalestate_output_msg_json( false,
|
||||||
__( 'Please enter data for all require fields before submitting', 'opalestate-pro' ),
|
__( 'Please enter data for all require fields before submitting', 'opalestate-pro' ),
|
||||||
array(
|
[
|
||||||
'heading' => esc_html__('Submission Information' ,'opalestate-pro')
|
'heading' => esc_html__( 'Submission Information', 'opalestate-pro' ),
|
||||||
)) ;
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_id = wp_insert_post( $data, true );
|
$post_id = wp_insert_post( $data, true );
|
||||||
@ -478,7 +490,7 @@ class OpalEstate_Submission {
|
|||||||
/**
|
/**
|
||||||
* Fetch sanitized values
|
* 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();
|
$cmb = $this->cmb2_get_metabox();
|
||||||
$sanitized_values = $cmb->get_sanitized_values( $_POST );
|
$sanitized_values = $cmb->get_sanitized_values( $_POST );
|
||||||
$cmb->save_fields( $post_id, 'post', $sanitized_values );
|
$cmb->save_fields( $post_id, 'post', $sanitized_values );
|
||||||
@ -487,59 +499,64 @@ 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 ) {
|
foreach ( $_POST[ $prefix . 'featured_image' ] as $key => $value ) {
|
||||||
set_post_thumbnail( $post_id, $key );
|
set_post_thumbnail( $post_id, $key );
|
||||||
}
|
}
|
||||||
unset( $_POST[ $prefix . 'featured_image' ] );
|
unset( $_POST[ $prefix . 'featured_image' ] );
|
||||||
} else {
|
} else {
|
||||||
delete_post_thumbnail( $post_id );
|
delete_post_thumbnail( $post_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove meta field;
|
// Remove meta field.
|
||||||
update_post_meta( $post_id, $prefix . 'featured_image', null );
|
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
|
//redirect
|
||||||
$_SESSION['messages'][] = [ 'success', esc_html__( 'Property has been successfully updated.', 'opalestate-pro' ) ];
|
$_SESSION['messages'][] = [ 'success', esc_html__( 'Property has been successfully updated.', 'opalestate-pro' ) ];
|
||||||
|
|
||||||
do_action( "opalestate_process_submission_after", $user_id, $post_id, $edit );
|
do_action( "opalestate_process_submission_after", $user_id, $post_id, $edit );
|
||||||
|
|
||||||
if ( $edit ) {
|
if ( $edit ) {
|
||||||
$type = OpalEstate()->session->set( 'submission' , 'edit' );
|
$type = OpalEstate()->session->set( 'submission', 'edit' );
|
||||||
$message = esc_html__('The property has updated completed with new information', 'opalestate-pro' );
|
$message = esc_html__( 'The property has updated completed with new information', 'opalestate-pro' );
|
||||||
do_action( "opalestate_processed_edit_submission", $user_id, $post_id );
|
do_action( "opalestate_processed_edit_submission", $user_id, $post_id );
|
||||||
} else {
|
} else {
|
||||||
$type = OpalEstate()->session->get( 'submission' , 'addnew' );
|
$type = OpalEstate()->session->get( 'submission', 'addnew' );
|
||||||
$message = esc_html__('You have submitted the property successful', 'opalestate-pro' );
|
$message = esc_html__( 'You have submitted the property successful', 'opalestate-pro' );
|
||||||
do_action( "opalestate_processed_new_submission", $user_id, $post_id );
|
do_action( "opalestate_processed_new_submission", $user_id, $post_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
// set ready of attachment for use.
|
// set ready of attachment for use.
|
||||||
if( $this->new_attachmenet_ids ){
|
if ( $this->new_attachmenet_ids ) {
|
||||||
foreach ( $this->new_attachmenet_ids as $_id ) {
|
foreach ( $this->new_attachmenet_ids as $_id ) {
|
||||||
delete_post_meta( $_id, '_pending_to_use_', 1 );
|
delete_post_meta( $_id, '_pending_to_use_', 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
return opalestate_output_msg_json( true,
|
return opalestate_output_msg_json( true,
|
||||||
$message,
|
$message,
|
||||||
array(
|
[
|
||||||
'heading' => esc_html__('Submission Information' ,'opalestate-pro'),
|
'heading' => esc_html__( 'Submission Information', 'opalestate-pro' ),
|
||||||
'redirect' => opalestate_submssion_page( $post_id, array('do' => 'completed') )
|
'redirect' => opalestate_submssion_page( $post_id, [ 'do' => 'completed' ] ),
|
||||||
)) ;
|
] );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return opalestate_output_msg_json( fales,
|
return opalestate_output_msg_json( fales,
|
||||||
__('Currently, your account was blocked, please keep contact admin to resolve this!.', 'opalestate-pro' ),
|
__( 'Currently, your account was blocked, please keep contact admin to resolve this!.', 'opalestate-pro' ),
|
||||||
array('heading' => esc_html__('Submission Information' ,'opalestate-pro') )
|
[ 'heading' => esc_html__( 'Submission Information', 'opalestate-pro' ) ]
|
||||||
) ;
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return opalestate_output_msg_json( fales,
|
return opalestate_output_msg_json( fales,
|
||||||
__('Sorry! Your submitted datcould not save a at this time', 'opalestate-pro' ),
|
__( 'Sorry! Your submitted datcould not save a at this time', 'opalestate-pro' ),
|
||||||
array('heading' => esc_html__('Submission Information', 'opalestate-pro') )
|
[ 'heading' => esc_html__( 'Submission Information', 'opalestate-pro' ) ]
|
||||||
) ;
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,57 +564,57 @@ class OpalEstate_Submission {
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private function get_field_name( $field ){
|
private function get_field_name( $field ) {
|
||||||
return OPALESTATE_PROPERTY_PREFIX.$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
|
//upload images for featured and gallery images
|
||||||
if( isset($_FILES) && !empty($_FILES) ){
|
if ( isset( $_FILES ) && ! empty( $_FILES ) ) {
|
||||||
|
|
||||||
///
|
///
|
||||||
$fields = array(
|
$fields = [
|
||||||
$this->get_field_name('gallery'),
|
$this->get_field_name( 'gallery' ),
|
||||||
$this->get_field_name('featured_image'),
|
$this->get_field_name( 'featured_image' ),
|
||||||
);
|
];
|
||||||
|
|
||||||
foreach( $_FILES as $key => $value ) {
|
foreach ( $_FILES as $key => $value ) {
|
||||||
// allow processing in fixed collection
|
// allow processing in fixed collection
|
||||||
if( in_array($key, $fields) ){
|
if ( in_array( $key, $fields ) ) {
|
||||||
$ufile = $_FILES[$key];
|
$ufile = $_FILES[ $key ];
|
||||||
|
|
||||||
/// /////
|
/// /////
|
||||||
if( isset( $ufile['name'] ) && is_array( $ufile['name'] ) ){
|
if ( isset( $ufile['name'] ) && is_array( $ufile['name'] ) ) {
|
||||||
$output = array();
|
$output = [];
|
||||||
|
|
||||||
foreach ( $ufile['name'] as $f_key => $f_value ) {
|
foreach ( $ufile['name'] as $f_key => $f_value ) {
|
||||||
$loop_file = array(
|
$loop_file = [
|
||||||
'name' => $ufile['name'][$f_key],
|
'name' => $ufile['name'][ $f_key ],
|
||||||
'type' => $ufile['type'][$f_key],
|
'type' => $ufile['type'][ $f_key ],
|
||||||
'tmp_name' => $ufile['tmp_name'][$f_key],
|
'tmp_name' => $ufile['tmp_name'][ $f_key ],
|
||||||
'error' => $ufile['error'][$f_key],
|
'error' => $ufile['error'][ $f_key ],
|
||||||
'size' => $ufile['size'][$f_key]
|
'size' => $ufile['size'][ $f_key ],
|
||||||
);
|
];
|
||||||
$new_atm = $this->upload_image( $loop_file, $post_id );
|
$new_atm = $this->upload_image( $loop_file, $post_id );
|
||||||
if( $new_atm ){
|
if ( $new_atm ) {
|
||||||
$_POST[$key] = isset($_POST[$key]) ? $_POST[$key] : array();
|
$_POST[ $key ] = isset( $_POST[ $key ] ) ? $_POST[ $key ] : [];
|
||||||
$_POST[$key][$new_atm['attachment_id']] = $new_atm['url'];
|
$_POST[ $key ][ $new_atm['attachment_id'] ] = $new_atm['url'];
|
||||||
$this->new_attachmenet_ids[$new_atm['attachment_id']] = $new_atm['attachment_id'];
|
$this->new_attachmenet_ids[ $new_atm['attachment_id'] ] = $new_atm['attachment_id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} ///
|
||||||
///
|
elseif ( isset( $ufile['name'] ) ) {
|
||||||
elseif( isset($ufile['name']) ) {
|
|
||||||
$new_atm = $this->upload_image( $ufile, $post_id );
|
$new_atm = $this->upload_image( $ufile, $post_id );
|
||||||
if( $new_atm ){
|
if ( $new_atm ) {
|
||||||
$_POST[$key][$new_atm['attachment_id']] = $new_atm['url'];
|
$_POST[ $key ][ $new_atm['attachment_id'] ] = $new_atm['url'];
|
||||||
$this->new_attachmenet_ids[$new_atm['attachment_id']] = $new_atm['attachment_id'];
|
$this->new_attachmenet_ids[ $new_atm['attachment_id'] ] = $new_atm['attachment_id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//// / //
|
//// / //
|
||||||
@ -605,34 +622,32 @@ class OpalEstate_Submission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for group files
|
// for group files
|
||||||
$fields = array(
|
$fields = [
|
||||||
$this->get_field_name('public_floor_group')
|
$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) ){
|
foreach ( $f_value as $u_key => $u_v ) {
|
||||||
$ufile = $_FILES[$key];
|
$loop_file = [
|
||||||
|
'name' => $ufile['name'][ $f_key ][ $u_key ],
|
||||||
if( isset( $ufile['name'] ) && is_array( $ufile['name'] ) ){
|
'type' => $ufile['type'][ $f_key ][ $u_key ],
|
||||||
$output = array();
|
'tmp_name' => $ufile['tmp_name'][ $f_key ][ $u_key ],
|
||||||
foreach ( $ufile['name'] as $f_key => $f_value ) {
|
'error' => $ufile['error'][ $f_key ][ $u_key ],
|
||||||
|
'size' => $ufile['size'][ $f_key ][ $u_key ],
|
||||||
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 );
|
$new_atm = $this->upload_image( $loop_file, $post_id );
|
||||||
if( $new_atm ){
|
if ( $new_atm ) {
|
||||||
|
|
||||||
$_POST[$key][$f_key][$u_key] = $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'];
|
$this->new_attachmenet_ids[ $new_atm['attachment_id'] ] = $new_atm['attachment_id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -642,11 +657,10 @@ class OpalEstate_Submission {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process upload images for properties
|
* 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 );
|
return opalesate_upload_image( $submitted_file, $parent_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,27 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
$post_id = intval( $_GET['id'] );
|
$post_id = intval( $_GET['id'] );
|
||||||
$post = get_post( $post_id );
|
$post = get_post( $post_id );
|
||||||
$type = OpalEstate()->session->get( 'submission' );
|
$type = OpalEstate()->session->get( 'submission' );
|
||||||
?>
|
?>
|
||||||
<div class="opalestate-box-completed alert alert-success">
|
<div class="opalestate-box-completed alert alert-success">
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<?php if( $type == 'addnew' ): ?>
|
<?php if ( $type == 'addnew' ): ?>
|
||||||
<div class="addnew-msg">
|
<div class="addnew-msg">
|
||||||
<h5><?php echo esc_html__('Thanks for your submission, it takes some time to review the property.'); ?></h5>
|
<?php if ( 'on' != opalestate_get_option( 'admin_approve', 'on' ) ) : ?>
|
||||||
<?php echo sprintf( esc_html__( 'Click to %s here %s to back to your listing or %s edit %s this.', 'opalestate-pro'),
|
<h5><?php esc_html_e( 'Thanks for your submission, your property is published.', 'opalestate-pro' ); ?></h5>
|
||||||
'<a href="'.opalestate_submssion_list_page().'">', '</a>',
|
<?php else : ?>
|
||||||
'<a href="'.opalestate_submssion_page( $post_id ).'">', '</a>'
|
<h5><?php esc_html_e( 'Thanks for your submission, it takes some time to review the property.', 'opalestate-pro' ); ?></h5>
|
||||||
); ?>
|
<?php endif; ?>
|
||||||
</div>
|
|
||||||
|
<?php echo sprintf( esc_html__( 'Click to %s here %s to back to your listing or %s edit %s this.', 'opalestate-pro' ),
|
||||||
|
'<a href="' . opalestate_submssion_list_page() . '">', '</a>',
|
||||||
|
'<a href="' . opalestate_submssion_page( $post_id ) . '">', '</a>'
|
||||||
|
); ?>
|
||||||
|
</div>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<div class="edit-msg">
|
<div class="edit-msg">
|
||||||
<?php echo esc_html__('Your property is completed success.'); ?>
|
<?php esc_html_e( 'Your property is completed success.', 'opalestate-pro' ); ?>
|
||||||
<?php echo sprintf( esc_html__( 'Click to %s here %s to back to your listing or %s edit %s this.', 'opalestate-pro'),
|
<?php echo sprintf( esc_html__( 'Click to %s here %s to back to your listing or %s edit %s this.', 'opalestate-pro' ),
|
||||||
'<a href="'.opalestate_submssion_list_page().'">', '</a>',
|
'<a href="' . opalestate_submssion_list_page() . '">', '</a>',
|
||||||
'<a href="'.opalestate_submssion_page( $post_id ).'">', '</a>'
|
'<a href="' . opalestate_submssion_page( $post_id ) . '">', '</a>'
|
||||||
); ?>
|
); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php OpalEstate()->session->set( 'submission', null ); ?>
|
<?php OpalEstate()->session->set( 'submission', null ); ?>
|
Loading…
Reference in New Issue
Block a user