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 PermalinksController extends Controller { public function __construct(){ add_filter('wilcity/filter/register-post-types/listings', array($this, 'filterRewriteRule')); add_filter('post_type_link', array($this, 'modifyLink'), 1, 2 ); add_filter('rewrite_rules_array', array($this, 'addRewriteRulesArray')); } public function addRewriteRulesArray($aRules){ if ( !class_exists('Wiloke') ){ return $aRules; } $new = array(); $aThemeOptions = \Wiloke::getThemeOptions(true); if ( !isset($aThemeOptions['listing_permalink_settings']) || empty($aThemeOptions['listing_permalink_settings']) ){ return $aRules; } $lCase = 0; $cCase = 0; if ( '%listingLocation%' == $aThemeOptions['listing_permalink_settings'] ){ $lCase = 3; }else if ('%listingCat%' == $aThemeOptions['listing_permalink_settings']){ $cCase = 3; }else if ( strpos($aThemeOptions['listing_permalink_settings'], '%listingLocation%/%listingCat%') !== false ){ $lCase = 1; $cCase = 2; }else if ( strpos($aThemeOptions['listing_permalink_settings'], '%listingCat%/%listingLocation%') !== false ){ $lCase = 2; $cCase = 1; } $aCustomPostTypes = GetSettings::getOptions(wilokeListingToolsRepository()->get('addlisting:customPostTypesKey')); foreach ($aCustomPostTypes as $aPostType){ if ( $lCase == 1 || $cCase == 1 ){ $new[$aPostType['slug'].'/([^/]+)/(.+)/(.+)/?$'] = 'index.php?'.$aPostType['key'].'=$matches[3]'; if ( $lCase == 1 ){ $new[$aPostType['slug'].'/(.+)/(.+)/(.+)/?$'] = 'index.php?listing_location=$matches[1]'; $new[$aPostType['slug'].'/(.+)/(.+)/(.+)/?$'] = 'index.php?listing_cat=$matches[2]'; }else if ( $lCase == 2 ){ $new[$aPostType['slug'].'/(.+)/(.+)/(.+)/?$'] = 'index.php?listing_cat=$matches[1]'; $new[$aPostType['slug'].'/(.+)/(.+)/(.+)/?$'] = 'index.php?listing_location=$matches[2]'; } }else if ( $lCase == 3 || $cCase == 3 ){ $new[$aPostType['slug'].'/([^/]+)/(.+)/?$'] = 'index.php?'.$aPostType['key'].'=$matches[2]'; if ( $lCase == 3 ){ $new[$aPostType['slug'].'/(.+)/(.+)/?$'] = 'index.php?listing_location=$matches[1]'; }else if ( $cCase == 3 ){ $new[$aPostType['slug'].'/(.+)/(.+)/?$'] = 'index.php?listing_cat=$matches[1]'; } } } return array_merge( $new, $aRules ); // Ensure our rules come first } protected function getChildCategory($aTerms){ foreach ($aTerms as $oTerm){ if ( $oTerm->parent != 0 ){ return $oTerm; } } return end($aTerms); } public function modifyLink($postLink, $post){ $aThemeOptions = \Wiloke::getThemeOptions(true); if ( !isset($aThemeOptions['listing_permalink_settings']) || empty($aThemeOptions['listing_permalink_settings']) ){ return $postLink; } $aPostTypes = General::getPostTypeKeys(false, true); if ( is_object( $post ) && in_array($post->post_type, $aPostTypes) ){ if ( strpos($aThemeOptions['listing_permalink_settings'],'%listingLocation%') !== false ){ $aTerms = wp_get_object_terms( $post->ID, 'listing_location' ); if ( !empty($aTerms) && !is_wp_error($aTerms) ){ $oTerm = $this->getChildCategory($aTerms); $slug = $oTerm->slug; if ( $oTerm->parent !== 0 && $aThemeOptions['taxonomy_add_parent_to_permalinks'] == 'enable' && strpos($aThemeOptions['listing_permalink_settings'], '%listingCat%') !== false ){ $oParent = get_term_by('term_taxonomy_id', $oTerm->parent); if ( !empty($oParent) && !is_wp_error($oParent) ){ $slug = $oParent->slug .'/' . $slug; } } }else{ $slug = apply_filters('wilcity/wiloke-listing-tools/custom-permalinks/unlocation', 'unlocation'); } $postLink = str_replace( '%listingLocation%' , $slug , $postLink ); } if ( strpos($aThemeOptions['listing_permalink_settings'],'%listingCat%') !== false ){ $aTerms = wp_get_object_terms( $post->ID, 'listing_cat' ); if ( !empty($aTerms) && !is_wp_error($aTerms) ){ $oTerm = $this->getChildCategory($aTerms); $slug = $oTerm->slug; }else{ $slug = 'uncategory'; } $postLink = str_replace( '%listingCat%' , $slug , $postLink ); } } return $postLink; } public function filterRewriteRule($aConfiguration){ if ( !class_exists('Wiloke') ){ return $aConfiguration; } if ( current_user_can('administrator') && defined('WPSEO_VERSION') ){ $currentPageUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; if ( preg_match('/\.xml$/', $currentPageUrl, $aMatches) ){ return $aConfiguration; } } $aThemeOptions = \Wiloke::getThemeOptions(true); if ( isset($aThemeOptions['listing_permalink_settings']) && !empty($aThemeOptions['listing_permalink_settings']) ){ $aConfiguration['rewrite']['slug'] = $aConfiguration['rewrite']['slug'] . '/' . $aThemeOptions['listing_permalink_settings']; $aConfiguration['has_archive'] = true; $aConfiguration['hierarchical'] = true; } return $aConfiguration; } }
[+]
..
[-] 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]