From 56e6f75efbfbbf4614d64b346156bbac84992fa7 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Wed, 30 Oct 2019 13:16:24 +0700 Subject: [PATCH 01/10] Update readme.txt --- readme.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 464aa3a9..d299637e 100755 --- a/readme.txt +++ b/readme.txt @@ -1,5 +1,5 @@ === Opal Estate Pro - Property Management and Submission === -Contributors: wpopal, ndoublehwp +Contributors: wpopal Donate link: https://wpdocs.gitbook.io/opal-estate/ Tags: estate, property, opalestate, house for rent, agency for lease, estate submission, agents estate property, property marketplace Requires at least: 4.6 @@ -120,6 +120,7 @@ The plugin will not make you disappointed with ease of use, friendly & flexible = WHAT IS NEW IN PRO VERSION = * Suport API use to develop great web app and mobile app . * Agency Agency and allow edit profile with user having Opal Estate Agency Role. Display Properties and members of agency +* Implement Google Map with custom styles. * Implement Google Capcha for all Email Form * Implement Saved Search Form allowing user save theirs result as loved collection. They are managed with Saved Search Menu of user dashboard * Supported Widgets working with Elementor page builder From 5af63726c31085d8b3b8486093a4920db15af17e Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 31 Oct 2019 10:58:21 +0700 Subject: [PATCH 02/10] Fix order settings. --- inc/admin/settings/property.php | 6 +++--- inc/property/class-metabox-property-admin.php | 19 ++++++++----------- inc/property/class-opalestate-search.php | 4 ++++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/inc/admin/settings/property.php b/inc/admin/settings/property.php index 2f067503..3ab8aeba 100755 --- a/inc/admin/settings/property.php +++ b/inc/admin/settings/property.php @@ -168,10 +168,10 @@ class Opalestate_Settings_Property_Tab extends Opalestate_Settings_Base_Tab { 'desc' => esc_html__( 'Show featured first in page result, as default Newest is showed', 'opalestate-pro' ), 'type' => 'switch', 'options' => [ - 0 => esc_html__( 'Disable', 'opalestate-pro' ), - 1 => esc_html__( 'Enable', 'opalestate-pro' ), + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), ], - 'default' => 0, + 'default' => 'off', ]; $fields[] = [ 'name' => esc_html__( 'Minimum of Search Price', 'opalestate-pro' ), diff --git a/inc/property/class-metabox-property-admin.php b/inc/property/class-metabox-property-admin.php index d7ab80e1..a791201e 100755 --- a/inc/property/class-metabox-property-admin.php +++ b/inc/property/class-metabox-property-admin.php @@ -177,10 +177,10 @@ class Opalestate_Property_MetaBox { 'id' => $prefix . 'featured', 'type' => 'switch', 'options' => [ - 0 => esc_html__( 'No', 'opalestate-pro' ), - 1 => esc_html__( 'Yes', 'opalestate-pro' ), + 'on' => esc_html__( 'Yes', 'opalestate-pro' ), + 'off' => esc_html__( 'No', 'opalestate-pro' ), ], - 'default' => 0, + 'default' => 'off', ], [ 'name' => esc_html__( 'Property SKU', 'opalestate-pro' ), @@ -206,17 +206,14 @@ class Opalestate_Property_MetaBox { 'id' => $prefix . 'enablemapview', 'type' => 'switch', 'options' => [ - 1 => esc_html__( 'Yes', 'opalestate-pro' ), - 0 => esc_html__( 'No', 'opalestate-pro' ), + 'on' => esc_html__( 'Yes', 'opalestate-pro' ), + 'off' => esc_html__( 'No', 'opalestate-pro' ), ], ], [ 'name' => esc_html__( 'Address', 'opalestate-pro' ), 'id' => $prefix . 'address', 'type' => 'textarea_small', - 'attributes' => [ - 'required' => 'required', - ], ], [ 'id' => "{$prefix}video", @@ -270,10 +267,10 @@ class Opalestate_Property_MetaBox { 'id' => $prefix . 'price_oncall', 'type' => 'switch', 'options' => [ - 0 => esc_html__( 'No', 'opalestate-pro' ), - 1 => esc_html__( 'Yes', 'opalestate-pro' ), + 'on' => esc_html__( 'Yes', 'opalestate-pro' ), + 'off' => esc_html__( 'No', 'opalestate-pro' ), ], - 'default' => 0, + 'default' => 'off', ], ]; diff --git a/inc/property/class-opalestate-search.php b/inc/property/class-opalestate-search.php index e29810d1..f1ce4341 100755 --- a/inc/property/class-opalestate-search.php +++ b/inc/property/class-opalestate-search.php @@ -245,6 +245,10 @@ class OpalEstate_Search { $args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . $ksearchs[0]; $args['orderby'] = 'meta_value_num'; $args['order'] = $ksearchs[1]; + } elseif ( 'on' == opalestate_options( 'show_featured_first', 'off' ) ) { + $args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . 'featured'; + $args['orderby'] = 'meta_value_num'; + $args['order'] = 'DESC'; } $metas = Opalestate_Property_MetaBox::metaboxes_info_fields(); From 934e0e87f0f4e9b9ed47074a3608490544d304c7 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 31 Oct 2019 12:20:32 +0700 Subject: [PATCH 03/10] Update order by --- inc/property/class-opalestate-property.php | 11 +++++------ inc/property/class-opalestate-search.php | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/inc/property/class-opalestate-property.php b/inc/property/class-opalestate-property.php index a5a302e0..f3b498fc 100755 --- a/inc/property/class-opalestate-property.php +++ b/inc/property/class-opalestate-property.php @@ -207,10 +207,10 @@ class Opalestate_Property { } /** - * + * Is featured? */ public function is_featured() { - return 'on' === $this->featured; + return ( 'on' === $this->featured ) || ( 1 == $this->featured ); } /** @@ -315,7 +315,7 @@ class Opalestate_Property { } /** - * + * Get location. */ public function get_locations() { $terms = wp_get_post_terms( $this->post_id, 'opalestate_location' ); @@ -515,7 +515,7 @@ class Opalestate_Property { * @access public * @param $key * @param $single - * @return string + * @return string|array */ public function get_metabox_value( $key, $single = true ) { return get_post_meta( $this->post_id, OPALESTATE_PROPERTY_PREFIX . $key, $single ); @@ -579,7 +579,7 @@ class Opalestate_Property { * @return array */ public function get_gallery() { - return $this->get_metabox_value( 'gallery', true ); + return $this->get_metabox_value( 'gallery' ); } /** @@ -677,7 +677,6 @@ class Opalestate_Property { return $this->get_metabox_value( 'attachments' ); } - public function get_content_single_layout() { return $this->get_metabox_value( 'layout' ); } diff --git a/inc/property/class-opalestate-search.php b/inc/property/class-opalestate-search.php index f1ce4341..9f6365e5 100755 --- a/inc/property/class-opalestate-search.php +++ b/inc/property/class-opalestate-search.php @@ -243,11 +243,11 @@ class OpalEstate_Search { if ( ! empty( $ksearchs ) && count( $ksearchs ) == 2 ) { $args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . $ksearchs[0]; - $args['orderby'] = 'meta_value_num'; + $args['orderby'] = 'meta_value'; $args['order'] = $ksearchs[1]; } elseif ( 'on' == opalestate_options( 'show_featured_first', 'off' ) ) { $args['meta_key'] = OPALESTATE_PROPERTY_PREFIX . 'featured'; - $args['orderby'] = 'meta_value_num'; + $args['orderby'] = 'meta_value'; $args['order'] = 'DESC'; } From a1e0f7b4ab8aad7f463013e4e302906cefee820f Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 31 Oct 2019 14:04:01 +0700 Subject: [PATCH 04/10] Fix thumbnail size when submission. --- templates/single-property/preview.php | 5 +++-- templates/single-property/preview/gallery-slider.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/templates/single-property/preview.php b/templates/single-property/preview.php index 45016f78..bd4d5c36 100755 --- a/templates/single-property/preview.php +++ b/templates/single-property/preview.php @@ -3,6 +3,7 @@ global $property; $galleries = $property->get_gallery(); $image_size = opalestate_get_option( 'opalestate_thumbnail_size', 'medium' ); + if ( isset( $galleries ) && $galleries ): ?> - + $src ): ?>
- gallery + gallery
diff --git a/templates/single-property/preview/gallery-slider.php b/templates/single-property/preview/gallery-slider.php index 03cb3882..2671e552 100755 --- a/templates/single-property/preview/gallery-slider.php +++ b/templates/single-property/preview/gallery-slider.php @@ -36,8 +36,8 @@ - -
gallery
+ $src ): ?> +
gallery
From 8d86aa767db201c2d81f6762a41fdd7b1d40543d Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 31 Oct 2019 14:11:53 +0700 Subject: [PATCH 05/10] Fix single image size. --- templates/single-property/preview.php | 17 +++++++++-------- .../single-property/preview/gallery-slider.php | 8 ++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/templates/single-property/preview.php b/templates/single-property/preview.php index bd4d5c36..71e0591b 100755 --- a/templates/single-property/preview.php +++ b/templates/single-property/preview.php @@ -1,8 +1,9 @@
get_gallery(); - $image_size = opalestate_get_option( 'opalestate_thumbnail_size', 'medium' ); + $galleries = $property->get_gallery(); + $thumb_image_size = opalestate_get_option( 'opalestate_thumbnail_size', 'medium' ); + $single_image_size = opalestate_get_option( 'featured_image_size', 'full' ); if ( isset( $galleries ) && $galleries ): ?> @@ -46,13 +47,13 @@
' + 'name' => esc_html__( 'Postal Code / Zip', 'opalestate-pro' ), + 'id' => $prefix . 'zipcode', + 'type' => 'text', + 'after_row' => '

