diff --git a/assets/js/frontend/property.js b/assets/js/frontend/property.js index 23d69a75..5b0e895c 100755 --- a/assets/js/frontend/property.js +++ b/assets/js/frontend/property.js @@ -120,6 +120,7 @@ window.opalestate_messages = function() { function make_ajax ( data, _this ) { $( '.opalestate-message-notify', _this ).remove(); var action = $( _this ).data('action')? $( _this ).data('action') : 'send_email_contact'; + console.log(action) toggle_submit_button( _this ); $.ajax({ type : 'POST', @@ -135,7 +136,10 @@ window.opalestate_messages = function() { } toggle_submit_button( _this ); } - } + }, + error: function( response ) { + console.log(response) + } }); } @@ -260,4 +264,4 @@ window.opalestate_messages = function() { window.wp = window.wp || {}; window.wp.opalestate_messages = opalestate_messages(); -}( jQuery, window )); \ No newline at end of file +}( jQuery, window )); diff --git a/inc/class-opalestate-email.php b/inc/class-opalestate-email.php index 266235bd..83da6c80 100755 --- a/inc/class-opalestate-email.php +++ b/inc/class-opalestate-email.php @@ -13,16 +13,18 @@ */ // Exit if accessed directly -if ( !defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} /** - * @class OpalMembership_Checkout + * @class OpalMembership_Checkout * * @version 1.0 */ class Opalestate_Emails { - + /** * init action to automatic send email when user edit or submit a new submission and init setting form in plugin setting of admin */ @@ -30,26 +32,26 @@ class Opalestate_Emails { self::load(); - add_action( 'opalestate_processed_new_submission' , array( __CLASS__ , 'new_submission_email'), 10, 2 ); - //add_action( 'opalestate_processed_edit_submission' , array( __CLASS__ , 'new_submission_email'), 10, 2 ); - if( is_admin() ){ - add_filter( 'opalestate_settings_tabs', array( __CLASS__, 'setting_email_tab'), 1 ); - add_filter( 'opalestate_registered_emails_settings', array( __CLASS__, 'setting_email_fields'), 10, 1 ); - } + add_action( 'opalestate_processed_new_submission', [ __CLASS__, 'new_submission_email' ], 10, 2 ); + //add_action( 'opalestate_processed_edit_submission' , array( __CLASS__ , 'new_submission_email'), 10, 2 ); + if ( is_admin() ) { + add_filter( 'opalestate_settings_tabs', [ __CLASS__, 'setting_email_tab' ], 1 ); + add_filter( 'opalestate_registered_emails_settings', [ __CLASS__, 'setting_email_fields' ], 10, 1 ); + } - $enable_approve_property_email = opalestate_get_option( 'enable_approve_property_email' ); + $enable_approve_property_email = opalestate_get_option( 'enable_approve_property_email' ); - if ( $enable_approve_property_email == 'on' ) { - add_action( 'transition_post_status', array( __CLASS__, 'send_email_when_publish_property') , 10, 3 ); - add_action( 'opalestate_processed_approve_publish_property', array( __CLASS__, 'approve_publish_property_email') , 10, 1 ); - } + if ( $enable_approve_property_email == 'on' ) { + add_action( 'transition_post_status', [ __CLASS__, 'send_email_when_publish_property' ], 10, 3 ); + add_action( 'opalestate_processed_approve_publish_property', [ __CLASS__, 'approve_publish_property_email' ], 10, 1 ); + } - /** - * Send email when User contact via Enquiry Form and Contact Form - */ - add_action( 'opalestate_send_email_notifycation', array(__CLASS__,'send_notifycation') ); - add_action( 'opalestate_send_email_submitted', array(__CLASS__,'new_submission_email') ); - add_action( 'opalestate_send_email_request_reviewing', array( __CLASS__, 'send_email_request_reviewing') ); + /** + * Send email when User contact via Enquiry Form and Contact Form + */ + add_action( 'opalestate_send_email_notifycation', [ __CLASS__, 'send_notifycation' ] ); + add_action( 'opalestate_send_email_submitted', [ __CLASS__, 'new_submission_email' ] ); + add_action( 'opalestate_send_email_request_reviewing', [ __CLASS__, 'send_email_request_reviewing' ] ); } /** @@ -61,128 +63,125 @@ class Opalestate_Emails { require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalestate-email-notifycation.php'; require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalestate-request-viewing.php'; require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalestate-new-submitted.php'; - require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalesate-approve.php'; + require_once OPALESTATE_PLUGIN_DIR . 'inc/email/class-opalesate-approve.php'; } /** * Send Email Notifycation with two types: Enquiry or Contact */ - public static function send_notifycation ( $content ) { - - $mail = new OpalEstate_Send_Email_Notification() ; - $mail->set_args ( $content ); - - $return = self::send_mail_now( $mail ); + public static function send_notifycation( $content ) { + $mail = new OpalEstate_Send_Email_Notification(); + $mail->set_args( $content ); - if( isset($content['data']) ){ + $return = self::send_mail_now( $mail ); + + if ( isset( $content['data'] ) ) { $return['data'] = $content['data']; } - echo json_encode( $return ); die(); - } + echo json_encode( $return ); + die(); + } /** * send email if agent submit a new property */ - public static function new_submission_email( $user_id, $post_id ){ - - $mail = new OpalEstate_Send_Email_New_Submitted() ; - + public static function new_submission_email( $user_id, $post_id ) { + $mail = new OpalEstate_Send_Email_New_Submitted(); $mail->set_pros( $post_id, $user_id ); + $return = self::send_mail_now( $mail ); - $return = self::send_mail_now( $mail ); - - - echo json_encode( $return ); die(); + echo json_encode( $return ); + die(); } /** * Send email to requet viewing a property */ - public static function send_email_request_reviewing( $content ){ - + public static function send_email_request_reviewing( $content ) { $mail = new OpalEstate_Send_Email_Request_Reviewing(); $mail->set_args( $content ); - $return = self::send_mail_now( $mail ); + $return = self::send_mail_now( $mail ); - - echo json_encode( $return ); die(); - + echo json_encode( $return ); + die(); } /** * */ - public static function send_mail_now( $mail ){ + public static function send_mail_now( $mail ) { + $from_name = $mail->from_name(); + $from_email = $mail->from_email(); + $headers = sprintf( "From: %s <%s>\r\n Content-type: text/html", $from_name, $from_email ); - $from_name = $mail->from_name(); - $from_email = $mail->from_email(); - $headers = sprintf( "From: %s <%s>\r\n Content-type: text/html", $from_name, $from_email ); + $subject = $mail->get_subject(); + $message = $mail->get_body(); - $subject = $mail->get_subject(); - $message = $mail->get_body(); + if ( $mail->to_email() ) { - if( $mail->to_email() ) { - - if( $mail->get_cc() ){ + if ( $mail->get_cc() ) { $status = @wp_mail( $mail->get_cc(), $subject, $message, $headers ); - } + } - $status = @wp_mail( $mail->to_email(), $subject, $message, $headers ); - $return = array( 'status' => true, 'msg' => esc_html__( 'Message has been successfully sent.', 'opalestate-pro' ) ); + $status = @wp_mail( $mail->to_email(), $subject, $message, $headers ); - } else { - $return = array( 'status' => true, 'msg' => esc_html__( 'Message has been successfully sent.', 'opalestate-pro' ) ); + if ( $status ) { + return [ 'status' => true, 'msg' => esc_html__( 'Message has been successfully sent.', 'opalestate-pro' ) ]; + } else { + return [ 'status' => true, 'msg' => esc_html__( 'Unable to send a message.', 'opalestate-pro' ) ]; + } } - return $return; + return [ 'status' => true, 'msg' => esc_html__( 'Missing some information!', 'opalestate-pro' ) ]; } /** * */ - public static function send_email_when_publish_property( $new_status, $old_status, $post ) { + public static function send_email_when_publish_property( $new_status, $old_status, $post ) { - if( is_object( $post ) ){ - if ( $post->post_type == 'opalestate_property' ) { - if ( $new_status != $old_status ) { - if ($new_status == 'publish' ) { - if ($old_status == 'draft' || $old_status == 'pending') { - // Send email - $post_id = $post->ID; - do_action( "opalestate_processed_approve_publish_property", $post_id ); - } - } - } - } - } + if ( is_object( $post ) ) { + if ( $post->post_type == 'opalestate_property' ) { + if ( $new_status != $old_status ) { + if ( $new_status == 'publish' ) { + if ( $old_status == 'draft' || $old_status == 'pending' ) { + // Send email + $post_id = $post->ID; + do_action( "opalestate_processed_approve_publish_property", $post_id ); + } + } + } + } + } - } + } /** * add new tab Email in opalestate -> setting */ - public static function setting_email_tab( $tabs ){ + public static function setting_email_tab( $tabs ) { $tabs['emails'] = esc_html__( 'Email', 'opalestate-pro' ); - return $tabs; - } - public static function newproperty_email_body(){ - + return $tabs; + } + + public static function newproperty_email_body() { + + } + + public static function approve_email_body() { + } - - public static function approve_email_body(){ - - } /** * render setting email fields with default values */ - public static function setting_email_fields( $fields ){ + public static function setting_email_fields( $fields ) { $contact_list_tags = '

