WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#36960 closed enhancement (wontfix)

Add filter to maintenance_mode() function for $maintenance_string

Reported by: amandato Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.5.2
Component: Upgrade/Install Keywords: reporter-feedback
Focuses: Cc:

Description

Please add a filter for the maintenance_mode() function found in includes/class-wp-upgrader.php.

New line:

<?php
...
$maintenance_string = apply_filters( 'maintenance_string', $maintenance_string );
...

Adding this would allow a custom plugin to modify the $maintenance_string. Here is an example where a custom plugin would modify the maintenance string value to allow wp-cli to work while maintaining maintenance mode in all other cases:

<?php
if( !(defined('WP_CLI') && WP_CLI) ) { $upgrading = time(); }

Attachments (1)

class-wp-upgrader.diff (576 bytes) - added by amandato 3 years ago.
Diff file of change made to WP 4.5.2

Download all attachments as: .zip

Change History (3)

@amandato
3 years ago

Diff file of change made to WP 4.5.2

#1 @ocean90
3 years ago

  • Keywords reporter-feedback close added

Why would someone want to change that string?

Snippet from wp_maintenance():

global $upgrading;

include( ABSPATH . '.maintenance' );
// If the $upgrading timestamp is older than 10 minutes, don't die.
if ( ( time() - $upgrading ) >= 600 )
	return;

class-wp-upgrader.diff is a bit broken. The patch should include the full path and the filename. Also, filters need to be documented as per the documentation standards.

#2 @ocean90
3 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.