PATH:
home
/
letacommog
/
laindinois
/
wp-content
/
plugins
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use WilokeListingTools\Framework\Helpers\DebugStatus; use WilokeListingTools\Framework\Helpers\General; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\GetWilokeSubmission; use WilokeListingTools\Framework\Helpers\HTML; use WilokeListingTools\Framework\Helpers\Submission; use WilokeListingTools\Framework\Routing\Controller; use WilokeListingTools\Framework\Store\Session; use WilokeListingTools\Frontend\User; use WilokeListingTools\Models\UserModel; class AddListingButtonController extends Controller { private $needBecomeAnAuthor = false; public function __construct() { add_filter('wilcity/single-listing/add-new-listing', [$this, 'addNewListing']); add_filter('wilcity/single-listing/edit-listing', [$this, 'editListing'], 10, 2); add_action('wilcity/single-listing/wil-content', [$this, 'printEditButton'], 10, 2); add_action('wilcity/single-event/wil-content', [$this, 'printEditButton'], 10, 2); add_action('wilcity/header/after-menu', [$this, 'printAddListingButton']); add_filter('wilcity/submission/pricingUrl', [$this, 'generatePricingUrl'], 10, 3); add_action('wp_ajax_wilcity_get_edit_url', [$this, 'ajaxGetEditUrl']); add_action('wp_ajax_wilcity_change_plan_for_post', [$this, 'ajaxChangePlanForThisPost']); add_filter('wilcity/add-new-event-url', [$this, 'addNewEventUrl'], 10, 2); add_filter('wilcity/wiloke-submission/box-listing-type-url', [$this, 'buildBoxUrl'], 10, 2); } public function buildBoxUrl($url, $aInfo) { $aLinkArgs = [ 'listing_type' => $aInfo['key'] ]; if (GetWilokeSubmission::getField('add_listing_mode') == 'free_add_listing') { $addListingUrl = GetWilokeSubmission::getField('addlisting', true); $addListingUrl = add_query_arg( $aLinkArgs, $addListingUrl ); return $addListingUrl; } $url = add_query_arg( $aLinkArgs, $url ); return $url; } public function addNewEventUrl($addListingUrl, $post) { $addListingUrl = GetWilokeSubmission::getField('package', true); $addListingUrl = add_query_arg( [ 'listing_type' => 'event', 'parentID' => isset($post->ID) ? $post->ID : '' ], $addListingUrl ); return $addListingUrl; } public function ajaxChangePlanForThisPost() { $this->middleware(['isPublishedPost'], [ 'postID' => $_POST['postID'] ]); $addListingUrl = GetWilokeSubmission::getField('package', true); $addListingUrl = add_query_arg( [ 'postID' => $_POST['postID'], 'listing_type' => get_post_type($_POST['postID']) ], $addListingUrl ); wp_send_json_success(['url' => $addListingUrl]); } public function ajaxGetEditUrl() { $this->middleware(['isPostAuthor'], [ 'postID' => $_POST['postID'], 'passedIfAdmin' => true ]); // rygkliniksjaelland@gmail.com $postStatus = get_post_status($_POST['postID']); $planID = GetSettings::getPostMeta($_POST['postID'], 'belongs_to'); if (empty($planID) || $postStatus == 'expired') { $addListingUrl = GetWilokeSubmission::getField('package', true); } else { $addListingUrl = GetWilokeSubmission::getField('addlisting', true); } $addListingUrl = add_query_arg( [ 'postID' => $_POST['postID'], 'planID' => $planID, 'listing_type' => get_post_type($_POST['postID']) ], $addListingUrl ); wp_send_json_success(['url' => $addListingUrl]); } public function addNewListing($postType) { $addListingUrl = GetWilokeSubmission::getField('addlisting', true); $addListingUrl = add_query_arg( [ 'listing_type' => $postType ], $addListingUrl ); return $addListingUrl; } public function editListing($nothing, $post) { $planID = GetSettings::getPostMeta($post->ID, 'belongs_to'); if (!empty($planID) || get_post_status($planID) !== 'publish') { $planID = ''; } if (!current_user_can('administrator') && $post->post_author !== User::getCurrentUserID()) { return ''; } if (empty($planID)) { if (!GetWilokeSubmission::isFreeAddListing()) { $addListingUrl = GetWilokeSubmission::getField('package', true); } else { $addListingUrl = GetWilokeSubmission::getField('addlisting', true); $planID = GetWilokeSubmission::getFreePlan($post->post_type); } } else { $addListingUrl = GetWilokeSubmission::getField('addlisting', true); } $addListingUrl = add_query_arg( [ 'postID' => $post->ID, 'planID' => $planID, 'listing_type' => $post->post_type ], $addListingUrl ); return $addListingUrl; } public function generatePricingUrl($planID, $postID, $aAtts) { $aArgs = [ 'planID' => $planID, 'listing_type' => $aAtts['listing_type'] ]; if (!empty($postID)) { $aArgs['postID'] = $postID; } if (isset($aAtts['parentID'])) { $aArgs['parentID'] = $aAtts['parentID']; } return add_query_arg( $aArgs, GetWilokeSubmission::getField('addlisting', true) ); } public function printAddListingButton() { $toggle = GetWilokeSubmission::getField('toggle'); $toggle_becomeauthor = GetWilokeSubmission::isEnable('toggle_become_an_author'); $pageUrl = GetWilokeSubmission::getField('become_an_author_page', true); if (!User::isUserLoggedIn() && $toggle != 'disable' && $toggle_becomeauthor) { global $wiloke; if (\WilokeThemeOptions::isEnable('toggle_custom_login_page', false)) { ?> <div class="header_loginItem__oVsmv wilcity-become-an-author"> <?php HTML::renderLink('wil-btn--secondary no-text-sm wil-btn--round wil-btn--xs no-text-sm mr-10', esc_html__('Become an author', 'wiloke-listing-tools'), add_query_arg(['action' => 'register'], get_permalink($wiloke->aThemeOptions['custom_login_page'])), 'la la-user'); ?> </div> <?php } else { ?> <div class="header_loginItem__oVsmv wilcity-become-an-author"> <?php HTML::renderLink('wilcity-trigger-register-button no-text-sm wil-btn--secondary wil-btn--round wil-btn--xs mr-10', esc_html__('Become an author', 'wiloke-listing-tools'), $pageUrl, 'la la-user'); ?> </div> <?php } return ''; } $toggle = apply_filters('wilcity/wiloke-listing-tools/filter/printAddListingButton/status', $toggle); if ($toggle == 'disable') { return ''; } if (!User::canSubmitListing(User::getCurrentUserID(), false)) { if (GetWilokeSubmission::isEnable('toggle_become_an_author')) { $this->needBecomeAnAuthor = true; } else { return ''; } } if ($this->needBecomeAnAuthor) { ?> <div class="header_loginItem__oVsmv wilcity-become-an-author"> <?php HTML::renderLink('no-text-sm wil-btn--secondary wil-btn--round wil-btn--md', esc_html__('Become an author', 'wiloke-listing-tools'), $pageUrl, 'la la-user'); ?> </div> <?php } else { $addListingUrl = GetWilokeSubmission::getField('package', true); if (empty($addListingUrl)) { return ''; } $addListingUrl = apply_filters('wilcity/wiloke-listing-tools/addlisting/filter/addlistingurl', $addListingUrl); $aPlans = Submission::getAddListingPostTypeKeys(); if (count($aPlans) == 1) { if (GetWilokeSubmission::isFreeAddListing()) { $addListingUrl = add_query_arg( [ 'listing_type' => $aPlans[0] ], GetWilokeSubmission::getField('addlisting', true) ); } else { $addListingUrl = add_query_arg( [ 'listing_type' => $aPlans[0] ], $addListingUrl ); } } ?> <div class="header_loginItem__oVsmv header-addlisting"> <?php HTML::renderLink('wil-addlisting-btn wil-btn wil-btn--primary2 wil-btn--round wil-btn--md', esc_html__('Add Listing', 'wiloke-listing-tools'), $addListingUrl, 'la la-pencil-square'); ?> </div> <?php } } public function printEditButton($post, $isFocused = false) { if (!is_user_logged_in()) { return ''; } if (DebugStatus::status('WILCITY_DISABLE_EDIT_BUTTON')) { return ''; } if (!$isFocused && ((Session::getPaymentObjectID() != $post->ID))) { return ''; } if ((!current_user_can('administrator') && (User::getCurrentUserID() != $post->post_author))) { return false; } global $post; $planID = Session::getPaymentPlanID(); if (empty($planID) && $isFocused) { $planID = GetSettings::getPostMeta($post->ID, 'belongs_to'); } $aAddListingArgs['postID'] = $post->ID; if (empty($planID)) { if (!GetWilokeSubmission::isFreeAddListing()) { $addListingUrl = GetWilokeSubmission::getField('package', true); } else { $addListingUrl = GetWilokeSubmission::getField('addlisting', true); $planID = GetWilokeSubmission::getFreePlan($post->post_type); $aAddListingArgs['planID'] = $planID; } } else { $addListingUrl = GetWilokeSubmission::getField('addlisting', true); $aAddListingArgs['planID'] = $planID; } if (isset($post->ID)) { $aAddListingArgs['listing_type'] = get_post_type($post->ID); } $addListingUrl = add_query_arg( $aAddListingArgs, $addListingUrl ); $aPlanSettings = GetSettings::getPlanSettings($planID); $remainingItems = UserModel::getRemainingItemsOfPlans($planID); if (empty($aPlanSettings['regular_price']) || $remainingItems > 0) { $btnName = __('Submit Listing', 'wiloke-listing-tools'); } else { $btnName = __('Pay & Publish', 'wiloke-listing-tools'); } echo '<div class="btn-group-fixed_module__3qULF pos-f-right-bottom text-right">'; HTML::renderLink('wil-btn--secondary wil-btn--round wil-btn--md', esc_html__('Edit Listing', 'wiloke-listing-tools'), $addListingUrl, 'la la-edit'); echo '<div class="mb-10"></div>'; if ($post->post_status != 'publish' && Session::getPaymentObjectID() == $post->ID && Session::getPaymentPlanID()) { $checkoutUrl = GetWilokeSubmission::getField('checkout', true); HTML::renderLink('wil-btn--primary2 wil-btn--round wil-btn--md disable', esc_html($btnName), $checkoutUrl, 'la la-send', 'wilcity-submit', true); } echo '</div>'; } }
[+]
..
[-] WebhookController.php
[edit]
[-] SetCoupon.php
[edit]
[-] TermController.php
[edit]
[-] PostController.php
[edit]
[-] SetMyPosts.php
[edit]
[-] NotificationsController.php
[edit]
[-] AjaxUploadImgController.php
[edit]
[-] TaxonomiesControllers.php
[edit]
[-] FavoriteStatisticController.php
[edit]
[-] BelongsToCustomTaxonomies.php
[edit]
[-] DashboardController.php
[edit]
[-] ModifyQueryController.php
[edit]
[-] SetCustomGroup.php
[edit]
[+]
Map
[-] TraitHostedBy.php
[edit]
[-] SearchFormController.php
[edit]
[-] InsertFeaturedImg.php
[edit]
[-] PaymentGatewaysController.php
[edit]
[-] PaymentController.php
[edit]
[-] DokanController.php
[edit]
[-] SchemaController.php
[edit]
[-] UserController.php
[edit]
[-] BelongsToLocation.php
[edit]
[-] WooCommerceBookingController.php
[edit]
[-] IsMyPaymentID.php
[edit]
[-] StripeController.php
[edit]
[-] ContactFormController.php
[edit]
[-] AddListingButtonController.php
[edit]
[-] Validation.php
[edit]
[-] GalleryController.php
[edit]
[-] SetListingRelationship.php
[edit]
[-] AddListingController.php
[edit]
[-] MergingSettingValues.php
[edit]
[-] GoogleReCaptchaController.php
[edit]
[-] CouponController.php
[edit]
[-] InvoiceController.php
[edit]
[-] SingleJsonSkeleton.php
[edit]
[-] SingleController.php
[edit]
[-] InsertImg.php
[edit]
[-] EmailController.php
[edit]
[-] BelongsToCategories.php
[edit]
[-] ReviewController.php
[edit]
[-] SetSinglePrice.php
[edit]
[-] PrintSidebarItems.php
[edit]
[-] SetPlanRelationship.php
[edit]
[-] BookingComController.php
[edit]
[-] WooCommerceController.php
[edit]
[-] FacebookLoginController.php
[edit]
[-] EventController.php
[edit]
[-] SetRestaurantMenu.php
[edit]
[-] SetProductsToListing.php
[edit]
[-] UserPlanController.php
[edit]
[-] FollowController.php
[edit]
[+]
Retrieve
[-] SetGeneral.php
[edit]
[-] VerifyPurchaseCode.php
[edit]
[-] PlanRelationshipController.php
[edit]
[-] FreePlanController.php
[edit]
[-] AddBookingComBannerCreator.php
[edit]
[-] ReportController.php
[edit]
[-] RetrieveController.php
[edit]
[-] SetCustomButton.php
[edit]
[-] GetWilokeToolSettings.php
[edit]
[-] PaymentMetaController.php
[edit]
[-] RegisterLoginController.php
[edit]
[-] TermsAndPolicyController.php
[edit]
[-] AppleLoginController.php
[edit]
[-] ChangePlanStatusController.php
[edit]
[-] NextBillingPaymentController.php
[edit]
[-] AddListingPaymentController.php
[edit]
[-] PromotionController.php
[edit]
[-] PrintAddListingSettings.php
[edit]
[-] PayPalExecuteAddListingPayment.php
[edit]
[-] ClaimController.php
[edit]
[-] ViewStatisticController.php
[edit]
[-] SessionController.php
[edit]
[-] SharesStatisticController.php
[edit]
[-] TraitSetEventData.php
[edit]
[-] PrintAddListingFields.php
[edit]
[-] GuardController.php
[edit]
[+]
TransformAddListingData
[-] MessageController.php
[edit]
[-] OptimizeScripts.php
[edit]
[-] InsertLogo.php
[edit]
[-] SetPostDuration.php
[edit]
[-] GridItemController.php
[edit]
[-] SetVideo.php
[edit]
[-] AddMorePhotosVideosController.php
[edit]
[-] TraitAddListingSettings.php
[edit]
[-] InsertGallery.php
[edit]
[-] BillingControllers.php
[edit]
[-] GetSingleImage.php
[edit]
[-] BelongsToTags.php
[edit]
[-] PermalinksController.php
[edit]
[-] RunUpdateDBToLatestVersionController.php
[edit]
[-] SetListingBelongsToPlanID.php
[edit]
[-] NoticeController.php
[edit]
[-] DirectBankTransferController.php
[edit]
[-] SetPriceRange.php
[edit]
[-] TagsBelongsToCatController.php
[edit]
[-] PayPalController.php
[edit]
[-] InsertAddress.php
[edit]
[-] MapListingController.php
[edit]
[-] ListingController.php
[edit]
[-] AuthorPageController.php
[edit]
[-] RestaurantMenuController.php
[edit]
[-] PaymentStatusController.php
[edit]
[-] SetSocialNetworks.php
[edit]
[-] SetCustomSections.php
[edit]
[-] TranslationController.php
[edit]
[-] IconController.php
[edit]
[-] SetGroupData.php
[edit]
[-] SetContactInfo.php
[edit]
[-] ProfileController.php
[edit]
[-] ShareController.php
[edit]
[-] InsertCoverImage.php
[edit]
[-] HandleSubmit.php
[edit]
[-] SetMyRoom.php
[edit]
[-] ModalController.php
[edit]