Skip to content

Commit

Permalink
Make recommended fixes from Plugin Check
Browse files Browse the repository at this point in the history
  • Loading branch information
dshanske committed Dec 28, 2024
1 parent 783c7a4 commit 36baa35
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 49 deletions.
3 changes: 1 addition & 2 deletions includes/class-location-plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public static function array_get( $array, $key, $default = array(), $index = tru
}

/**
*
*
* Adds location properties to webmention returns.
*/
public static function webmention_handler_mf2_set_properties( $meta, $handler ) {
$item = $handler->get_webmention_item();
Expand Down
12 changes: 6 additions & 6 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,22 +631,22 @@ function sloc_get_attachment_datetime( $attachment, $field = 'created' ) {
}

function sloc_file_exists( $file ) {
require_once ( ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php' );
require_once ( ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php' );
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
$wpfile = new WP_Filesystem_Direct( false );
return $wpfile->exists( $file );
}

function sloc_get_contents( $file ) {
require_once ( ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php' );
require_once ( ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php' );
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
$wpfile = new WP_Filesystem_Direct( false );
return $wpfile->get_contents( $file );
}

function sloc_get_contents_array( $file ) {
require_once ( ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php' );
require_once ( ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php' );
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
$wpfile = new WP_Filesystem_Direct( false );
return $wpfile->get_contents_array( $file );
}
2 changes: 1 addition & 1 deletion includes/weather/class-weather-provider-aeris.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private function code_map( $id ) {
case 'L': // Drizzle.
return 301;
case 'R': // Rain.
500;
return 500;
case 'RW': // Rain showers.
return 521;
case 'RS': // Rain/snow mix.
Expand Down
6 changes: 0 additions & 6 deletions includes/weather/class-weather-provider-meteostat.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ function ( $a, $b ) {
return $return;
}
return self::get_fallback_conditions( $time );

$conditions = $this->get_cache();
if ( $conditions ) {
return $conditions;
}
return array();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/weather/class-weather-provider-metoffice.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function ( $a, $b ) {
}

/**
* converts code into weather description.
* Converts code into weather description.
*
* @param int $type code.
* @return string description.
Expand Down
64 changes: 32 additions & 32 deletions includes/weather/class-weather-provider-nwsus.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,15 @@ private function phenomenon_code_map( $weather ) {

switch ( $condition ) {
case 'thunderstorms':
if ( ! isset( $weather['intensity'] ) ) {
return 211;
}
if ( 'light' === $weather['intensity'] ) {
return 210;
}
if ( 'heavy' === $weather['intensity'] ) {
return 212;
if ( array_key_exists( 'intensity', $weather ) ) {
if ( 'light' === $weather['intensity'] ) {
return 210;
}
if ( 'heavy' === $weather['intensity'] ) {
return 212;
}
}
return 211;
case 'fog':
case 'fog_mist':
return 741;
Expand All @@ -294,15 +294,15 @@ private function phenomenon_code_map( $weather ) {
case 'dust_whirls':
return 761;
case 'drizzle':
if ( ! isset( $weather['intensity'] ) ) {
return 301;
}
if ( 'light' === $weather['intensity'] ) {
return 300;
}
if ( 'heavy' === $weather['intensity'] ) {
return 302;
if ( array_key_exists( 'intensity', $weather ) ) {
if ( 'light' === $weather['intensity'] ) {
return 300;
}
if ( 'heavy' === $weather['intensity'] ) {
return 302;
}
}
return 301;
case 'smoke':
return 711;
case 'hail':
Expand All @@ -315,29 +315,29 @@ private function phenomenon_code_map( $weather ) {
case 'ice_pellets':
case 'spray':
case 'rain':
if ( ! isset( $weather['intensity'] ) ) {
return 521;
}
if ( 'light' === $weather['intensity'] ) {
return 520;
}
if ( 'heavy' === $weather['intensity'] ) {
return 522;
if ( array_key_exists( 'intensity', $weather ) ) {
if ( 'light' === $weather['intensity'] ) {
return 520;
}
if ( 'heavy' === $weather['intensity'] ) {
return 522;
}
}
return 521;
case 'sand':
case 'sand_storm':
return 751;
case 'snow_grains':
case 'snow':
if ( ! isset( $weather['intensity'] ) ) {
return 601;
}
if ( 'light' === $weather['intensity'] ) {
return 600;
}
if ( 'heavy' === $weather['intensity'] ) {
return 602;
if ( array_key_exists( 'intensity', $weather ) ) {
if ( 'light' === $weather['intensity'] ) {
return 600;
}
if ( 'heavy' === $weather['intensity'] ) {
return 602;
}
}
return 601;
case 'squalls':
return 771;
case 'volcanic_ash':
Expand Down
1 change: 0 additions & 1 deletion includes/weather/class-weather-provider-station.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ function ( $a, $b ) {
public function get_station_data() {
$return = array();
$stations = get_option( 'sloc_stations' );
$endpoint = null;
foreach ( $stations as $key => $station ) {
if ( trim( $station['id'] === $this->station_id ) ) {
$return = $this->fetch_json( $station['url'], array() );
Expand Down

0 comments on commit 36baa35

Please sign in to comment.