PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use WilokeListingTools\Framework\Helpers\DebugStatus; use WilokeListingTools\Framework\Helpers\FileSystem; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\GetWilokeSubmission; use WilokeListingTools\Framework\Helpers\SetSettings; use WilokeListingTools\Framework\Helpers\Submission; use WilokeListingTools\Framework\Payment\FreePlan\FreePlan; use WilokeListingTools\Framework\Payment\Receipt\ReceiptStaticFactory; use WilokeListingTools\Framework\Store\Session; use WilokeListingTools\Frontend\User; use WilokeListingTools\Models\RemainingItems; use WilokeListingTools\Models\UserModel; use WilokeListingTools\Register\WilokeSubmission; trait HandleSubmit { private $oReceipt; private $isChangedPlan; private $aMaybeUserPlan = []; private function isSentEmailNotificationAboutSubmission($listingID) { return get_transient('wilcity_is_sent_email_nas_' . $listingID); } private function setSentEmailNotificationAboutSubmission($listingID) { set_transient('wilcity_is_sent_email_nas_' . $listingID, 'yes', apply_filters('wilcity/stop-sending-email-within', 60 * 24)); } private function hookAfterListingSubmitted($isSubmit = false) { /** * @hooked WilokeListingTools\Controllers\EmailController::submittedListing 10 * @hooked WilokeListingTools\Controllers\PlanRelationshipController::addPlanRelationshipUserPurchasedPlan 10 * @hooked WilokeListingTools\Controllers\PostController::handleListingPlanAfterSubmitting 15 * @hooked WilokeListingTools\Controllers\SessionController::maybeDeletePaymentSessions 15 */ do_action( 'wiloke/submitted-listing', [ 'planID' => $this->planID, 'postID' => $this->listingID, 'postAuthor' => get_post_field('post_author', $this->listingID), 'isAutoApproved' => false, 'isSubmit' => $isSubmit, 'isChangedPlan' => $this->isChangedPlan, 'aUserPlan' => $this->aMaybeUserPlan ] ); } private function hookBeforeSubmitListing() { /** * @hooked WilokeListingTools\Controllers\EmailController::submittedListing 10 * @hooked WilokeListingTools\Controllers\PlanRelationshipController::addPlanRelationshipUserPurchasedPlan 10 * @hooked WilokeListingTools\Controllers\PostController::handleListingPlanAfterSubmitting 15 * @hooked WilokeListingTools\Controllers\SessionController::maybeDeletePaymentSessions 15 */ do_action( 'wilcity/wiloke-listing-tools/before-submit-listing', [ 'planID' => $this->planID, 'postID' => $this->listingID, 'postAuthor' => get_post_field('post_author', $this->listingID), ] ); } private function goToThankyouPage() { wp_send_json_success( [ 'redirectTo' => GetWilokeSubmission::getThankyouPageURL( [ 'postID' => $this->listingID, 'category' => 'addlisting' ] ) ] ); } private function _handleSubmit() { $this->middleware( [ 'isLockedAddListing' ] ); Session::setPaymentCategory('addlisting'); $this->listingID = Session::getPaymentObjectID(false); Session::setSession(wilokeListingToolsRepository()->get('payment:listingType'), get_post_type($this->listingID)); $this->postStatus = get_post_status($this->listingID); $this->planID = Session::getSession(wilokeListingToolsRepository()->get('payment:storePlanID')); $this->aPlanSettings = GetSettings::getPlanSettings($this->planID); $oldPlanID = GetSettings::getPostMeta($this->listingID, 'oldPlanID'); $this->isChangedPlan = !empty($oldPlanID) && $oldPlanID != $this->planID; $this->middleware([ 'isUserLoggedIn', 'canSubmissionListing', 'isPassedPostAuthor', 'isPlanExists' ], [ 'postID' => $this->listingID, 'planID' => $this->planID, 'listingID' => $this->listingID, 'userID' => get_current_user_id(), 'listingType' => get_post_type($this->listingID) ]); $aUpdatePost = [ 'ID' => $this->listingID ]; $this->hookBeforeSubmitListing(); if (!defined('WILOKE_LISTING_TOOLS_CHECK_EVEN_ADMIN') && current_user_can('administrator')) { $aUpdatePost['post_status'] = 'publish'; $this->setDuration(GetWilokeSubmission::getBillingType(), $this->listingID, $this->planID); wp_update_post($aUpdatePost); $this->goToThankyouPage(); } if ($this->postStatus == 'editing') { if (GetWilokeSubmission::getField('published_listing_editable') == 'allow_trust_approved') { $aUpdatePost['post_status'] = 'publish'; } else { $oldPostStatus = GetSettings::getPostMeta($this->listingID, 'oldPostStatus'); if (Submission::listingStatusWillPublishImmediately($oldPostStatus)) { $aUpdatePost['post_status'] = 'publish'; } else { $aUpdatePost['post_status'] = 'pending'; } $aUpdatePost['post_status'] = 'pending'; SetSettings::deletePostMeta($oldPostStatus, 'oldPostStatus'); } if ($aUpdatePost['post_status'] != 'publish' && !$this->isSentEmailNotificationAboutSubmission($this->listingID) ) { $this->hookAfterListingSubmitted(); $this->setSentEmailNotificationAboutSubmission($this->listingID); } wp_update_post($aUpdatePost); $this->goToThankyouPage(); } if (in_array($this->postStatus, ['unpaid', 'expired'])) { if ((UserModel::getRemainingItemsOfPlans($this->planID) > 0) && (!defined('WILOKE_ALWAYS_PAY') || !WILOKE_ALWAYS_PAY) ) { $this->aMaybeUserPlan = UserModel::getSpecifyUserPlanID($this->planID, User::getCurrentUserID(), true); $isTrial = isset($this->aMaybeUserPlan['isTrial']) && $this->aMaybeUserPlan['isTrial']; $this->setDuration(GetWilokeSubmission::getBillingType(), $this->listingID, $this->planID, $isTrial); $oldPostStatus = GetSettings::getPostMeta($this->listingID, 'oldPostStatus'); if ( GetWilokeSubmission::getField('approved_method') == 'auto_approved_after_payment' || Submission::listingStatusWillPublishImmediately($oldPostStatus) ) { $aUpdatePost['post_status'] = 'publish'; } else { $aUpdatePost['post_status'] = 'pending'; } wp_update_post($aUpdatePost); SetSettings::deletePostMeta($oldPostStatus, 'oldPostStatus'); $this->hookAfterListingSubmitted(); $this->goToThankyouPage(); } } // Free Add Listing if (empty($this->aPlanSettings['regular_price'])) { $this->oReceipt = ReceiptStaticFactory::get('addlisting', [ 'planID' => $this->planID, 'userID' => User::getCurrentUserID(), 'couponCode' => '', 'aRequested' => $_REQUEST ]); $this->oReceipt->setupPlan(); $oFreePlan = new FreePlan($this->planID); $aStatus = $oFreePlan->proceedPayment($this->oReceipt); if ($aStatus['status'] == 'success') { if (empty($this->aMaybeUserPlan)) { $this->aMaybeUserPlan = UserModel::getSpecifyUserPlanID( $this->planID, User::getCurrentUserID(), true ); } $isTrial = isset($this->aMaybeUserPlan['isTrial']) && $this->aMaybeUserPlan['isTrial']; $this->setDuration( wilokeListingToolsRepository()->get('payment:billingTypes', true)->sub('nonrecurring'), $this->listingID, $this->planID, $isTrial ); wp_update_post([ 'ID' => $this->listingID, 'post_status' => GetWilokeSubmission::getField('approved_method') != 'manual_review' ? 'publish' : 'pending' ]); do_action('wilcity/wiloke-listing-tools/NonRecurringPayment/payment-gateway-completed', ['paymentID' => $oFreePlan->paymentID, 'billingType' => wilokeListingToolsRepository()->get('payment:billingTypes', true)->sub('nonrecurring')]); $this->hookAfterListingSubmitted(); $this->goToThankyouPage(); } else { wp_send_json_error([ 'msg' => esc_html__('ERROR: We could not create Free Plan', 'wiloke-listing-tools') ]); } } $redirectTo = GetWilokeSubmission::getField('checkout', true); // If paying via WooCoomerce, we need to get rid of this product id from the cart $productID = GetSettings::getPostMeta($this->planID, 'woocommerce_association'); if (!empty($productID)) { $redirectTo = GetSettings::getCartUrl($this->planID); /* * @hooked WooCommerceController:removeProductFromCart */ do_action('wiloke-listing-tools/before-redirecting-to-cart', $productID); // Session::setSession(wilokeListingToolsRepository()->get('payment:associateProductID'), $productID); Session::setProductID($productID); } $this->hookAfterListingSubmitted(true); wp_send_json_success( [ 'redirectTo' => $redirectTo ] ); } }
[+]
..
[-] 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]