', ], [ @@ -387,10 +383,10 @@ class Opalestate_Property_MetaBox_Submission { ], ], [ - 'name' => esc_html__( 'Google Map View', 'opalestate-pro' ), - 'id' => $prefix . 'enablemapview', - 'type' => 'switch', - 'options' => [ + 'name' => esc_html__( 'Google Map View', 'opalestate-pro' ), + 'id' => $prefix . 'enablemapview', + 'type' => 'switch', + 'options' => [ 0 => esc_html__( 'No', 'opalestate-pro' ), 1 => esc_html__( 'Yes', 'opalestate-pro' ), ], @@ -414,13 +410,13 @@ class Opalestate_Property_MetaBox_Submission { $prefix = OPALESTATE_PROPERTY_PREFIX; $fields = [ [ - 'name' => esc_html__( 'Amenities', 'opalestate-pro' ), - 'id' => $prefix . 'amenity', - 'type' => 'taxonomy_multicheck', - 'before_row' => '
', - 'after_row' => '
', - 'taxonomy' => 'opalestate_amenities', + 'name' => esc_html__( 'Amenities', 'opalestate-pro' ), + 'id' => $prefix . 'amenity', + 'type' => 'taxonomy_multicheck', + 'before_row' => '
', + 'after_row' => '
', + 'taxonomy' => 'opalestate_amenities', 'render_row_cb' => [ $this, 'amenities_html_callback' ], ], ]; @@ -437,7 +433,7 @@ class Opalestate_Property_MetaBox_Submission { 'type' => 'group', 'before_group' => '
', 'after_group' => '
', + 'opalestate-pro' ) . '', 'fields' => [ [ 'id' => $prefix . 'public_facilities_key', @@ -480,7 +476,7 @@ class Opalestate_Property_MetaBox_Submission { 'id' => $prefix . 'apartments', 'type' => 'group', 'after_group' => '', + 'opalestate-pro' ) . '', 'fields' => [ [ 'id' => $prefix . 'apartment_plot', @@ -489,7 +485,7 @@ class Opalestate_Property_MetaBox_Submission { 'type' => 'text', ], - + [ 'id' => $prefix . 'apartment_beds', 'name' => esc_html__( 'Beds', 'opalestate-pro' ), @@ -590,11 +586,11 @@ class Opalestate_Property_MetaBox_Submission { 'type' => 'textarea_small', ], [ - 'id' => "{$prefix}floor_image_id", - 'name' => esc_html__( 'Image Preview', 'opalestate-pro' ), - 'type' => 'uploader', - 'single' => 1, - + 'id' => "{$prefix}floor_image_id", + 'name' => esc_html__( 'Image Preview', 'opalestate-pro' ), + 'type' => 'uploader', + 'single' => 1, + 'query_args' => [ 'type' => [ 'image/gif', @@ -625,8 +621,8 @@ class Opalestate_Property_MetaBox_Submission { /** * Manually render a field column display. * - * @param array $field_args Array of field arguments. - * @param CMB2_Field $field The field object + * @param array $field_args Array of field arguments. + * @param CMB2_Field $field The field object */ public function amenities_html_callback( $field_args, $field ) { $id = $field->args( 'id' ); @@ -646,34 +642,34 @@ class Opalestate_Property_MetaBox_Submission { return; } ?> -
-
-
- -
+
+
+
+ +
-
-
    +
    +
      $amenity ) : ?> -
    • - -
    • + + -
    • + + -
    -
    -
