<?php

/**
 * Disable WordPress update notifications
 * @category Functions
 * @author Krik
 */

// Hide WordPress update notifications
add_filter('pre_site_transient_update_core', 'krik_hide_update_notifications');

// Hide plugin update notifications
add_filter('pre_site_transient_update_plugins', 'krik_hide_update_notifications');

// Hide theme update notifications
add_filter('pre_site_transient_update_themes', 'krik_hide_update_notifications');

// Hide update menu link
add_action('admin_init', 'krik_hide_updates_from_menu');
add_action('admin_init', 'krik_redirect_updates_page');

function krik_hide_update_notifications()
{
	global $wp_version;
	return(object) array(
		'last_checked' => time(),
		'version_checked' => $wp_version,
	);
}

function krik_hide_updates_from_menu()
{
	remove_submenu_page('index.php', 'update-core.php');
}

function krik_redirect_updates_page()
{
	global $pagenow;
	if ($pagenow === 'update-core.php') {
		wp_redirect(admin_url());
		exit;
	}
}
