Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need custom retry-after: #31

Open
1 task done
nisbet-hubbard opened this issue Sep 14, 2024 · 2 comments
Open
1 task done

Need custom retry-after: #31

nisbet-hubbard opened this issue Sep 14, 2024 · 2 comments

Comments

@nisbet-hubbard
Copy link

Feature Request

Describe your use case and the problem you are facing

When you consider that there isn’t a GUI equivalent for it, maintenance-mode is really one of the unique features of CLI, unfortunately not as widely known as it should be.

Currently, we still have to rely on our maintenance mode snippet in functions.php, however, because the retry-after: 600 of CLI is hardcoded.

Describe the solution you'd like

Sysadmins usually know how long the maintenance work is going to take. So ideally we’d want to be able to tell crawlers precisely how long to wait before visiting again.

A retry-after flag would be very much appreciated.

@swissspidy
Copy link
Member

Just to clarify, when you say retry-after: 600 is hardcoded, are you referring to the following line?

if ( ( time() - $upgrading ) >= 10 * MINUTE_IN_SECONDS ) {

That value is also hardcoded in WordPress core itself in wp_is_maintenance_mode()

@nisbet-hubbard
Copy link
Author

Thanks for this info! So maybe we can just do something like the following?

function maintenance() {
if (!current_user_can('edit_themes') || !is_user_logged_in()) {
	require_once ABSPATH . WPINC . '/functions.php';
	wp_load_translations_early();

	header( 'Retry-After: $var' );
	wp_die(
		__( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ),
		__( 'Maintenance' ),
		503
	);
}
}

add_action('get_header', 'maintenance');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants