Plugin Directory

Changeset 1850196


Ignore:
Timestamp:
03/30/2018 05:37:47 PM (7 years ago)
Author:
ChrisMKindred
Message:

Deploy version 2.6.2

Location:
usgs-stream-flow-data
Files:
31 added
3 edited

Legend:

Unmodified
Added
Removed
  • usgs-stream-flow-data/trunk/README.txt

    r1848795 r1850196  
    55Requires at least: 3.7
    66Tested up to: 4.9.4
    7 Stable tag: 2.6.1
     7Stable tag: 2.6.2
    88License: GPLv2 or later
    99License URI: //www.gnu.org/licenses/gpl-2.0.html
  • usgs-stream-flow-data/trunk/kwcusgs.php

    r1848795 r1850196  
    1313 * Plugin URI:        //wordpress.org/plugins/usgs-stream-flow-data/
    1414 * Description:       USGS Stream Flow Data
    15  * Version:           2.6.1
     15 * Version:           2.6.2
    1616 * Author:            Chris Kindred
    1717 * Author URI:        //www.kindredwebconsulting.com
  • usgs-stream-flow-data/trunk/public/class-kwc-usgs.php

    r1848669 r1850196  
    1717     * @var     string
    1818     */
    19     const VERSION = '2.5.1';
     19    const VERSION = '2.6.2';
    2020
    2121    /**
     
    292292                ), $atts ) );
    293293
    294         $thePage = get_transient( 'kwc_usgs-' . $location . $graph . $title );
     294        //$thePage = get_transient( 'kwc_usgs-' . $location . $graph . $title );
    295295
    296296        if ( !$thePage ) {
    297             $url = "https://waterservices.usgs.gov/nwis/iv?site=$location&parameterCd=00010,00060,00065&format=waterml";
    298 
    299             $response = wp_remote_get( $url );
    300             $data = wp_remote_retrieve_body( $response );
    301 
    302             if ( ! $data ) {
    303                 return 'USGS Not Responding.';
    304             }
    305 
    306             $data = str_replace( 'ns1:', '', $data );
     297            $response = $this->get_usgs( $location );
     298
     299            if( is_wp_error( $response ) ) {
     300                return get_error_message( $response );
     301            }
     302
     303            if ( ! $response['response_code'] ) {
     304                return $response['response_message'];
     305            }
     306
     307            $data = str_replace( 'ns1:', '', $response['data'] );
    307308
    308309            $xml_tree = simplexml_load_string( $data );
     
    374375            $thePage .= "</div>";
    375376
    376             set_transient( 'kwc_usgs-' . $location . $graph . $title, $thePage, 60 * 15 );
     377            // set_transient( 'kwc_usgs-' . $location . $graph . $title, $thePage, 60 * 15 );
    377378        }
    378379        return $thePage;
    379380    }
    380381
     382    /**
     383     * Makes USGS Call
     384     *
     385     * @param string $location
     386     * @return mixed|array|WP_Error
     387     */
     388    public function get_usgs( $location ) {
     389        $url = "https://waterservices.usgs.gov/nwis/iv?site=$location&parameterCd=00010,00060,00065&format=waterml";
     390        $response = wp_remote_get( $url );
     391        if ( is_wp_error( $response ) ) {
     392            return $response;
     393        }
     394        return array(
     395            'response_code' => wp_remote_retrieve_response_code( $response ),
     396            'response_message' => wp_remote_retrieve_response_message( $response ),
     397            'data' => wp_remote_retrieve_body( $response ),
     398        );
     399    }
     400
    381401}
Note: See TracChangeset for help on using the changeset viewer.