Define global variable in theme file and call that variable in plugin file

The most important thing about your problem is the loading priority. By default, Plugins are loaded before the theme. So, when you define a global variable in the functions.php it is not available in plugins code like your example.

global $ww_new;
echo $ww_new;

But you can use the defined global variable if you make sure your code is running after defining it. It is possible by using hooks.

in functions.php change the code to

function ww_new(){
    global $ww_new;
    $ww_new = $post_slug;
}

// Define it immediately after `init` in a high priority.
add_action('init', 'ww_new', 1, 1);

and then, in your plugin codes, you can use it like

 add_action( 'init', 'ww_new_usage', 10, 1 );

 function ww_new_usage() {
    global $ww_new;
    // Use the variable here.
 }

Please read the $priority part of the add_action developer docs.