From c6fe17404cbf086e9983cb404203a7eb4659e9de Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sat, 2 Nov 2024 09:15:00 -0700 Subject: [PATCH 01/16] add multisite support --- aspire-update.php | 1 + includes/class-admin-settings.php | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/aspire-update.php b/aspire-update.php index 09ac602..6daeb8c 100644 --- a/aspire-update.php +++ b/aspire-update.php @@ -20,6 +20,7 @@ * License URI: https://www.gnu.org/licenses/gpl-3.0.txt * Text Domain: AspireUpdate * Domain Path: /languages + * Network: true */ if ( ! defined( 'ABSPATH' ) ) { diff --git a/includes/class-admin-settings.php b/includes/class-admin-settings.php index b7d6fc0..61277a1 100644 --- a/includes/class-admin-settings.php +++ b/includes/class-admin-settings.php @@ -44,7 +44,7 @@ class Admin_Settings { * The Constructor. */ public function __construct() { - add_action( 'admin_menu', array( $this, 'register_admin_menu' ) ); + add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', array( $this, 'register_admin_menu' ) ); add_action( 'admin_init', array( $this, 'reset_settings' ) ); add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'admin_notices', array( $this, 'reset_admin_notice' ) ); @@ -216,6 +216,8 @@ private function get_settings_from_config_file() { * @return void */ public function register_admin_menu() { + $capability = is_multisite() ? 'manage_network_options' : 'manage_options'; + if ( ! defined( 'AP_REMOVE_UI' ) ) { define( 'AP_REMOVE_UI', false ); } @@ -224,7 +226,7 @@ public function register_admin_menu() { 'index.php', 'AspireUpdate', 'AspireUpdate', - 'manage_options', + $capability, 'aspireupdate-settings', array( $this, 'the_settings_page' ) ); @@ -502,10 +504,10 @@ public function add_settings_field_callback( $args = array() ) { -