Plugin Directory

Changeset 1702542


Ignore:
Timestamp:
07/25/2017 05:31:45 PM (9 years ago)
Author:
trackhs
Message:

Fixed issue with lodging types and added version logging in API request.

Location:
track-connect/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • track-connect/trunk/includes/api/request.php

    r1527834 r1702542  
    2323        array(
    2424            'timeout'     => 500,
    25             'body' => array(
     25            'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; TrackConnect/'. WP_LISTINGS_VERSION .'; ' . get_bloginfo( 'url' ) ),
     26            'body' => array(
    2627                'token'     => $this->token
    2728                )
     
    6465            array(
    6566                'timeout'     => 500,
    66                 'body' => array(
     67                'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; TrackConnect/'. WP_LISTINGS_VERSION .'; ' . get_bloginfo( 'url' ) ),
     68                'body' => array(
    6769                    'token'     => $this->token,
    6870                    'nodetype'  => $nodeTypeId
     
    99101            $unitsCreated = 0;
    100102            $unitsUpdated = 0;
    101            
     103            $lodgingTypes = [];
     104            if(get_option('track_connect_lodging_types')){
     105                $lodgingTypes = (array)json_decode(get_option('track_connect_lodging_types'));
     106            }
     107
    102108            foreach(json_decode($units['body'])->response as $id => $unit){
    103109                if(isset($unit->images)){
     
    228234                        )
    229235                    ));
    230                    
     236
     237                    if($unit->lodgingtypes){
     238                        foreach ($unit->lodgingtypes as $lodgingTypeId => $lodgingTypeName){
     239                            update_post_meta($post_id, '_listing_lodging_type_'.$lodgingTypeId, $lodgingTypeId);
     240                            $lodgingTypes[$lodgingTypeId] = $lodgingTypeName;
     241                        }
     242                    }
     243
    231244                    $my_post = array(
    232245                          'ID'           => $post_id,
     
    358371                            $post_id,'_listing_youtube_id', !isset($youtube_id)?null:$youtube_id
    359372                        )
    360                     ));       
    361                        
     373                    ));
     374
     375                    if($unit->lodgingtypes){
     376                        foreach ($unit->lodgingtypes as $lodgingTypeId => $lodgingTypeName){
     377                            update_post_meta($post_id, '_listing_lodging_type_'.$lodgingTypeId, $lodgingTypeId);
     378                            $lodgingTypes[$lodgingTypeId] = $lodgingTypeName;
     379                        }
     380                    }
     381
    362382                    // Create image
    363383                    $image = $wpdb->get_row("SELECT post_id FROM ".$wpdb->prefix."postmeta WHERE post_id = '".$post_id."' AND meta_key = '_thumbnail_id' LIMIT 1;");
     
    390410                }           
    391411   
    392             }   
    393              
    394             $this->rebuildTaxonomies();
     412            }
     413
     414            /**
     415             * It's possible that if they delete a lodging type it won't get removed, if that happens we can just delete
     416             * the option manually and re-sync.
     417             */
     418
     419            if(count($lodgingTypes)){
     420                update_option('track_connect_lodging_types', json_encode($lodgingTypes));
     421            }
     422
     423            $this->rebuildTaxonomies();
    395424   
    396425            return array(
     
    416445        $unitsUpdated = 0;
    417446        $unitsRemoved = 0;
     447        $lodgingTypes = [];
     448        if(get_option('track_connect_lodging_types')){
     449            $lodgingTypes = (array)json_decode(get_option('track_connect_lodging_types'));
     450        }
     451
    418452       
    419453        $this->getAmenities();
     
    421455        array(
    422456            'timeout'     => 500,
    423             'body' => array(
     457            'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; TrackConnect/'. WP_LISTINGS_VERSION .'; ' . get_bloginfo( 'url' ) ),
     458            'body' => array(
    424459                'token'     => $this->token,
    425460                'page'      => $page,
     
    583618                    )
    584619                ));
    585                
     620
     621                if(isset($unit->lodgingtype) && isset($unit->lodgingtypename)){
     622                    $lodgingTypes[$unit->lodgingtype] = $unit->lodgingtypename;
     623                }
     624
    586625                $my_post = array(
    587626                      'ID'           => $post_id,
     
    731770                        $post_id,'_listing_youtube_id', null
    732771                    )
    733                 ));       
    734                    
     772                ));
     773
     774                if(isset($unit->lodgingtype) && isset($unit->lodgingtypename)){
     775                    $lodgingTypes[$unit->lodgingtype] = $unit->lodgingtypename;
     776                }
     777
    735778                // Create image
    736779                $image = $wpdb->get_row("SELECT post_id FROM ".$wpdb->prefix."postmeta WHERE post_id = '".$post_id."' AND meta_key = '_thumbnail_id' LIMIT 1;");
     
    763806            }           
    764807
    765         }   
     808        }
     809
     810        update_option('track_connect_lodging_types', json_encode($lodgingTypes));
    766811       
    767812        return array(
     
    792837        array(
    793838            'timeout'     => 500,
    794             'body' => array(
     839            'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; TrackConnect/'. WP_LISTINGS_VERSION .'; ' . get_bloginfo( 'url' ) ),
     840            'body' => array(
    795841                'token'     => $this->token
    796842                )
     
    876922        array(
    877923            'timeout'     => 500,
    878             'body' => array(
     924            'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; TrackConnect/'. WP_LISTINGS_VERSION .'; ' . get_bloginfo( 'url' ) ),
     925            'body' => array(
    879926                'token'     => $this->token
    880927                )
     
    940987        array(
    941988            'timeout'     => 500,
    942             'body' => array(
     989            'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; TrackConnect/'. WP_LISTINGS_VERSION .'; ' . get_bloginfo( 'url' ) ),
     990            'body' => array(
    943991                'token'     => $this->token,
    944992                'checkin'   => $checkin,
     
    9881036        array(
    9891037            'timeout'     => 500,
    990             'body' => array(
     1038            'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; TrackConnect/'. WP_LISTINGS_VERSION .'; ' . get_bloginfo( 'url' ) ),
     1039            'body' => array(
    9911040                'token'     => $this->token,
    9921041                'unit_id'   => $unitId
     
    10021051        array(
    10031052            'timeout'     => 500,
    1004             'body' => array(
     1053            'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; TrackConnect/'. WP_LISTINGS_VERSION .'; ' . get_bloginfo( 'url' ) ),
     1054            'body' => array(
    10051055                'token'     => $this->token,
    10061056                'cid'       => $unitId,
  • track-connect/trunk/includes/views/archive-listing.php

    r1699200 r1702542  
    1919$sleeps = (isset($_REQUEST['sleeps']))? $_REQUEST['sleeps']:0;
    2020$debug = (isset($_REQUEST['track_debug']))? $_REQUEST['track_debug']:0;
     21$lodgingType = (isset($_REQUEST['lodging']))? $_REQUEST['lodging']:0;
     22
    2123$availableUnits = false;
    2224$checkAvailability = false;
     
    7678function archive_listing_loop() {
    7779
    78         global $post,$wp_query,$wp_the_query,$availableUnits,$checkAvailability,$bedrooms,$checkin,$checkout,$mam_posts_query,$lowRate,$highRate,$lowBed,$highBed, $sleeps;
     80        global $post,$wp_query,$wp_the_query,$availableUnits,$checkAvailability,$bedrooms,$checkin,$checkout,$mam_posts_query,$lowRate,$highRate,$lowBed,$highBed, $sleeps, $lodgingType;
    7981
    8082        $count = 0; // start counter at 0
     
    160162        }
    161163
     164        if($lodgingType){
     165            $metaArgs[] = array(
     166                'key' => '_listing_lodging_type',
     167                'value' => $lodgingType,
     168                'compare' => '='
     169            );
     170        }
     171
    162172        if(count($metaArgs)){
    163173            $args += array('meta_query' => array(
  • track-connect/trunk/includes/views/search-widget.php

    r1699211 r1702542  
    5555            <select name="lodging" id="lodging" class="listing-lodging">
    5656                <option value="">No Preference</option>
    57                 <?php foreach ( $this->getLodgingTypes() as $lodge ): ?>
    58                     <option <?= ( $lodgingType == $lodge->meta_value ) ? 'SELECTED' : ''; ?>
    59                         value="<?= $lodge->meta_value ?>"><?= $lodge->meta_value ?></option>';
     57                <?php foreach ( (array)json_decode(get_option('track_connect_lodging_types')) as $lodgingTypeId => $lodgingTypeValue): ?>
     58                    <option <?= ( $lodgingType == $lodgingTypeId ) ? 'SELECTED' : ''; ?>
     59                        value="<?= $lodgingTypeId ?>"><?= $lodgingTypeValue; ?></option>';
    6060                <?php endforeach; ?>
    6161            </select>
  • track-connect/trunk/plugin.php

    r1699211 r1702542  
    77    Author URI: http://www.trackhs.com
    88
    9     Version: 3.0.7
     9    Version: 3.0.8
    1010
    1111    License: GNU General Public License v2.0 (or later)
  • track-connect/trunk/readme.txt

    r1699211 r1702542  
    44Requires at least: 3.7
    55Tested up to: 4.8
    6 Stable tag: 3.0.7
     6Stable tag: 3.0.8
    77
    88Creates and syncs listing-type posts from TRACK PM, a cloud-based property management system (www.trackhs.com).
     
    4545== Changelog ==
    4646
     47= 3.0.8 =
     48Fixed issue with lodging types and added version logging in API request.
     49
    4750= 3.0.7 =
    4851Fixed another issue with sidebar bedroom slider.
Note: See TracChangeset for help on using the changeset viewer.