plugin-controls/plugin_controls.php

64 lines
1.5 KiB
PHP

<?php
/*
Plugin Name: Plugin Control
Plugin URI: https://cooini.com/services/dev/wordpress
Description: This plugin will disable access to the plugins and other pages
Version: 1.0
Author: sbyrd
Author URI: https://cooini.com/
License: MINE-all-mine
*/
function plugin_controls_remove_menus()
{
$allow_plugin_file = plugin_dir_path(__FILE__)."/.allow_plugin_list";
if (isset($_GET['allow_plugin_list']) and $_GET['allow_plugin_list'] === "123letmesee")
{
touch( $allow_plugin_file );
}
//
if (!file_exists($allow_plugin_file)) {
remove_menu_page('plugins.php');
remove_menu_page('update-core.php');
}
}
function plugin_page_control()
{
$allow_plugin_file = plugin_dir_path(__FILE__)."/.allow_updates";
if (isset($_GET['allow_updates']) and $_GET['allow_updates'] === "123letmeupdate")
{
touch( $allow_plugin_file );
}
else
{
if (file_exists($allow_plugin_file) and (time() - filectime($allow_plugin_file) >= 60 * 60 * 12 ))
{
// File is older than threshold, delete
unlink($allow_plugin_file);
}
}
//
if (file_exists($allow_plugin_file))
{
define( 'DISALLOW_FILE_EDIT', false ); // allow
define( 'DISALLOW_FILE_MODS', false);
}
else
{
define( 'DISALLOW_FILE_EDIT', true ); // disable
define( 'DISALLOW_FILE_MODS', true);
}
}
add_action( 'admin_menu', 'plugin_controls_remove_menus' );
add_action( 'admin_menu', 'plugin_page_control' );