Plugin Directory

Changeset 1751990


Ignore:
Timestamp:
10/24/2017 05:04:51 PM (8 years ago)
Author:
reblogdog
Message:

Commit v7.0.1

Location:
blogdog/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • blogdog/trunk/admin/admin.php

    r1750834 r1751990  
    175175        wp_enqueue_script( 'jquery-ui-button' );
    176176        wp_enqueue_script( 'jquery-ui-sortable' );
    177         wp_enqueue_script( 'blogdog_js' );
    178 
    179         $this->get_json(); ?>
     177        wp_enqueue_script( 'blogdog_js' ); ?>
    180178
    181179        <div id="blogdog_admin" class="wrap">
     
    199197           
    200198        </div><?
    201 
    202     }
    203 
    204     public function get_json() {
    205 
    206         $this->location_json = true;
    207 
    208         if( $location_json = get_transient( 'blogdog_location_json' ) ) {
    209 
    210             $this->state_json       = $location_json->state_json;
    211             $this->city_json        = $location_json->city_json;
    212             $this->zip_json         = $location_json->zip_json;
    213 
    214         } else {
    215 
    216             $endpoint = 'json/';
    217 
    218             $this->state_json       = json_decode( file_get_contents( $this->base_url . $endpoint . 'state.json'  ), true );
    219             $this->city_json        = json_decode( file_get_contents( $this->base_url . $endpoint . 'city.json'   ), true );
    220             $this->zip_json         = json_decode( file_get_contents( $this->base_url . $endpoint . 'zipcode.json'), true );
    221 
    222             set_transient( 'blogdog_location_json', $this, 12 * HOUR_IN_SECONDS );
    223 
    224         }
    225199
    226200    }
     
    640614                    <div id="sortable" class="wait-to-load">
    641615
    642                         <? _e( 'Loading . . .', 'blogdog' ); ?><i class="fa fa-spinner fa-pulse fa-fw fa-2x"></i>
     616                        <? _e( 'Loading . . . Please Wait.', 'blogdog' ); ?><i class="fa fa-spinner fa-pulse fa-fw fa-2x"></i>
    643617
    644618                    </div>
     
    671645        check_ajax_referer( 'blogdog_secure_me', 'blogdog_ajax_nonce' );
    672646
    673         $this->get_json();
    674 
    675647        $settings = get_option( 'blogdog_api_settings' );
    676648
     
    678650                   
    679651        if( $locations = get_option( 'blogdog_locations' ) ) {
    680                                
     652                       
    681653            foreach( $locations as $location ) {
    682654                               
    683655                echo $this->blogdog_location( $location, $location['type'] );
    684                                
     656                   
    685657            }
    686658                         
     
    10501022   
    10511023    public function blogdog_location( $location, $type, $ajax = false ) {
    1052    
    1053         if( ! isset( $this->location_json ) ) {
    1054 
    1055             $this->get_json();
    1056 
    1057         }
    10581024
    10591025        extract( $location );
     
    11521118                        if( ! empty ( $city ) ) {
    11531119                           
    1154                             $result = $this->blogdog_zipcode_checkbox( $city, $zip, $section );
    1155                            
    1156                             if( $result )  echo $result;
    1157                             else  _e( 'No zipcodes available for this city.', 'blogdog' );
     1120                            echo $this->blogdog_zipcode_checkbox( $city, $zip, $section ); 
    11581121                       
    11591122                        } ?>
     
    12461209                        <? _e( ' 4 Bedrooms and 3 Bath', 'blogdog' ); ?></td>
    12471210                       
    1248                     </tr>
    1249                    
    1250                     <?
    1251                     $settings = array();
     1211                    </tr><?
     1212
    12521213                    $settings = get_option( 'blogdog_api_settings' );
    12531214                   
     
    12801241    }
    12811242
    1282    
     1243    /**
     1244     * Get Json
     1245     *
     1246     * Get type of json requestsed and store in transient if not already.
     1247     *
     1248     * @since 7.0.0
     1249     *
     1250     * @param string $type Filename of json.
     1251     */
     1252
     1253    public function get_json( $type ) {
     1254
     1255        $transient = 'blogdog_json_' . $type;
     1256
     1257        if( $json = get_transient( $transient ) ) {
     1258
     1259            return $json;
     1260
     1261        } else {
     1262
     1263            $json = json_decode( file_get_contents( $this->base_url . 'json/' . $type . '.json'  ), true );
     1264
     1265            set_transient( $transient, $json, 12 * HOUR_IN_SECONDS );
     1266
     1267            return $json;
     1268
     1269        }
     1270
     1271    }
     1272
    12831273    /**
    12841274     * State select
     
    12971287            <option value=""><? _e( 'Select One', 'blogdog' ); ?></option><?
    12981288
    1299             foreach ( $this->state_json as $state ) { ?>
     1289            foreach ( $this->get_json( 'state' ) as $state ) { ?>
    13001290               
    13011291                <option value="<? echo $state['state_code']; ?>" <? if( $saved_state == $state['state_code'] ) echo 'selected'; ?>>
     
    13481338        <option value=""><? _e( 'Select City', 'blogdog' ); ?></option><?
    13491339       
    1350         foreach ( $this->city_json as $row ) {
     1340        foreach ( $this->get_json( 'city' ) as $row ) {
    13511341               
    13521342            if( $row['state_code'] == $state ) { ?>
     
    13851375       
    13861376        $i = false;
    1387        
    1388         $this->get_json();
    13891377
    13901378        ob_start();
    13911379       
    1392         foreach ( $this->zip_json as $row ) {
     1380        foreach ( $this->get_json( 'zipcode' ) as $row ) {
    13931381           
    13941382            if( $row['city'] == $city && $row['state'] == $state ) {
     
    14131401
    14141402        }
    1415        
    1416         if( $i ) return ob_get_clean();
    1417         else return false;
     1403
     1404        if( ! $i ) 'No zipcodes available for this city.';
     1405       
     1406        return ob_get_clean();
    14181407       
    14191408    }
  • blogdog/trunk/blogdog.php

    r1750834 r1751990  
    44Plugin URI:  https://reblogdog.com
    55Description: Add automated real estate content to your website. We publish an SEO optimized blog post for you everyday.
    6 Version:     7.0.0
     6Version:     7.0.1
    77Author:      reblogdog
    88Author URI:  https://reblogdog.com
     
    2828
    2929if ( ! defined( 'BLOGDOG_PLUGIN_VERSION' ) )
    30     define( 'BLOGDOG_PLUGIN_VERSION', '7.0.0' );
     30    define( 'BLOGDOG_PLUGIN_VERSION', '7.0.1' );
    3131
    3232/**
     
    156156       
    157157        add_action( 'check_event_schedule', array( $this, 'check_event_schedule' ), 10, 1 );
     158
     159        /**
     160         * Refresh Transients
     161         *
     162         * @since 7.0.1
     163         */
     164
     165        add_action( 'init', array( $this, 'blogdog_refresh_transients' ) );
    158166       
    159167       
     
    639647       
    640648    }
     649
     650    /**
     651     * Blogdog Refresh Tarnsients.
     652     *
     653     * Delete the location json transients.
     654     *
     655     * @since 7.0.1
     656     */
     657
     658    public function blogdog_refresh_transients() {
     659
     660        if( isset( $_GET['blogdog_refresh'] ) ) {
     661            delete_transient( 'blogdog_json_city' );
     662            delete_transient( 'blogdog_json_state' );
     663            delete_transient( 'blogdog_json_zipcode' );
     664        }
     665
     666    }
    641667   
    642668    /**
  • blogdog/trunk/readme.txt

    r1750834 r1751990  
    6363== Changelog ==
    6464
     65= 7.0.1 =
     66
     67* Bug fix - Storing locations json in separate transients.
     68
    6569= 7.0.0 =
    6670
Note: See TracChangeset for help on using the changeset viewer.