Plugin Directory

Changeset 1876522


Ignore:
Timestamp:
05/17/2018 03:53:13 PM (7 years ago)
Author:
ChrisMKindred
Message:

Deploy version 2.6.4

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

Legend:

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

    r1850211 r1876522  
    55Requires at least: 3.7
    66Tested up to: 5.0
    7 Stable tag: 2.6.3
     7Stable tag: 2.6.4
    88License: GPLv2 or later
    99License URI: //www.gnu.org/licenses/gpl-2.0.html
  • usgs-stream-flow-data/trunk/admin/class-kwc-usgs-admin.php

    r1848669 r1876522  
    11<?php
    22/**
    3  * Admin class for plugin
     3 * Admin
    44 *
    5  * @package   USGS Steam Flow Data
    6  * @author    Chris Kindred <[email protected]>
    7  * @license   GPL-2.0+
    8  * @link      //www.kindredwebconsulting.com
    9  * @copyright 2015 Kindred Web Consulting
     5 * @package    USGS Steam Flow Data
     6 * @author     Chris Kindred <[email protected]>
     7 * @license    GPL-2.0+
     8 * @link       //www.kindredwebconsulting.com
     9 * @copyright  2015 Kindred Web Consulting
     10 */
     11
     12/**
     13 * The admin-specific functionality of the plugin.
     14 *
     15 * Defines the plugin name, version, and two examples hooks for how to
     16 * enqueue the admin-specific stylesheet and JavaScript.
     17 *
     18 * @package    USGS Steam Flow Data
     19 * @subpackage usgs_stream_flow_data/admin
    1020 */
    1121class Kwc_Usgs_Admin {
     
    3949         * Call $plugin_slug from public plugin class.
    4050         */
    41         $plugin = Kwc_Usgs::get_instance();
    42         $this->plugin_slug = $plugin->get_plugin_slug();
     51        $this->plugin_slug = Kwc_Usgs::get_instance()->get_plugin_slug();
    4352
    4453        // Load admin style sheet and JavaScript.
     
    118127     */
    119128    public function add_plugin_admin_menu() {
    120 
    121         /*
    122          * Add a settings page for this plugin to the Settings menu.
    123          *
    124          * NOTE:  Alternative menu locations are available via WordPress administration menu functions.
    125          *
    126          *        Administration Menus: //codex.wordpress.org/Administration_Menus
    127          *
    128          */
    129129        $this->plugin_screen_hook_suffix = add_options_page(
    130             __( 'USGS Stream Flow Data', $this->plugin_slug ),
    131             __( 'Stream Flow Data', $this->plugin_slug ),
     130            __( 'USGS Stream Flow Data', 'kwc_usgs' ),
     131            __( 'Stream Flow Data', 'kwc_usgs' ),
    132132            'manage_options',
    133133            $this->plugin_slug,
     
    149149     * Add settings action link to the plugins page.
    150150     *
    151      * @since    1.0.0
     151     * @since 1.0.0
     152     * @param array $links      The links array.
    152153     */
    153154    public function add_action_links( $links ) {
     
    155156        return array_merge(
    156157            array(
    157                 'settings' => '<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_slug ) . '">' . __( 'Settings', $this->plugin_slug ) . '</a>'
     158                'settings' => '<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_slug ) . '">' . __( 'Settings', 'kwc_usgs' ) . '</a>',
    158159            ),
    159160            $links
     
    161162
    162163    }
    163 
    164     /**
    165      * NOTE:     Actions are points in the execution of a page or process
    166      *           lifecycle that WordPress fires.
    167      *
    168      *           Actions:    //codex.wordpress.org/Plugin_API#Actions
    169      *           Reference:  //codex.wordpress.org/Plugin_API/Action_Reference
    170      *
    171      * @since    1.0.0
    172      */
    173     // public function action_method_name() {
    174         // @TODO: Define your action hook callback here
    175     // }
    176 
    177164
    178165    /**
     
    200187        });
    201188        </script>
    202 <?php
     189    <?php
    203190    }
    204191    /**
     
    209196    public function kwcusgsajax_callback() {
    210197        $state = $_POST['state'];
    211 
    212         $url  = "https://waterservices.usgs.gov/nwis/iv?stateCd=$state&format=waterml&parameterCd=00060";
    213         $data = wp_remote_get( $url );
     198        $url   = "https://waterservices.usgs.gov/nwis/iv?stateCd=$state&format=waterml&parameterCd=00060";
     199        $data  = wp_remote_get( $url );
    214200        if ( ! $data ) {
    215201            echo 'Error retrieving: ' . esc_url( $url );
     
    241227                        </tr>
    242228                    </tfoot>";
    243         $cnt = 0;
     229        $cnt  = 0;
     230        // phpcs:disable
     231        /**
     232         * phpcs is disabled because the data coming from the api is not formed
     233         * correctly to match the valid snake_case format required by the CS.
     234         */
    244235        foreach ( $xml_tree->timeSeries as $site_data ) {
    245236            $cnt = ++$cnt;
     
    256247        }
    257248            $page .= '</tbody></table>';
    258             echo $page;
     249        // phpcs:enable
     250        echo $page;
    259251        die();
    260252    }
  • usgs-stream-flow-data/trunk/admin/views/admin.php

    r1622006 r1876522  
    11<?php
    22/**
     3 * The admin view file for plugin
     4 *
    35 * @package   USGS Steam Flow Data
    46 * @author    Chris Kindred <[email protected]>
     
    79 * @copyright 2015 Kindred Web Consulting
    810 */
    9 ?>
    10 <?php
    11 if ( !current_user_can( 'manage_options' ) )  {
    12     wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
     11
     12if ( ! current_user_can( 'manage_options' ) ) {
     13    wp_die( __( 'You do not have sufficient permissions to access this page.', 'kwc_usgs' ) );
    1314}
    14 $tabs = array( 'home-settings' => 'Usage', 'search' => 'Search Site Codes', 'credits' => 'Credits' );
    15 $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'home-settings';
     15
     16$usgs_tabs = array(
     17    'home-settings' => 'Usage',
     18    'search'        => 'Search Site Codes',
     19    'credits'       => 'Credits',
     20);
     21
     22$usgs_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'home-settings';
    1623?>
    1724<div class="wrap">
    18     <h2><span style="padding-top: 5px;" class="dashicons dashicons-location"></span> <?php echo esc_html( get_admin_page_title() ); ?> </h2><br />
    19     <h2 class="nav-tab-wrapper">
    20 <?php
    21     foreach( $tabs as $tab => $name ){
    22         $class = ( $tab == $active_tab ) ? ' nav-tab-active' : '';
    23         echo "<a class='nav-tab$class' href='?page=kwcusgs&tab=$tab'>$name</a>";
    24     }
    25 ?>
    26     </h2>
    27 <?php
    28         switch ( $active_tab ){
    29             case 'search':
    30                 $state_values=array(
    31                         'AL' => "Alabama",
    32                         'AK' => "Alaska",
    33                         'AZ' => "Arizona",
    34                         'AR' => "Arkansas",
    35                         'CA' => "California",
    36                         'CO' => "Colorado",
    37                         'CT' => "Connecticut",
    38                         'DE' => "Delaware",
    39                         'DC' => "District Of Columbia",
    40                         'FL' => "Florida",
    41                         'GA' => "Georgia",
    42                         'HI' => "Hawaii",
    43                         'ID' => "Idaho",
    44                         'IL' => "Illinois",
    45                         'IN' => "Indiana",
    46                         'IA' => "Iowa",
    47                         'KS' => "Kansas",
    48                         'KY' => "Kentucky",
    49                         'LA' => "Louisiana",
    50                         'ME' => "Maine",
    51                         'MD' => "Maryland",
    52                         'MA' => "Massachusetts",
    53                         'MI' => "Michigan",
    54                         'MN' => "Minnesota",
    55                         'MS' => "Mississippi",
    56                         'MO' => "Missouri",
    57                         'MT' => "Montana",
    58                         'NE' => "Nebraska",
    59                         'NV' => "Nevada",
    60                         'NH' => "New Hampshire",
    61                         'NJ' => "New Jersey",
    62                         'NM' => "New Mexico",
    63                         'NY' => "New York",
    64                         'NC' => "North Carolina",
    65                         'ND' => "North Dakota",
    66                         'OH' => "Ohio",
    67                         'OK' => "Oklahoma",
    68                         'OR' => "Oregon",
    69                         'PA' => "Pennsylvania",
    70                         'RI' => "Rhode Island",
    71                         'SC' => "South Carolina",
    72                         'SD' => "South Dakota",
    73                         'TN' => "Tennessee",
    74                         'TX' => "Texas",
    75                         'UT' => "Utah",
    76                         'VT' => "Vermont",
    77                         'VA' => "Virginia",
    78                         'WA' => "Washington",
    79                         'WV' => "West Virginia",
    80                         'WI' => "Wisconsin",
    81                         'WY' => "Wyoming"
    82             );
    83     ?>
    84             <h3>Search Site Codes</h3>
    85             <p class="">You can search for a site by selecting a state and pressing the 'Get Stations' button.  The stations come up in code order directly from USGS.  Once you are showing a states stations the easiest way to find the one you are looking for is to use the browswers built in search.  The search can take as long as two minutes to contact USGS and bring back the data in some cases.</p>
    86             <p class="">Click the Site Name link to go directly to the site on the USGS website.</p>
    87             <p class="">Click the Latitude / Longitude link to view the site location in google maps.  The location in google maps is an aproximation.</p>
    88             <label>Select State:</label>
    89             <?php
    90                 echo "<select id='state' class='state' name='state'>";
    91                 if ( !empty( $state_values ) ) {
    92                     $blnfirst = true;
    93                     foreach( $state_values as $state_short => $state_full ) {
    94                         if ( true == $blnfirst ){
    95                             echo "<option value='$state_short' SELECTED >$state_full</option>";
    96                             $blnfirst = false;
    97                         } else {
    98                             echo "<option value='$state_short' >$state_full</option>";
    99                         }
    100                     }
    101                 }
    102                 echo "</select>";
    103             ?>
    104             <input type='submit' value='<?php _e('Get Stations'); ?>' class='button-secondary' />
    105             <br /><br />
    106             <div class="" id="results"></div>
    107 <?php
    108                 break;
     25    <h2><span style="padding-top: 5px;" class="dashicons dashicons-location"></span> <?php echo esc_html( get_admin_page_title() ); ?> </h2><br />
     26    <h2 class="nav-tab-wrapper">
     27    <?php
     28    foreach ( $usgs_tabs as $usgs_tab => $name ) {
     29        $usgs_class = ( $usgs_tab == $usgs_active_tab ) ? ' nav-tab-active' : '';
     30        echo "<a class='nav-tab$usgs_class' href='?page=kwcusgs&tab=$usgs_tab'>$name</a>";
     31    }
     32    ?>
     33    </h2>
     34    <?php
     35    switch ( $usgs_active_tab ) {
     36        case 'search':
     37            $usgs_state_values = array(
     38                'AL' => 'Alabama',
     39                'AK' => 'Alaska',
     40                'AZ' => 'Arizona',
     41                'AR' => 'Arkansas',
     42                'CA' => 'California',
     43                'CO' => 'Colorado',
     44                'CT' => 'Connecticut',
     45                'DE' => 'Delaware',
     46                'DC' => 'District Of Columbia',
     47                'FL' => 'Florida',
     48                'GA' => 'Georgia',
     49                'HI' => 'Hawaii',
     50                'ID' => 'Idaho',
     51                'IL' => 'Illinois',
     52                'IN' => 'Indiana',
     53                'IA' => 'Iowa',
     54                'KS' => 'Kansas',
     55                'KY' => 'Kentucky',
     56                'LA' => 'Louisiana',
     57                'ME' => 'Maine',
     58                'MD' => 'Maryland',
     59                'MA' => 'Massachusetts',
     60                'MI' => 'Michigan',
     61                'MN' => 'Minnesota',
     62                'MS' => 'Mississippi',
     63                'MO' => 'Missouri',
     64                'MT' => 'Montana',
     65                'NE' => 'Nebraska',
     66                'NV' => 'Nevada',
     67                'NH' => 'New Hampshire',
     68                'NJ' => 'New Jersey',
     69                'NM' => 'New Mexico',
     70                'NY' => 'New York',
     71                'NC' => 'North Carolina',
     72                'ND' => 'North Dakota',
     73                'OH' => 'Ohio',
     74                'OK' => 'Oklahoma',
     75                'OR' => 'Oregon',
     76                'PA' => 'Pennsylvania',
     77                'RI' => 'Rhode Island',
     78                'SC' => 'South Carolina',
     79                'SD' => 'South Dakota',
     80                'TN' => 'Tennessee',
     81                'TX' => 'Texas',
     82                'UT' => 'Utah',
     83                'VT' => 'Vermont',
     84                'VA' => 'Virginia',
     85                'WA' => 'Washington',
     86                'WV' => 'West Virginia',
     87                'WI' => 'Wisconsin',
     88                'WY' => 'Wyoming',
     89            );
     90            ?>
     91            <h3>Search Site Codes</h3>
     92            <p class="">You can search for a site by selecting a state and pressing the 'Get Stations' button.  The stations come up in code order directly from USGS.  Once you are showing a states stations the easiest way to find the one you are looking for is to use the browswers built in search.  The search can take as long as two minutes to contact USGS and bring back the data in some cases.</p>
     93            <p class="">Click the Site Name link to go directly to the site on the USGS website.</p>
     94            <p class="">Click the Latitude / Longitude link to view the site location in google maps.  The location in google maps is an aproximation.</p>
     95            <label>Select State:</label>
     96            <?php
     97            echo "<select id='state' class='state' name='state'>";
     98            if ( ! empty( $usgs_state_values ) ) {
     99                $usgs_blnfirst = true;
     100                foreach ( $usgs_state_values as $usgs_state_short => $usgs_state_full ) {
     101                    if ( true == $usgs_blnfirst ) {
     102                        echo "<option value='$usgs_state_short' SELECTED >$usgs_state_full</option>";
     103                        $usgs_blnfirst = false;
     104                    } else {
     105                        echo "<option value='$usgs_state_short' >$usgs_state_full</option>";
     106                    }
     107                }
     108            }
     109            echo '</select>';
     110            ?>
     111            <input type='submit' value='<?php _e( 'Get Stations', 'kwc_usgs' ); ?>' class='button-secondary' />
     112            <br /><br />
     113            <div class="" id="results"></div>
     114            <?php
     115            break;
    109116
    110             case 'home-settings':
    111 ?>
    112                 <h3 class="">Using USGS Steam Flow Data</h3>
    113                 <p class="">This plugin uses short codes to allow you to include the USGS infromation for a location on any post or in a Text Widget.</p>
    114                 <p class="">You can copy and paste the shortcode below to get started.</p>
    115                 <p>[USGS location='09080400' title='Great Place To Fish' graph='show'] </p>
    116                 <h4 class="">Location</h4>
    117                 <p>The location is the Site Code for the location you want to show. You can get the Site Code by using the Search tab or by finding it on the USGS website.</p>
    118                 <h4 class="">Title</h4>
    119                 <p>The title is what you would like to use as a title for the location information.  The title defaults to the Site Name if you leave it blank. </p>
    120                 <h4 class="">Graph</h4>
    121                 <p>Graph is for showing graphs with the information (true) or not (false).  If you leave Graph blank it will default to false.</p>
    122 <?php
    123                 break;
     117        case 'home-settings':
     118        ?>
     119            <h3 class="">Using USGS Steam Flow Data</h3>
     120            <p class="">This plugin uses short codes to allow you to include the USGS infromation for a location on any post or in a Text Widget.</p>
     121            <p class="">You can copy and paste the shortcode below to get started.</p>
     122            <p>
     123                <code>[USGS location='09080400' title='Great Place To Fish' graph='show' /]</code>
     124            </p>
     125            <h4 class="">Location</h4>
     126            <p>The location is the Site Code for the location you want to show. You can get the Site Code by using the Search tab or by finding it on the USGS website.</p>
     127            <h4 class="">Title</h4>
     128            <p>The title is what you would like to use as a title for the location information.  The title defaults to the Site Name if you leave it blank. </p>
     129            <h4 class="">Graph</h4>
     130            <p>Graph is for showing graphs with the information (true) or not (false).  If you leave Graph blank it will default to false.</p>
     131            <?php
     132            break;
    124133
    125             default:
    126 ?>
    127                 <center><a href="https://www.kindredwebconsulting.com/"><img src="<?php echo plugins_url( '../assets/kwc-logo.png', __FILE__ ) ?>" alt="Kindred Web Consulting Logo" border="0" /></a><p>Development by: <a href="https://www.kindredwebconsulting.com">Kindred Web Consulting</a></p></center>
    128                 <div class="sidebar">
    129                     <h2 class="">Support</h2>
    130                     <p class="">Thanks for using our plugin.  We are happy to address any bugs you might find and address suggestions you have by either posting on the plugin page at WordPress.org or through the <a href="https://www.kindredwebconsulting.com/contact-us/">Contact Us</a> on our website.</p>
    131                     <h2 class="">Donations</h2>
    132                     <p class="">If you are interested in helping us to add new features and fix bugs please consider donating a few dollars.
    133                     <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
    134                     <input type="hidden" name="cmd" value="_s-xclick">
    135                     <input type="hidden" name="hosted_button_id" value="BUFMZVZ6L358J">
    136                     <table>
    137                     <tr><td><input type="hidden" name="on0" value="Donation"></td></tr><tr><td><select name="os0">
    138                         <option value="Buy Us a Drink">Buy Us a Drink $5.00 USD</option>
    139                         <option value="Buy Us a Meal">Buy Us a Meal $25.00 USD</option>
    140                         <option value="Be The Coolest Person We Know">Be The Coolest Person We Know $100.00 USD</option>
    141                     </select> </td></tr>
    142                     </table>
    143                     <input type="hidden" name="currency_code" value="USD">
    144                     <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
    145                     <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
    146                     </form></p>
    147                     <h2 class="">Social Media</h2>
    148                     <p class="">
    149                         <a href="https://www.facebook.com/kindredwebconsulting/" ><img src="<?php echo plugins_url( '../assets/facebook.png', __FILE__ ) ?>" alt="Kindred Web Consulting on Facebook" width="" height="32px" border="" align="" /></a>
    150                         <a href="https://www.google.com/+KindredWebConsulting"><img src="<?php echo plugins_url( '../assets/google.png', __FILE__ ) ?>" alt="Kindred Web Consulting on Google+" width="" height="32px" border="" align="" /></a>
    151                         <a href="https://www.kindredwebconsulting.com/"><img src="<?php echo plugins_url( '../assets/kwc.png', __FILE__ ) ?>" alt="Kindred Web Consulting" width="" height="32px" border="" align="" /></a>
    152                     </p>
    153 
    154                 </div>
    155                 <h2 class="">About the Plugin</h2>
    156                 <p class="">We are avid fly fishermen.  We wanted an easier way to find out what the rivers and streams were flowing at besides to going to the USGS website and looking each one up individually every day.  We decided the easiest way would be to write our own plugin to get the data.  We hope you enjoy using it and if you have any suggestions please let us know!</p>
    157                 <p class="">If you would like to receive updates about development and features of USGS Stream Flow Data please <a href="//eepurl.com/JQ68X">click here</a> and enter your email.</p>
    158                 <h2 class="">USGS</h2>
    159                 <p class="">We are dependent on the <a href="//www.usgs.gov/water/">USGS website</a> for the data that this plugin uses.  They do a good job of notifying developers of any updates.  We will quickly update the plugin any time there are updates that effect the API calls.</p>
    160                 <a href="//www.usgs.gov/water/"><img src="<?php echo plugins_url( '../assets/usgs.jpg', __FILE__ ) ?>" alt="USGS" border="0" height="32px" /></a>
    161 <?php
    162                 break;
    163         }
     134        default:
     135        ?>
     136            <center><a href="https://www.kindredwebconsulting.com/"><img src="<?php echo plugins_url( '../assets/kwc-logo.png', __FILE__ ); ?>" alt="Kindred Web Consulting Logo" border="0" /></a><p>Development by: <a href="https://www.kindredwebconsulting.com">Kindred Web Consulting</a></p></center>
     137            <div class="sidebar">
     138                <h2 class="">Support</h2>
     139                <p class="">Thanks for using our plugin.  We are happy to address any bugs you might find and address suggestions you have by either posting on the plugin page at WordPress.org or through the <a href="https://www.kindredwebconsulting.com/contact-us/">Contact Us</a> on our website.</p>
     140                <h2 class="">Donations</h2>
     141                <p class="">If you are interested in helping us to add new features and fix bugs please consider donating a few dollars.
     142                <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
     143                <input type="hidden" name="cmd" value="_s-xclick">
     144                <input type="hidden" name="hosted_button_id" value="BUFMZVZ6L358J">
     145                <table>
     146                <tr><td><input type="hidden" name="on0" value="Donation"></td></tr><tr><td><select name="os0">
     147                    <option value="Buy Us a Meal">Buy Us a Meal $25.00 USD</option>
     148                    <option value="Buy Us a Drink">Buy Us a Drink $5.00 USD</option>
     149                    <option value="Be The Coolest Person We Know">Be The Coolest Person We Know $100.00 USD</option>
     150                </select></td></tr>
     151                </table>
     152                <input type="hidden" name="currency_code" value="USD">
     153                <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
     154                <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
     155                </form></p>
     156                <h2 class="">Social Media</h2>
     157                <p class="">
     158                    <a href="https://www.facebook.com/kindredwebconsulting/" ><img src="<?php echo plugins_url( '../assets/facebook.png', __FILE__ ); ?>" alt="Kindred Web Consulting on Facebook" width="" height="32px" border="" align="" /></a>
     159                    <a href="https://www.google.com/+KindredWebConsulting"><img src="<?php echo plugins_url( '../assets/google.png', __FILE__ ); ?>" alt="Kindred Web Consulting on Google+" width="" height="32px" border="" align="" /></a>
     160                    <a href="https://www.kindredwebconsulting.com/"><img src="<?php echo plugins_url( '../assets/kwc.png', __FILE__ ); ?>" alt="Kindred Web Consulting" width="" height="32px" border="" align="" /></a>
     161                </p>
     162            </div>
     163            <h2 class="">About the Plugin</h2>
     164            <p class="">We are avid fly fishermen.  We wanted an easier way to find out what the rivers and streams were flowing at besides to going to the USGS website and looking each one up individually every day.  We decided the easiest way would be to write our own plugin to get the data.  We hope you enjoy using it and if you have any suggestions please let us know!</p>
     165            <p class="">If you would like to receive updates about development and features of USGS Stream Flow Data please <a href="//eepurl.com/JQ68X">click here</a> and enter your email.</p>
     166            <h2 class="">USGS</h2>
     167            <p class="">We are dependent on the <a href="//www.usgs.gov/water/">USGS website</a> for the data that this plugin uses.  They do a good job of notifying developers of any updates.  We will quickly update the plugin any time there are updates that effect the API calls.</p>
     168            <a href="//www.usgs.gov/water/"><img src="<?php echo plugins_url( '../assets/usgs.jpg', __FILE__ ); ?>" alt="USGS" border="0" height="32px" /></a>
     169            <?php
     170            break;
     171    }
    164172?>
    165173</div>
  • usgs-stream-flow-data/trunk/kwcusgs.php

    r1850211 r1876522  
    1313 * Plugin URI:        //wordpress.org/plugins/usgs-stream-flow-data/
    1414 * Description:       USGS Stream Flow Data
    15  * Version:           2.6.3
     15 * Version:           2.6.4
    1616 * Author:            Chris Kindred
    1717 * Author URI:        //www.kindredwebconsulting.com
  • usgs-stream-flow-data/trunk/public/assets/css/public.css

    r812236 r1876522  
    1919div .KWC_USGS ul.sitevalues li {
    2020    margin: 0px;
    21     padding-left: 14px; 
     21    padding-left: 14px;
    2222}
    2323
    2424div .KWC_USGS a {
    25     float: right; 
     25    float: right;
    2626}
    2727
  • usgs-stream-flow-data/trunk/public/assets/js/public.js

    r1208516 r1876522  
     1/**
     2 * All of the code for your public-facing JavaScript source
     3 * should reside in this file.
     4 *
     5 * @package   USGS Steam Flow Data
     6 */
     7
    18(function ( $ ) {
    29    "use strict";
    310
    4     $(function () {
    5 
    6 
    7     });
    8 
    9 }(jQuery));
     11}( jQuery ) );
  • usgs-stream-flow-data/trunk/public/class-kwc-usgs.php

    r1850211 r1876522  
    11<?php
     2/**
     3 * Public
     4 *
     5 * @package    USGS Steam Flow Data
     6 * @author     Chris Kindred <[email protected]>
     7 * @license    GPL-2.0+
     8 * @link       //www.kindredwebconsulting.com
     9 * @copyright  2015 Kindred Web Consulting
     10 */
     11
    212/**
    313 * The main class for the plugin
    414 *
    515 * @package   USGS Steam Flow Data
     16 * @subpackage public
    617 * @author    Chris Kindred <[email protected]>
    718 * @license   GPL-2.0+
     
    1728     * @var     string
    1829     */
    19     const VERSION = '2.6.3';
     30    const VERSION = '2.6.4';
    2031
    2132    /**
    2233     * Unique identifier for your plugin.
    23      *
    2434     *
    2535     * The variable name is used as the text domain when internationalizing strings
     
    5060    private function __construct() {
    5161
    52         // Load plugin text domain
    5362        add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
    54 
    55         // Activate plugin when new blog is added
    5663        add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) );
    57 
    58         // Load public-facing style sheet and JavaScript.
    5964        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
    6065        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    61 
    6266        add_shortcode( 'USGS', array( $this, 'USGS' ) );
    63         /* Define custom functionality.
    64          * Refer To //codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters
    65          */
    66         //  add_action( '@TODO', array( $this, 'action_method_name' ) );
    67         //  add_filter( '@TODO', array( $this, 'filter_method_name' ) );
    68 
    6967    }
    7068
     
    108106     */
    109107    public static function activate( $network_wide ) {
    110 
    111108        if ( function_exists( 'is_multisite' ) && is_multisite() ) {
    112 
    113             if ( $network_wide  ) {
    114 
    115                 // Get all blog ids
     109            if ( $network_wide ) {
    116110                $blog_ids = self::get_blog_ids();
    117 
    118111                foreach ( $blog_ids as $blog_id ) {
    119 
    120112                    switch_to_blog( $blog_id );
    121113                    self::single_activate();
    122114                }
    123 
    124115                restore_current_blog();
    125 
    126116            } else {
    127117                self::single_activate();
    128118            }
    129 
    130119        } else {
    131120            self::single_activate();
    132121        }
    133 
    134122    }
    135123
     
    149137
    150138            if ( $network_wide ) {
    151 
    152                 // Get all blog ids
    153139                $blog_ids = self::get_blog_ids();
    154 
    155140                foreach ( $blog_ids as $blog_id ) {
    156 
    157141                    switch_to_blog( $blog_id );
    158142                    self::single_deactivate();
    159 
    160                 }
    161 
     143                }
    162144                restore_current_blog();
    163 
    164145            } else {
    165146                self::single_deactivate();
    166147            }
    167 
    168148        } else {
    169149            self::single_deactivate();
    170150        }
    171 
    172151    }
    173152
     
    177156     * @since    1.0.0
    178157     *
    179      * @param int     $blog_id ID of the new blog.
     158     * @param int $blog_id ID of the new blog.
    180159     */
    181160    public function activate_new_site( $blog_id ) {
     
    202181     */
    203182    private static function get_blog_ids() {
    204 
    205183        global $wpdb;
    206 
    207         // get an array of blog ids
    208         $sql = "SELECT blog_id FROM $wpdb->blogs
    209             WHERE archived = '0' AND spam = '0'
    210             AND deleted = '0'";
    211 
    212         return $wpdb->get_col( $sql );
    213 
     184        return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE archived = %s AND spam = %s AND deleted = %s", array( '0', '0', '0' ) ) );
    214185    }
    215186
     
    240211
    241212        $domain = $this->plugin_slug;
    242         $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
     213        $locale = apply_filters( 'kwc_usgs_plugin_locale', get_locale(), $domain );
    243214
    244215        load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' );
     
    281252     * This needs to be split into different functions
    282253     *
    283      * @since   1.0.0
    284      */
    285 
    286     public function USGS( $atts, $content = null ) {
    287         extract( shortcode_atts(
    288                 array(
    289                     'location'  => '09080400',
    290                     'title'  => null,
    291                     'graph'  => null
    292                 ), $atts ) );
    293 
    294         $thePage = get_transient( 'kwc_usgs-' . $location . $graph . $title );
    295 
    296         if ( !$thePage ) {
     254     * @since 1.0.0
     255     */
     256    /**
     257     * Undocumented function
     258     *
     259     * @param array  $atts      the attributes passed to the shortcode.
     260     * @param string $content   the content.
     261     * @return string           the html for the shortcode.
     262     */
     263    public function USGS( $atts, $content = null ) { //phpcs:ignore
     264        $defaults = array(
     265            'location' => '09080400',
     266            'title'    => null,
     267            'graph'    => null,
     268        );
     269        $atts     = shortcode_atts( $defaults, $atts );
     270        $location = $atts['location'];
     271        $title    = $atts['title'];
     272        $graph    = $atts['graph'];
     273        $the_page = get_transient( 'kwc_usgs-' . $location . $graph . $title );
     274
     275        if ( ! $the_page ) {
    297276            $response = $this->get_usgs( $location );
    298277
    299             if( is_wp_error( $response ) ) {
     278            if ( is_wp_error( $response ) ) {
    300279                return get_error_message( $response );
    301280            }
     
    308287
    309288            $xml_tree = simplexml_load_string( $data );
    310             if ( False === $xml_tree ) {
     289            if ( false === $xml_tree ) {
    311290                return 'Unable to parse USGS\'s XML';
    312291            }
    313292
    314             if ( ! isset( $title )  ) {
    315                 $SiteName = $xml_tree->timeSeries->sourceInfo->siteName;
     293            if ( ! isset( $title ) ) {
     294                $site_name = $xml_tree->timeSeries->sourceInfo->siteName; //phpcs:ignore
    316295            } else {
    317                 if ( $title == '' ) {
    318                     $SiteName = $xml_tree->timeSeries->sourceInfo->siteName;
     296                if ( '' == $title ) {
     297                    $site_name = $xml_tree->timeSeries->sourceInfo->siteName; //phpcs:ignore
    319298                } else {
    320                     $SiteName = $title;
    321                 }
    322             }
    323 
    324             $thePage = "<div class='KWC_USGS clearfix'>
    325                             <h3 class='header'>$SiteName</h3>
     299                    $site_name = $title;
     300                }
     301            }
     302
     303            $the_page = "<div class='KWC_USGS clearfix'>
     304                            <h3 class='header'>$site_name</h3>
    326305                                <ul class='sitevalues'>";
    327             $graphflow = "";
    328             $graphgage = "";
    329             foreach ( $xml_tree->timeSeries as $site_data ) {
    330                 if ( $site_data->values->value == '' ) {
     306            $graphflow = '';
     307            $graphgage = '';
     308            foreach ( $xml_tree->timeSeries as $site_data ) { //phpcs:ignore
     309                if ( '' == $site_data->values->value ) {
    331310                    $value = '-';
    332                 } else if ( $site_data->values->value == -999999 ) {
    333                         $value = 'UNKNOWN';
     311                } elseif ( -999999 == $site_data->values->value ) {
     312                        $value       = 'UNKNOWN';
    334313                        $provisional = '-';
    335314                } else {
    336315                    $desc = $site_data->variable->variableName;
    337316                    switch ( $site_data->variable->variableCode ) {
    338                     case "00010":
    339                         $value  = $site_data->values->value;
    340                         $degf   = ( 9 / 5 ) * (float)$value + 32;
    341                         $watertemp      = $degf;
    342                         $watertempdesc  = "&deg; F";
    343                         $thePage .= "<li class='watertemp'>Water Temp: $watertemp $watertempdesc</li>";
    344                         break;
    345 
    346                     case "00060":
    347                         $splitDesc = explode( ",", $desc );
    348                         $value  = $site_data->values->value;
    349                         $streamflow     = $value;
    350                         $streamflowdesc = $splitDesc[1];
    351                         $thePage .= "<li class='flow'>Flow: $streamflow $streamflowdesc</li>";
    352                         $graphflow = "<img src='https://waterdata.usgs.gov/nwisweb/graph?agency_cd=USGS&site_no=$location&parm_cd=00060" . "&rand=" . rand() . "'/>";
    353                         break;
    354 
    355                     case "00065":
    356                         $splitDesc = explode( ",", $desc );
    357                         $value  = $site_data->values->value;
    358                         $gageheight = $value;
    359                         $gageheightdesc = $splitDesc[1];
    360                         $thePage .= "<li class='gageheight'>Water Level: $gageheight $gageheightdesc</li>";
    361                         $graphgage = "<img src='https://waterdata.usgs.gov/nwisweb/graph?agency_cd=USGS&site_no=$location&parm_cd=00065" . "&rand=" . rand() . "'/>";
    362                         break;
     317                        case '00010':
     318                            $value         = $site_data->values->value;
     319                            $degf          = ( 9 / 5 ) * (float) $value + 32;
     320                            $watertemp     = $degf;
     321                            $watertempdesc = '&deg; F';
     322                            $the_page    .= "<li class='watertemp'>Water Temp: $watertemp $watertempdesc</li>";
     323                            break;
     324
     325                        case '00060':
     326                            $split_desc     = explode( ',', $desc );
     327                            $value          = $site_data->values->value;
     328                            $streamflow     = $value;
     329                            $streamflowdesc = $split_desc[1];
     330                            $the_page      .= "<li class='flow'>Flow: $streamflow $streamflowdesc</li>";
     331                            $graphflow      = "<img src='https://waterdata.usgs.gov/nwisweb/graph?agency_cd=USGS&site_no=$location&parm_cd=00060&rand=" . rand() . "'/>";
     332                            break;
     333
     334                        case '00065':
     335                            $split_desc     = explode( ',', $desc );
     336                            $value          = $site_data->values->value;
     337                            $gageheight    = $value;
     338                            $gageheightdesc = $split_desc[1];
     339                            $the_page      .= "<li class='gageheight'>Water Level: $gageheight $gageheightdesc</li>";
     340                            $graphgage      = "<img src='https://waterdata.usgs.gov/nwisweb/graph?agency_cd=USGS&site_no=$location&parm_cd=00065&rand=" . rand() . "'/>";
     341                            break;
    363342                    }
    364343                }
    365344            }
    366             $thePage .=  "</ul>";
     345            $the_page .= '</ul>';
    367346            if ( isset( $graph ) ) {
    368                 if ( $graph == 'show' ) {
    369                     $thePage .= "<div class='clearfix'>";
    370                     $thePage .= $graphgage . $graphflow;
    371                     $thePage .= "</div>";
    372                 }
    373             }
    374             $thePage .= "<a class='clearfix' href='https://waterdata.usgs.gov/nwis/uv?$location' target='_blank'>USGS</a>";
    375             $thePage .= "</div>";
    376 
    377             set_transient( 'kwc_usgs-' . $location . $graph . $title, $thePage, 60 * 15 );
    378         }
    379         return $thePage;
     347                if ( 'show' == $graph ) {
     348                    $the_page .= "<div class='clearfix'>$graphgage . $graphflow</div>";
     349                }
     350            }
     351            $the_page .= "<a class='clearfix' href='https://waterdata.usgs.gov/nwis/uv?$location' target='_blank'>USGS</a>";
     352            $the_page .= '</div>';
     353
     354            set_transient( 'kwc_usgs-' . $location . $graph . $title, $the_page, 60 * 15 );
     355        }
     356        return $the_page;
    380357    }
    381358
     
    383360     * Makes USGS Call
    384361     *
    385      * @param string $location
     362     * @param string $location  the location to make call with.
    386363     * @return mixed|array|WP_Error
    387364     */
    388365    public function get_usgs( $location ) {
    389         $url = "https://waterservices.usgs.gov/nwis/iv?site=$location&parameterCd=00010,00060,00065&format=waterml";
     366        $url      = "https://waterservices.usgs.gov/nwis/iv?site=$location&parameterCd=00010,00060,00065&format=waterml";
    390367        $response = wp_remote_get( $url );
    391368        if ( is_wp_error( $response ) ) {
     
    393370        }
    394371        return array(
    395             'response_code' => wp_remote_retrieve_response_code( $response ),
     372            'response_code'    => wp_remote_retrieve_response_code( $response ),
    396373            'response_message' => wp_remote_retrieve_response_message( $response ),
    397             'data' => wp_remote_retrieve_body( $response ),
     374            'data'             => wp_remote_retrieve_body( $response ),
    398375        );
    399376    }
Note: See TracChangeset for help on using the changeset viewer.