/home/u336066629/websites/AmAL87tCa/public_html/wp-content/mu-plugins/hostinger-h5g-plugin.php
<?php
/**
* Plugin Name: Hostinger H5G Plugin
* Description: Hostinger H5G Plugin
* Author: Hostinger
* Version: 1.0.1
* MU Plugin: Yes
*/
defined( 'ABSPATH' ) || exit;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Hostinger_H5G_Plugin {
public function __construct() {
// Hide security updates information from Site Health
add_filter( 'site_status_tests', [ $this, 'hide_site_health_updates' ] );
// Remove WordPress core update notification
add_action( 'admin_menu', [ $this, 'remove_core_update_notification' ] );
// Hide update messages from the update page
add_action( 'admin_head', [ $this, 'hide_update_messages' ] );
// Disable core update checks
add_filter( 'pre_site_transient_update_core', '__return_null' );
add_filter( 'pre_option_update_core', '__return_null' );
// Trigger actual update of plugins & themes
add_action( 'admin_init', [ $this, 'schedule_auto_update'] );
add_action( 'hostinger_h5g_maybe_auto_update', [ $this, 'maybe_do_updates' ] );
}
public function hide_site_health_updates( $site_health_tests ) {
unset( $site_health_tests['direct']['available_updates_disk_space'] );
unset( $site_health_tests['async']['background_updates'] );
return $site_health_tests;
}
public function remove_core_update_notification() {
remove_action( 'admin_notices', 'update_nag', 3 );
remove_action( 'network_admin_notices', 'update_nag', 3 );
}
public function hide_update_messages() {
echo '<style>
.update-nag, .updated, .update-core-php .core-updates, .update-core-php .response {
display: none !important;
}
</style>';
}
public function schedule_auto_update() {
if ( ! wp_next_scheduled( 'hostinger_h5g_maybe_auto_update' ) ) {
wp_schedule_event( time(), 'twicedaily', 'hostinger_h5g_maybe_auto_update' );
}
}
public function maybe_do_updates() {
$doing_cron = wp_doing_cron();
if ( $doing_cron && ! doing_action( 'wp_maybe_auto_update' ) ) {
do_action( 'wp_maybe_auto_update' );
}
}
}
new Hostinger_H5G_Plugin();