*/ public static function json_decode_array( $json ): array { if ( ! is_string( $json ) || '' === $json ) { return array(); } $data = json_decode( $json, true ); return is_array( $data ) ? $data : array(); } /** * IP address of the current request, validated, or an empty string. * * @since 0.1.0 * * @return string */ public static function client_ip(): string { $ip = isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : ''; return false !== filter_var( $ip, FILTER_VALIDATE_IP ) ? $ip : ''; } }