For anyone else who needs it, I solved it as follows via a plugin:
(1) The first block of code needed to be triggered with: add_action( 'wp_loaded', 'redirect_block' );
(2) The second block involving redirects was originally after the wp();
call in wp-blog-header.php, so in the plugin it is triggered as follows: add_action( 'wp', 'redirect_old_style_urls' );