PATH:
home
/
letacommog
/
laindinois
/
wp-content
/
plugins
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use WilokeListingTools\Framework\Helpers\General; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Routing\Controller; class AddMorePhotosVideosController extends Controller { public static $aPlanSettings = null; protected $aRawGallery; protected $listingID; protected $aGallery; protected $aVideos; use InsertGallery; use SetVideo; public function __construct() { // add_action('wilcity/footer/vue-popup-wrapper', array($this, 'printFooter')); add_action('wp_ajax_fetch_photos_of_listing', array($this, 'fetchPhotos')); add_action('wp_ajax_nopriv_fetch_photos_of_listing', array($this, 'fetchPhotos')); // add_action('wp_ajax_fetch_videos_of_listing', array($this, 'fetchVideos')); // add_action('wp_ajax_nopriv_fetch_videos_of_listing', array($this, 'fetchVideos')); add_action( 'rest_api_init', function () { register_rest_route( WILOKE_PREFIX.'/v2', '/listings/(?P<postID>\d+)/add-more-videos', array( 'methods' => 'GET', 'callback' => array($this, 'getVideos') )); register_rest_route( WILOKE_PREFIX.'/v2', '/listings/(?P<postID>\d+)/add-more-photos', array( 'methods' => 'GET', 'callback' => array($this, 'getPhotos') )); }); add_action('wp_ajax_update_gallery_and_videos', array($this, 'updateGalleryAndVideos')); } protected function getPlanSettings(){ $planID = GetSettings::getPostMeta($this->listingID, 'belongs_to'); if ( isset(self::$aPlanSettings[$planID]) ){ return self::$aPlanSettings[$planID]; } if ( empty($planID) ){ self::$aPlanSettings[$planID] = array(); }else{ self::$aPlanSettings[$planID] = GetSettings::getPlanSettings($planID); } return self::$aPlanSettings[$planID]; } protected function parseVideo(){ $this->aVideos = $_POST['videos']; if ( !current_user_can('edit_theme_options') ){ $aPlanSettings = $this->getPlanSettings(); if ( $aPlanSettings && $aPlanSettings['toggle_videos'] == 'disable' ){ return true; } if ( !empty($this->aVideos) ){ if ( !empty($aPlanSettings['maximumVideos']) ){ $this->aVideos = array_splice($this->aVideos, 0, $aPlanSettings['maximumVideos']); } } } $this->setVideos(); return true; } protected function parseGallery(){ $this->aRawGallery = $_POST['gallery']; if ( !current_user_can('edit_theme_options') ){ $aPlanSettings = $this->getPlanSettings(); if ( !empty($aPlanSettings) && $aPlanSettings['toggle_gallery'] == 'disable' ){ return true; } if ( !empty($this->aRawGallery) ){ if ( !empty($aPlanSettings['maximumGalleryImages']) ){ $this->aRawGallery = array_splice($this->aRawGallery, 0, $aPlanSettings['maximumGalleryImages']); } } } $this->insertGallery(); return true; } public function updateGalleryAndVideos(){ $this->listingID = $_POST['listingID']; $this->middleware(['isListingBeingReviewed', 'isPostAuthor'], array( 'postID' => $this->listingID, 'passedIfAdmin' => true )); $this->parseGallery(); $this->parseVideo(); wp_send_json_success(array( 'msg' => esc_html__('Congratulations! Your update has been successfully', 'wiloke-listing-tools') )); } public function getVideos($oData){ $this->listingID = $oData->get_param('postID'); $aPlanSettings = $this->getPlanSettings(); if ( !empty($aPlanSettings) && $aPlanSettings['toggle_videos'] == 'disable' ){ return array( 'error' => array( 'userMessage' => esc_html__('The Add Video is not supported by this plan.', 'wiloke-listing-tools'), 'code' => 404 ) ); } $aRawVideos = GetSettings::getPostMeta($this->listingID, 'video_srcs'); if ( !empty($aRawVideos) ){ $aReturn = array('videos'=>$aRawVideos); $aReturn = $aReturn + array('oPlanSettings'=>$aPlanSettings); } if ( !isset($aPlanSettings['maximumVideos']) || empty($aPlanSettings['maximumVideos']) ){ $aReturn['msg'] = ''; $aReturn['videos'] = array(); }else{ $aReturn['msg'] = sprintf(esc_html__('You can upload maximum %s video urls to this listing', 'wiloke-listing-tools'), $aPlanSettings['maximumVideos']); } return array('data'=>$aReturn); } public function getPhotos($oData){ $this->listingID = $oData->get_param('postID'); $aPlanSettings = $this->getPlanSettings(); if ( $aPlanSettings && $aPlanSettings['toggle_gallery'] == 'disable' ){ return array( 'error' => array( 'userMessage' => esc_html__('The add photos feature is not supported by this plan.', 'wiloke-listing-tools'), 'code' => 404 ) ); } $aRawPhotos = GetSettings::getPostMeta($this->listingID, 'gallery'); $aReturn = array(); $aPhotos = array(); if ( !empty($aRawPhotos) ){ foreach ($aRawPhotos as $id => $src){ $aPhoto['imgID'] = $id; $aPhoto['src'] = wp_get_attachment_image_url($id, 'medium'); $aPhotos['images'][] = $aPhoto; } $aReturn = $aPhotos; } if ( !current_user_can('edit_theme_options') ){ $aReturn = $aReturn + array('oPlanSettings'=>$aPlanSettings); } if ( !isset($aPlanSettings['maximumGalleryImages']) || empty($aPlanSettings['maximumGalleryImages']) ){ $aReturn['msg'] = ''; }else{ $aReturn['msg'] = sprintf(esc_html__('You can upload maximum %s images to this listing', 'wiloke-listing-tools'), $aPlanSettings['maximumGalleryImages']); } return array('data'=>$aReturn); } }
[+]
..
[-] 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]