init(); } } /** * Initialise the sitewide admin panel: register actions and filters */ function init() { if ( is_null( $this->settings ) ) { $this->settings = AA_settings(); } if ( function_exists( 'is_network_admin' ) ) { // Wordpress 3.1 add_action( 'network_admin_menu', array( &$this, 'add_submenu' ) ); } else { add_action( 'admin_menu', array( &$this, 'add_submenu' ) ); } } /** * Adds the settings page to the "Site Admin" menu */ function add_submenu() { wp_get_current_user(); if ( ! AA_is_super_admin() ) { return false; } // only for site admins if ( function_exists( 'is_network_admin' ) ) { // Wordpress 3.1 add_submenu_page( 'settings.php', __( 'Sitewide Author Avatars Configuration', 'author-avatars' ), __( 'Author Avatars List', 'author-avatars' ), 'manage_options', 'wpmu_author_avatars', array( &$this, 'config_page' ) ); } else { add_submenu_page( 'wpmu-admin.php', __( 'Sitewide Author Avatars Configuration', 'author-avatars' ), __( 'Author Avatars List', 'author-avatars' ), 'manage_options', 'wpmu_author_avatars', array( &$this, 'config_page' ) ); } } /** * Renders the sitewide configuration page */ function config_page() { if ( array_key_exists( 'action', $_POST ) && $_POST['action'] == 'update' ) { $updated = $this->save_settings(); } else { $updated = false; } $this->render_config_page( $updated ); } function save_settings() { check_admin_referer( 'wpmu_author_avatars'); $settings = $_POST['settings_sitewide']; return $this->settings->save_sitewide( $settings ); } function render_config_page( $updated ) { require_once( 'AAFormHelper.class.php' ); echo '
' . __( 'Options saved.', 'author-avatars' ) . '
' . implode( '
', $updated ) . '