plugin-controls/plugin_controls.php

64 lines
1.5 KiB
PHP
Raw Normal View History

2022-12-15 16:18:06 -05:00
<?php
2023-08-14 15:27:17 -04:00
/*
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);
}
2022-12-15 16:18:06 -05:00
}
2023-08-14 15:27:17 -04:00
2022-12-15 16:18:06 -05:00
add_action( 'admin_menu', 'plugin_controls_remove_menus' );
2023-08-14 15:27:17 -04:00
add_action( 'admin_menu', 'plugin_page_control' );
2022-12-15 16:18:06 -05:00