UPDATE
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: CropLogic Performance Guards
|
||||
* Description: Reduces delays caused by blocked external services on this WordPress install.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert env values like 1/true/on/yes into booleans.
|
||||
*/
|
||||
function croplogic_env_flag( $name, $default = false ) {
|
||||
$value = getenv( $name );
|
||||
|
||||
if ( false === $value || '' === $value ) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the theme from waiting on Google Fonts when external traffic is blocked.
|
||||
*/
|
||||
function croplogic_disable_upstudy_google_fonts() {
|
||||
wp_dequeue_style( 'upstudy-main-fonts' );
|
||||
wp_deregister_style( 'upstudy-main-fonts' );
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'croplogic_disable_upstudy_google_fonts', 100 );
|
||||
|
||||
/**
|
||||
* Short-circuit login/admin notification emails that can hang on blocked SMTP calls.
|
||||
*/
|
||||
function croplogic_skip_slow_wp_mail( $pre, $atts ) {
|
||||
if ( ! croplogic_env_flag( 'WORDPRESS_DISABLE_SLOW_MAIL', true ) ) {
|
||||
return $pre;
|
||||
}
|
||||
|
||||
$request_uri = isset( $_SERVER['REQUEST_URI'] ) ? (string) wp_unslash( $_SERVER['REQUEST_URI'] ) : '';
|
||||
$is_login = false !== strpos( $request_uri, 'wp-login.php' );
|
||||
$is_admin = is_admin();
|
||||
$action = isset( $_REQUEST['action'] ) ? sanitize_key( wp_unslash( $_REQUEST['action'] ) ) : '';
|
||||
|
||||
if ( in_array( $action, array( 'lostpassword', 'retrievepassword', 'rp', 'resetpass' ), true ) ) {
|
||||
return $pre;
|
||||
}
|
||||
|
||||
if ( ! $is_login && ! $is_admin ) {
|
||||
return $pre;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
add_filter( 'pre_wp_mail', 'croplogic_skip_slow_wp_mail', 10, 2 );
|
||||
Reference in New Issue
Block a user