How to add CSS via custom plugin?

Here’s your problem:

  wp_enqueue_style( 'style', get_stylesheet_uri() );
 
  wp_enqueue_style( 'slider', get_template_directory_uri() . 'test.css', array(), '1.1', 'all');

Neither of those files are in your theme. get_stylesheet_uri refers to the style.css that has the themes name etc, and get_template_directory_uri is the URL of the parent theme. Neither of those are your plugin folder.

You can confirm this by looking at the browser dev tools and seeing an error in the console that it tried to load a test.css from your themes folder and failed.

Instead use plugins_url.

e.g.

plugins_url( 'images/wordpress.png', __FILE__ )

Where the first parameter is the path to the file in your plugin folder, and the second parameter is the main plugin file location on the server.

So this:

get_template_directory_uri() . 'test.css'

becomes:

plugins_url( 'test.css', __FILE__ );