Use the following tags to automatically add property information to the emails. Tags labeled with an asterisk (*) can be used in the email subject as well.

@@ -251,137 +250,137 @@ class Opalestate_Emails {
'; $list_tags = apply_filters( 'opalestate_email_tags', $list_tags ); - - $fields = array( - 'id' => 'options_page', - 'title' => esc_html__( 'Email Settings', 'opalestate-pro' ), - 'show_on' => array( 'key' => 'options-page', 'value' => array( 'opalestate_settings' ), ), - 'fields' => apply_filters( 'opalestate_settings_emails', array( - array( + + $fields = [ + 'id' => 'options_page', + 'title' => esc_html__( 'Email Settings', 'opalestate-pro' ), + 'show_on' => [ 'key' => 'options-page', 'value' => [ 'opalestate_settings' ], ], + 'fields' => apply_filters( 'opalestate_settings_emails', [ + [ 'name' => esc_html__( 'Email Settings', 'opalestate-pro' ), 'desc' => '
', 'id' => 'opalestate_title_email_settings_1', - 'type' => 'title' - ), - array( + 'type' => 'title', + ], + [ 'id' => 'from_name', 'name' => esc_html__( 'From Name', 'opalestate-pro' ), 'desc' => esc_html__( 'The name donation receipts are said to come from. This should probably be your site or shop name.', 'opalestate-pro' ), 'default' => get_bloginfo( 'name' ), - 'type' => 'text' - ), - array( + 'type' => 'text', + ], + [ 'id' => 'from_email', 'name' => esc_html__( 'From Email', 'opalestate-pro' ), 'desc' => esc_html__( 'Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'opalestate-pro' ), 'default' => get_bloginfo( 'admin_email' ), - 'type' => 'text' - ), + 'type' => 'text', + ], - - array( + [ 'name' => esc_html__( 'Email Submission Templates (Template Tags)', 'opalestate-pro' ), - 'desc' => $list_tags.'

', + 'desc' => $list_tags . '

', 'id' => 'opalestate_title_email_settings_2', - 'type' => 'title' - ), + 'type' => 'title', + ], - - array( + [ 'name' => esc_html__( 'Notification For New Property Submission', 'opalestate-pro' ), 'desc' => '
', 'id' => 'opalestate_title_email_settings_3', - 'type' => 'title' - ), - + 'type' => 'title', + ], - array( - 'id' => 'newproperty_email_subject', - 'name' => esc_html__( 'Email Subject', 'opalestate-pro' ), - 'type' => 'text', - 'desc' => esc_html__( 'The email subject for admin notifications.', 'opalestate-pro' ), - 'attributes' => array( - 'placeholder' => 'Your package is expired', - 'rows' => 3, - ), - 'default' => esc_html__( 'New Property Listing Submitted: {property_name}', 'opalestate-pro' ) - ), - array( + [ + 'id' => 'newproperty_email_subject', + 'name' => esc_html__( 'Email Subject', 'opalestate-pro' ), + 'type' => 'text', + 'desc' => esc_html__( 'The email subject for admin notifications.', 'opalestate-pro' ), + 'attributes' => [ + 'placeholder' => 'Your package is expired', + 'rows' => 3, + ], + 'default' => esc_html__( 'New Property Listing Submitted: {property_name}', 'opalestate-pro' ), + + ], + [ 'id' => 'newproperty_email_body', 'name' => esc_html__( 'Email Body', 'opalestate-pro' ), 'type' => 'wysiwyg', - 'desc' => esc_html__( 'Enter the email an admin should receive when an initial payment request is made.', 'opalestate-pro' ), + 'desc' => esc_html__( 'Enter the email an admin should receive when an initial payment request is made.', 'opalestate-pro' ), 'default' => OpalEstate_Send_Email_New_Submitted::get_default_template(), - ), + ], //------------------------------------------ - array( + [ 'name' => esc_html__( 'Approve property for publish', 'opalestate-pro' ), 'desc' => '
', 'id' => 'opalestate_title_email_settings_4', - 'type' => 'title' - ), + 'type' => 'title', + ], - array( - 'name' => esc_html__( 'Enable approve property email', 'opalestate-pro' ), - 'desc' => esc_html__( 'Enable approve property email.', 'opalestate-pro' ), - 'id' => 'enable_approve_property_email', - 'type' => 'switch', - 'options' => array( - 'on' => esc_html__( 'Enable', 'opalestate-pro' ), - 'off' => esc_html__( 'Disable', 'opalestate-pro' ), - ), - 'default' => 'off', - ), + [ + 'name' => esc_html__( 'Enable approve property email', 'opalestate-pro' ), + 'desc' => esc_html__( 'Enable approve property email.', 'opalestate-pro' ), + 'id' => 'enable_approve_property_email', + 'type' => 'switch', + 'options' => [ + 'on' => esc_html__( 'Enable', 'opalestate-pro' ), + 'off' => esc_html__( 'Disable', 'opalestate-pro' ), + ], + 'default' => 'off', + ], - array( - 'id' => 'approve_email_subject', - 'name' => esc_html__( 'Email Subject', 'opalestate-pro' ), - 'type' => 'text', - 'desc' => esc_html__( 'The email subject a user should receive when they make an initial property request.', 'opalestate-pro' ), - 'attributes' => array( - 'placeholder' => 'Your property at I Love WordPress is pending',get_bloginfo( 'name' ), - 'rows' => 3, - ), - 'default' => esc_html__( 'New Property Listing Submitted: {property_name}', 'opalestate-pro' ) - ), + [ + 'id' => 'approve_email_subject', + 'name' => esc_html__( 'Email Subject', 'opalestate-pro' ), + 'type' => 'text', + 'desc' => esc_html__( 'The email subject a user should receive when they make an initial property request.', 'opalestate-pro' ), + 'attributes' => [ + 'placeholder' => 'Your property at I Love WordPress is pending', + get_bloginfo( 'name' ), + 'rows' => 3, + ], + 'default' => esc_html__( 'New Property Listing Submitted: {property_name}', 'opalestate-pro' ), + ], - array( - 'id' => 'approve_email_body', - 'name' => esc_html__( 'Email Body', 'opalestate-pro' ), - 'type' => 'wysiwyg', - 'desc' => esc_html__( 'Enter the email a user should receive when they make an initial payment request.', 'opalestate-pro' ), - 'default' => OpalEstate_Send_Email_Approve::get_default_template(), - ), + [ + 'id' => 'approve_email_body', + 'name' => esc_html__( 'Email Body', 'opalestate-pro' ), + 'type' => 'wysiwyg', + 'desc' => esc_html__( 'Enter the email a user should receive when they make an initial payment request.', 'opalestate-pro' ), + 'default' => OpalEstate_Send_Email_Approve::get_default_template(), + ], /// email contact template //// - array( + [ 'name' => esc_html__( 'Email Contact Templates (Template Tags)', 'opalestate-pro' ), - 'desc' => $contact_list_tags.'

', + 'desc' => $contact_list_tags . '

', 'id' => 'opalestate_title_email_settings_6', - 'type' => 'title' - ), + 'type' => 'title', + ], - array( - 'id' => 'contact_email_subject', - 'name' => esc_html__( 'Email Subject', 'opalestate-pro' ), - 'type' => 'text', - 'desc' => esc_html__( 'The email subject a user should receive when they make an initial property request.', 'opalestate-pro' ), - 'attributes' => array( - 'placeholder' => 'Your property at I Love WordPress is pending',get_bloginfo( 'name' ), - 'rows' => 3, - ), - 'default' => esc_html__('You got a message', 'opalestate-pro') - ), + [ + 'id' => 'contact_email_subject', + 'name' => esc_html__( 'Email Subject', 'opalestate-pro' ), + 'type' => 'text', + 'desc' => esc_html__( 'The email subject a user should receive when they make an initial property request.', 'opalestate-pro' ), + 'attributes' => [ + 'placeholder' => 'Your property at I Love WordPress is pending', + get_bloginfo( 'name' ), + 'rows' => 3, + ], + 'default' => esc_html__( 'You got a message', 'opalestate-pro' ), + ], - array( - 'id' => 'contact_email_body', - 'name' => esc_html__( 'Email Body', 'opalestate-pro' ), - 'type' => 'wysiwyg', - 'desc' => trim(preg_replace('/\t+/', '', "Hi {receive_name},
+ [ + 'id' => 'contact_email_body', + 'name' => esc_html__( 'Email Body', 'opalestate-pro' ), + 'type' => 'wysiwyg', + 'desc' => trim( preg_replace( '/\t+/', '', "Hi {receive_name},
You have got message from {name} with email {email}. Here is detail:

@@ -389,11 +388,11 @@ class Opalestate_Emails {
 

- This message was sent by {site_link} on {current_time}.")) - ) - ) - ) - ); + This message was sent by {site_link} on {current_time}." ) ), + ], + ] + ), + ]; return $fields; } @@ -401,58 +400,62 @@ class Opalestate_Emails { /** * get data of newrequest email * - * @var $args array: property_id , $body * @return text: message + * @var $args array: property_id , $body */ public static function replace_shortcode( $args, $body ) { - $tags = array( - 'user_name' => "", - 'user_mail' => "", + $tags = [ + 'user_name' => "", + 'user_mail' => "", 'submitted_date' => "", - 'property_name' => "", - 'site_name' => '', - 'site_link' => '', - 'property_link' => '', - ); + 'property_name' => "", + 'site_name' => '', + 'site_link' => '', + 'property_link' => '', + ]; $tags = array_merge( $tags, $args ); extract( $tags ); - $tags = array( "{user_mail}", - "{user_name}", - "{submitted_date}", - "{site_name}", - "{site_link}", - "{current_time}", - '{property_name}', - '{property_link}'); + $tags = [ + "{user_mail}", + "{user_name}", + "{submitted_date}", + "{site_name}", + "{site_link}", + "{current_time}", + '{property_name}', + '{property_link}', + ]; - $values = array( $user_mail, - $user_name , - $submitted_date , - get_bloginfo( 'name' ) , - get_home_url(), - date("F j, Y, g:i a"), - $property_name, - $property_link - ); + $values = [ + $user_mail, + $user_name, + $submitted_date, + get_bloginfo( 'name' ), + get_home_url(), + date( "F j, Y, g:i a" ), + $property_name, + $property_link, + ]; - $message = str_replace($tags, $values, $body); + $message = str_replace( $tags, $values, $body ); return $message; } - + public static function approve_publish_property_email( $post_id ) { - $mail = new OpalEstate_Send_Email_Approve(); + $mail = new OpalEstate_Send_Email_Approve(); $mail->set_pros( $post_id ); - $return = self::send_mail_now( $mail ); + $return = self::send_mail_now( $mail ); - echo json_encode( $return ); die(); - } + echo json_encode( $return ); + die(); + } } -Opalestate_Emails::init(); \ No newline at end of file +Opalestate_Emails::init(); diff --git a/inc/email/class-opalestate-abs-email-template.php b/inc/email/class-opalestate-abs-email-template.php index 8f7d7c6c..b2078d11 100755 --- a/inc/email/class-opalestate-abs-email-template.php +++ b/inc/email/class-opalestate-abs-email-template.php @@ -22,8 +22,8 @@ if ( ! defined( 'ABSPATH' ) ) { * @version 1.0 */ class OpalEstate_Abstract_Email_Template { - - public $args = array(); + + public $args = []; /** * Get the unique email notification key. @@ -34,7 +34,7 @@ class OpalEstate_Abstract_Email_Template { return 'opalestate-notification'; } - /** + /** * Get the friendly name for this email notification. * * @return string @@ -53,8 +53,8 @@ class OpalEstate_Abstract_Email_Template { return esc_html__( 'Send notices to the site administrator before a job listing expires.', 'opalestate-pro' ); } - public function to_email () { - + public function to_email() { + } public function get_content_template() { @@ -62,64 +62,63 @@ class OpalEstate_Abstract_Email_Template { } - public function set_args ( $args ) { + public function set_args( $args ) { return $this->args = $args; } - - public function replace_tags ( $template ) { - - $args = $this->args; - $default = array( - 'receiver_name' => '', - 'name' => '', - 'receiver_email' => '', - 'property_link' => '', - 'message' => '', - 'site_name' => bloginfo(), - 'site_link' => get_home_url(), - 'current_time' => date("F j, Y, g:i a"), - 'phone' => '' - ); - $args = array_merge( $default, $args ); + public function replace_tags( $template ) { + $args = $this->args; + $default = [ + 'receiver_name' => '', + 'name' => '', + 'receiver_email' => '', + 'property_link' => '', + 'message' => '', + 'site_name' => get_bloginfo(), + 'site_link' => get_home_url(), + 'current_time' => date( "F j, Y, g:i a" ), + 'phone' => '', + ]; - $tags = array(); - $values = array() ; + $args = array_merge( $default, $args ); + + $tags = []; + $values = []; foreach ( $args as $key => $value ) { - $tags[] = "{".$key."}"; + $tags[] = "{" . $key . "}"; $values[] = $value; - } - + } + $message = str_replace( $tags, $values, $template ); - + return $message; - } - - public function get_subject () { - - } - - public function from_email() { - return opalestate_get_option( 'from_email' , get_bloginfo( 'admin_email' ) ); - } - - public function from_name() { - return opalestate_get_option('from_name', get_bloginfo( 'name' ) ); - } - - public function get_cc() { - - } - - - public function get_body(){ - - $template = $this->get_content_template(); - return $this->replace_tags( $template ); } - public function get_plain_text_body () { + public function get_subject() { + + } + + public function from_email() { + return opalestate_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); + } + + public function from_name() { + return opalestate_get_option( 'from_name', get_bloginfo( 'name' ) ); + } + + public function get_cc() { + + } + + + public function get_body() { + $template = $this->get_content_template(); + + return $this->replace_tags( $template ); + } + + public function get_plain_text_body() { } } diff --git a/inc/email/class-opalestate-request-viewing.php b/inc/email/class-opalestate-request-viewing.php index 217163a3..99ee9356 100755 --- a/inc/email/class-opalestate-request-viewing.php +++ b/inc/email/class-opalestate-request-viewing.php @@ -11,7 +11,7 @@ * @website http://www.wpopal.com * @support http://www.wpopal.com/support/forum.html */ - + if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } @@ -22,33 +22,34 @@ if ( ! defined( 'ABSPATH' ) ) { * @version 1.0 */ class OpalEstate_Send_Email_Request_Reviewing extends OpalEstate_Abstract_Email_Template { - + /** * Send Email */ - public function get_subject () { - $propety_title = '' ; - return sprintf( esc_html__( 'You have a message request reviewing: %s at', 'opalestate-pro' ), $propety_title ); + public function get_subject() { + $propety_title = ''; + + return sprintf( esc_html__( 'You have a message request reviewing: %s at', 'opalestate-pro' ), $propety_title ); } /** * Send Email */ public function get_content_template() { - return opalestate_load_template_path( 'emails/request-reviewing' ); - } + return opalestate_load_template_path( 'emails/request-reviewing' ); + } /** * Send Email */ - public function to_email () { + public function to_email() { return $this->args ['receiver_email']; } /** * Send Email */ - public function cc_email () { + public function cc_email() { return $this->args ['sender_email']; } @@ -56,15 +57,12 @@ class OpalEstate_Send_Email_Request_Reviewing extends OpalEstate_Abstract_Email_ * Send Email */ public function get_body() { - - $post = get_post( $this->args['post_id'] ); - - $this->args['email'] = $this->args['receiver_email']; - $this->args['property_link'] = get_permalink( $post->ID ); - $this->args['property_name'] = $post->post_title; - + $post = get_post( $this->args['post_id'] ); + + $this->args['email'] = $this->args['receiver_email']; + $this->args['property_link'] = get_permalink( $post->ID ); + $this->args['property_name'] = $post->post_title; return parent::get_body(); } } -?> \ No newline at end of file diff --git a/inc/message/class-opalestate-message.php b/inc/message/class-opalestate-message.php index ad5fb2e3..03c88fea 100755 --- a/inc/message/class-opalestate-message.php +++ b/inc/message/class-opalestate-message.php @@ -99,13 +99,13 @@ class OpalEstate_User_Message { $post['property_link'] = (int) $post['post_id'] ? get_permalink( $post['post_id'] ) : get_home_url(); - $post['receive_name'] = $member['name']; + $post['receive_name'] = isset( $member['name'] ) ? $member['name'] : ''; $subject = html_entity_decode( esc_html__( 'You got a message', 'opalestate-pro' ) ); $post['receiver_name'] = $member['receiver_name']; $output = [ 'subject' => $subject, - 'name' => $member['name'], + 'name' => isset( $member['name'] ) ? $member['name'] : '', 'receiver_email' => $member['receiver_email'], 'receiver_id' => $member['receiver_id'], 'sender_id' => get_current_user_id(), @@ -241,20 +241,16 @@ class OpalEstate_User_Message { } /** - * + * Process send email. */ public function process_send_email() { - do_action( 'opalestate_process_send_email_before' ); - if ( isset( $_POST['type'] ) && $_POST['type'] ) { - $content = []; switch ( trim( $_POST['type'] ) ) { case 'send_equiry': if ( wp_verify_nonce( $_POST['message_action'], 'send-enquiry-form' ) ) { - $member = $this->get_member_email_data( (int) $_POST['post_id'] ); $content = $this->send_equiry( $_POST, $member ); } @@ -269,8 +265,6 @@ class OpalEstate_User_Message { } if ( $content ) { - - // only save in db for user only if ( $content['receiver_id'] > 0 && $this->is_log ) { $this->insert( $content ); diff --git a/templates/messages/enquiry-form.php b/templates/messages/enquiry-form.php index 76164fd4..ed94ee91 100755 --- a/templates/messages/enquiry-form.php +++ b/templates/messages/enquiry-form.php @@ -1,45 +1,46 @@ -get_equiry_form_fields( $message ); -$form = OpalEstate()->html->render_form( $fields ); +$message = sprintf( __( 'Hi, I am interested in %s (Property ID: %s)', 'opalestate-pro' ), get_the_title(), get_the_ID() ); -$id = 'send-enquiry-form'; +$property_id = get_the_ID(); +$heading = esc_html__( 'Enquire about property', 'opalestate-pro' ); +$object = OpalEstate_User_Message::get_instance(); +$fields = $object->get_equiry_form_fields( $message ); +$form = OpalEstate()->html->render_form( $fields ); + +$id = 'send-enquiry-form'; ?> - -
- - - + + + - - - -
- -
-
-
-
-
-
- - - + - - - -
-
-
- -
-
+ + + + + +
+
+
+
+
+
+ + + + + + + +
+
+
+
+