- - -
+ +
+
+ + +
[ + 'submission' => [ 'code' => 'submission', 'label' => esc_html__( 'Submission Form', 'opalestate-pro' ), ], - 'submission_list' => [ + 'submission_list' => [ 'code' => 'submission_list', 'label' => esc_html__( 'My Properties', 'opalestate-pro' ), - ] + ], ]; foreach ( $shortcodes as $shortcode ) { @@ -107,7 +107,7 @@ class OpalEstate_Submission { * Is submission page. 'submission_page' option in General Setting */ 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; } @@ -145,23 +145,20 @@ class OpalEstate_Submission { 'type' => 'select', 'default' => '', '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' ), ], ], [ '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', - 'type' => 'checkbox', - ], - [ - 'name' => esc_html__( 'Enable Require Price', 'opalestate-pro' ), - 'desc' => esc_html__( 'Enable or Disable require user enter price and price label.', 'opalestate-pro' ), - 'id' => 'require_input_price', - 'type' => 'checkbox', - + 'type' => 'switch', + 'options' => [ + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], ], [ 'name' => esc_html__( 'Submission Tab Settings', 'opalestate-pro' ), @@ -240,6 +237,30 @@ class OpalEstate_Submission { 'off' => esc_html__( 'Disable', 'opalestate-pro' ), ], ], + [ + 'name' => esc_html__( 'Submission Settings', 'opalestate-pro' ), + 'id' => 'opalestate_title_submission_settings', + 'type' => 'title', + 'before_row' => '
', + 'after_row' => '
', + ], + [ + '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 */ public function render_button_edit() { - global $post, $current_user; + wp_get_current_user(); if ( $current_user->ID == $post->post_author ) { @@ -281,13 +302,12 @@ class OpalEstate_Submission { return opalestate_get_option( 'submission_page' ) == $post->ID; } - /** + * Register metabox. * - * + * @return \Opalestate_Property_MetaBox_Submission */ public function register_metabox() { - $metabox = new Opalestate_Property_MetaBox_Submission(); add_filter( 'cmb2_meta_boxes', [ $metabox, 'register_form' ], 9999 ); @@ -299,32 +319,30 @@ class OpalEstate_Submission { * FrontEnd Submission */ public function submission() { - global $current_user; if ( ! is_user_logged_in() ) { echo opalestate_load_template_path( 'submission/require-login' ); - if( empty(opalestate_get_option("submission_show_content")) ){ - return ""; + if ( empty( opalestate_get_option( "submission_show_content" ) ) ) { + return ""; } } - if( isset($_GET['do']) && $_GET['do'] == 'completed' ){ - + if ( isset( $_GET['do'] ) && $_GET['do'] == 'completed' ) { OpalEstate()->session->set( 'submission', 'addnew' ); echo opalestate_load_template_path( 'submission/completed' ); - return ; + + return; } // remove all dirty images before edit/create new a property - $this->cleanup(); + $this->cleanup(); wp_enqueue_script( 'opalestate-submission' ); wp_enqueue_style( 'opalesate-submission' ); wp_enqueue_style( 'opalesate-cmb2-front' ); - $metabox = $this->register_metabox(); $metaboxes = apply_filters( 'cmb2_meta_boxes', [] ); @@ -333,8 +351,8 @@ class OpalEstate_Submission { return esc_html__( 'A metabox with the specified \'metabox_id\' doesn\'t exist.', 'opalestate-pro' ); } $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 // We need to remove all data before. $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 ) ) { echo opalestate_load_template_path( 'parts/has-warning' ); - return ; + return; } } + return opalestate_load_template_path( 'submission/submission-form', [ 'post_id' => $post_id, @@ -369,6 +388,7 @@ class OpalEstate_Submission { */ public function cmb2_get_metabox() { $object_id = 'fake-oject-id'; + return cmb2_get_metabox( OPALESTATE_PROPERTY_PREFIX . 'front', $object_id ); } @@ -380,35 +400,28 @@ class OpalEstate_Submission { if ( isset( $_POST['submission_action'] ) && ! empty( $_POST['submission_action'] ) ) { if ( wp_verify_nonce( $_POST['submission_action'], 'submitted-property' ) ) { - + $user_id = get_current_user_id(); $edit = false; - $prefix = OPALESTATE_PROPERTY_PREFIX; + $prefix = OPALESTATE_PROPERTY_PREFIX; $blocked = OpalEstate_User::is_blocked(); - + // Setup and sanitize data if ( isset( $_POST[ $prefix . 'title' ] ) && ! $blocked && $user_id ) { - $metabox = $this->register_metabox(); $metaboxes = apply_filters( 'cmb2_meta_boxes', [] ); - - - $post_id = ! empty( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : false; - if( $post_id ){ + if ( $post_id ) { do_action( 'opalestate_process_edit_submission_before' ); } else { do_action( 'opalestate_process_submission_before' ); } - - - $review_before = opalestate_get_option( 'admin_approve' ); $post_status = 'pending'; - if ( ! $review_before ) { + if ( 'on' != opalestate_get_option( 'admin_approve', 'on' ) ) { $post_status = 'publish'; } @@ -424,8 +437,7 @@ class OpalEstate_Submission { $post_content = isset( $_POST[ $prefix . 'text' ] ) ? wp_kses( $_POST[ $prefix . 'text' ], '

' ) : ''; - - $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 ); ?> From 2b89a8ffb604de95d9f1442067c3b8ad33aa4fa4 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 31 Oct 2019 15:37:37 +0700 Subject: [PATCH 07/10] Update class-opalestate-submission.php --- .../class-opalestate-submission.php | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/inc/submission/class-opalestate-submission.php b/inc/submission/class-opalestate-submission.php index 20564fd7..aaf9b87d 100755 --- a/inc/submission/class-opalestate-submission.php +++ b/inc/submission/class-opalestate-submission.php @@ -129,7 +129,7 @@ class OpalEstate_Submission { ], [ 'name' => esc_html__( 'Property Submission Page', 'opalestate-pro' ), - 'desc' => esc_html__( 'This is the submission page. The [opalestate_submission] shortcode should be on this page.', 'opalestate-pro' ), + 'desc' => __( 'This is the submission page. The [opalestate_submission] shortcode should be on this page.', 'opalestate-pro' ), 'id' => 'submission_page', 'type' => 'select', 'options' => opalestate_cmb2_get_post_options( [ @@ -137,10 +137,9 @@ class OpalEstate_Submission { 'numberposts' => -1, ] ), ], - [ 'name' => esc_html__( 'Show Content Use Not Login', 'opalestate-pro' ), - 'desc' => esc_html__( 'Show Login/Register form and submission form if user not logined', 'opalestate-pro' ), + 'desc' => esc_html__( 'Show Login/Register form and submission form if the user is not logged in.', 'opalestate-pro' ), 'id' => 'submission_show_content', 'type' => 'select', 'default' => '', @@ -149,16 +148,16 @@ class OpalEstate_Submission { 'login_submission' => esc_html__( 'Show Login Form and Submission Form', 'opalestate-pro' ), ], ], - [ - 'name' => esc_html__( 'Enable Admin Approve', 'opalestate-pro' ), - 'desc' => esc_html__( 'Admin must review and approve before properties are published.', 'opalestate-pro' ), - 'id' => 'admin_approve', - 'type' => 'switch', + 'name' => esc_html__( 'Enable Admin Approve', 'opalestate-pro' ), + 'desc' => esc_html__( 'Admin must review and approve before properties are published.', 'opalestate-pro' ), + 'id' => 'admin_approve', + 'type' => 'switch', 'options' => [ 'on' => esc_html__( 'Enable', 'opalestate-pro' ), 'off' => esc_html__( 'Disable', 'opalestate-pro' ), ], + 'default' => 'on', ], [ 'name' => esc_html__( 'Submission Tab Settings', 'opalestate-pro' ), @@ -255,11 +254,11 @@ class OpalEstate_Submission { ], ], [ - 'name' => esc_html__( 'Property SKU prefix', 'opalestate-pro' ), - 'desc' => esc_html__( 'Prefix for property SKU.', 'opalestate-pro' ), - 'id' => 'submission_sku_prefix', + 'name' => esc_html__( 'Property SKU format', 'opalestate-pro' ), + 'desc' => __( 'Use {property_id} to generate the property ID.', 'opalestate-pro' ), + 'id' => 'submission_sku_format', 'type' => 'text', - 'default' => 'SKU', + 'default' => 'SKU-{property_id}', ], ] ), @@ -370,6 +369,7 @@ class OpalEstate_Submission { if ( $post_id && ! opalestate_is_own_property( $post_id, $current_user->ID ) ) { echo opalestate_load_template_path( 'parts/has-warning' ); + return; } } @@ -512,7 +512,8 @@ class OpalEstate_Submission { // 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 ) ); + $_sku = str_replace( '{property_id}', $post_id, opalestate_options( 'submission_sku_format', 'SKU-{property_id}' ) ); + $sku_generated = apply_filters( 'opalestate_submission_sku_generated', sanitize_text_field( $_sku ) ); update_post_meta( $post_id, $prefix . 'sku', $sku_generated ); } From fcf1a025338e49d35d32ef90fbdc29ca15c2eb78 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 31 Oct 2019 16:06:36 +0700 Subject: [PATCH 08/10] Add Request viewing settings. --- inc/admin/settings/property.php | 12 ++++++++++++ inc/class-opalestate-install.php | 1 + inc/template-hook-functions.php | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/inc/admin/settings/property.php b/inc/admin/settings/property.php index 3ab8aeba..e0205432 100755 --- a/inc/admin/settings/property.php +++ b/inc/admin/settings/property.php @@ -334,6 +334,18 @@ class Opalestate_Settings_Property_Tab extends Opalestate_Settings_Base_Tab { private function get_subtab_detail_fields() { $fields = []; + $fields[] = [ + 'name' => esc_html__( 'Enable Request Viewing', 'opalestate-pro' ), + 'desc' => esc_html__( 'Enable Request Viewing feature in the single property page.', 'opalestate-pro' ), + 'id' => 'enable_single_request_viewing', + 'type' => 'switch', + 'options' => [ + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], + 'default' => 'on', + ]; + $fields[] = [ 'name' => esc_html__( 'Show Amenities tab', 'opalestate-pro' ), 'desc' => esc_html__( 'Show Amenities tab in the single property page.', 'opalestate-pro' ), diff --git a/inc/class-opalestate-install.php b/inc/class-opalestate-install.php index 19768a24..bed36653 100755 --- a/inc/class-opalestate-install.php +++ b/inc/class-opalestate-install.php @@ -108,6 +108,7 @@ class Opalestate_Install { $options[ OPALESTATE_PROPERTY_PREFIX . 'areasize_opt_v' ] = 'on'; $options[ OPALESTATE_PROPERTY_PREFIX . 'price_opt_v' ] = 'on'; + $options['enable_single_request_viewing'] = 'on'; $options['enable_single_amenities'] = 'on'; $options['enable_single_facilities'] = 'on'; $options['enable_single_attachments'] = 'on'; diff --git a/inc/template-hook-functions.php b/inc/template-hook-functions.php index fd938f55..6d15ae61 100755 --- a/inc/template-hook-functions.php +++ b/inc/template-hook-functions.php @@ -218,6 +218,10 @@ add_action( 'opalestate_single_property_preview', 'opalestate_property_preview', function opalestate_property_request_viewing_button( $islink = false ) { + if ( 'on' != opalestate_get_option( 'enable_single_request_viewing', 'on' ) ) { + return; + } + $class = $islink ? 'btn-link' : 'btn btn-primary'; if ( ! is_user_logged_in() ) { $class .= ' opalestate-need-login'; @@ -260,6 +264,10 @@ add_action( 'opalestate_single_property_layout', 'opalestate_single_property_lay * Forms */ function opalestate_property_request_view_form() { + if ( 'on' != opalestate_get_option( 'enable_single_request_viewing', 'on' ) ) { + return; + } + if ( ! is_user_logged_in() ) { return; } From d36b238ab450d87055105c6b550e742b27891ac5 Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 31 Oct 2019 16:24:23 +0700 Subject: [PATCH 09/10] Tag 1.1.8 --- opal-estate-pro.php | 6 +++--- readme.txt | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/opal-estate-pro.php b/opal-estate-pro.php index 58c2aed4..f316602f 100755 --- a/opal-estate-pro.php +++ b/opal-estate-pro.php @@ -3,7 +3,7 @@ * Plugin Name: Opal Estate Pro * Plugin URI: https://wpdocs.gitbook.io/opal-estate/ * Description: Opal Real Estate Plugin is an ideal solution and brilliant choice for you to set up a professional estate website. - * Version: 1.1.7 + * Version: 1.1.8 * Author: WPOPAL * Author URI: http://www.wpopal.com * Requires at least: 4.6 @@ -151,7 +151,7 @@ if ( ! class_exists( 'OpalEstate' ) ) { */ public function __clone() { // Cloning instances of the class is forbidden - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.1.7' ); + _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'opalestate-pro' ), '1.1.8' ); } /** @@ -160,7 +160,7 @@ if ( ! class_exists( 'OpalEstate' ) ) { public function setup_constants() { // Plugin version if ( ! defined( 'OPALESTATE_VERSION' ) ) { - define( 'OPALESTATE_VERSION', '1.1.7' ); + define( 'OPALESTATE_VERSION', '1.1.8' ); } // Plugin Folder Path diff --git a/readme.txt b/readme.txt index d299637e..fc8b8727 100755 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://wpdocs.gitbook.io/opal-estate/ Tags: estate, property, opalestate, house for rent, agency for lease, estate submission, agents estate property, property marketplace Requires at least: 4.6 Tested up to: 5.2.3 -Stable tag: 1.1.7 +Stable tag: 1.1.8 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -156,6 +156,12 @@ This section describes how to install the plugin and get it working. * System tickets support 24/7 available : [free support](https://wpopal.ticksy.com/ "Visit the Plugin support Page") == Changelog == += 1.1.8 - 2019-10-31 = +* Fixes - Submission settings. +* Added - Automatic generate property SKU. +* Added - Enable/Disable Request Viewing. + + = 1.1.7 - 2019-10-30 = * Added - Google Map styles. From 3fcded9caf7157040550fb4876a4c4289a27bf0f Mon Sep 17 00:00:00 2001 From: Hoang Huu Date: Thu, 31 Oct 2019 16:25:52 +0700 Subject: [PATCH 10/10] Update readme.txt --- readme.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.txt b/readme.txt index fc8b8727..b216ad02 100755 --- a/readme.txt +++ b/readme.txt @@ -158,6 +158,8 @@ This section describes how to install the plugin and get it working. == Changelog == = 1.1.8 - 2019-10-31 = * Fixes - Submission settings. +* Fixes - Order settings in the search page. +* Fixes - Single property image size. * Added - Automatic generate property SKU. * Added - Enable/Disable Request Viewing.