From e06060b955c16219ed0338b93c14ec7d0d6cbbb9 Mon Sep 17 00:00:00 2001 From: sbyrd Date: Tue, 12 Nov 2024 17:13:52 -0500 Subject: [PATCH] and the password goes too... --- plugin_controls.php | 79 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 8 deletions(-) diff --git a/plugin_controls.php b/plugin_controls.php index 80bc181..0dbb436 100644 --- a/plugin_controls.php +++ b/plugin_controls.php @@ -4,12 +4,24 @@ 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 +Version: 1.1.1 Author: sbyrd Author URI: https://cooini.com/ License: MINE-all-mine */ +function plugin_controls_isUserManagingService() : bool +{ + $users = ['clpsupport','clsupport']; + $user = wp_get_current_user(); + if (in_array($user->user_login, $users) ) + return true; + elseif (preg_match("/courselauncher.io$/", $user->user_email )) + return true; + else + return false; +} + function plugin_controls_remove_menus() { $allow_plugin_file = plugin_dir_path(__FILE__)."/.allow_plugin_list"; @@ -18,14 +30,53 @@ function plugin_controls_remove_menus() { touch( $allow_plugin_file ); } - // - - if (!file_exists($allow_plugin_file)) { - remove_menu_page('plugins.php'); - remove_menu_page('update-core.php'); + 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); + } } + $menus_to_hide = ['Plugins'=>'plugins.php', + 'Updates'=>"update-core.php", + 'Activity Log'=>'aryo-activity-log/aryo-activity-log.php' + ]; + + if (plugin_controls_isUserManagingService() ) + { + // This is us + add_action( 'admin_notices', function() use ($menus_to_hide) { + ?> +
+

Wordpress Management

+

Following menus are only visible to us

+ +
+ $value) + { + remove_menu_page($value); + } + } + + } + function plugin_page_control() { $allow_plugin_file = plugin_dir_path(__FILE__)."/.allow_updates"; @@ -45,13 +96,25 @@ function plugin_page_control() // - if (file_exists($allow_plugin_file)) + if ( file_exists($allow_plugin_file)) { define( 'DISALLOW_FILE_EDIT', false ); // allow - define( 'DISALLOW_FILE_MODS', false); + define( 'DISALLOW_FILE_MODS', false ); + + if (plugin_controls_isUserManagingService()) + { + add_action( 'admin_notices', function() { + ?> +
+

Updates, file edits, are currently unlocked.

+
+