Plugin Directory

Changeset 3277790


Ignore:
Timestamp:
04/21/2025 01:20:11 AM (11 months ago)
Author:
inspireui
Message:

version 4.17.3

Location:
mstore-api
Files:
494 added
6 edited

Legend:

Unmodified
Added
Removed
  • mstore-api/trunk/controllers/flutter-user.php

    r3264257 r3277790  
    408408        }
    409409
    410         if(array_key_exists('role', $params)){
    411             $role = $params["role"];
    412         }
    413         if (isset($role)) {
    414             if (!in_array($role, ['subscriber', 'wcfm_vendor', 'seller', 'wcfm_delivery_boy', 'driver'], true)) {
    415                 return parent::sendError("invalid_role", "Role is invalid.", 400);
    416             }
    417         }
    418410        if( isset($params['dokan_enable_selling'])){
    419411            $dokan_enable_selling  =  $params['dokan_enable_selling'];
     
    474466
    475467                $default_role = class_exists( 'WooCommerce' ) ? 'customer' : get_option('default_role');
    476                 $user['role'] = isset($params["role"]) ? sanitize_text_field($params["role"]) : $default_role;
     468                if( isset($params['dokan_enable_selling'])){
     469                    $user['role'] = 'seller';
     470                }else{
     471                    if (array_key_exists('role', $params) && in_array($params['role'], ['wcfm_delivery_boy', 'driver'], true)) {
     472                        $user['role'] = $params['role'];
     473                    }else{
     474                        $user['role'] = $default_role;
     475                    }
     476                }
    477477                $_POST['user_role'] = $user['role'];//fix to register account with role in listeo
    478478
  • mstore-api/trunk/controllers/flutter-vendor-admin.php

    r2895420 r3277790  
    569569                $data['id'] = $tax->attribute_id;
    570570                $data['label'] = $tax->attribute_label;
    571                 $data['name'] =  $tax->labels->singular_name;
     571                $data['name'] =  isset($tax->labels) ? $tax->labels->singular_name : $tax->attribute_name;
    572572                foreach ($taxonomy_terms as $term) {
    573573                    $data['options'][] = $term->name;
  • mstore-api/trunk/controllers/listing-rest-api/class.api.fields.php

    r3264257 r3277790  
    2424            'add_custom_type_to_rest_api'
    2525        ));
    26        
     26
    2727        add_action('rest_api_init', array(
    2828            $this,
     
    3030        ));
    3131    }
    32    
     32
    3333    /**
    3434     * Detect the theme and set related properties
     
    176176                ) ,
    177177            ));
    178        
     178
    179179            register_rest_route('wp/v2', '/lp-reviews/(?P<listing_id>\d+)', array(
    180180                'methods' => 'GET',
     
    416416                }
    417417        ));
    418        
     418
    419419        register_rest_route('wp/v2', '/get-nearby-listings', array(
    420420            'methods' => 'GET',
     
    444444                $this,
    445445                'get_listing_types'
     446            ),
     447            'permission_callback' => function () {
     448                return true;
     449            }
     450        ));
     451
     452        register_rest_route('wp/v2', '/get-listing-regions', array(
     453            'methods' => 'GET',
     454            'callback' => array(
     455                $this,
     456                'get_listing_regions'
    446457            ),
    447458            'permission_callback' => function () {
     
    503514    }
    504515
     516    public function get_listing_regions($request){
     517        if ($this->_isMyListing) {
     518            $regions = get_terms([
     519                'taxonomy' => 'region',
     520                'hide_empty' => false,
     521            ]);
     522
     523            return $regions;
     524        } else {
     525            return new WP_Error("not_found",  "get_listing_regions is not implemented", array('status' => 404));
     526        }
     527    }
     528
    505529    public function get_nearby_listings($request){
    506530        $current_lat = $request['lat'];
     
    520544            $offset= ($offset -1) * $limit;
    521545        }
    522        
     546
    523547        $data = array();
    524548        global $wpdb;
     
    543567        }
    544568        if( $this->_isMyListing){
    545             $listing_type = $request['listing_type'] ?? 'place';
    546             $bodyReq = ['proximity_units'=>'km','listing_type'=>$listing_type, 'form_data'=>[
    547                 'search_keywords'=>'',
    548                 'proximity'=>$radius,
    549                 'lat'=>$current_lat,
    550                 'lng'=>$current_long,
    551                 'category'=>'',
    552                 'search_location'=> $search_location ?? '',
    553                 'region'=>'',
    554                 'tags'=>'',
    555                 'sort'=>'nearby'
    556                 ]
    557             ];
    558             if(isset($request['per_page']) && $request['per_page'] != -1){
    559                 $bodyReq['form_data']['page'] = $offset / $limit;
    560                 $bodyReq['form_data']['per_page'] = $limit;
    561             }
    562             $posts =  myListingExploreListings($bodyReq);
     569            $listing_type = $request['listing_type'] ?? '';
     570            $listing_category = $request['listing_category'] ?? '';
     571            $listing_region = $request['listing_region'] ?? '';
     572
     573
     574            if (!empty($listing_category)) {
     575                // Filter by listing category
     576                $bodyReq = [
     577                    'listing_category' => $listing_category,
     578                    'form_data' => [
     579                        'page' => $offset / $limit,
     580                        'per_page' => $limit,
     581                        'orderby' => 'date',
     582                        'order' => 'DESC'
     583                    ]
     584                ];
     585            } else if (!empty($listing_type)) {
     586                // Filter by listing type
     587                $bodyReq = [
     588                    'proximity_units' => 'km',
     589                    'listing_type' => $listing_type,
     590                    'form_data' => [
     591                        'search_keywords' => '',
     592                        'proximity' => $radius,
     593                        'lat' => $current_lat,
     594                        'lng' => $current_long,
     595                        'search_location' => $search_location ?? '',
     596                        'region' => '',
     597                        'tags' => '',
     598                        'sort' => 'nearby',
     599                        'page' => $offset / $limit,
     600                        'per_page' => $limit
     601                    ]
     602                ];
     603            } else if (!empty($listing_region)) {
     604                // Filter by listing region
     605                $bodyReq = [
     606                    'listing_region' => $listing_region,
     607                    'form_data' => [
     608                        'page' => $offset / $limit,
     609                        'per_page' => $limit,
     610                        'orderby' => 'date',
     611                        'order' => 'DESC'
     612                    ]
     613                ];
     614            }
     615            else {
     616                $bodyReq = [];
     617            }
     618
     619            $posts = myListingExploreListings($bodyReq);
    563620            $items = (array)($posts);
    564621            foreach ($items as $item):
     
    596653                $this_long = listing_get_metabox_by_ID('longitude',$item->ID);
    597654                if( !empty($this_lat) && !empty($this_long) ){
    598                    
     655
    599656                    $calDistance = GetDrivingDistance($current_lat, $this_lat, $current_long, $this_long, 'km');
    600657                    if(!empty($calDistance['distance'])){
     
    627684        $page = max(1, absint($request->get_param('page') ?: 1));
    628685        $per_page = absint($request->get_param('per_page') ?: 100);
    629        
     686
    630687        $query = new WP_Query([
    631688            'post_type' => 'lp-reviews',
     
    638695            ]]
    639696        ]);
    640        
     697
    641698        $results = [];
    642699        while ($query->have_posts()) {
     
    646703            $avatar = get_user_meta($author_id, 'user_avatar', true);
    647704            $avatar_url = (!empty($avatar) && !is_bool($avatar)) ? $avatar[0] : get_avatar_url($author_id);
    648            
     705
    649706            $results[] = [
    650707                'id' => $post_id,
     
    861918        $_hour = isset($data->_hour) ? $data->_hour : null;
    862919        $services = isset($data->services) ? $data->services : false;
     920        $services = is_array($services) || is_object($services)
     921        ? array_values(array_filter(array_map(
     922            fn($item) => is_object($item)
     923                ? ['service' => sanitize_title($item->service), 'value' => $item->value]
     924                : (is_array($item) && isset($item['service'], $item['value'])
     925                    ? ['service' => sanitize_title($item['service']), 'value' => $item['value']]
     926                    : null),
     927            is_object($services) ? (array)$services : $services
     928        )))
     929        : [];
    863930        $comment_services = false;
    864931        $coupon = isset($data->coupon) ? $data->coupon : null;
     
    11761243
    11771244        // End of Listeo theme functions
    1178        
     1245
    11791246
    11801247        function _rest_get_address_data( $object ) {
     
    11871254                if($results) {
    11881255                    return $results->address;
    1189             } else return ""; //return nothing 
     1256            } else return ""; //return nothing
    11901257        }
    11911258
     
    11991266                if($results) {
    12001267                    return $results->lat;
    1201             } else return ""; //return nothing 
    1202         } 
     1268            } else return ""; //return nothing
     1269        }
    12031270
    12041271        function _rest_get_lng_data( $object ) {
     
    12111278                if($results) {
    12121279                    return $results->lng;
    1213             } else return ""; //return nothing 
     1280            } else return ""; //return nothing
    12141281        }
    12151282
     
    14141481                $data['lng'] = $results->lng;
    14151482            }
    1416             return $data; 
     1483            return $data;
    14171484        }
    14181485
     
    16291696                $meta['_case27_listing_type_name'] = $listing_type->get_name();
    16301697            }
    1631            
     1698
    16321699            if (array_key_exists('_menu', $meta)) {
    16331700                $meta['_menu'] = array_map(function($item){
     
    16461713                }, $meta['_menu']);
    16471714            }
    1648            
     1715
    16491716            return $meta;
    16501717        }
     
    18761943                    {
    18771944                        $getVal = get_post_meta($value, '_wp_attached_file', true);
    1878    
     1945
    18791946                        if (!empty($getVal))
    18801947                        {
     
    21462213            $is_featured = $request['featured'] == 'true';
    21472214            if($is_featured == true){
    2148              $args['meta_key'] = '_featured';   
     2215             $args['meta_key'] = '_featured';
    21492216             $args['meta_query'] = array( 'key' => '_featured', 'value' => 'on', 'compare' => '=' );
    21502217            }
     
    21522219        }
    21532220    } // end Class
    2154    
     2221
    21552222
    21562223    // class For get case27_job_listing_tags for get All Tags to show in Filter Search
     
    21862253         * Detect the theme and set related properties
    21872254         */
    2188         public function detect_theme() 
     2255        public function detect_theme()
    21892256        {
    21902257            $isChild = strstr(strtolower(wp_get_theme()), "child");
     
    23302397                'register_fields_for_search_advance'
    23312398            ));
    2332            
     2399
    23332400            // Call parent constructor to ensure proper initialization
    23342401            parent::__construct();
     
    23582425                        //  return is_string( $param );
    23592426                        // }
    2360                        
     2427
    23612428                    ) ,
    23622429                    'type' => array(
     
    23642431                        //  return is_string( $param );
    23652432                        // }
    2366                        
     2433
    23672434                    ) ,
    23682435                    'regions' => array(
     
    23702437                        //  return is_string( $param );
    23712438                        // }
    2372                        
     2439
    23732440                    ) , // for listify
    23742441                    'typeListable' => array() , // for listable
     
    23772444                        //  return is_string( $param );
    23782445                        // }
    2379                        
     2446
    23802447                    ) ,
    23812448                    'author' => array(
     
    23832450                        //  return is_string( $param );
    23842451                        // }
    2385                        
     2452
    23862453                    ) ,
    23872454                    'isGetLocate' => array(
     
    25142581                $sql .= "b.meta_key='geolocation_lat' OR b.meta_key='geolocation_long') AND a.post_status='publish' GROUP BY b.post_id) AS t INNER ";
    25152582                $sql .= "JOIN {$wpdb->prefix}posts as p on (p.ID=t.post_id)  ORDER BY distance LIMIT 30";
    2516                
     2583
    25172584                $sql = $wpdb->prepare($sql,$lat,$long,$lat);
    25182585                $posts = $wpdb->get_results($sql, OBJECT);
     
    25222589                }
    25232590                // return $posts;
    2524                
     2591
    25252592            }
    25262593
  • mstore-api/trunk/controllers/listing-rest-api/mylisting-functions.php

    r3166875 r3277790  
    11<?php
    22
    3 function myListingExploreListings($request) 
     3function myListingExploreListings($request)
    44{
    55    global $wpdb;
    66
    7     if ( empty( $request['form_data'] ) || ! is_array( $request['form_data'] ) || empty( $request['listing_type'] ) ) {
     7    if (empty($request['form_data']) || !is_array($request['form_data'])) {
    88        return [];
    99    }
    1010
    11     if ( ! ( $listing_type_obj = ( get_page_by_path( $request['listing_type'], OBJECT, 'case27_listing_type' ) ) ) ) {
    12         return [];
    13     }
     11    $form_data = $request['form_data'];
     12    $page = absint(isset($form_data['page']) ? $form_data['page'] : 0);
     13    $per_page = isset($form_data['per_page']) ? absint($form_data['per_page']) : -1;
     14    $orderby = sanitize_text_field(isset($form_data['orderby']) ? $form_data['orderby'] : 'date');
    1415
    15     $type = new \MyListing\Src\Listing_Type( $listing_type_obj );
    16     $form_data = $request['form_data'];
    17     $starttime = microtime(true);
    18 
    19     $page = absint( isset($form_data['page']) ? $form_data['page'] : 0 );
    20     $per_page = isset($form_data['per_page']) ? absint(  $form_data['per_page'])  : -1;
    21     $orderby = sanitize_text_field( isset($form_data['orderby']) ? $form_data['orderby'] : 'date' );
    2216    $args = [
    23         'order' => sanitize_text_field( isset($form_data['order']) ? $form_data['order'] : 'DESC' ),
     17        'order' => sanitize_text_field(isset($form_data['order']) ? $form_data['order'] : 'DESC'),
    2418        'offset' => $page * $per_page,
    2519        'orderby' => $orderby,
     
    3125    ];
    3226
    33     \MyListing\Src\Queries\Explore_Listings::instance()->get_ordering_clauses( $args, $type, $form_data );
    34 
    35     // Make sure we're only querying listings of the requested listing type.
    36     if ( ! $type->is_global() ) {
    37         $args['meta_query']['listing_type_query'] = [
    38             'key'     => '_case27_listing_type',
    39             'value'   =>  $type->get_slug(),
    40             'compare' => '='
     27    // Handle listing category filter
     28    if (!empty($request['listing_category'])) {
     29        $args['tax_query'][] = [
     30            'taxonomy' => 'job_listing_category',
     31            'field' => 'name',
     32            'terms' => sanitize_text_field($request['listing_category'])
    4133        ];
    4234    }
    43    
    44     foreach ( (array) $type->get_advanced_filters() as $filter ) {
    45         $args = $filter->apply_to_query( $args, $form_data );
     35
     36    // Handle listing region filter
     37    if (!empty($request['listing_region'])) {
     38        $args['tax_query'][] = [
     39            'taxonomy' => 'region',
     40            'field' => 'name',
     41            'terms' => sanitize_text_field($request['listing_region'])
     42        ];
    4643    }
    47    
     44
     45    // Handle listing type filter
     46    if (!empty($request['listing_type'])) {
     47        if (!($listing_type_obj = get_page_by_path($request['listing_type'], OBJECT, 'case27_listing_type'))) {
     48            return [];
     49        }
     50
     51        $type = new \MyListing\Src\Listing_Type($listing_type_obj);
     52
     53        // Make sure we're only querying listings of the requested listing type.
     54        if (!$type->is_global()) {
     55            $args['meta_query']['listing_type_query'] = [
     56                'key' => '_case27_listing_type',
     57                'value' => $type->get_slug(),
     58                'compare' => '='
     59            ];
     60        }
     61
     62        foreach ((array) $type->get_advanced_filters() as $filter) {
     63            $args = $filter->apply_to_query($args, $form_data);
     64        }
     65    }
     66
    4867    $result = [];
    4968
     
    5372     * @since 1.7.0
    5473     */
    55     do_action_ref_array( 'mylisting/get-listings/before-query', [ &$args, $type, $result ] );
    56    
    57     $listings = \MyListing\Src\Queries\Explore_Listings::instance()->query( $args );
     74    do_action_ref_array('mylisting/get-listings/before-query', [&$args, $type ?? null, $result]);
    5875
    59     if(count($listings->posts) > 0){
    60         $in = '(' . implode(',', $listings->posts) .')';
     76    $listings = \MyListing\Src\Queries\Explore_Listings::instance()->query($args);
     77
     78    if (count($listings->posts) > 0) {
     79        $in = '(' . implode(',', $listings->posts) . ')';
    6180        $table_name = $wpdb->prefix . "posts";
    6281        $sql = "SELECT * FROM {$table_name}";
    63         $sql .= " WHERE {$table_name}.ID in ".$in;
     82        $sql .= " WHERE {$table_name}.ID in " . $in;
    6483        $sql = $wpdb->prepare($sql);
    6584        $results = $wpdb->get_results($sql);
    6685
    6786        return $results;
    68     }else{
     87    } else {
    6988        return [];
    7089    }
  • mstore-api/trunk/mstore-api.php

    r3264257 r3277790  
    44 * Plugin URI: https://github.com/inspireui/mstore-api
    55 * Description: The MStore API Plugin which is used for the FluxBuilder and FluxStore Mobile App
    6  * Version: 4.17.2
     6 * Version: 4.17.3
    77 * Author: FluxBuilder
    88 * Author URI: https://fluxbuilder.com
     
    6262class MstoreCheckOut
    6363{
    64     public $version = '4.17.2';
     64    public $version = '4.17.3';
    6565
    6666    public function __construct()
  • mstore-api/trunk/readme.txt

    r3264257 r3277790  
    44Requires at least: 4.4
    55Tested up to:      6.5.3
    6 Stable tag:        4.17.2
     6Stable tag:        4.17.3
    77License:           GPL-2.0
    88License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    4949
    5050== Changelog ==
     51= 4.17.3 =
     52  * fix register security issue
     53  * Support get nearby listings by category and region
     54 
    5155= 4.17.2 =
    5256  * fix addons in webview
Note: See TracChangeset for help on using the changeset viewer.