Shortcode not being executed

Welcome.

  1. By using die function, You are stopping the process and it will stop immediately after running the shortcode callback. Better to let the rest of the code to be executed.

  2. You need to return something in shortcode callback function instead of sending headers using die or echo.

So, change your code to something like the following one and it should work. You are free to wrap it in init hook.

add_shortcode(
    'my_shortcode',
    function($atts, $content="") {
        return 'This is from My shortcode!';
    }
);
  1. The condition for checking shortcode existence is problematic. If you want to check if a certain shortcode exists in a page, has_shortcode function. Check has_shortcode document here.