Plugin alternative to wp-blog-header.php hacks?

I have 2 extra pieces of code in wp-blog-header.php.

The first handles 410 and 404 headers and goes at the top, before the line if ( !isset($wp_did_header) ) {

The second handles some complex redirects and goes after the wp(); line.

I know it's a bad idea to hack core WP scripts (especially as my hacks get overwritten on most WP updates). I'd like to do both as plugins, but I can't figure out which hooks to use, nor how.

I've looked at a few existing plugins, but none do what I need.

Any advice would be appreciated.

Topic wp-blog-header.php Wordpress

Category Web


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' );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.