$method, 'body' => $data, ]; } else { $url = add_query_arg( $data, $url ); } $args['timeout'] = $timeout; $response = self::get_remote_request( $url, $args ); if ( $response === false ) { return false; } return $json ? json_decode( $response, true ) : $response; } /** * redirect to URL * * @param string $to * @param array $variables * * @since 1.0.0 * */ public static function redirect( $to, $variables = [] ) { wp_safe_redirect( self::get_link_with_params( $variables, $to ) ); exit(); } /** * get environment from key * * @param string $key * * @return string * * @since 2.0.2 * */ public static function get_environment( $key ) { $environment = ''; if ( empty( $key ) ) { return $environment; } $key = explode( '.', $key ); if ( sizeof( $key ) == 1 ) { return $environment; } return $key[0]; } /** * remove environment type from key * * @param string $key * * @return string * * @since 2.0.2 * */ public static function remove_environment_type_from_key( $key ) { $key = explode( '.', $key ); return isset( $key[1] ) ? $key[1] : $key[0]; } }