PATH:
home
/
letacommog
/
laindinois
/
wp-content
/
plugins
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use WilokeListingTools\Controllers\Retrieve\AjaxRetrieve; use WilokeListingTools\Framework\Helpers\FileSystem; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\HTML; use WilokeListingTools\Framework\Helpers\SetSettings; use WilokeListingTools\Framework\Helpers\Time; use WilokeListingTools\Framework\Routing\Controller; use WilokeListingTools\Models\SharesStatistic; use WilokeListingTools\Models\ViewStatistic; class SharesStatisticController extends Controller { public function __construct() { add_action('wp_ajax_wilcity_count_shares', [$this, 'update']); add_action('wp_ajax_nopriv_wilcity_count_shares', [$this, 'update']); add_action('wp_ajax_wilcity_shares_latest_week', [$this, 'getSharesOfLatestWeek']); add_action('wp_ajax_wilcity_fetch_shares_general', [$this, 'fetchSharesGeneral']); add_action('rest_api_init', function () { register_rest_route(WILOKE_PREFIX.'/v2', '/dashboard/(?P<postID>\d+)/compare-shares', [ 'methods' => 'GET', 'callback' => [$this, 'getCompareShare'] ]); }); } public function getCompareShare(\WP_REST_Request $oRequest) { $postID = $oRequest->get_param('postID'); $aComparison = SharesStatistic::compare(get_post_field('post_author', $postID), $postID); if ($aComparison['number'] > 1) { $aComparison['text'] = esc_html__('Shares', 'wiloke-listing-tools'); } else { $aComparison['text'] = esc_html__('Share', 'wiloke-listing-tools'); } return ['data' => $aComparison]; } public function fetchSharesGeneral() { $this->middleware(['isUserLoggedIn'], []); $userID = get_current_user_id(); $aCompare = SharesStatistic::compare($userID); wp_send_json_success( [ 'totalShares' => $aCompare['total'], 'oChanging' => [ 'number' => $aCompare['number'], 'description' => esc_html__('Compared to the last week', 'wiloke-listing-tools'), 'status' => $aCompare['status'], 'is' => $aCompare['is'] ] ] ); } public function getSharesOfLatestWeek() { $oRetrieve = new RetrieveController(new AjaxRetrieve()); $this->middleware(['isUserLoggedIn'], []); $aDateInThisWeek = Time::getAllDaysInThis(); $aCountViewsOfWeek = []; $today = Time::mysqlDate(\time()); $userID = get_current_user_id(); $aCompareShares = SharesStatistic::compare($userID); foreach ($aDateInThisWeek as $date) { if ($today == $date) { $shareToday = SharesStatistic::getShareToday($userID); $aCountViewsOfWeek[] = $shareToday; } else { $aCountViewsOfWeek[] = SharesStatistic::getTotalSharesOfAuthorInDay($userID, $date); } } $oRetrieve->success([ 'data' => $aCountViewsOfWeek, 'total' => $aCompareShares['total'], 'compare' => [ 'diff' => $aCompareShares['diff'], 'tooltip' => esc_html__('Compare with the last week', 'wiloke-listing-tools'), 'label' => esc_html__('Share Statistic', 'wiloke-listing-tools'), 'status' => $aCompareShares['status'], 'representColor' => $aCompareShares['representColor'] ] ]); } public static function renderShared($postID, $hasDecoration = true) { $countShared = GetSettings::getPostMeta($postID, 'count_shared'); $countShared = abs($countShared); if (!$hasDecoration) { return $countShared; } $countShared = empty($countShared) ? 0 : $countShared; echo '<span class="wilcity-count-shared-'.esc_attr($postID).'">'.$countShared.' '. esc_html__('Shared', 'wiloke-listing-tools').'</span>'; } public function update() { $this->middleware(['isPublishedPost'], [ 'postID' => $_POST['postID'] ]); $postID = abs($_POST['postID']); if ($countSharedToday = SharesStatistic::countSharesToday($postID, Time::mysqlDate())) { SharesStatistic::update($postID); } else { SharesStatistic::insert($postID, 1); } $postShared = GetSettings::getPostMeta($postID, 'count_shared'); $postShared = absint($postShared) + 1; SetSettings::setPostMeta($postID, 'count_shared', $postShared); wp_send_json_success([ 'countShared' => $postShared, 'text' => esc_html__('Shared', 'wiloke-listing-tools') ]); } }
[+]
..
[-] 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]