Created
January 26, 2024 15:19
-
-
Save woodwardtw/4f7240fabba0967f58318c61585e10e9 to your computer and use it in GitHub Desktop.
example helper plugin for Skidmore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Skidmore Multisite Helpers | |
Plugin URI: https://github.com/ | |
Description: A network activated plugin used to house small functions that apply to all sites. | |
Version: 1.0 | |
Author: Tom Woodward et al. | |
Author URI: https://tomwoodward.us | |
License: GPL2 | |
License URI: https://www.gnu.org/licenses/gpl-2.0.html | |
Domain Path: /languages | |
Text Domain: my-toolset | |
*/ | |
defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); | |
/* | |
** hide menu items from everyone who is NOT a superadmin | |
** this doesn't prevent access via the direct page URL so don't use it alone if you need that kind of block | |
** more information on the remove_menu_page function at https://developer.wordpress.org/reference/functions/remove_menu_page/ | |
** | |
*/ | |
function skidmore_hide_menu_items(){ | |
if(!is_super_admin()){ | |
remove_menu_page('litespeed'); //hides the litespeed caching plugin menu item | |
//add additional menu items here with the remove_menu_page('slug-name'); pattern | |
} | |
} | |
add_action( 'admin_menu', 'skidmore_hide_menu_items', 999 ); | |
/* | |
** | |
** use write_log($whatever) to provide additional formatting for troubleshooting | |
** | |
*/ | |
if ( ! function_exists('write_log')) { | |
function write_log ( $log ) { | |
if ( is_array( $log ) || is_object( $log ) ) { | |
error_log( print_r( $log, true ) ); | |
} else { | |
error_log( $log ); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment